language stringclasses 1
value | repo stringclasses 346
values | path stringlengths 6 201 | class_span dict | source stringlengths 21 2.38M | target stringlengths 1 96 |
|---|---|---|---|---|---|
python | EpistasisLab__tpot | tpot/builtin_modules/arithmetictransformer.py | {
"start": 13452,
"end": 14082
} | class ____(TransformerMixin, BaseEstimator):
def __init__(self):
"""
A transformer that returns an array of zeros.
"""
pass
def fit(self, X, y=None):
return self
def transform(self, X):
transformed_X = np.array(self.transform_helper(np.array(X)))
... | ZeroTransformer |
python | django__django | tests/migrations/test_migrations_plan/0003_third.py | {
"start": 43,
"end": 449
} | class ____(migrations.Migration):
dependencies = [
("migrations", "0002_second"),
]
operations = [
migrations.CreateModel(
"Author",
[
("id", models.AutoField(primary_key=True)),
],
),
migrations.RunSQL(
["SELEC... | Migration |
python | gevent__gevent | src/gevent/testing/util.py | {
"start": 15061,
"end": 17572
} | class ____(object):
"""
Something that uses the ``examples/`` directory
from the root of the gevent distribution.
The `cwd` property is set to the root of the gevent distribution.
"""
#: Arguments to pass to the example file.
example_args = []
before_delay = 3
after_delay = 0.5
... | ExampleMixin |
python | fluentpython__example-code-2e | 15-more-types/cafeteria/cafeteria.py | {
"start": 251,
"end": 436
} | class ____(Generic[T_co]):
def __init__(self, beverage: T_co) -> None:
self.beverage = beverage
def dispense(self) -> T_co:
return self.beverage
| BeverageDispenser |
python | apache__airflow | airflow-core/src/airflow/ti_deps/deps/ready_to_reschedule.py | {
"start": 1084,
"end": 3833
} | class ____(BaseTIDep):
"""Determines whether a task is ready to be rescheduled."""
NAME = "Ready To Reschedule"
IGNORABLE = True
IS_TASK_DEP = True
RESCHEDULEABLE_STATES = {TaskInstanceState.UP_FOR_RESCHEDULE, None}
@provide_session
def _get_dep_statuses(self, ti, session, dep_context):
... | ReadyToRescheduleDep |
python | huggingface__transformers | src/transformers/models/perception_lm/modular_perception_lm.py | {
"start": 5768,
"end": 12779
} | class ____(LlavaModel):
_checkpoint_conversion_mapping = {}
def __init__(self, config: PerceptionLMConfig):
super().__init__(config)
self.vision_tower = AutoModel.from_config(config.vision_config)
self.multi_modal_projector = PerceptionLMMultiModalProjector(config)
self.language... | PerceptionLMModel |
python | neetcode-gh__leetcode | python/0036-valid-sudoku.py | {
"start": 0,
"end": 749
} | class ____:
def isValidSudoku(self, board: List[List[str]]) -> bool:
cols = collections.defaultdict(set)
rows = collections.defaultdict(set)
squares = collections.defaultdict(set) # key = (r /3, c /3)
for r in range(9):
for c in range(9):
if board[r][c] ... | Solution |
python | getsentry__sentry | src/sentry/sentry_apps/api/parsers/sentry_app.py | {
"start": 2026,
"end": 2498
} | class ____(serializers.URLField):
def to_internal_value(self, url):
# The Django URLField doesn't distinguish between different types of
# invalid URLs, so do any manual checks here to give the User a better
# error message.
if url and not url.startswith("http"):
raise Va... | URLField |
python | langchain-ai__langchain | libs/standard-tests/langchain_tests/unit_tests/embeddings.py | {
"start": 734,
"end": 4597
} | class ____(EmbeddingsTests):
"""Base class for embeddings unit tests.
Test subclasses must implement the `embeddings_class` property to specify the
embeddings model to be tested. You can also override the
`embedding_model_params` property to specify initialization parameters.
```python
from ty... | EmbeddingsUnitTests |
python | kamyu104__LeetCode-Solutions | Python/query-kth-smallest-trimmed-number.py | {
"start": 58,
"end": 1108
} | class ____(object):
def smallestTrimmedNumbers(self, nums, queries):
"""
:type nums: List[str]
:type queries: List[List[int]]
:rtype: List[int]
"""
max_t = max(t for _, t in queries)
lookup = [[] for _ in xrange(max_t+1)]
for i, (k, t) in enumerate(que... | Solution |
python | ray-project__ray | python/ray/serve/tests/unit/test_proxy_state.py | {
"start": 949,
"end": 1159
} | class ____:
def __init__(self, *args, **kwargs):
pass
def ready(self):
return json.dumps(["mock_worker_id", "mock_log_file_path"])
def check_health(self):
pass
| FakeProxyActor |
python | PrefectHQ__prefect | src/prefect/cli/transfer/_migratable_resources/deployments.py | {
"start": 947,
"end": 10191
} | class ____(MigratableResource[DeploymentResponse]):
_instances: dict[uuid.UUID, Self] = {}
def __init__(self, deployment: DeploymentResponse):
self.source_deployment = deployment
self.destination_deployment: DeploymentResponse | None = None
self._dependencies: dict[uuid.UUID, Migratable... | MigratableDeployment |
python | PyCQA__pylint | pylint/reporters/reports_handler_mix_in.py | {
"start": 754,
"end": 3304
} | class ____:
"""A mix-in class containing all the reports and stats manipulation
related methods for the main lint class.
"""
def __init__(self) -> None:
self._reports: ReportsDict = collections.defaultdict(list)
self._reports_state: dict[str, bool] = {}
def report_order(self) -> Mu... | ReportsHandlerMixIn |
python | PyCQA__pylint | tests/functional/i/implicit/implicit_flag_alias.py | {
"start": 369,
"end": 509
} | class ____(ExplicitUnionFlags): # [invalid-enum-extension]
"""Class with flags that overlap a superclass"""
RWX = 7
| SubclassUnionFlags |
python | great-expectations__great_expectations | contrib/experimental/great_expectations_experimental/rule_based_profiler/data_assistant/statistics_data_assistant.py | {
"start": 1343,
"end": 32260
} | class ____(DataAssistant):
"""
StatisticsDataAssistant provides metrics for dataset exploration purposes.
Fundamentally, StatisticsDataAssistant is "OnboardingDataAssistant minus Expectations -- only Metrics", the intended
usecase being obtaining description of data via metrics as well as comparing met... | StatisticsDataAssistant |
python | getsentry__sentry | src/sentry/auth/providers/saml2/jumpcloud/provider.py | {
"start": 80,
"end": 177
} | class ____(GenericSAML2Provider):
name = "Jumpcloud"
key = "jumpcloud"
| JumpcloudSAML2Provider |
python | dask__dask | dask/array/core.py | {
"start": 3199,
"end": 44342
} | class ____(Warning):
"""A warning given when bad chunking may cause poor performance"""
def getter(a, b, asarray=True, lock=None):
if isinstance(b, tuple) and any(x is None for x in b):
b2 = tuple(x for x in b if x is not None)
b3 = tuple(
None if x is None else slice(None, None)
... | PerformanceWarning |
python | apache__airflow | providers/google/src/airflow/providers/google/cloud/hooks/dataproc.py | {
"start": 2441,
"end": 7148
} | class ____:
"""A helper class for building Dataproc job."""
def __init__(
self,
project_id: str,
task_id: str,
cluster_name: str,
job_type: str,
properties: dict[str, str] | None = None,
) -> None:
name = f"{task_id.replace('.', '_')}_{uuid.uuid4()!s:... | DataProcJobBuilder |
python | jmcnamara__XlsxWriter | xlsxwriter/test/comparison/test_chart_bar04.py | {
"start": 315,
"end": 2165
} | class ____(ExcelComparisonTest):
"""
Test file created by XlsxWriter against a file created by Excel.
"""
def setUp(self):
self.set_filename("chart_bar04.xlsx")
def test_create_file(self):
"""Test the creation of a simple XlsxWriter file."""
workbook = Workbook(self.got_f... | TestCompareXLSXFiles |
python | mlflow__mlflow | mlflow/system_metrics/metrics/base_metrics_monitor.py | {
"start": 94,
"end": 780
} | class ____(abc.ABC):
"""Base class of system metrics monitor."""
def __init__(self):
self._metrics = defaultdict(list)
@abc.abstractmethod
def collect_metrics(self):
"""Method to collect metrics.
Subclass should implement this method to collect metrics and store in `self._metr... | BaseMetricsMonitor |
python | apache__airflow | airflow-core/tests/unit/ti_deps/deps/test_pool_slots_available_dep.py | {
"start": 1229,
"end": 3039
} | class ____:
def setup_method(self):
db.clear_db_pools()
with create_session() as session:
test_pool = Pool(pool="test_pool", include_deferred=False)
test_includes_deferred_pool = Pool(pool="test_includes_deferred_pool", include_deferred=True)
session.add_all([test... | TestPoolSlotsAvailableDep |
python | cherrypy__cherrypy | cherrypy/process/plugins.py | {
"start": 8186,
"end": 12151
} | class ____(SimplePlugin):
"""Drop privileges. uid/gid arguments not available on Windows.
Special thanks to `Gavin Baker
<http://antonym.org/2005/12/dropping-privileges-in-python.html>`_.
"""
def __init__(self, bus, umask=None, uid=None, gid=None):
"""Initialize the privilege dropping plug... | DropPrivileges |
python | doocs__leetcode | solution/2000-2099/2089.Find Target Indices After Sorting Array/Solution.py | {
"start": 0,
"end": 170
} | class ____:
def targetIndices(self, nums: List[int], target: int) -> List[int]:
nums.sort()
return [i for i, v in enumerate(nums) if v == target]
| Solution |
python | huggingface__transformers | tests/fsdp/test_context_parallel.py | {
"start": 1125,
"end": 7748
} | class ____(TestCasePlus):
"""Test Trainer with Torch context parallelism enabled via accelerate's ParallelismConfig."""
@require_torch_multi_accelerator
@require_accelerate
@slow
@run_first
def test_cp_equivalence(self):
"""Test that CP produces the same losses as without CP."""
... | TestContextParallel |
python | microsoft__pyright | packages/pyright-internal/src/tests/samples/constructor14.py | {
"start": 537,
"end": 756
} | class ____(Generic[T_contra]):
def __init__(self, callback: Callback[T_contra]) -> None:
self._callback: Callback[T_contra] = callback
def copy(self) -> Self:
return type(self)(self._callback)
| Thing |
python | apache__airflow | airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dags.py | {
"start": 2441,
"end": 8814
} | class ____:
"""Common class for /dags related unit tests."""
@staticmethod
def _clear_db():
clear_db_connections()
clear_db_runs()
clear_db_dags()
clear_db_assets()
clear_db_serialized_dags()
def _create_deactivated_paused_dag(self, session=None):
dag_mo... | TestDagEndpoint |
python | sqlalchemy__sqlalchemy | test/orm/test_lockmode.py | {
"start": 1860,
"end": 4652
} | class ____(_fixtures.FixtureTest):
__sparse_driver_backend__ = True
# test against the major backends. We are naming specific databases
# here rather than using requirements rules since the behavior of
# "FOR UPDATE" as well as "OF" is very specific to each DB, and we need
# to run the query diff... | BackendTest |
python | pallets__click | src/click/testing.py | {
"start": 6336,
"end": 19102
} | class ____:
"""The CLI runner provides functionality to invoke a Click command line
script for unittesting purposes in a isolated environment. This only
works in single-threaded systems without any concurrency as it changes the
global interpreter state.
:param charset: the character set for the in... | CliRunner |
python | getsentry__sentry | src/sentry/monitors/endpoints/project_monitor_details.py | {
"start": 875,
"end": 3181
} | class ____(ProjectMonitorEndpoint, MonitorDetailsMixin):
publish_status = {
"DELETE": ApiPublishStatus.PUBLIC,
"GET": ApiPublishStatus.PUBLIC,
"PUT": ApiPublishStatus.PUBLIC,
}
owner = ApiOwner.CRONS
@extend_schema(
operation_id="Retrieve a Monitor for a Project",
... | ProjectMonitorDetailsEndpoint |
python | getsentry__sentry | tests/sentry/seer/autofix/test_autofix.py | {
"start": 44329,
"end": 49246
} | class ____(TestCase):
def test_get_github_username_for_user_with_github(self) -> None:
"""Tests getting GitHub username from ExternalActor with GitHub provider."""
from sentry.integrations.models.external_actor import ExternalActor
from sentry.integrations.types import ExternalProviders
... | TestGetGithubUsernameForUser |
python | numpy__numpy | numpy/f2py/tests/test_symbolic.py | {
"start": 450,
"end": 18561
} | class ____(util.F2PyTest):
def test_eliminate_quotes(self):
def worker(s):
r, d = eliminate_quotes(s)
s1 = insert_quotes(r, d)
assert s1 == s
for kind in ["", "mykind_"]:
worker(kind + '"1234" // "ABCD"')
worker(kind + '"1234" // ' + kind ... | TestSymbolic |
python | ansible__ansible | test/lib/ansible_test/_internal/ci/azp.py | {
"start": 571,
"end": 4180
} | class ____(CIProvider):
"""CI provider implementation for Azure Pipelines."""
def __init__(self) -> None:
self.auth = AzurePipelinesAuthHelper()
self._changes: AzurePipelinesChanges | None = None
@staticmethod
def is_supported() -> bool:
"""Return True if this provider is supp... | AzurePipelines |
python | scipy__scipy | benchmarks/benchmarks/cluster.py | {
"start": 3077,
"end": 3529
} | class ____(Benchmark):
params = [[2, 10, 50], ['float32', 'float64']]
param_names = ['k', 'dtype']
def __init__(self):
rnd = np.random.RandomState(0)
self.data = rnd.rand(5000, 5)
self.cbook_source = rnd.rand(50, 5)
def setup(self, k, dtype):
self.obs = self.data.astype... | VQ |
python | allegroai__clearml | clearml/backend_api/services/v2_23/frames.py | {
"start": 130330,
"end": 133918
} | class ____(Request):
"""
Get specific frames for a dataset version using the frame ids. Random Access API.
:param dataset: Dataset ID
:type dataset: str
:param version: Version ID
:type version: str
:param frame_ids: Frame IDs
:type frame_ids: Sequence[str]
:param projection: Used t... | GetByIdsRequest |
python | tensorflow__tensorflow | tensorflow/python/keras/layers/rnn_cell_wrapper_v2.py | {
"start": 4994,
"end": 5385
} | class ____(rnn_cell_wrapper_impl.DeviceWrapperBase,
_RNNCellWrapperV2):
"""Operator that ensures an RNNCell runs on a particular device."""
def __init__(self, *args, **kwargs): # pylint: disable=useless-super-delegation
super(DeviceWrapper, self).__init__(*args, **kwargs)
__init__.__doc... | DeviceWrapper |
python | ipython__ipython | IPython/lib/display.py | {
"start": 9136,
"end": 10185
} | class ____:
"""
Generic class to embed an iframe in an IPython notebook
"""
iframe = """
<iframe
width="{width}"
height="{height}"
src="{src}{params}"
frameborder="0"
allowfullscreen
{extras}
></iframe>
"""
... | IFrame |
python | openai__openai-python | src/openai/_module_client.py | {
"start": 2131,
"end": 2258
} | class ____(LazyProxy["Videos"]):
@override
def __load__(self) -> Videos:
return _load_client().videos
| VideosProxy |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 7