id int64 20 338k | vocab_size int64 2 671 | ast_levels int64 4 32 | nloc int64 1 451 | n_ast_nodes int64 12 5.6k | n_identifiers int64 1 186 | n_ast_errors int64 0 10 | n_words int64 2 2.17k | n_whitespaces int64 2 13.8k | fun_name stringlengths 2 73 | commit_message stringlengths 51 15.3k | url stringlengths 31 59 | code stringlengths 51 31k | ast_errors stringlengths 0 1.46k | token_counts int64 6 3.32k | file_name stringlengths 5 56 | language stringclasses 1
value | path stringlengths 7 134 | commit_id stringlengths 40 40 | repo stringlengths 3 28 | complexity int64 1 153 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
259,364 | 62 | 15 | 19 | 288 | 20 | 0 | 96 | 347 | _make_estimator | API Deprecate max_feature=`auto` for tree classes (#22476)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> | https://github.com/scikit-learn/scikit-learn.git | def _make_estimator(self, append=True, random_state=None):
estimator = clone(self.base_estimator_)
estimator.set_params(**{p: getattr(self, p) for p in self.estimator_params})
# TODO: Remove in v1.2
# criterion "mse" and "mae" would cause warnings in every call to
# Dec... | 175 | _base.py | Python | sklearn/ensemble/_base.py | e5736afb316038c43301d2c53ce39f9a89b64495 | scikit-learn | 11 | |
28,221 | 2 | 6 | 9 | 12 | 1 | 0 | 2 | 5 | test_flat_concat_drop_exceeding_count_no_silently_fail | Limit the maximum number of search vectors to generate per index (#10284)
This fixes a crash when multiple thousand values are to be indexed due to PostgreSQL rejecting the statement. Such crash would look like this:
```
django.db.utils.OperationalError: stack depth limit exceeded
HINT: Increase the configuration ... | https://github.com/saleor/saleor.git | def test_flat_concat_drop_exceeding_count_no_silently_fail():
| 85 | test_postgresql_search.py | Python | saleor/core/tests/test_postgresql_search.py | e5873b338db3a24afee0a7ae7bd7fffe09397ee4 | saleor | 1 | |
51,540 | 25 | 14 | 11 | 138 | 17 | 0 | 33 | 102 | postprocess | update efficientnetb0_imagenet (#2041)
* update efficientnetb0_imagenet
* remove unused print | https://github.com/PaddlePaddle/PaddleHub.git | def postprocess(data_out, label_list, top_k):
output = []
for result in data_out:
result_i = softmax(result)
output_i = {}
indexs = np.argsort(result_i)[::-1][0:top_k]
for index in indexs:
label = label_list[index].split(',')[0]
output_i[label] = floa... | 86 | processor.py | Python | modules/image/classification/efficientnetb0_imagenet/processor.py | 7cd67aba38c19a835c3229d9b4be21798c5c8673 | PaddleHub | 3 | |
259,004 | 175 | 16 | 68 | 694 | 53 | 0 | 329 | 1,288 | fit | ENH Allow prefit in stacking (#22215)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Siqi He <siqi.he@upstart.com> | https://github.com/scikit-learn/scikit-learn.git | def fit(self, X, y, sample_weight=None):
# all_estimators contains all estimators, the one to be fitted and the
# 'drop' string.
names, all_estimators = self._validate_estimators()
self._validate_final_estimator()
stack_method = [self.stack_method] * len(all_estimators)... | 439 | _stacking.py | Python | sklearn/ensemble/_stacking.py | 691972a7cf04e7a8918b907556b4e9904f82bd0c | scikit-learn | 20 | |
31,489 | 19 | 12 | 9 | 61 | 7 | 0 | 22 | 80 | unk_token | Fix properties of unset special tokens in non verbose mode (#17797)
Co-authored-by: SaulLu <55560583+SaulLu@users.noreply.github.com> | https://github.com/huggingface/transformers.git | def unk_token(self) -> str:
if self._unk_token is None:
if self.verbose:
logger.error("Using unk_token, but it is not set yet.")
return None
return str(self._unk_token)
| 35 | tokenization_utils_base.py | Python | src/transformers/tokenization_utils_base.py | 3eed5530ec74bb60ad9f8f612717d0f6ccf820f2 | transformers | 3 | |
278,518 | 15 | 13 | 10 | 102 | 14 | 0 | 21 | 98 | distributions_and_v1_optimizers | let the linter ignore certain lines, prepare to enforce line length | https://github.com/keras-team/keras.git | def distributions_and_v1_optimizers():
return tf.__internal__.test.combinations.combine(
distribution=[
tf.__internal__.distribute.combinations.one_device_strategy,
tf.__internal__.distribute.combinations.mirrored_strategy_with_gpu_and_cpu, # noqa: E501
tf.__interna... | 66 | optimizer_combinations.py | Python | keras/distribute/optimizer_combinations.py | 7c46f914413fafe472e0c577ecb10e310543cd50 | keras | 1 | |
296,195 | 20 | 9 | 8 | 88 | 12 | 0 | 24 | 81 | frontend_stream_type | Replace Camera STREAM_ constants with StreamType enum (#69871) | https://github.com/home-assistant/core.git | def frontend_stream_type(self) -> StreamType | None:
if CameraLiveStreamTrait.NAME not in self._device.traits:
return None
trait = self._device.traits[CameraLiveStreamTrait.NAME]
if StreamingProtocol.WEB_RTC in trait.supported_protocols:
return StreamType.WEB_RTC... | 55 | camera_sdm.py | Python | homeassistant/components/nest/camera_sdm.py | c93c7e8eff466624aa492011f157e64e50fed728 | core | 3 | |
140,169 | 11 | 9 | 10 | 50 | 9 | 0 | 11 | 43 | _execute_impl | [Serve][Deployment Graph][Perf] Add minimal executor DAGNode (#24754)
closes #24475
Current deployment graph has big perf issues compare with using plain deployment handle, mostly because overhead of DAGNode traversal mechanism. We need this mechanism to empower DAG API, specially deeply nested objects in args wher... | https://github.com/ray-project/ray.git | def _execute_impl(self, *args, **kwargs) -> ObjectRef:
return self._deployment_function_handle.remote(
*self._bound_args, **self._bound_kwargs
)
| 31 | deployment_function_executor_node.py | Python | python/ray/serve/deployment_function_executor_node.py | f27e85cd7df5ca2873ef6231200a1530e16ac35d | ray | 1 | |
37,288 | 6 | 6 | 8 | 22 | 5 | 0 | 6 | 20 | default_num_choices | Add onnx export of models with a multiple choice classification head (#16758)
* Add export of models with a multiple-choice classification head | https://github.com/huggingface/transformers.git | def default_num_choices(self) -> int:
return OnnxConfig.default_fixed_num_choices
| 12 | config.py | Python | src/transformers/onnx/config.py | 77de8d6c31dbf756e7b2495e272efc0b92927fc3 | transformers | 1 | |
100,394 | 31 | 13 | 14 | 193 | 16 | 0 | 43 | 161 | compile_timelapse_sample | Update code to support Tensorflow versions up to 2.8 (#1213)
* Update maximum tf version in setup + requirements
* - bump max version of tf version in launcher
- standardise tf version check
* update keras get_custom_objects for tf>2.6
* bugfix: force black text in GUI file dialogs (linux)
* dssim loss -... | https://github.com/deepfakes/faceswap.git | def compile_timelapse_sample(self):
batchsizes = []
samples = {}
images = {}
masks = {}
for side in ("a", "b"):
batch = next(self._display_feeds["timelapse"][side])
batchsizes.append(len(batch["samples"]))
samples[side] = batch["sample... | 116 | _base.py | Python | plugins/train/trainer/_base.py | c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf | faceswap | 2 | |
181,873 | 27 | 15 | 11 | 152 | 17 | 0 | 33 | 110 | auto_select_categorical_features | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | https://github.com/EpistasisLab/tpot.git | def auto_select_categorical_features(X, threshold=10):
feature_mask = []
for column in range(X.shape[1]):
if sparse.issparse(X):
indptr_start = X.indptr[column]
indptr_end = X.indptr[column + 1]
unique = np.unique(X.data[indptr_start:indptr_end])
else:
... | 96 | one_hot_encoder.py | Python | tpot/builtins/one_hot_encoder.py | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot | 3 | |
90,226 | 47 | 14 | 15 | 144 | 24 | 0 | 66 | 249 | auto_add_recovery_codes | ref(hybrid-cloud): Additional test annotations: auth_index (#42425)
Extends the hybrid cloud auth service to be usable in many more places (
TY @corps)
Annotate 30+ more api endpoint tests
Co-authored-by: Mike Ihbe <mike.ihbe@sentry.io>
Co-authored-by: Zachary Collins <zachary.collins@sentry.io>
Co-authored-by: Z... | https://github.com/getsentry/sentry.git | def auto_add_recovery_codes(self, user, force=False):
from sentry.auth.authenticators.recovery_code import RecoveryCodeInterface
has_authenticators = False
# If we're not forcing, check for a backup interface already setup
# or if it's missing, we'll need to set it.
if... | 91 | authenticator.py | Python | src/sentry/models/authenticator.py | 17644550024d6a2eb01356ee48ec0d3ef95c043d | sentry | 7 | |
169,356 | 18 | 8 | 5 | 33 | 6 | 0 | 21 | 51 | size | TYP: Fix typing errors caused by new numpy (#48850) | https://github.com/pandas-dev/pandas.git | def size(self) -> int:
# error: Incompatible return value type (got "signedinteger[_64Bit]",
# expected "int") [return-value]
return np.prod(self.shape) # type: ignore[return-value]
| 17 | base.py | Python | pandas/core/arrays/base.py | 336896907748389e2cd0d57504508475d425348e | pandas | 1 | |
38,881 | 97 | 20 | 47 | 638 | 36 | 0 | 163 | 1,029 | test_batch_encode_dynamic_overflowing | Add LayoutLMv3 (#17060)
* Make forward pass work
* More improvements
* Remove unused imports
* Remove timm dependency
* Improve loss calculation of token classifier
* Fix most tests
* Add docs
* Add model integration test
* Make all tests pass
* Add LayoutLMv3FeatureExtractor
* Improve in... | https://github.com/huggingface/transformers.git | def test_batch_encode_dynamic_overflowing(self):
for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
tokenizer = self.rust_tokenizer_class.from_pretrained(pretrained_name, **kwargs)
with self.subTest(f"{tokenizer.__class__.__name__} ({pretrained_name}, {tokenizer.__... | 383 | test_tokenization_layoutlmv3.py | Python | tests/models/layoutlmv3/test_tokenization_layoutlmv3.py | 31ee80d55673f32c0f5d50936f371e661b74b21a | transformers | 11 | |
149,955 | 37 | 18 | 12 | 214 | 21 | 0 | 47 | 209 | create_follower_dict | rehaul of backend data management - increasing performance by holding history in memory, reducing load on the ratelimit by only pinging exchange once per candle. Improve code readability. | https://github.com/freqtrade/freqtrade.git | def create_follower_dict(self):
follower_name = self.config.get('bot_name', 'follower1')
whitelist_pairs = self.config.get('exchange', {}).get('pair_whitelist')
exists = Path(self.full_path / str('follower_dictionary-' +
follower_name + '.json... | 121 | data_drawer.py | Python | freqtrade/freqai/data_drawer.py | 16b4a5b71ff140f5de31e5d5572f1f193457cf6b | freqtrade | 3 | |
158,217 | 18 | 14 | 5 | 91 | 7 | 0 | 25 | 47 | voc_label_indices | [PaddlePaddle] Merge master into Paddle branch (#1186)
* change 15.2 title in chinese version (#1109)
change title ’15.2. 情感分析:使用递归神经网络‘ to ’15.2. 情感分析:使用循环神经网络‘
* 修改部分语义表述 (#1105)
* Update r0.17.5 (#1120)
* Bump versions in installation
* 94行typo: (“bert.mall”)->(“bert.small”) (#1129)
* line 313: "b... | https://github.com/d2l-ai/d2l-zh.git | def voc_label_indices(colormap, colormap2label):
colormap = colormap.astype(np.int32)
idx = ((colormap[:, :, 0] * 256 + colormap[:, :, 1]) * 256
+ colormap[:, :, 2])
return colormap2label[idx]
| 59 | mxnet.py | Python | d2l/mxnet.py | b64b41d8c1ac23c43f7a4e3f9f6339d6f0012ab2 | d2l-zh | 1 | |
104,391 | 77 | 12 | 40 | 164 | 14 | 0 | 104 | 264 | subsplit | Update docs to new frontend/UI (#3690)
* WIP: update docs to new UI
* make style
* Rm unused
* inject_arrow_table_documentation __annotations__
* hasattr(arrow_table_method, "__annotations__")
* Update task_template.rst
* Codeblock PT-TF-SPLIT
* Convert loading scripts
* Convert docs to mdx
... | https://github.com/huggingface/datasets.git | def subsplit(self, arg=None, k=None, percent=None, weighted=None): # pylint: disable=redefined-outer-name
# Note that the percent kwargs redefine the outer name datasets.percent. This
# is done for consistency (.subsplit(percent=datasets.percent[:40]))
if sum(bool(x) for x in (arg, k, ... | 285 | splits.py | Python | src/datasets/splits.py | e35be138148333078284b942ccc9ed7b1d826f97 | datasets | 17 | |
38,308 | 53 | 12 | 31 | 220 | 33 | 0 | 61 | 343 | test_xsum_summarization_same_as_fairseq | Black preview (#17217)
* Black preview
* Fixup too!
* Fix check copies
* Use the same version as the CI
* Bump black | https://github.com/huggingface/transformers.git | def test_xsum_summarization_same_as_fairseq(self):
model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-xsum").to(torch_device)
tok = self.default_tokenizer
PGE_ARTICLE =
EXPECTED_SUMMARY = (
"California's largest power company has begun shutting off e... | 143 | test_modeling_bart.py | Python | tests/models/bart/test_modeling_bart.py | afe5d42d8d1d80af911ed980c2936bfe887078f6 | transformers | 1 | |
47,646 | 60 | 15 | 35 | 383 | 40 | 0 | 85 | 430 | test_branch_list_with_dag_run | Replace usage of `DummyOperator` with `EmptyOperator` (#22974)
* Replace usage of `DummyOperator` with `EmptyOperator` | https://github.com/apache/airflow.git | def test_branch_list_with_dag_run(self, mock_get_db_hook):
branch_op = BranchSQLOperator(
task_id="make_choice",
conn_id="mysql_default",
sql="SELECT 1",
follow_task_ids_if_true=["branch_1", "branch_2"],
follow_task_ids_if_false="branch_3",
... | 229 | test_sql.py | Python | tests/operators/test_sql.py | 49e336ae0302b386a2f47269a6d13988382d975f | airflow | 6 | |
320,768 | 4 | 9 | 2 | 30 | 4 | 0 | 4 | 18 | _model | mypy: Upgrade to PyQt5-stubs 5.15.6.0
For some unknown reason, those new stubs cause a *lot* of things now to be
checked by mypy which formerly probably got skipped due to Any being implied
somewhere.
The stubs themselves mainly improved, with a couple of regressions too.
In total, there were some 337 (!) new mypy e... | https://github.com/qutebrowser/qutebrowser.git | def _model(self):
return self._completion().model()
| 16 | completer.py | Python | qutebrowser/completion/completer.py | a20bb67a878b2e68abf8268c1b0a27f018d01352 | qutebrowser | 1 | |
93,002 | 9 | 9 | 16 | 39 | 5 | 0 | 9 | 18 | parametrize_backend | fix(snuba): Add appropriate `UseCaseKey` for indexer [TET-146] (#36308)
* fix(snuba): Add appropriate `UseCaseKey` for indexer
Update indexer invocation call to have the appropriate
`UseCaseKey` depending on use case.
In `src/sentry/sentry_metrics/indexer/base.py::StringIndexer`
when using `resolve` and `rever... | https://github.com/getsentry/sentry.git | def parametrize_backend(cls):
assert not hasattr(cls, "backend")
cls.backend = SessionsReleaseHealthBackend()
| 104 | test_sessions.py | Python | tests/snuba/sessions/test_sessions.py | cd803d173c72b64d06c0687170bf9a945d0b503c | sentry | 1 | |
26,573 | 59 | 12 | 28 | 210 | 25 | 0 | 86 | 216 | fetch_jwks | Make OIDC plugin public (#9406)
* Make OIDC plugin public
* Add missing dependency package
* Apply changes after review
* Update changelog
* Apply changes after review
* Add const file | https://github.com/saleor/saleor.git | def fetch_jwks(jwks_url) -> Optional[dict]:
response = None
try:
response = requests.get(jwks_url, timeout=REQUEST_TIMEOUT)
response.raise_for_status()
jwks = response.json()
except requests.exceptions.RequestException:
logger.exception("Unable to fetch jwks from %s", jw... | 122 | utils.py | Python | saleor/plugins/openid_connect/utils.py | 7d2e77c5f235ca60a2bf3ee02f4f9a8b10b03214 | saleor | 5 | |
120,553 | 47 | 12 | 15 | 136 | 14 | 0 | 50 | 90 | verify_mac_libraries_dont_reference_chkstack | feat: refactor code using pyupgrade
This PR upgrades legacy Python code to 3.7+ code using pyupgrade:
```sh
pyupgrade --py37-plus --keep-runtime-typing **.py
```
a | https://github.com/google/jax.git | def verify_mac_libraries_dont_reference_chkstack():
if not _is_mac():
return
nm = subprocess.run(
["nm", "-g",
r.Rlocation("org_tensorflow/tensorflow/compiler/xla/python/xla_extension.so")
],
capture_output=True, text=True,
check=False)
if nm.returncode != 0:
raise RuntimeError(f"n... | 69 | build_wheel.py | Python | build/build_wheel.py | 17de89b16ac5ee05aee03115d858e67489eab973 | jax | 4 | |
77,580 | 40 | 15 | 51 | 223 | 27 | 0 | 51 | 337 | test_title_column | Allow passing arbitrary link attributes to TitleColumn | https://github.com/wagtail/wagtail.git | def test_title_column(self):
root_page = Page.objects.filter(depth=2).first()
blog = Site.objects.create(
hostname="blog.example.com", site_name="My blog", root_page=root_page
)
gallery = Site.objects.create(
hostname="gallery.example.com", site_name="My gallery",... | 136 | test_tables.py | Python | wagtail/admin/tests/ui/test_tables.py | 5994cc43dfc5cc1ed891ab78eff3a3bcf56f6830 | wagtail | 1 | |
36,915 | 35 | 9 | 3 | 65 | 10 | 1 | 38 | 56 | _set_gradient_checkpointing | RegNet (#16188)
* base model done
* make style
* done
* added files
* Apply suggestions from code review
Co-authored-by: NielsRogge <48327001+NielsRogge@users.noreply.github.com>
* Apply suggestions from code review
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
* Tr... | https://github.com/huggingface/transformers.git | def _set_gradient_checkpointing(self, module, value=False):
if isinstance(module, RegNetModel):
module.gradient_checkpointing = value
REGNET_START_DOCSTRING = r
REGNET_INPUTS_DOCSTRING = r
@add_start_docstrings(
"The bare RegNet model outputting raw features without any specific head on top... | @add_start_docstrings(
"The bare RegNet model outputting raw features without any specific head on top.",
REGNET_START_DOCSTRING,
) | 24 | modeling_regnet.py | Python | src/transformers/models/regnet/modeling_regnet.py | af14c61973effd8b8077ac61b3f24bdd4a632f25 | transformers | 2 |
157,142 | 76 | 15 | 32 | 376 | 32 | 0 | 119 | 548 | _loc | Generalize array checking and remove `pd.Index` call in `_get_partitions` (#9634) | https://github.com/dask/dask.git | def _loc(self, iindexer, cindexer):
if isinstance(iindexer, Series):
return self._loc_series(iindexer, cindexer)
elif isinstance(iindexer, Array):
return self._loc_array(iindexer, cindexer)
elif callable(iindexer):
return self._loc(iindexer(self.obj),... | 242 | indexing.py | Python | dask/dataframe/indexing.py | 8be183c570dd953aa16d790afb709786b3d7cbf8 | dask | 14 | |
293,763 | 44 | 11 | 42 | 448 | 17 | 0 | 117 | 343 | test_lazy_state_handles_same_last_updated_and_last_changed | Separate attrs into another table (reduces database size) (#68224) | https://github.com/home-assistant/core.git | async def test_lazy_state_handles_same_last_updated_and_last_changed(caplog):
now = datetime(2021, 6, 12, 3, 4, 1, 323, tzinfo=dt_util.UTC)
row = PropertyMock(
entity_id="sensor.valid",
state="off",
shared_attrs='{"shared":true}',
last_updated=now,
last_changed=now,
... | 261 | test_models.py | Python | tests/components/recorder/test_models.py | 9215702388eef03c7c3ed9f756ea0db533d5beec | core | 1 | |
101,335 | 20 | 10 | 12 | 107 | 12 | 0 | 24 | 88 | terminate_queues | Bugfix: convert - Gif Writer
- Fix non-launch error on Gif Writer
- convert plugins - linting
- convert/fs_media/preview/queue_manager - typing
- Change convert items from dict to Dataclass | https://github.com/deepfakes/faceswap.git | def terminate_queues(self) -> None:
logger.debug("QueueManager terminating all queues")
self.shutdown.set()
self._flush_queues()
for q_name, queue in self.queues.items():
logger.debug("QueueManager terminating: '%s'", q_name)
queue.put("EOF")
logg... | 59 | queue_manager.py | Python | lib/queue_manager.py | 1022651eb8a7741014f5d2ec7cbfe882120dfa5f | faceswap | 2 | |
275,526 | 5 | 6 | 2 | 18 | 3 | 0 | 5 | 19 | _transform_loss | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _transform_loss(self, loss):
return loss
| 10 | optimizer_v2.py | Python | keras/optimizers/optimizer_v2/optimizer_v2.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 | |
98,544 | 6 | 6 | 2 | 20 | 5 | 0 | 6 | 20 | get_next_event_id | ref: clean up sentry flake8 plugin (#33847)
* fix: Remove unused `# noqa` lint disable comments
* ref: clean up sentry flake8 plugin
- remove S005: pyupgrade handles this for us
- remove `pycodestyle` handling: flake8 does this natively
- clean up the ignore list and use extend-ignore | https://github.com/getsentry/sentry.git | def get_next_event_id(self, event, snuba_filter):
raise NotImplementedError
| 12 | base.py | Python | src/sentry/eventstore/base.py | 94c896a4a3663abbd31775957f1aa5448fde5491 | sentry | 1 | |
269,617 | 11 | 7 | 2 | 67 | 12 | 1 | 11 | 14 | prod | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def prod(x, axis=None, keepdims=False):
return tf.reduce_prod(x, axis, keepdims)
@keras_export("keras.backend.cumsum")
@tf.__internal__.dispatch.add_dispatch_support
@doc_controls.do_not_generate_docs | @keras_export("keras.backend.cumsum")
@tf.__internal__.dispatch.add_dispatch_support
@doc_controls.do_not_generate_docs | 25 | backend.py | Python | keras/backend.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 |
111,194 | 31 | 12 | 9 | 175 | 22 | 0 | 42 | 69 | get_characters_loss | Auto-format code with black (#10209)
* Auto-format code with black
* add black requirement to dev dependencies and pin to 22.x
* ignore black dependency for comparison with setup.cfg
Co-authored-by: explosion-bot <explosion-bot@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com> | https://github.com/explosion/spaCy.git | def get_characters_loss(ops, docs, prediction, nr_char):
target_ids = numpy.vstack([doc.to_utf8_array(nr_char=nr_char) for doc in docs])
target_ids = target_ids.reshape((-1,))
target = ops.asarray(to_categorical(target_ids, n_classes=256), dtype="f")
target = target.reshape((-1, 256 * nr_char))
... | 112 | multi_task.py | Python | spacy/ml/models/multi_task.py | 91ccacea12a46c62ccb5e7f6de891a37cb71e184 | spaCy | 2 | |
259,914 | 9 | 11 | 21 | 45 | 7 | 0 | 9 | 24 | get_conda_environment_content | CI: move Linux and MacOS Azure builds to conda lock files (#22448)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> | https://github.com/scikit-learn/scikit-learn.git | def get_conda_environment_content(build_metadata):
template = environment.from_string(
.strip()
)
return template.render(build_metadata=build_metadata)
| 26 | update_environments_and_lock_files.py | Python | build_tools/azure/update_environments_and_lock_files.py | f862129f36786acbae3d9f2d161bbb72d77b87ec | scikit-learn | 1 | |
266,001 | 11 | 13 | 2 | 66 | 7 | 0 | 11 | 17 | title | Closes #10698: Omit app label from content type in table columns | https://github.com/netbox-community/netbox.git | def title(value):
return ' '.join([w[0].upper() + w[1:] for w in str(value).split()])
| 39 | utils.py | Python | netbox/utilities/utils.py | 0ad7ae28377f44ff7d1ed119a6ff7a8f43bf8e91 | netbox | 2 | |
154,522 | 11 | 10 | 6 | 51 | 8 | 0 | 11 | 65 | get_key | REFACTOR-#5009: use RayWrapper.materialize instead of ray.get (#5010)
Signed-off-by: Myachev <anatoly.myachev@intel.com> | https://github.com/modin-project/modin.git | def get_key(self):
return (
RayWrapper.materialize(self.key)
if isinstance(self.key, ray.ObjectRef)
else self.key
)
| 32 | partition.py | Python | modin/core/execution/ray/implementations/cudf_on_ray/partitioning/partition.py | 1dc16415333bf2428ee2b1f4d31ff94e66b9a0a6 | modin | 2 | |
181,640 | 9 | 8 | 4 | 40 | 6 | 0 | 10 | 22 | test_CategoricalSelector_fit | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | https://github.com/EpistasisLab/tpot.git | def test_CategoricalSelector_fit():
op = CategoricalSelector()
ret_op = op.fit(iris_data)
assert ret_op==op
| 22 | feature_transformers_tests.py | Python | tests/feature_transformers_tests.py | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot | 1 | |
155,537 | 115 | 15 | 51 | 391 | 43 | 0 | 153 | 807 | shift | Add groupby shift method (#8522)
Implements the shift `method` following the `transform` and `apply` methods. | https://github.com/dask/dask.git | def shift(self, periods=1, freq=None, axis=0, fill_value=None, meta=no_default):
if meta is no_default:
with raise_on_meta_error("groupby.shift()", udf=False):
meta_kwargs = _extract_meta(
{
"periods": periods,
... | 246 | groupby.py | Python | dask/dataframe/groupby.py | 336aac39ee8a616ac2645e532392123ae1bfddd1 | dask | 7 | |
273,581 | 65 | 17 | 28 | 212 | 18 | 0 | 105 | 441 | _fix_unknown_dimension | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _fix_unknown_dimension(self, input_shape, output_shape):
output_shape = list(output_shape)
msg = (
"total size of new array must be unchanged, "
"input_shape = {}, output_shape = {}".format(
input_shape, output_shape
)
)
k... | 128 | reshape.py | Python | keras/layers/reshaping/reshape.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 8 | |
37,344 | 28 | 10 | 12 | 114 | 12 | 0 | 31 | 131 | test_small_model_long_context_cls_slow | Long QuestionAnsweringPipeline fix. (#16778)
* Temporary commit witht the long QA fix.
* Adding slow tests covering this fix.
* Removing fast test as it doesn't fail anyway. | https://github.com/huggingface/transformers.git | def test_small_model_long_context_cls_slow(self):
question_answerer = pipeline(
"question-answering",
model="deepset/roberta-base-squad2",
handle_impossible_answer=True,
max_seq_length=512,
)
outputs = question_answerer(
question="What ... | 66 | test_pipelines_question_answering.py | Python | tests/pipelines/test_pipelines_question_answering.py | 6620f60c0abb56d441ed3ef627d9a87f27dba479 | transformers | 1 | |
132,846 | 17 | 14 | 9 | 112 | 17 | 0 | 17 | 100 | add_trial | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | https://github.com/ray-project/ray.git | def add_trial(self, trial):
self._trials.append(trial)
if trial.status != Trial.TERMINATED:
self._live_trials.add(trial)
with warn_if_slow("scheduler.on_trial_add"):
self._scheduler_alg.on_trial_add(
TrialRunnerWrapper(self, runner_whitelist_attr=... | 66 | trial_runner.py | Python | python/ray/tune/trial_runner.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 2 | |
268,015 | 4 | 6 | 2 | 23 | 5 | 0 | 4 | 11 | get_controller_target_connections | ansible-test - Use more native type hints. (#78435)
* ansible-test - Use more native type hints.
Simple search and replace to switch from comments to native type hints for return types of functions with no arguments.
* ansible-test - Use more native type hints.
Conversion of simple single-line function annota... | https://github.com/ansible/ansible.git | def get_controller_target_connections(self) -> t.List[SshConnection]:
| 13 | host_profiles.py | Python | test/lib/ansible_test/_internal/host_profiles.py | 3eb0485dd92c88cc92152d3656d94492db44b183 | ansible | 1 | |
162,026 | 6 | 8 | 33 | 30 | 6 | 0 | 6 | 20 | unify | Update URLs in error messages to refer to RTD docs.
As title. This replaces references to documentation at
numba.pydata.org with numba.readthedocs.io. It also fixes URLs
that were invalid. | https://github.com/numba/numba.git | def unify(self, raise_errors=True):
typdict = utils.UniqueDict()
| 193 | typeinfer.py | Python | numba/core/typeinfer.py | fc1e0cef7f574826114185a27d0686f527b7ffaf | numba | 11 | |
46,790 | 11 | 12 | 4 | 58 | 7 | 0 | 11 | 27 | commit_sha | Prepare Breeze2 for prime time :) (#22713)
This is a review and clean-up for all the parameters and
commands for Breeze2 in order to prepare it for being
used by the contribugors.
There are various small fixes here and there, removal
of duplicated code, refactoring and moving code around
as well as cleanup and ... | https://github.com/apache/airflow.git | def commit_sha():
return run_command(
['git', 'rev-parse', 'HEAD'], capture_output=True, text=True, check=False
).stdout.strip()
| 34 | run_utils.py | Python | dev/breeze/src/airflow_breeze/utils/run_utils.py | 4ffd4f09532fceb67675fce4c1f5cd383eff992e | airflow | 1 | |
172,905 | 219 | 23 | 124 | 1,748 | 115 | 1 | 396 | 2,178 | render_adv_search_results | Refactored load read status for web access and opds access
Refactored and removed discover html page
Bugfix show author
Bugfix open dialog in author page
Fix for #2341 (advanced search with linked read column and read column having a higher number than number of available custom columns) | https://github.com/janeczku/calibre-web.git | def render_adv_search_results(term, offset=None, order=None, limit=None):
sort_param = order[0] if order else [db.Books.sort]
pagination = None
cc = get_cc_columns(filter_config_custom_read=True)
calibre_db.session.connection().connection.connection.create_function("lower", 1, db.lcase)
query = cal... | @web.route("/advsearch", methods=['GET'])
@login_required_if_no_ano | 1,056 | web.py | Python | cps/web.py | 32a3c45ee0f7e13bd61075f32a4dcebc415585a1 | calibre-web | 31 |
2,284 | 43 | 8 | 2 | 59 | 5 | 0 | 109 | 286 | all | added conversion for syft object to json
working client.users table | https://github.com/OpenMined/PySyft.git | def all(self) -> List[SyftObject]:
return self.find({})
# def delete(self, **kwargs: Any) -> None:
#
# session_local = sessionmaker(autocommit=False, autoflush=False, bind=self.db)()
# session_local.query(self._schema).filter_by(**kwargs).delete()
# session_local.commit()
... | 18 | database_manager.py | Python | packages/syft/src/syft/core/node/common/node_manager/database_manager.py | 99efeb99fc7753a28cbf53906b6502aadf01fcf1 | PySyft | 1 | |
267,791 | 6 | 7 | 3 | 29 | 5 | 0 | 6 | 20 | root_namespace | ansible-test - Use more native type hints. (#78435)
* ansible-test - Use more native type hints.
Simple search and replace to switch from comments to native type hints for return types of functions with no arguments.
* ansible-test - Use more native type hints.
Conversion of simple single-line function annota... | https://github.com/ansible/ansible.git | def root_namespace(self) -> t.Any:
return self.namespaces[0]
| 17 | parsers.py | Python | test/lib/ansible_test/_internal/cli/argparsing/parsers.py | 3eb0485dd92c88cc92152d3656d94492db44b183 | ansible | 1 | |
203,275 | 58 | 12 | 17 | 146 | 12 | 0 | 65 | 248 | test_body_after_POST_multipart_related | Refs #33476 -- Refactored problematic code before reformatting by Black.
In these cases Black produces unexpected results, e.g.
def make_random_password(
self,
length=10,
allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789',
):
or
cursor.execute("""
SELECT ...
""",
... | https://github.com/django/django.git | def test_body_after_POST_multipart_related(self):
# Ticket #9054
# There are cases in which the multipart data is related instead of
# being a binary upload, in which case it should still be accessible
# via body.
payload_data = b"\r\n".join([
b'--boundary',
... | 83 | tests.py | Python | tests/requests/tests.py | c5cd8783825b5f6384417dac5f3889b4210b7d08 | django | 1 | |
101,209 | 13 | 12 | 6 | 72 | 11 | 0 | 16 | 84 | has_thumbnails | lib.align updates:
- alignments.py
- Add typed dicts for imported alignments
- Explicitly check for presence of thumb value in alignments dict
- linting
- detected_face.py
- Typing
- Linting
- Legacy support for pre-aligned face
- Update dependencies to new property names | https://github.com/deepfakes/faceswap.git | def has_thumbnails(self):
retval = all(face.get("thumb")
for frame in self._alignments_dict.values()
for face in frame["faces"])
logger.trace(retval)
return retval
| 42 | alignments.py | Python | lib/align/alignments.py | 5e73437be47f2410439a3c6716de96354e6a0c94 | faceswap | 3 | |
208,278 | 47 | 13 | 8 | 126 | 11 | 0 | 59 | 141 | _freeze_gid | Canvas.py doc enhancement (#7902)
* Added reference in comment to issue #6973 regarding slow downs when using a group with a generator of many tasks
* Added TODO comment to group.skew() to consider removing it
* Enhanced doc for canvas.group.from_dict()
* Enhanced doc for canvas.group._prepared()
* Enhanced doc fo... | https://github.com/celery/celery.git | def _freeze_gid(self, options):
# remove task_id and use that as the group_id,
# if we don't remove it then every task will have the same id...
options = {**self.options, **{
k: v for k, v in options.items()
if k not in self._IMMUTABLE_OPTIONS or k not in self.op... | 77 | canvas.py | Python | celery/canvas.py | 4e2280b12958edd0acdcd40e4bb845bbc3070791 | celery | 4 | |
38,996 | 4 | 10 | 2 | 35 | 7 | 0 | 4 | 10 | get_expert_parallel_world_size | MoE inference + PR-MoE model support (#1705)
Co-authored-by: Reza Yazdani <reyazda@microsoft.com>
Co-authored-by: Zhewei Yao <zheweiy@berkeley.edu>
Co-authored-by: Ammar Ahmad Awan <ammar.awan@microsoft.com>
Co-authored-by: Jeff Rasley <jerasley@microsoft.com>
Co-authored-by: Samyam Rajbhandari <samyamr@microsoft.... | https://github.com/microsoft/DeepSpeed.git | def get_expert_parallel_world_size(group_name):
return torch.distributed.get_world_size(group=get_expert_parallel_group(group_name))
| 20 | groups.py | Python | deepspeed/utils/groups.py | e46d808a1b6cb7e04cb2806e38547b1e3e50c25a | DeepSpeed | 1 | |
46,793 | 39 | 13 | 14 | 214 | 19 | 0 | 48 | 126 | fix_group_permissions | Prepare Breeze2 for prime time :) (#22713)
This is a review and clean-up for all the parameters and
commands for Breeze2 in order to prepare it for being
used by the contribugors.
There are various small fixes here and there, removal
of duplicated code, refactoring and moving code around
as well as cleanup and ... | https://github.com/apache/airflow.git | def fix_group_permissions():
console.print("[bright_blue]Fixing group permissions[/]")
files_to_fix_result = run_command(['git', 'ls-files', './'], capture_output=True, text=True)
if files_to_fix_result.returncode == 0:
files_to_fix = files_to_fix_result.stdout.strip().split('\n')
for f... | 123 | run_utils.py | Python | dev/breeze/src/airflow_breeze/utils/run_utils.py | 4ffd4f09532fceb67675fce4c1f5cd383eff992e | airflow | 5 | |
105,716 | 23 | 13 | 7 | 91 | 14 | 0 | 29 | 57 | _load_table_data | Fix bugs in msr_sqa dataset (#3715)
* Fix problems in msr_sqa
* Update metadata JSON
* Update version
* Update dummy data version
* Update metadata JSON
Co-authored-by: Tianbao Xie <tianbaoxiexxx@gmail.com>
Co-authored-by: Albert Villanova del Moral <8515462+albertvillanova@users.noreply.github.com> | https://github.com/huggingface/datasets.git | def _load_table_data(table_file):
rows = []
table_data = pd.read_csv(table_file)
# the first line is header
header = list(table_data.columns)
for row_data in table_data.values:
rows.append([str(_) for _ in list(row_data)])
return header, rows
| 55 | msr_sqa.py | Python | datasets/msr_sqa/msr_sqa.py | 55924c5e3b823a3b1206269bb0892cd3a9508570 | datasets | 3 | |
28,887 | 12 | 13 | 6 | 70 | 8 | 0 | 12 | 38 | call_event | [Change] Change the way transactions are handled in mutations (#10606)
* refactor account, app, attribute mutations
* add checkout refactor
* Change transactions on all mutations to context, and use call_event method to trigger webhooks
* remove comments
* refactor call_event and move app load outside tran... | https://github.com/saleor/saleor.git | def call_event(func_obj, *func_args):
connection = transaction.get_connection()
if connection.in_atomic_block:
transaction.on_commit(lambda: func_obj(*func_args))
else:
func_obj(*func_args)
| 40 | events.py | Python | saleor/core/utils/events.py | 89786f24b5296a23c093fcfea90893292473b275 | saleor | 2 | |
107,135 | 20 | 12 | 8 | 96 | 13 | 0 | 27 | 91 | set_constrained_layout | ENH: implement and use base layout_engine for more flexible layout. | https://github.com/matplotlib/matplotlib.git | def set_constrained_layout(self, constrained):
if constrained is None:
constrained = mpl.rcParams['figure.constrained_layout.use']
_constrained = bool(constrained)
_parameters = constrained if isinstance(constrained, dict) else {}
if _constrained:
self.se... | 58 | figure.py | Python | lib/matplotlib/figure.py | ec4dfbc3c83866f487ff0bc9c87b0d43a1c02b22 | matplotlib | 4 | |
31,845 | 38 | 15 | 7 | 87 | 10 | 1 | 43 | 115 | _reorder_cache | Add MVP model (#17787)
* Add MVP model
* Update README
* Remove useless module
* Update docs
* Fix bugs in tokenizer
* Remove useless test
* Remove useless module
* Update vocab
* Remove specifying
* Remove specifying
* Add #Copied ... statement
* Update paper link
* Remove useless ... | https://github.com/huggingface/transformers.git | def _reorder_cache(past, beam_idx):
reordered_past = ()
for layer_past in past:
# cached cross_attention states don't have to be reordered -> they are always the same
reordered_past += (
tuple(past_state.index_select(0, beam_idx) for past_state in layer_past[:2]) ... | @add_start_docstrings(
"""
Mvp model with a sequence classification/head on top (a linear layer on top of the pooled output) e.g. for GLUE
tasks.
""",
MVP_START_DOCSTRING,
) | 48 | modeling_mvp.py | Python | src/transformers/models/mvp/modeling_mvp.py | 3cff4cc58730409c68f8afa2f3b9c61efa0e85c6 | transformers | 3 |
95,753 | 49 | 17 | 48 | 407 | 28 | 0 | 106 | 634 | test_fetching_release_sessions_time_bounds_for_different_release | fix(release_health): Adjust granularity to be bug-compatible with sessions (#31246) | https://github.com/getsentry/sentry.git | def test_fetching_release_sessions_time_bounds_for_different_release(self):
# Same release session
self.store_session(
self.build_session(
release=self.session_release,
environment="prod",
status="exited",
started=self.... | 256 | test_sessions.py | Python | tests/snuba/sessions/test_sessions.py | e851f67ee6ca0185112a0d1c919ee63f6bed98e3 | sentry | 1 | |
167,732 | 14 | 11 | 32 | 67 | 8 | 0 | 14 | 75 | to_dense | TYP: more return annotations in core/ (#47618)
* TYP: more return annotations in core/
* from __future__ import annotations
* more __future__ | https://github.com/pandas-dev/pandas.git | def to_dense(self) -> Series:
from pandas import Series
return Series(
self._parent.array.to_dense(),
index=self._parent.index,
name=self._parent.name,
)
| 42 | accessor.py | Python | pandas/core/arrays/sparse/accessor.py | f65417656ba8c59438d832b6e2a431f78d40c21c | pandas | 1 | |
78,248 | 12 | 12 | 5 | 61 | 6 | 0 | 15 | 54 | base_queryset | Add generic settings to compliment site-specific settings (#8327) | https://github.com/wagtail/wagtail.git | def base_queryset(cls):
queryset = cls.objects.all()
if cls.select_related is not None:
queryset = queryset.select_related(*cls.select_related)
return queryset
| 36 | models.py | Python | wagtail/contrib/settings/models.py | d967eccef28ce47f60d26be1c28f2d83a25f40b0 | wagtail | 2 | |
107,364 | 7 | 9 | 3 | 40 | 6 | 0 | 7 | 28 | locator | MNT: make colorbars locators and formatters properties | https://github.com/matplotlib/matplotlib.git | def locator(self, loc):
self._long_axis().set_major_locator(loc)
self._locator = loc
| 23 | colorbar.py | Python | lib/matplotlib/colorbar.py | 6010bb43ed01c48c7c403569dd210490b236a853 | matplotlib | 1 | |
133,252 | 9 | 8 | 21 | 30 | 4 | 0 | 9 | 23 | test_failure_during_resize | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | https://github.com/ray-project/ray.git | def test_failure_during_resize(ray_start_2_cpus): # noqa: F811
if not dist.is_available():
return
| 98 | test_torch_failure.py | Python | python/ray/util/sgd/tests/test_torch_failure.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 2 | |
22,083 | 26 | 13 | 11 | 109 | 9 | 0 | 39 | 116 | dispatch_hook | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | https://github.com/pypa/pipenv.git | def dispatch_hook(key, hooks, hook_data, **kwargs):
hooks = hooks or {}
hooks = hooks.get(key)
if hooks:
if hasattr(hooks, "__call__"):
hooks = [hooks]
for hook in hooks:
_hook_data = hook(hook_data, **kwargs)
if _hook_data is not None:
... | 68 | hooks.py | Python | pipenv/patched/pip/_vendor/requests/hooks.py | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | pipenv | 6 | |
42,539 | 44 | 12 | 12 | 139 | 14 | 0 | 55 | 179 | frame_by_id | Docstring tests (#3050)
* fixed pytests
* fixed more pytests
* fixed more pytest and changed multiline pytest issues fixes for snowball.py and causal.py
* fixed pytests (mainly multiline or rounding issues)
* fixed treebank pytests, removed test for return_string=True (deprecated)
* fixed destructive.py... | https://github.com/nltk/nltk.git | def frame_by_id(self, fn_fid, ignorekeys=[]):
# get the name of the frame with this id number
try:
fentry = self._frame_idx[fn_fid]
if "_type" in fentry:
return fentry # full frame object is cached
name = fentry["name"]
except TypeEr... | 81 | framenet.py | Python | nltk/corpus/reader/framenet.py | 8a4cf5d94eb94b6427c5d1d7907ba07b119932c5 | nltk | 4 | |
45,477 | 11 | 12 | 4 | 85 | 12 | 0 | 11 | 31 | downgrade | Autogenerate migration reference doc (#21601)
* document airflow version in each alembic migration module and use this to autogen the doc
* update each migration module to have the same description used in migration ref (so it can be used in autogen) | https://github.com/apache/airflow.git | def downgrade():
with op.batch_alter_table('connection') as batch_op:
batch_op.drop_constraint(constraint_name="unique_conn_id", type_="unique")
batch_op.alter_column("conn_id", nullable=True, existing_type=sa.String(250))
| 46 | 8d48763f6d53_add_unique_constraint_to_conn_id.py | Python | airflow/migrations/versions/8d48763f6d53_add_unique_constraint_to_conn_id.py | 69f6f9e01b6df76c3c8fa266d460324163957887 | airflow | 1 | |
288,953 | 8 | 7 | 3 | 31 | 4 | 0 | 8 | 22 | serial | Add button entities for Lutron Caseta/RA3/HWQSX (#79963)
Co-authored-by: J. Nick Koston <nick@koston.org> | https://github.com/home-assistant/core.git | def serial(self) -> int | None:
return self._device["serial"]
| 17 | __init__.py | Python | homeassistant/components/lutron_caseta/__init__.py | 82322e3804af9cac55c6bea106f4bb0faff4c298 | core | 1 | |
304,022 | 10 | 10 | 3 | 45 | 6 | 0 | 10 | 24 | async_discovered_devices | Rework bluetooth to support scans from multiple sources (#76900) | https://github.com/home-assistant/core.git | def async_discovered_devices(self) -> list[BLEDevice]:
return [history[0] for history in self.history.values()]
| 28 | manager.py | Python | homeassistant/components/bluetooth/manager.py | 3bcc274dfa90d7d3c01ace83137c46a0898c107f | core | 2 | |
247,637 | 17 | 10 | 9 | 143 | 9 | 0 | 21 | 77 | test_callback_error | Add type hints to some tests/handlers files. (#12224) | https://github.com/matrix-org/synapse.git | def test_callback_error(self) -> None:
request = Mock(args={})
request.args[b"error"] = [b"invalid_client"]
self.get_success(self.handler.handle_oidc_callback(request))
self.assertRenderedError("invalid_client", "")
request.args[b"error_description"] = [b"some descripti... | 83 | test_oidc.py | Python | tests/handlers/test_oidc.py | 5dd949bee6158a8b651db9f2ae417a62c8184bfd | synapse | 1 | |
126,136 | 2 | 6 | 19 | 13 | 2 | 0 | 2 | 5 | test_checkpoint_success_by_http | [workflow] http_event_provider and accompanied listener (#26010)
### Why are these changes needed?
This PR enhances workflow functionality to receive external events from a Serve based HTTP endpoint. A workflow can then consume events asynchronously as they arrive.
### Design Logic
A `workflow.wait_for_event` no... | https://github.com/ray-project/ray.git | def test_checkpoint_success_by_http(workflow_start_regular_shared_serve):
| 101 | test_http_events_3.py | Python | python/ray/workflow/tests/test_http_events_3.py | 659d25a3a9c4794db9dbe8f428ec587470b261b0 | ray | 4 | |
187,140 | 21 | 15 | 25 | 231 | 14 | 0 | 38 | 140 | test_url | plugin.api.validate: implement ValidationError
- Implement `ValidationError`
- Inherit from `ValueError` to preserve backwards compatiblity
- Allow collecting multiple errors (AnySchema)
- Keep an error stack of parent `ValidationError`s or other exceptions
- Format error stack when converting error to string
... | https://github.com/streamlink/streamlink.git | def test_url(self):
url_ = "https://google.se/path"
assert validate(url(), url_)
assert validate(url(scheme="http"), url_)
assert validate(url(path="/path"), url_)
with self.assertRaises(ValueError) as cm:
validate(url(), "foo")
assert_validationerror(cm.exc... | 128 | test_api_validate.py | Python | tests/test_api_validate.py | 3d44da082b3ba202b9d0557bfd8ce747a1d7960c | streamlink | 1 | |
267,457 | 13 | 6 | 34 | 25 | 5 | 0 | 13 | 33 | find_matches | ansible-galaxy - support resolvelib versions >= 0.5.3, < 0.9.0 (#77649)
* ansible-galaxy - support resolvelib versions >= 0.5.3, <= 0.8.1
Test incompatibilities are removed for resolvelib >= 0.6.0
Test against the latest 0.8.x version and fix requirements
* Fix tests - use a venv for testing the range of reso... | https://github.com/ansible/ansible.git | def find_matches(self, *args, **kwargs):
# type: (t.Any, t.Any) -> list[Candidate]
r
raise NotImplementedError
| 15 | providers.py | Python | lib/ansible/galaxy/dependency_resolution/providers.py | 143e7fb45e7b916fa973613000e97ee889f5666c | ansible | 1 | |
246,021 | 136 | 15 | 98 | 755 | 58 | 0 | 243 | 1,189 | test_backfill_floating_outlier_membership_auth | Refactor the way we set `outlier` (#11634)
* `_auth_and_persist_outliers`: mark persisted events as outliers
Mark any events that get persisted via `_auth_and_persist_outliers` as, well,
outliers.
Currently this will be a no-op as everything will already be flagged as an
outlier, but I'm going to change that.
... | https://github.com/matrix-org/synapse.git | def test_backfill_floating_outlier_membership_auth(self):
OTHER_SERVER = "otherserver"
OTHER_USER = "@otheruser:" + OTHER_SERVER
# create the room
user_id = self.register_user("kermit", "test")
tok = self.login("kermit", "test")
room_id = self.helper.create_room... | 523 | test_federation.py | Python | tests/handlers/test_federation.py | 0fb3dd0830e476c0e0b89c3bf6c7855a4129ff11 | synapse | 1 | |
288,874 | 34 | 19 | 25 | 168 | 23 | 0 | 37 | 308 | test_meross_mss565_setup | Migrate HomeKit Controller to use stable identifiers (#80064) | https://github.com/home-assistant/core.git | async def test_meross_mss565_setup(hass):
accessories = await setup_accessories_from_file(hass, "mss565.json")
await setup_test_accessories(hass, accessories)
await assert_devices_and_entities_created(
hass,
DeviceTestInfo(
unique_id=HUB_TEST_ACCESSORY_ID,
name=... | 100 | test_mss565.py | Python | tests/components/homekit_controller/specific_devices/test_mss565.py | f23b1750e85f07091eb896a0b12b8f95e5646338 | core | 1 | |
276,934 | 47 | 10 | 7 | 137 | 14 | 0 | 58 | 121 | test_similar_matrices | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def test_similar_matrices(self, exact_kernel_fn, expected_values):
x = tf.constant([1.0, 3.4, -2.1, 0.9, 3.3, -2.0], shape=[2, 3])
y = tf.constant([1.1, 3.35, -2.05])
exact_kernel = exact_kernel_fn(x, y)
shape = exact_kernel.shape.as_list()
self.assertLen(shape, 2)
... | 112 | kernelized_utils_test.py | Python | keras/utils/kernelized_utils_test.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 | |
154,387 | 33 | 17 | 13 | 134 | 21 | 0 | 39 | 120 | trigger_import | FEAT-#4913: Enabling pyhdk (#4900)
Co-authored-by: ienkovich <ilya.enkovich@intel.com>
Signed-off-by: izamyati <igor.zamyatin@intel.com> | https://github.com/modin-project/modin.git | def trigger_import(*dfs):
if ASV_USE_STORAGE_FORMAT != "omnisci" or ASV_USE_IMPL == "pandas":
return
from modin.experimental.core.execution.native.implementations.omnisci_on_native.db_worker import (
DbWorker,
)
for df in dfs:
df.shape # to trigger real execution
... | 86 | common.py | Python | asv_bench/benchmarks/utils/common.py | 1c0935c1bc0856d43f69c1e32498636ee24ebc85 | modin | 4 | |
10,901 | 16 | 10 | 11 | 95 | 11 | 0 | 22 | 119 | wait_start_success | refactor: rename pod to deployment (#4230)
* refactor: rename pod to deployment
* style: fix overload and cli autocomplete
* fix: undo daemon mistake
* refactor: leftover cleanup
* fix: more test fixes
* fix: more fixes
* fix: more fixes
* fix: more fixes
* fix: more tests
* fix: fix more te... | https://github.com/jina-ai/jina.git | def wait_start_success(self):
_timeout = self.args.timeout_ready
if _timeout <= 0:
_timeout = None
else:
_timeout /= 1e3
if self._wait_for_ready_or_shutdown(_timeout):
self._check_failed_to_start()
self.logger.debug(__ready_msg__)
... | 56 | __init__.py | Python | jina/orchestrate/pods/__init__.py | 13edc16d806fb5d77a6849551178ccc75937f25f | jina | 3 | |
165,734 | 5 | 7 | 2 | 22 | 4 | 0 | 5 | 19 | _maybe_convert_setitem_value | REF: move ArrowStringArray.__setitem__ and related methods to ArrowExtensionArray (#46439) | https://github.com/pandas-dev/pandas.git | def _maybe_convert_setitem_value(self, value):
raise NotImplementedError()
| 12 | _mixins.py | Python | pandas/core/arrays/_mixins.py | 2d6a2c3e981208bf67bdd36cca726e8a399e487c | pandas | 1 | |
101,754 | 62 | 13 | 27 | 231 | 25 | 0 | 80 | 336 | __call__ | Alignments Tool updates
- Copy info back to alignments file from faces | https://github.com/deepfakes/faceswap.git | def __call__(self) -> bool:
for meta in tqdm(self._face_alignments,
desc="Updating Alignments File from PNG Header",
leave=False):
src = meta["source"]
alignment = meta["alignments"]
if not any(alignment.get(key, {}) ... | 138 | jobs_faces.py | Python | tools/alignments/jobs_faces.py | c79175cbde5600bebd65785f3821fc74b3a80cbe | faceswap | 6 | |
144,345 | 13 | 8 | 3 | 53 | 10 | 0 | 13 | 34 | _bind | [Ray DAG] Implement experimental Ray DAG API for task/class (#22058) | https://github.com/ray-project/ray.git | def _bind(self, *args, **kwargs):
from ray.experimental.dag.function_node import FunctionNode
return FunctionNode(self._function, args, kwargs, {})
| 36 | remote_function.py | Python | python/ray/remote_function.py | c065e3f69ec248383d98b45a8d1c00832ccfdd57 | ray | 1 | |
153,577 | 13 | 7 | 4 | 35 | 4 | 0 | 15 | 44 | pop | DOCS-#3099: Fix `BasePandasDataSet` docstrings warnings (#4333)
Co-authored-by: Yaroslav Igoshev <Poolliver868@mail.ru>
Signed-off-by: Alexander Myskov <alexander.myskov@intel.com> | https://github.com/modin-project/modin.git | def pop(self, item): # noqa: PR01, RT01, D200
result = self[item]
del self[item]
return result
| 21 | base.py | Python | modin/pandas/base.py | 605efa618e7994681f57b11d04d417f353ef8d50 | modin | 1 | |
294,496 | 30 | 12 | 15 | 95 | 11 | 0 | 40 | 153 | connect_with_error_handling | Add config flow to fibaro (#65203)
Co-authored-by: J. Nick Koston <nick@koston.org> | https://github.com/home-assistant/core.git | def connect_with_error_handling(self) -> None:
try:
connected = self.connect()
if not connected:
raise FibaroConnectFailed("Connect status is false")
except HTTPException as http_ex:
if http_ex.details == "Forbidden":
raise Fib... | 55 | __init__.py | Python | homeassistant/components/fibaro/__init__.py | e844c2380a2f970377bb4481bf3f6abe50ea006b | core | 5 | |
128,303 | 10 | 9 | 5 | 42 | 5 | 0 | 11 | 43 | normalized_base_dir | [Datasets] Add `partitioning` parameter to `read_` functions (#28413) | https://github.com/ray-project/ray.git | def normalized_base_dir(self) -> str:
if self._normalized_base_dir is None:
self._normalize_base_dir()
return self._normalized_base_dir
| 24 | partitioning.py | Python | python/ray/data/datasource/partitioning.py | c3ff77f5a13395631a2af580ea4429ceb5dfea13 | ray | 2 | |
208,102 | 15 | 10 | 4 | 78 | 12 | 0 | 18 | 47 | test_group_lone | Canvas Header Stamping (#7384)
* Strip down the header-stamping PR to the basics.
* Serialize groups.
* Add groups to result backend meta data.
* Fix spelling mistake.
* Revert changes to canvas.py
* Revert changes to app/base.py
* Add stamping implementation to canvas.py
* Send task to AMQP with ... | https://github.com/celery/celery.git | def test_group_lone(self, manager):
sig = group(identity.s(42), identity.s(42)) # [42, 42]
res = sig.delay()
assert res.get(timeout=TIMEOUT) == [42, 42]
| 48 | test_canvas.py | Python | t/integration/test_canvas.py | 1c4ff33bd22cf94e297bd6449a06b5a30c2c1fbc | celery | 1 | |
100,422 | 28 | 13 | 12 | 129 | 14 | 0 | 45 | 175 | process_arguments | Update code to support Tensorflow versions up to 2.8 (#1213)
* Update maximum tf version in setup + requirements
* - bump max version of tf version in launcher
- standardise tf version check
* update keras get_custom_objects for tf>2.6
* bugfix: force black text in GUI file dialogs (linux)
* dssim loss -... | https://github.com/deepfakes/faceswap.git | def process_arguments(self):
args = [arg for arg in sys.argv] # pylint:disable=unnecessary-comprehension
if self.updater:
from lib.utils import get_backend # pylint:disable=import-outside-toplevel
args.append(f"--{get_backend()}")
for arg in args:
... | 70 | setup.py | Python | setup.py | c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf | faceswap | 7 | |
216,262 | 67 | 14 | 60 | 464 | 16 | 0 | 118 | 818 | test_network_grains_secondary_ip | Filter secondary IP address by type (#61434)
* Add filter for secondary ip addresses
Should improve #61370
* Remove unnecessary space
* Add test case for secondary IP address
Test data for IPv6 secondary IP looks wrong but this is what _interfaces_ip() could return looking at the current code
* Change o... | https://github.com/saltstack/salt.git | def test_network_grains_secondary_ip(tmp_path):
data = {
"wlo1": {
"up": True,
"hwaddr": "29:9f:9f:e9:67:f4",
"inet": [
{
"address": "172.16.13.85",
"netmask": "255.255.248.0",
"broadcast": "... | 239 | test_core.py | Python | tests/pytests/unit/grains/test_core.py | 75c0cb7181d14f780b24ee5dd126f2836730053b | salt | 1 | |
294,005 | 60 | 13 | 20 | 180 | 19 | 0 | 91 | 274 | async_press | Add update platform to WLED (#68454)
* Add update platform to WLED
* Copy pasta fixes
* Apply suggestions from code review
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Update tests/components/wled/test_update.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Fix tests
Co-authored... | https://github.com/home-assistant/core.git | async def async_press(self) -> None:
LOGGER.warning(
"The WLED update button '%s' is deprecated, please "
"use the new update entity as a replacement",
self.entity_id,
)
current = self.coordinator.data.info.version
beta = self.coordinator.data... | 110 | button.py | Python | homeassistant/components/wled/button.py | 40d4495ed098624a1f0816357b260bd8a298d969 | core | 8 | |
138,162 | 53 | 15 | 28 | 259 | 32 | 0 | 66 | 446 | profile_events | [core][state] Task events backend - port profile events and turn on task backend [4/n] (#31207) | https://github.com/ray-project/ray.git | def profile_events(self):
self._check_connected()
result = defaultdict(list)
task_events = self.global_state_accessor.get_task_events()
for i in range(len(task_events)):
event = gcs_utils.TaskEvents.FromString(task_events[i])
profile = event.profile_even... | 156 | state.py | Python | python/ray/_private/state.py | 53f68cd4d6b36965dddf9409015cba8ba313da2f | ray | 5 | |
128,881 | 2 | 6 | 8 | 13 | 2 | 0 | 2 | 5 | test_torch_amp_with_custom_get_state | [AIR] Hard deprecate old Trainer, old callbacks (#29015)
Hard deprecations for ray.train.Trainer, ray.train.callbacks and ray.train.checkpoint.CheckpointStrategy. Restart-on-failure logic from BackendExecutor has also been removed as it is superseded by Tune.
Some tests have been refactored to use the new API. Test... | https://github.com/ray-project/ray.git | def test_torch_amp_with_custom_get_state(ray_start_4_cpus):
| 35 | test_torch_trainer.py | Python | python/ray/train/tests/test_torch_trainer.py | d99eff919bf785f911e4eebc87ddc4960344a139 | ray | 1 | |
250,103 | 53 | 11 | 30 | 239 | 17 | 0 | 80 | 268 | test_chain_of_fail_cleanup | Require types in tests.storage. (#14646)
Adds missing type hints to `tests.storage` package
and does not allow untyped definitions. | https://github.com/matrix-org/synapse.git | def test_chain_of_fail_cleanup(self) -> None:
# Create the room graph
event_id_a = self.create_and_send_event(self.room_id, self.user)
event_id_sf1 = self.create_and_send_event(
self.room_id, self.user, True, [event_id_a]
)
event_id_sf2 = self.create_and_send... | 156 | test_cleanup_extrems.py | Python | tests/storage/test_cleanup_extrems.py | 3ac412b4e2f8c5ba11dc962b8a9d871c1efdce9b | synapse | 1 | |
287,669 | 8 | 6 | 3 | 25 | 5 | 0 | 8 | 22 | native_value | Link manually added MQTT entities the the MQTT config entry (#78547)
Co-authored-by: Erik <erik@montnemery.com> | https://github.com/home-assistant/core.git | def native_value(self) -> StateType | datetime:
return self._state
| 14 | sensor.py | Python | homeassistant/components/mqtt/sensor.py | dea221b155da483fc1901d054e2aec38aabf618b | core | 1 | |
180,674 | 9 | 10 | 15 | 36 | 4 | 0 | 9 | 34 | create | Fix async tests (#2000)
* fix examples test
* formatting
* async examples
* working on mix
* comment out failing test
* fixed interface problem
* fixes | https://github.com/gradio-app/gradio.git | async def create(self) -> None:
if self.cache_examples:
await self.cache_interface_examples()
| 71 | examples.py | Python | gradio/examples.py | a424832ec119c490d5d1d2d7d635b4a7232dc77e | gradio | 4 | |
30,249 | 8 | 8 | 8 | 27 | 3 | 0 | 8 | 14 | get_config_file | fixed arguments for frozen env
fixed pylint errors
fixed arguments
black
fixed argument parser for all scenarios
black
docs
black | https://github.com/spotDL/spotify-downloader.git | def get_config_file() -> Path:
return get_spotdl_path() / "config.json"
| 13 | config.py | Python | spotdl/utils/config.py | 773398048b7990ab58e2998fe4d15355f7998774 | spotify-downloader | 1 | |
29,303 | 17 | 9 | 18 | 78 | 10 | 0 | 19 | 41 | _fetch_all_variants | Split test_product.py and test_variant.py into multiple files (#11173)
* Split test_product.py into multiple files
* Split test_variant.py into multiple files | https://github.com/saleor/saleor.git | def _fetch_all_variants(client, variables={}, permissions=None):
query =
response = client.post_graphql(
query, variables, permissions=permissions, check_no_permissions=False
)
content = get_graphql_content(response)
return content["data"]["productVariants"]
| 49 | test_product_variants_query.py | Python | saleor/graphql/product/tests/queries/test_product_variants_query.py | d90be220d6b687d08153934a51354011a3cb5ca1 | saleor | 1 | |
322,151 | 111 | 16 | 46 | 596 | 64 | 0 | 166 | 546 | evaluate | Update neural search readme and Add Paddle Serving Support (#1558)
* add recall inference similarity
* update examples
* updatea readme
* update dir name
* update neural search readme
* update milvus readme
* update domain adaptive pretraining readme
* fix the mistakes
* update readme
* add ... | https://github.com/PaddlePaddle/PaddleNLP.git | def evaluate(model, criterion, data_loader, file_path, mode):
example_all = []
with open(file_path, "r", encoding="utf-8") as fp:
for line in fp:
example_all.append(json.loads(line))
id2spo_path = os.path.join(os.path.dirname(file_path), "id2spo.json")
with open(id2spo_path, 'r'... | 365 | run_duie.py | Python | examples/information_extraction/DuIE/run_duie.py | 621357338437ee420eabbbf5ab19065bc85e73a5 | PaddleNLP | 6 | |
313,222 | 51 | 13 | 28 | 259 | 27 | 0 | 69 | 213 | test_event_zones | Publish Nest Motion/Person events with optional user defined zone information (#66187)
Publish Nest events with zone information if present. User defined zones are configured
in the Google Home app, and are published with Motion/Person event. | https://github.com/home-assistant/core.git | async def test_event_zones(hass):
events = async_capture_events(hass, NEST_EVENT)
subscriber = await async_setup_devices(
hass,
"sdm.devices.types.DOORBELL",
create_device_traits(["sdm.devices.traits.CameraMotion"]),
)
registry = er.async_get(hass)
entry = registry.async... | 150 | test_events.py | Python | tests/components/nest/test_events.py | b2f5ab200811c19284dea81ba298a4566fd87eda | core | 1 | |
294,621 | 37 | 15 | 21 | 166 | 13 | 0 | 43 | 246 | test_frame_interval_property | Generic IP Camera configflow 2 (#52360)
Co-authored-by: J. Nick Koston <nick@koston.org> | https://github.com/home-assistant/core.git | async def test_frame_interval_property(hass, mock_av_open):
with mock_av_open:
await async_setup_component(
hass,
"camera",
{
"camera": {
"name": "config_test",
"platform": "generic",
"strea... | 93 | test_camera.py | Python | tests/components/generic/test_camera.py | c1a2be72fc8b76b55cfde1823c5688100e397369 | core | 1 | |
275,497 | 15 | 9 | 4 | 33 | 6 | 0 | 15 | 47 | _resource_apply_dense | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _resource_apply_dense(self, grad, handle, apply_state):
raise NotImplementedError(
"`_resource_apply_dense` must be implemented in " "subclasses."
)
| 18 | optimizer_v2.py | Python | keras/optimizers/optimizer_v2/optimizer_v2.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 | |
136,345 | 6 | 6 | 7 | 21 | 3 | 0 | 6 | 20 | ping | [RLlib] Fault tolerant and elastic WorkerSets used across RLlib's algorithms (for sampling and evaluation). (#30118) | https://github.com/ray-project/ray.git | def ping(self) -> str:
return "pong"
| 10 | actor_manager.py | Python | rllib/utils/actor_manager.py | 76cb42c578adf19a70a6b4401098a7a21e0d3b29 | ray | 1 | |
128,824 | 29 | 11 | 8 | 144 | 16 | 0 | 35 | 67 | list_changed_files | [ci] Fetch base branch before git diff in determine_tests_to_run.py (#29185)
Some PRs (e.g. #29064) only change a single file but trigger the full test suite. The reason is likely that we have a stale master head ref. By fetching the latest head, we should be able to see more accurate results here and avoid running to... | https://github.com/ray-project/ray.git | def list_changed_files(commit_range):
base_branch = os.environ.get("BUILDKITE_PULL_REQUEST_BASE_BRANCH")
if base_branch:
pull_command = ["git", "fetch", "origin", base_branch]
subprocess.check_call(pull_command)
command = ["git", "diff", "--name-only", commit_range, "--"]
out = sub... | 82 | determine_tests_to_run.py | Python | ci/pipeline/determine_tests_to_run.py | 31347c026e985e9baa438bdaa3159fb5cd7dea6c | ray | 4 | |
213,050 | 40 | 14 | 13 | 203 | 21 | 0 | 58 | 181 | _get_method_path_uri_list | fix: Py27hash fix (#2182)
* Add third party py27hash code
* Add Py27UniStr and unit tests
* Add py27hash_fix utils and tests
* Add to_py27_compatible_template and tests
* Apply py27hash fix to wherever it is needed
* Apply py27hash fix, all tests pass except api_with_any_method_in_swagger
* apply py2... | https://github.com/aws/serverless-application-model.git | def _get_method_path_uri_list(self, path, stage):
methods = list(self.get_path(path).keys())
uri_list = []
path = SwaggerEditor.get_path_without_trailing_slash(path)
for m in methods:
method = "*" if (m.lower() == self._X_ANY_METHOD or m.lower() == "any") else m.up... | 124 | swagger.py | Python | samtranslator/swagger/swagger.py | a5db070f446b7cfebdaa6ad2e3dcf78f6105a272 | serverless-application-model | 6 | |
183,840 | 27 | 10 | 7 | 96 | 12 | 0 | 33 | 54 | test_stylesheet_apply_highest_specificity_wins_multiple_classes | Add various additional tests around CSS specificity | https://github.com/Textualize/textual.git | def test_stylesheet_apply_highest_specificity_wins_multiple_classes():
css = ".b.c {background: blue;} .a {background: red; color: lime;}"
stylesheet = _make_stylesheet(css)
node = DOMNode(classes="a b c")
stylesheet.apply(node)
assert node.styles.background == Color(0, 0, 255)
assert node... | 58 | test_stylesheet.py | Python | tests/css/test_stylesheet.py | 4dd0d9fae43583638f34257f97d5749ca4f2c00c | textual | 1 | |
48,737 | 10 | 11 | 6 | 115 | 10 | 0 | 15 | 65 | test_conflicting_specified_basename | raise ImproperlyConfigured exception if `basename` is not unique (#8438)
* raise ImproperlyConfigured if basename already exists
* rename already_registered function; return True/False
* additional basename tests
* additional basename tests
* Update rest_framework/routers.py
Co-authored-by: David Graves... | https://github.com/encode/django-rest-framework.git | def test_conflicting_specified_basename(self):
self.router.register(r'notes', NoteViewSet, basename='notes')
with pytest.raises(ImproperlyConfigured):
self.router.register(r'notes_kwduplicate', KWargedNoteViewSet, basename='notes')
with pytest.raises(ImproperlyConfigured):... | 67 | test_routers.py | Python | tests/test_routers.py | 48a21aa0eb3a95d32456c2a927eff9552a04231e | django-rest-framework | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.