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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
250,426 | 14 | 9 | 5 | 68 | 7 | 0 | 15 | 43 | test_no_order_last | Add missing type hints to tests.handlers. (#14680)
And do not allow untyped defs in tests.handlers. | https://github.com/matrix-org/synapse.git | def test_no_order_last(self) -> None:
ev1 = _create_event("!abc:test")
ev2 = _create_event("!xyz:test", "xyz")
self.assertEqual([ev2, ev1], _order(ev1, ev2))
| 39 | test_room_summary.py | Python | tests/handlers/test_room_summary.py | 652d1669c5a103b1c20478770c4aaf18849c09a3 | synapse | 1 | |
183,499 | 26 | 8 | 3 | 31 | 5 | 0 | 27 | 55 | _get_time | [App] Finally, time mocking in tests seems to be working! 😅
I had to add a flag in the `_timer` module that allows us to completely disable the "skip" feature of Timers, though - but it shouldn't cause too much trouble 🤞 | https://github.com/Textualize/textual.git | def _get_time(self) -> float:
# N.B. We could remove this method and always call `self._timer.get_time()` internally,
# but it's handy to have in mocking situations
return self._timer.get_time()
| 16 | _animator.py | Python | src/textual/_animator.py | 15df75919744fbea824bbf029cfb56029a3d0dc8 | textual | 1 | |
197,178 | 37 | 14 | 43 | 120 | 10 | 0 | 48 | 127 | variations | Reduce "yield from" overhead in iterables.variations()
Same treatment as was recently applied to iterables.subsets(). All
paths through iterables.variations() still return a generator object,
but variations() is no longer itself a generator function. This
avoids the overhead of one level of yield from. This change ... | https://github.com/sympy/sympy.git | def variations(seq, n, repetition=False):
r
if not repetition:
seq = tuple(seq)
if len(seq) < n:
return (val for val in []) # 0 length generator
return permutations(seq, n)
else:
if n == 0:
return (val for val in [()]) # yields 1 empty tuple
... | 76 | iterables.py | Python | sympy/utilities/iterables.py | f8ee5f4f6410ea7130fdb3080680248ac0667d8f | sympy | 6 | |
87,190 | 42 | 12 | 23 | 237 | 16 | 0 | 53 | 330 | test_get_dynamic_sampling_after_migrating_to_new_plan_manually_set_biases | feat(ds): Support new DS behaviour in project_details endpoint (#40387)
Supports new adaptive dynamic sampling behaviour alongside
the deprecated dynamic sampling behaviour and achieves that
through feature flag differentiation
This PR achieve that through the following:
- Introducing a new `DynamicSamplingBiasS... | https://github.com/getsentry/sentry.git | def test_get_dynamic_sampling_after_migrating_to_new_plan_manually_set_biases(self):
self.project.update_option("sentry:dynamic_sampling", self.dynamic_sampling_data)
new_biases = [{"id": "boostEnvironments", "active": False}]
self.project.update_option("sentry:dynamic_sampling_biases"... | 138 | test_project_details.py | Python | tests/sentry/api/endpoints/test_project_details.py | 5462ee11ad11ebb9a50323befcd286816d7898c8 | sentry | 1 | |
171,566 | 9 | 9 | 64 | 31 | 4 | 0 | 9 | 24 | unique | STYLE: Enable Pylint useless-parent-delegation warning (#49773)
* Enable Pylint useless-parent-delegation warning and remove superfluous overriding methods
* Remove annotations that caused errors.
Remove @skip_nested annotations that cause test failures and replace them with statements that suppress the useless-... | https://github.com/pandas-dev/pandas.git | def unique(self) -> ArrayLike: # pylint: disable=useless-parent-delegation
return super().unique()
| 16 | series.py | Python | pandas/core/series.py | 005486fa6c2f065e25df3c244a2bd53abe80ffb3 | pandas | 1 | |
20,520 | 17 | 11 | 6 | 87 | 13 | 0 | 21 | 43 | doctype_matches | check point progress on only bringing in pip==22.0.4 (#4966)
* vendor in pip==22.0.4
* updating vendor packaging version
* update pipdeptree to fix pipenv graph with new version of pip.
* Vendoring of pip-shims 0.7.0
* Vendoring of requirementslib 1.6.3
* Update pip index safety restrictions patch for p... | https://github.com/pypa/pipenv.git | def doctype_matches(text, regex):
m = doctype_lookup_re.search(text)
if m is None:
return False
doctype = m.group(1)
return re.compile(regex, re.I).match(doctype.strip()) is not None
| 54 | util.py | Python | pipenv/patched/notpip/_vendor/pygments/util.py | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | pipenv | 2 | |
249,499 | 20 | 10 | 13 | 99 | 12 | 0 | 22 | 126 | test_success_urlencoded | Add an admin API endpoint to find a user based on its external ID in an auth provider. (#13810) | https://github.com/matrix-org/synapse.git | def test_success_urlencoded(self) -> None:
url = "/_synapse/admin/v1/auth_providers/another-auth-provider/users/a%3Acomplex%40external%2Fid"
channel = self.make_request(
"GET",
url,
access_token=self.admin_user_tok,
)
self.assertEqual(200, c... | 61 | test_user.py | Python | tests/rest/admin/test_user.py | 74f60cec92c5aff87d6e74d177e95ec5f1a69f2b | synapse | 1 | |
309,521 | 21 | 10 | 7 | 95 | 13 | 0 | 24 | 89 | turn_on | Cleanup ADS constants and add type hints (#63390)
Co-authored-by: epenet <epenet@users.noreply.github.com> | https://github.com/home-assistant/core.git | def turn_on(self, **kwargs):
brightness = kwargs.get(ATTR_BRIGHTNESS)
self._ads_hub.write_by_name(self._ads_var, True, pyads.PLCTYPE_BOOL)
if self._ads_var_brightness is not None and brightness is not None:
self._ads_hub.write_by_name(
self._ads_var_brightne... | 62 | light.py | Python | homeassistant/components/ads/light.py | 0042bb68d97fb3cdebb6ad82500a578b1c0b647f | core | 3 | |
39,239 | 21 | 15 | 10 | 153 | 22 | 0 | 25 | 107 | compute_cooccurrence_matrix | Remove drop_duplicates() from SAR method fix #1464 (#1588)
* Remove drop_duplicates() from SAR method fix #1464
* flake is complaining
* Typos
* Define self.unity_user_affinity inside __init__()
* Remove drop_duplicates() from SAR method
* Remove duplicates in testing data
* Remove duplicates in test... | https://github.com/microsoft/recommenders.git | def compute_cooccurrence_matrix(self, df):
user_item_hits = sparse.coo_matrix(
(np.repeat(1, df.shape[0]), (df[self.col_user_id], df[self.col_item_id])),
shape=(self.n_users, self.n_items),
).tocsr()
item_cooccurrence = user_item_hits.transpose().dot(user_item_... | 101 | sar_singlenode.py | Python | recommenders/models/sar/sar_singlenode.py | 96b5053fa688bec79a729f9ea238e5f916bced01 | recommenders | 1 | |
136,002 | 6 | 12 | 3 | 45 | 8 | 0 | 6 | 20 | _remote_workers | [RLlib] Refactor `WorkerSet` on top of `FaultTolerantActorManager`. (#29938)
Signed-off-by: Jun Gong <jungong@anyscale.com> | https://github.com/ray-project/ray.git | def _remote_workers(self) -> List[ActorHandle]:
return list(self.__worker_manager.actors().values())
| 26 | worker_set.py | Python | rllib/evaluation/worker_set.py | e707ce4fb3717e3c05118c57f503dfbd03552ca9 | ray | 1 | |
125,003 | 27 | 12 | 8 | 124 | 15 | 0 | 30 | 90 | test_dataset_reader_itr_batches | [RLlib] improved unittests for dataset_reader and fixed bugs (#26458) | https://github.com/ray-project/ray.git | def test_dataset_reader_itr_batches(self):
input_config = {"format": "json", "paths": self.dset_path}
dataset, _ = get_dataset_and_shards(
{"input": "dataset", "input_config": input_config}
)
ioctx = IOContext(config={"train_batch_size": 1200}, worker_index=0)
... | 70 | test_dataset_reader.py | Python | rllib/offline/tests/test_dataset_reader.py | 569fe0109629048d08e1d9e023f7769f10bd2244 | ray | 1 | |
19,220 | 20 | 11 | 9 | 88 | 10 | 0 | 21 | 60 | find_diff | add diff style check test (#617)
* add diff style check test
* add diff style check test
* add diff style check test
* add diff style check test
* add license
* add license | https://github.com/AtsushiSakai/PythonRobotics.git | def find_diff(sha):
files = ['*.py']
res = subprocess.run(
['git', 'diff', '--unified=0', sha, '--'] + files,
stdout=subprocess.PIPE,
encoding='utf-8'
)
res.check_returncode()
return res.stdout
| 50 | test_diff_codestyle.py | Python | tests/test_diff_codestyle.py | 0dfa274be3eaddb270b2bcee197f7d34acbc1363 | PythonRobotics | 1 | |
199,311 | 27 | 11 | 15 | 103 | 11 | 0 | 32 | 59 | make_authors_file_lines | mailmap documents python2
I believe this to be useful for at least two reasons.
Current documentation either state to use `python bin/mailmap_check.py` or just
`bin/mailmap_check.py` which itself calles `python`. In both case, on ubuntu
this will run python2.
Worse, instead of printing "This script requires Python 3... | https://github.com/sympy/sympy.git | def make_authors_file_lines(git_people):
# define new lines for the file
header = filldedent().lstrip()
header_extra = "There are a total of %d authors." % len(git_people)
lines = header.splitlines()
lines.append('')
lines.append(header_extra)
lines.append('')
lines.extend(git_people)
... | 56 | mailmap_check.py | Python | bin/mailmap_check.py | e8bf22b0eb76ecb6aec12dd45549649c490e1354 | sympy | 1 | |
293,723 | 6 | 11 | 3 | 35 | 4 | 0 | 6 | 31 | dispose | Use a dedicated executor pool for database operations (#68105)
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Franck Nijhof <git@frenck.dev> | https://github.com/home-assistant/core.git | def dispose(self):
if self.recorder_or_dbworker:
return super().dispose()
| 19 | pool.py | Python | homeassistant/components/recorder/pool.py | bc862e97ed68cce8c437327651f85892787e755e | core | 2 | |
208,110 | 41 | 13 | 17 | 309 | 26 | 0 | 61 | 188 | test_group_stamping_with_replaced_group | 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_stamping_with_replaced_group(self, subtests):
self.app.conf.task_always_eager = True
self.app.conf.task_store_eager_result = True
self.app.conf.result_extended = True
nested_g = self.replace_with_group.s(8)
nested_g_res = nested_g.freeze()
sig_1 = ... | 186 | test_canvas.py | Python | t/unit/tasks/test_canvas.py | 1c4ff33bd22cf94e297bd6449a06b5a30c2c1fbc | celery | 1 | |
195,033 | 4 | 6 | 2 | 16 | 2 | 0 | 4 | 18 | is_prebuilt | Add is_prebuilt method in base huggingface class (#4508) | https://github.com/facebookresearch/ParlAI.git | def is_prebuilt(self):
return True
| 8 | dict.py | Python | parlai/agents/hugging_face/dict.py | 137afdde991f2cda824d42c8f295eead5b43e773 | ParlAI | 1 | |
60,255 | 8 | 8 | 3 | 39 | 6 | 0 | 8 | 29 | set_raw_scale | Balanced joint maximum mean discrepancy for deep transfer learning | https://github.com/jindongwang/transferlearning.git | def set_raw_scale(self, in_, scale):
self.__check_input(in_)
self.raw_scale[in_] = scale
| 24 | io.py | Python | code/deep/BJMMD/caffe/python/caffe/io.py | cc4d0564756ca067516f71718a3d135996525909 | transferlearning | 1 | |
277,073 | 4 | 12 | 2 | 42 | 7 | 0 | 4 | 10 | isbuiltin | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def isbuiltin(obj):
return _inspect.isbuiltin(tf.__internal__.decorator.unwrap(obj)[1])
| 25 | tf_inspect.py | Python | keras/utils/tf_inspect.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 | |
299,595 | 31 | 10 | 14 | 99 | 8 | 0 | 41 | 195 | _update_effect | Add entity id to template error logging (#71107)
* Add entity id to template error logging
* Increase coverage | https://github.com/home-assistant/core.git | def _update_effect(self, effect):
if effect in (None, "None", ""):
self._effect = None
return
if effect not in self._effect_list:
_LOGGER.error(
"Received invalid effect: %s for entity %s. Expected one of: %s",
effect,
... | 61 | light.py | Python | homeassistant/components/template/light.py | 75debb7dece50744713a2822fe8f508ce633c818 | core | 3 | |
142,915 | 19 | 7 | 2 | 25 | 3 | 0 | 21 | 49 | set_location | [tune/structure] Introduce experiment package (#26033)
Experiment, Trial, and config parsing moves into an `experiment` package.
Notably, the new public facing APIs will be
```
from ray.tune.experiment import Experiment
from ray.tune.experiment import Trial
``` | https://github.com/ray-project/ray.git | def set_location(self, location):
self.location = location
# No need to invalidate state cache: location is not stored in json
# self.invalidate_json_state()
| 13 | trial.py | Python | python/ray/tune/experiment/trial.py | 8a2f6bda62378c07a66169ee49504cc3703f7d35 | ray | 1 | |
297,520 | 108 | 17 | 41 | 674 | 42 | 0 | 190 | 519 | test_upload_image | Rename image integration to image_upload (#84063)
* Rename image integration to image_upload
* fix test | https://github.com/home-assistant/core.git | async def test_upload_image(hass, hass_client, hass_ws_client):
now = util_dt.utcnow()
with tempfile.TemporaryDirectory() as tempdir, patch.object(
hass.config, "path", return_value=tempdir
), patch("homeassistant.util.dt.utcnow", return_value=now):
assert await async_setup_component(h... | 367 | test_init.py | Python | tests/components/image_upload/test_init.py | 80b357262795a57dc267a313064266fd2682ca74 | core | 2 | |
301,380 | 97 | 16 | 44 | 560 | 43 | 0 | 166 | 667 | async_turn_on | Fix Hue SONOFF S31 Lite zb plug (#69589)
* Update light.py
Same issue as https://github.com/home-assistant/core/issues/46619 with SONOFF S13 Lite Zigbee plug.
* Update light.py | https://github.com/home-assistant/core.git | async def async_turn_on(self, **kwargs):
command = {"on": True}
if ATTR_TRANSITION in kwargs:
command["transitiontime"] = int(kwargs[ATTR_TRANSITION] * 10)
if ATTR_HS_COLOR in kwargs:
if self.is_osram:
command["hue"] = int(kwargs[ATTR_HS_COLOR][... | 332 | light.py | Python | homeassistant/components/hue/v1/light.py | 72cb320ed769275424b739bf00890d4d33451f5c | core | 16 | |
153,630 | 12 | 7 | 3 | 32 | 4 | 0 | 12 | 34 | loc | 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 loc(self): # noqa: RT01, D200
from .indexing import _LocIndexer
return _LocIndexer(self)
| 16 | base.py | Python | modin/pandas/base.py | 605efa618e7994681f57b11d04d417f353ef8d50 | modin | 1 | |
216,179 | 18 | 11 | 7 | 90 | 10 | 0 | 23 | 52 | hash_file | fixes saltstack/salt#61562 cp functions derive saltenv from config | https://github.com/saltstack/salt.git | def hash_file(path, saltenv=None):
if not saltenv:
saltenv = __opts__["saltenv"] or "base"
path, senv = salt.utils.url.split_env(path)
if senv:
saltenv = senv
return _client().hash_file(path, saltenv)
| 53 | cp.py | Python | salt/modules/cp.py | 2bd6323ef5f87d871891a59917ee96f44ef55e75 | salt | 4 | |
268,960 | 45 | 14 | 17 | 208 | 20 | 0 | 58 | 102 | map_structure_with_atomic | Improve the error message.
Because `repr(np.int64(3)) == repr(3)`, the error message is frustratingly confusing when numpy ints are passed as dimensions.
PiperOrigin-RevId: 428366474 | https://github.com/keras-team/keras.git | def map_structure_with_atomic(is_atomic_fn, map_fn, nested):
if is_atomic_fn(nested):
return map_fn(nested)
# Recursively convert.
if not tf.nest.is_nested(nested):
raise ValueError(
f'Received non-atomic and non-sequence element: {nested} '
f'of type {type(nested)}')
if tf.__interna... | 123 | tf_utils.py | Python | keras/utils/tf_utils.py | cff8cc93305d1c4a54385fb623fe895dafa0845c | keras | 7 | |
338,247 | 21 | 10 | 3 | 53 | 9 | 0 | 21 | 31 | parse_flag_from_env | Make rich toggleable and seperate out a new environment utility file (#779)
* Toggleable rich
* Refactor into environment utils | https://github.com/huggingface/accelerate.git | def parse_flag_from_env(key, default=False):
value = os.environ.get(key, str(default))
return strtobool(value) == 1 # As its name indicates `strtobool` actually returns an int...
| 32 | environment.py | Python | src/accelerate/utils/environment.py | 6f7fa4f48e05da0f1fc745f39e840b6304844202 | accelerate | 1 | |
52,902 | 18 | 13 | 12 | 90 | 9 | 0 | 18 | 79 | __str__ | Update `State.__str__` to only include type if meaningful and drop "message=" | https://github.com/PrefectHQ/prefect.git | def __str__(self) -> str:
display_type = (
f", type={self.type}"
if self.type.value.lower() != self.name.lower()
else ""
)
return f"{self.name}({self.message!r}{display_type})"
| 37 | states.py | Python | src/prefect/orion/schemas/states.py | db6b16ef0f7d0adcd47d2ad96e8453ebd7590a22 | prefect | 2 | |
244,309 | 12 | 10 | 6 | 98 | 13 | 0 | 13 | 55 | _log_data_table | [Feature] Dedicated WandbLogger for MMDetection (#7459)
* [Fix] Adjust the order of get_classes and FileClient. (#7276)
* delete -sv (#7277)
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
* wandb-integration
* docstring
* lint
* log config+handle segmentation results
* r... | https://github.com/open-mmlab/mmdetection.git | def _log_data_table(self):
data_artifact = self.wandb.Artifact('val', type='dataset')
data_artifact.add(self.data_table, 'val_data')
self.wandb.run.use_artifact(data_artifact)
data_artifact.wait()
self.data_table_ref = data_artifact.get('val_data')
| 55 | wandblogger_hook.py | Python | mmdet/core/hook/wandblogger_hook.py | b637c99d4955e69ca2ff5d94a2c9bd9d962096ab | mmdetection | 1 | |
266,668 | 63 | 12 | 16 | 245 | 30 | 0 | 84 | 154 | execute_command | ansible-test - Fix consistency of managed venvs. (#77028) | https://github.com/ansible/ansible.git | def execute_command(cmd, cwd=None, capture=False, env=None): # type: (t.List[str], t.Optional[str], bool, t.Optional[t.Dict[str, str]]) -> None
log('Execute command: %s' % ' '.join(cmd_quote(c) for c in cmd), verbosity=1)
cmd_bytes = [to_bytes(c) for c in cmd]
if capture:
stdout = subprocess... | 156 | requirements.py | Python | test/lib/ansible_test/_util/target/setup/requirements.py | 68fb3bf90efa3a722ba5ab7d66b1b22adc73198c | ansible | 7 | |
299,381 | 50 | 15 | 20 | 226 | 21 | 0 | 64 | 260 | save_language_translations | Skip translations when integration no longer exists (#71004)
* Skip translations when integration no longer exists
* Update script/translations/download.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> | https://github.com/home-assistant/core.git | def save_language_translations(lang, translations):
components = translations.get("component", {})
for component, component_translations in components.items():
base_translations = get_component_translations(component_translations)
if base_translations:
if (path := get_component_... | 136 | download.py | Python | script/translations/download.py | 7fbc3f63643c314d8c8097e6fd4bc9a1b2314dc2 | core | 6 | |
38,770 | 33 | 13 | 4 | 83 | 13 | 0 | 36 | 71 | create_position_ids_from_input_ids | 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 create_position_ids_from_input_ids(self, input_ids, padding_idx):
# The series of casts and type-conversions here are carefully balanced to both work with ONNX export and XLA.
mask = input_ids.ne(padding_idx).int()
incremental_indices = (torch.cumsum(mask, dim=1).type_as(mask)) * ma... | 51 | modeling_layoutlmv3.py | Python | src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | 31ee80d55673f32c0f5d50936f371e661b74b21a | transformers | 1 | |
319,804 | 14 | 10 | 11 | 50 | 6 | 0 | 16 | 35 | supported_file_type | Moves the barcode related functionality out of tasks and into its own location. Splits up the testing based on that | https://github.com/paperless-ngx/paperless-ngx.git | def supported_file_type(mime_type) -> bool:
supported_mime = ["application/pdf"]
if settings.CONSUMER_BARCODE_TIFF_SUPPORT:
supported_mime += ["image/tiff"]
return mime_type in supported_mime
| 27 | barcodes.py | Python | src/documents/barcodes.py | ec045e81f217e8b667614c32879f873c220ae035 | paperless-ngx | 2 | |
195,808 | 81 | 12 | 9 | 119 | 17 | 0 | 122 | 234 | root_equality_test | Introduce `Poly.root_equality_test()`
This replaces the `Poly.root_comparison_tools()` method. | https://github.com/sympy/sympy.git | def root_equality_test(f):
delta_sq = f.root_separation_lower_bound_squared()
# We have delta_sq = delta**2, where delta is a lower bound on the
# minimum separation between any two roots of this polynomial.
# Let eps = delta/3, and define eps_sq = eps**2 = delta**2/9.
e... | 73 | polytools.py | Python | sympy/polys/polytools.py | a4072458438847d3da259ad91828566dbf1e214b | sympy | 1 | |
247,622 | 219 | 22 | 190 | 1,519 | 42 | 0 | 539 | 3,789 | test_upload_signatures | Add type hints to some tests/handlers files. (#12224) | https://github.com/matrix-org/synapse.git | def test_upload_signatures(self) -> None:
# set up a user with cross-signing keys and a device. This user will
# try uploading signatures
local_user = "@boris:" + self.hs.hostname
device_id = "xyz"
# private key: OMkooTr76ega06xNvXIGPbgvvxAOzmQncN8VObS7aBA
devic... | 876 | test_e2e_keys.py | Python | tests/handlers/test_e2e_keys.py | 5dd949bee6158a8b651db9f2ae417a62c8184bfd | synapse | 1 | |
19,685 | 33 | 13 | 8 | 101 | 13 | 0 | 36 | 107 | pip_version | Issue 4993 Add standard pre commit hooks and apply linting. (#4994)
* Add .pre-commit-config.yaml to the project and exclude tests (for now). This does not include the MyPy linting that pip does but does include everything else. | https://github.com/pypa/pipenv.git | def pip_version(self):
# type: () -> Version
from .vendor.packaging.version import parse as parse_version
pip = next(
iter(pkg for pkg in self.get_installed_packages() if pkg.key == "pip"), None
)
if pip is not None:
return parse_version(pip.vers... | 60 | environment.py | Python | pipenv/environment.py | 9a3b3ce70621af6f9adaa9eeac9cf83fa149319c | pipenv | 4 | |
119,833 | 64 | 15 | 17 | 286 | 31 | 1 | 85 | 111 | poly | lax_numpy: move poly functions into numpy.polynomial | https://github.com/google/jax.git | def poly(seq_of_zeros):
_check_arraylike('poly', seq_of_zeros)
seq_of_zeros, = _promote_dtypes_inexact(seq_of_zeros)
seq_of_zeros = atleast_1d(seq_of_zeros)
sh = seq_of_zeros.shape
if len(sh) == 2 and sh[0] == sh[1] and sh[0] != 0:
# import at runtime to avoid circular import
from jax._src.numpy impo... | @_wraps(np.polyval, lax_description="""\
The ``unroll`` parameter is JAX specific. It does not effect correctness but can
have a major impact on performance for evaluating high-order polynomials. The
parameter controls the number of unrolled steps with ``lax.scan`` inside the
``polyval`` implementation. Consider settin... | 158 | polynomial.py | Python | jax/_src/numpy/polynomial.py | 603bb3c5ca288674579211e64fa47c6b2b0fb7a6 | jax | 7 |
186,168 | 5 | 6 | 13 | 16 | 1 | 0 | 5 | 8 | test_overlapping_priority_bindings | Add tests for competing bindings an priority permutations
This is set to xfail at the moment because the tested result is what I think
should be the result, but what happens now isn't that. Need to check with
Will to see what he thinks the correct resolution is here. | https://github.com/Textualize/textual.git | async def test_overlapping_priority_bindings() -> None:
| 57 | test_binding_inheritance.py | Python | tests/test_binding_inheritance.py | 618db503b9179481a7374e61a1cfce7007934970 | textual | 1 | |
299,284 | 32 | 14 | 14 | 115 | 12 | 0 | 42 | 200 | _media_status | Add state buffering to media_player and use it in cast (#70802) | https://github.com/home-assistant/core.git | def _media_status(self):
media_status = self.media_status
media_status_received = self.media_status_received
if (
media_status is None
or media_status.player_state == MEDIA_PLAYER_STATE_UNKNOWN
):
groups = self.mz_media_status
for... | 72 | media_player.py | Python | homeassistant/components/cast/media_player.py | 66551e6fcbd063e53c13adc8a6462b8e00ce1450 | core | 6 | |
215,968 | 60 | 20 | 93 | 538 | 25 | 0 | 153 | 406 | list_repo_pkgs | Update to latest ``pyupgrade`` hook. Stop skipping it on CI.
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com> | https://github.com/saltstack/salt.git | def list_repo_pkgs(*args, **kwargs):
byrepo = kwargs.pop("byrepo", False)
cacheonly = kwargs.pop("cacheonly", False)
fromrepo = kwargs.pop("fromrepo", "") or ""
disablerepo = kwargs.pop("disablerepo", "") or ""
enablerepo = kwargs.pop("enablerepo", "") or ""
repo_arg = _get_options(fromrep... | 713 | yumpkg.py | Python | salt/modules/yumpkg.py | f2a783643de61cac1ff3288b40241e5ce6e1ddc8 | salt | 53 | |
19,706 | 9 | 8 | 2 | 43 | 5 | 0 | 9 | 23 | matches_minor | Issue 4993 Add standard pre commit hooks and apply linting. (#4994)
* Add .pre-commit-config.yaml to the project and exclude tests (for now). This does not include the MyPy linting that pip does but does include everything else. | https://github.com/pypa/pipenv.git | def matches_minor(self, other):
return (self.major, self.minor) == (other.major, other.minor)
| 28 | installers.py | Python | pipenv/installers.py | 9a3b3ce70621af6f9adaa9eeac9cf83fa149319c | pipenv | 1 | |
312,987 | 6 | 9 | 3 | 38 | 6 | 0 | 6 | 20 | name | Add Moehlenhoff Alpha2 underfloor heating system integration (#42771)
* Add Moehlenhoff Alpha2 underfloor heating system integration
* isort changes
* flake8 changes
* Do not exclude config_flow.py
* pylint changes
* Add config_flow test
* correct requirements_test_all.txt
* more tests
* Update... | https://github.com/home-assistant/core.git | def name(self) -> str:
return self.coordinator.data[self.heat_area_id]["HEATAREA_NAME"]
| 22 | climate.py | Python | homeassistant/components/moehlenhoff_alpha2/climate.py | 243d003acc11d638feb3867410c3cbb1987520bc | core | 1 | |
14,099 | 7 | 4 | 11 | 35 | 7 | 1 | 8 | 28 | test_class_var_forward_ref | guard against ClassVar in fields (#4064)
* guard against ClassVar in fields, fix #3679
* fix linting
* skipif for test_class_var_forward_ref | https://github.com/pydantic/pydantic.git | def test_class_var_forward_ref(create_module):
# see #3679
create_module(
# language=Python
| create_module(
# language=Python
""" | 9 | test_forward_ref.py | Python | tests/test_forward_ref.py | a45276d6b1c0dd7c10d46767bb19954401b3b04a | pydantic | 1 |
281,687 | 47 | 12 | 17 | 221 | 8 | 0 | 69 | 108 | excel_columns | DCF Refactoring and Improvements (#1198)
* Refactored excel letter generation
* Updated error handling
* Refactored df creation
* Refactored sisters
* Refactored ratios
* Refactored worksheets
* Finished refactoring attributes
* Massively refactored add _ratios
* Slight changes
* refactored ... | https://github.com/OpenBB-finance/OpenBBTerminal.git | def excel_columns() -> List[str]:
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"]
letters += ["N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
opts = (
[f"{x}" for x in letters]
+ [f"{x}{y}" for x in letters for y in letters]
+ [f"{x}... | 112 | helper_funcs.py | Python | gamestonk_terminal/helper_funcs.py | a3d551105fd038ed00da277717b15df7c465b0a9 | OpenBBTerminal | 7 | |
35,793 | 34 | 10 | 5 | 111 | 11 | 0 | 35 | 74 | remove_low_and_no_objects | Maskformer (#15682)
* maskformer
* conflicts
* conflicts
* minor fixes
* feature extractor test fix
refactor MaskFormerLoss following conversation
MaskFormer related types should not trigger a module time import error
missed one
removed all the types that are not used
update config mapping
... | https://github.com/huggingface/transformers.git | def remove_low_and_no_objects(self, masks, scores, labels, object_mask_threshold, num_labels):
if not (masks.shape[0] == scores.shape[0] == labels.shape[0]):
raise ValueError("mask, scores and labels must have the same shape!")
to_keep = labels.ne(num_labels) & (scores > object_mas... | 75 | feature_extraction_maskformer.py | Python | src/transformers/models/maskformer/feature_extraction_maskformer.py | d83d22f578276e9f201b0b3b0f8f9bd68e86c133 | transformers | 2 | |
129,202 | 14 | 10 | 3 | 46 | 9 | 0 | 14 | 71 | update_context | [doc] Fix sklearn doc error, introduce MyST markdown parser (#21527) | https://github.com/ray-project/ray.git | def update_context(app, pagename, templatename, context, doctree):
context["feedback_form_url"] = feedback_form_url(app.config.project,
pagename)
# see also http://searchvoidstar.tumblr.com/post/125486358368/making-pdfs-from-markdown-on-readthedocsorg-usin... | 29 | conf.py | Python | doc/source/conf.py | 703c1610348615dcb8c2d141a0c46675084660f5 | ray | 1 | |
294,547 | 18 | 9 | 10 | 83 | 10 | 0 | 21 | 104 | _async_update_and_abort_for_matching_unique_id | Add support for setting up encrypted samsung tvs from config flow (#68717)
Co-authored-by: epenet <epenet@users.noreply.github.com> | https://github.com/home-assistant/core.git | def _async_update_and_abort_for_matching_unique_id(self) -> None:
updates = {CONF_HOST: self._host}
if self._mac:
updates[CONF_MAC] = self._mac
if self._ssdp_rendering_control_location:
updates[
CONF_SSDP_RENDERING_CONTROL_LOCATION
] =... | 51 | config_flow.py | Python | homeassistant/components/samsungtv/config_flow.py | cc75cebfc5b3e9316cdbaf82c5c72437521f819b | core | 3 | |
245,867 | 162 | 11 | 74 | 862 | 54 | 0 | 338 | 1,252 | test_condinst_bboxhead_loss | [Feature]: Support Condinst (#9223)
* [Feature]: support condinst for instance segmentation
* update
* update
* update
* fix config name and add test unit
* fix squeeze error
* add README and chang mask to poly | https://github.com/open-mmlab/mmdetection.git | def test_condinst_bboxhead_loss(self):
s = 256
img_metas = [{
'img_shape': (s, s, 3),
'pad_shape': (s, s, 3),
'scale_factor': 1,
}]
condinst_bboxhead = CondInstBboxHead(
num_classes=4,
in_channels=1,
feat_ch... | 545 | test_condinst_head.py | Python | tests/test_models/test_dense_heads/test_condinst_head.py | 79c8295801acedee0cbdbf128a01b9fe162646b0 | mmdetection | 2 | |
57,784 | 5 | 6 | 13 | 18 | 4 | 0 | 5 | 12 | test_flow_timeouts_are_not_crashes | Add `Crashed` as canonical state type (PrefectHQ/orion#2353)
Co-authored-by: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> | https://github.com/PrefectHQ/prefect.git | async def test_flow_timeouts_are_not_crashes(self, flow_run, orion_client):
| 80 | test_engine.py | Python | tests/test_engine.py | 907fc7c0a895b9f46484690be44a2a5660b320ee | prefect | 1 | |
269,772 | 72 | 12 | 17 | 171 | 16 | 0 | 107 | 355 | _get_benchmark_name | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _get_benchmark_name(self):
stack = tf_inspect.stack()
name = None
for frame in stack[::-1]:
f_locals = frame[0].f_locals
f_self = f_locals.get("self", None)
if isinstance(f_self, tf.test.Benchmark):
name = frame[3] # Get the metho... | 97 | eager_microbenchmarks_test.py | Python | keras/benchmarks/eager_microbenchmarks_test.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 6 | |
271,559 | 61 | 13 | 23 | 258 | 29 | 0 | 86 | 303 | _set_save_spec | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _set_save_spec(self, inputs, args=None, kwargs=None):
if self._saved_model_inputs_spec is not None:
return # Already set.
args = args or []
kwargs = kwargs or {}
input_names = self.input_names
if not input_names:
input_names = compile_utils.... | 165 | training.py | Python | keras/engine/training.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 9 | |
138,198 | 7 | 6 | 7 | 27 | 5 | 0 | 7 | 21 | get_metrics | [data] New executor backend [1/n]--- Add basic interfaces (#31216)
This PR adds the basic interfaces and feature flags; split out from https://github.com/ray-project/ray/pull/30903/files
See REP ray-project/enhancements#18 for more details. | https://github.com/ray-project/ray.git | def get_metrics(self) -> Dict[str, int]:
return {}
| 16 | interfaces.py | Python | python/ray/data/_internal/execution/interfaces.py | 2cd4637521a0c75e0375266ff52d3dfca2084c2d | ray | 1 | |
6,396 | 45 | 14 | 19 | 190 | 9 | 0 | 72 | 184 | _get_text_feature_max_length | Improve AutoML heuristics for text classification (#1815)
* Improve AutoML heuristics for text classification
Co-authored-by: Anne Holler <anne@vmware.com> | https://github.com/ludwig-ai/ludwig.git | def _get_text_feature_max_length(config, training_set_metadata) -> int:
max_length = 0
for feature in config["input_features"]:
if feature["type"] == TEXT:
feature_max_len = training_set_metadata[feature["name"]]["word_max_sequence_length"]
if feature_max_len > max_length:
... | 110 | auto_tune_config.py | Python | ludwig/automl/auto_tune_config.py | d77aaf8da39f04a353a3a08fb699ae8a96ffea3a | ludwig | 8 | |
260,274 | 17 | 11 | 5 | 64 | 11 | 0 | 18 | 37 | test_warning_new_default | API prepare change of default solver QuantileRegressor (#23637)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> | https://github.com/scikit-learn/scikit-learn.git | def test_warning_new_default(X_y_data):
X, y = X_y_data
model = QuantileRegressor()
with pytest.warns(FutureWarning, match="The default solver will change"):
model.fit(X, y)
| 36 | test_quantile.py | Python | sklearn/linear_model/tests/test_quantile.py | a7e27dab2ce76281425e66bfc8611a84a2bf6afa | scikit-learn | 1 | |
94,771 | 19 | 9 | 6 | 75 | 6 | 0 | 25 | 47 | resolve_full_name | feat(devtools): Add support to dump the import graph (#37698) | https://github.com/getsentry/sentry.git | def resolve_full_name(base, name, level):
if level == 0:
return name
bits = base.rsplit(".", level - 1)
base = bits[0]
return f"{base}.{name}" if name else base
| 42 | _importchecker.py | Python | src/sentry/_importchecker.py | 36d17659021fab2e2a618a8c8a9c003bc0f359fe | sentry | 3 | |
189,404 | 15 | 12 | 6 | 86 | 12 | 0 | 16 | 62 | add_axes | Fix `add_axes` in :class:`~.VectorScene`. (#2444)
* fix bug
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> | https://github.com/ManimCommunity/manim.git | def add_axes(self, animate=False, color=WHITE, **kwargs):
axes = Axes(color=color, axis_config={"unit_size": 1})
if animate:
self.play(Create(axes))
self.add(axes)
return axes
| 53 | vector_space_scene.py | Python | manim/scene/vector_space_scene.py | 5789be81609c8bf6d98d1d87d4061477d0cd37b9 | manim | 2 | |
337,603 | 70 | 13 | 36 | 182 | 26 | 0 | 79 | 243 | debug_launcher | Refactor version checking into a utility (#395)
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> | https://github.com/huggingface/accelerate.git | def debug_launcher(function, args=(), num_processes=2):
if is_torch_version("<", "1.5.0"):
raise ImportError(
"Using `debug_launcher` for distributed training on GPUs require torch >= 1.5.0, got "
f"{torch.__version__}."
)
from torch.multiprocessing import start_pro... | 102 | launchers.py | Python | src/accelerate/launchers.py | f6ec2660f01e5bb37399407b3a01b72a43ceb328 | accelerate | 2 | |
6,553 | 55 | 14 | 18 | 229 | 30 | 0 | 62 | 253 | extract_pytorch_structures | feat: Modify Trainer to use marshmallow_dataclass syntax for handling hyperparameters. Add basic scripting for docstring extraction to marshmallow schema. Fix some existing marshmallow issues. (#1606) | https://github.com/ludwig-ai/ludwig.git | def extract_pytorch_structures():
for opt in lmo.optimizer_registry:
# Get the torch class:
optimizer_class = lmo.optimizer_registry[opt][0]
# Parse and clean the class structure:
path = get_fully_qualified_class_name(optimizer_class)
opt_struct = get_pytkdocs_structure... | 136 | extract_schema.py | Python | scripts/extract_schema.py | 23a33eef3bc7ea3ba33ec56dc9b56ba38462648a | ludwig | 2 | |
154,614 | 50 | 16 | 24 | 387 | 19 | 0 | 86 | 394 | test_uint | FEAT-#4946: Replace OmniSci with HDK (#4947)
Co-authored-by: Iaroslav Igoshev <Poolliver868@mail.ru>
Signed-off-by: Andrey Pavlenko <andrey.a.pavlenko@gmail.com> | https://github.com/modin-project/modin.git | def test_uint(self, md_df_constructor):
pd_df = pandas.DataFrame(
{
"uint8_in_int_bounds": np.array([1, 2, 3], dtype="uint8"),
"uint8_out-of_int_bounds": np.array(
[(2**8) - 1, (2**8) - 2, (2**8) - 3], dtype="uint8"
),
... | 248 | test_dataframe.py | Python | modin/experimental/core/execution/native/implementations/hdk_on_native/test/test_dataframe.py | e5b1888cd932909e49194d58035da34b210b91c4 | modin | 1 | |
154,579 | 79 | 16 | 36 | 387 | 35 | 0 | 126 | 604 | astype | FEAT-#4946: Replace OmniSci with HDK (#4947)
Co-authored-by: Iaroslav Igoshev <Poolliver868@mail.ru>
Signed-off-by: Andrey Pavlenko <andrey.a.pavlenko@gmail.com> | https://github.com/modin-project/modin.git | def astype(self, col_dtypes, **kwargs):
columns = col_dtypes.keys()
new_dtypes = self._dtypes.copy()
for column in columns:
dtype = col_dtypes[column]
if (
not isinstance(dtype, type(self._dtypes[column]))
or dtype != self._dtypes[... | 244 | dataframe.py | Python | modin/experimental/core/execution/native/implementations/hdk_on_native/dataframe/dataframe.py | e5b1888cd932909e49194d58035da34b210b91c4 | modin | 13 | |
100,326 | 20 | 12 | 6 | 84 | 10 | 0 | 21 | 87 | _clear_trace_variables | 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 _clear_trace_variables(self):
if self._trace_vars:
for name, (var, trace) in self._trace_vars.items():
logger.debug("Clearing trace from variable: %s", name)
var.trace_vdelete("w", trace)
self._trace_vars = {}
| 50 | display_command.py | Python | lib/gui/display_command.py | c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf | faceswap | 3 | |
86,527 | 33 | 15 | 10 | 116 | 18 | 0 | 33 | 126 | update_existing_attachments | ref(perf-issues): Modularize post_process_group (ISP-11) (#39594)
Fully modularizes `post_process_group` as final step before adding
multiple event types to it. | https://github.com/getsentry/sentry.git | def update_existing_attachments(job):
# Patch attachments that were ingested on the standalone path.
with sentry_sdk.start_span(op="tasks.post_process_group.update_existing_attachments"):
try:
from sentry.models import EventAttachment
event = job["event"]
Event... | 66 | post_process.py | Python | src/sentry/tasks/post_process.py | bc59434031930199dcdc056943c2ba4a17bbd5c8 | sentry | 2 | |
306,781 | 31 | 8 | 3 | 117 | 17 | 1 | 31 | 96 | test_convert_from_miles | Refactor distance, speed and volume utils (#77952)
* Refactor distance util
* Fix bmw connected drive tests
* Adjust here travel time tests
* Adjust waze travel time tests
* Adjust test_distance
* Adjust rounding values
* Adjust more tests
* Adjust volume conversions
* Add tests | https://github.com/home-assistant/core.git | def test_convert_from_miles(unit, expected):
miles = 5
assert distance_util.convert(miles, LENGTH_MILES, unit) == pytest.approx(expected)
@pytest.mark.parametrize(
"unit,expected",
[
(LENGTH_KILOMETERS, 0.0045720000000000005),
(LENGTH_METERS, 4.572),
(LENGTH_CENTIMETERS, 4... | @pytest.mark.parametrize(
"unit,expected",
[
(LENGTH_KILOMETERS, 0.0045720000000000005),
(LENGTH_METERS, 4.572),
(LENGTH_CENTIMETERS, 457.2),
(LENGTH_MILLIMETERS, 4572),
(LENGTH_MILES, 0.002840908212),
(LENGTH_FEET, 15.00000048),
(LENGTH_INCHES, 180.000097... | 29 | test_distance.py | Python | tests/util/test_distance.py | 9490771a8737892a7a86afd866a3520b836779fd | core | 1 |
276,113 | 14 | 6 | 7 | 18 | 4 | 0 | 14 | 20 | layer_call_wrapper | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def layer_call_wrapper(call_collection, method, name):
# Create wrapper that deals with losses and call context. | 37 | save_impl.py | Python | keras/saving/saved_model/save_impl.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 | |
85,584 | 77 | 16 | 35 | 386 | 37 | 0 | 90 | 526 | test_dynamic_smapling_rule_edition | ref(sampling): Create sampling audit logs - (#38501) | https://github.com/getsentry/sentry.git | def test_dynamic_smapling_rule_edition(self):
dynamic_sampling = _dyn_sampling_data()
project = self.project # force creation
# Update project adding three rules
project.update_option("sentry:dynamic_sampling", dynamic_sampling)
self.login_as(self.user)
token ... | 230 | test_project_details.py | Python | tests/sentry/api/endpoints/test_project_details.py | 414347e903b490c69dbe5115bb5572c97aab4493 | sentry | 1 | |
291,598 | 18 | 10 | 6 | 72 | 8 | 0 | 19 | 58 | async_update_movies | Add Twinkly effects (#82861)
* Add Twinkly effects
* Remove spurious comment | https://github.com/home-assistant/core.git | async def async_update_movies(self) -> None:
movies = await self._client.get_saved_movies()
_LOGGER.debug("Movies: %s", movies)
if "movies" in movies:
self._movies = movies["movies"]
| 39 | light.py | Python | homeassistant/components/twinkly/light.py | 33cd59d3c2e1f945c16b39d929349e3eeb4cfb9a | core | 2 | |
266,660 | 26 | 10 | 9 | 93 | 11 | 0 | 29 | 65 | collect_bootstrap | ansible-test - Fix consistency of managed venvs. (#77028) | https://github.com/ansible/ansible.git | def collect_bootstrap(python): # type: (PythonConfig) -> t.List[PipCommand]
infrastructure_packages = get_venv_packages(python)
pip_version = infrastructure_packages['pip']
packages = [f'{name}=={version}' for name, version in infrastructure_packages.items()]
bootstrap = PipBootstrap(
pip... | 51 | python_requirements.py | Python | test/lib/ansible_test/_internal/python_requirements.py | 68fb3bf90efa3a722ba5ab7d66b1b22adc73198c | ansible | 2 | |
3,815 | 20 | 10 | 9 | 125 | 17 | 0 | 27 | 98 | test_jobs_completed_immediately | 🎉 🎉 Source FB Marketing: performance and reliability fixes (#9805)
* Facebook Marketing performance improvement
* add comments and little refactoring
* fix integration tests with the new config
* improve job status handling, limit concurrency to 10
* fix campaign jobs, refactor manager
* big refactori... | https://github.com/airbytehq/airbyte.git | def test_jobs_completed_immediately(self, api, mocker, time_mock):
jobs = [
mocker.Mock(spec=InsightAsyncJob, attempt_number=1, failed=False),
mocker.Mock(spec=InsightAsyncJob, attempt_number=1, failed=False),
]
manager = InsightAsyncJobManager(api=api, jobs=jobs... | 83 | test_async_job_manager.py | Python | airbyte-integrations/connectors/source-facebook-marketing/unit_tests/test_async_job_manager.py | a3aae8017a0a40ff2006e2567f71dccb04c997a5 | airbyte | 1 | |
191,668 | 15 | 11 | 5 | 68 | 7 | 0 | 17 | 29 | test__split_list_double_doc | Harrison/map reduce merge (#344)
Co-authored-by: John Nay <JohnNay@users.noreply.github.com> | https://github.com/hwchase17/langchain.git | def test__split_list_double_doc() -> None:
docs = [Document(page_content="foo"), Document(page_content="bar")]
doc_list = _split_list_of_docs(docs, _fake_docs_len_func, 100)
assert doc_list == [docs]
| 40 | test_combine_documents.py | Python | tests/unit_tests/chains/test_combine_documents.py | c1b50b7b13545b1549c051182f547cfc2f8ed0be | langchain | 1 | |
266,482 | 30 | 14 | 7 | 151 | 18 | 0 | 36 | 98 | get_default_targets | ansible-test - Defer loading of completion entries. (#76852)
* ansible-test - Defer loading of completion entries.
This avoids a traceback when running ansible-test outside of a supported directory. | https://github.com/ansible/ansible.git | def get_default_targets(self, context): # type: (HostContext) -> t.List[ControllerConfig]
if self.name in filter_completion(docker_completion()):
defaults = self.get_defaults(context)
pythons = {version: defaults.get_python_path(version) for version in defaults.supported_python... | 95 | host_configs.py | Python | test/lib/ansible_test/_internal/host_configs.py | e9ffcf3c85f2fa40a20ee03bd9c1ce7296574cd1 | ansible | 4 | |
129,038 | 78 | 14 | 54 | 242 | 27 | 0 | 96 | 315 | step | [tune] Add test for heterogeneous resource request deadlocks (#21397)
This adds a test for potential resource deadlocks in experiments with heterogeneous PGFs. If the PGF of a later trial becomes ready before that of a previous trial, we could run into a deadlock. This is currently avoided, but untested, flagging the ... | https://github.com/ray-project/ray.git | def step(self):
self._updated_queue = False
if self.is_finished():
raise TuneError("Called step when all trials finished?")
with warn_if_slow("on_step_begin"):
self.trial_executor.on_step_begin(self.get_trials())
with warn_if_slow("callbacks.on_step_begi... | 352 | trial_runner.py | Python | python/ray/tune/trial_runner.py | 976ece4bc43abdb628cf4cbffc8546abab723a6d | ray | 20 | |
42,090 | 39 | 10 | 5 | 47 | 5 | 0 | 46 | 88 | show | Add rudimentary themeing support (#2929)
* WIP Plot.theme
* Add default values for theme to match set_theme()
* Depend on matplotib style defaults and update rcParams more selectively
* Fix lines test
* Improve test coverage | https://github.com/mwaskom/seaborn.git | def show(self, **kwargs) -> None:
# TODO make pyplot configurable at the class level, and when not using,
# import IPython.display and call on self to populate cell output?
# Keep an eye on whether matplotlib implements "attaching" an existing
# figure to pyplot: https://github... | 25 | plot.py | Python | seaborn/_core/plot.py | 762db897b52d16ab2f164d5103df4cc26c1d0503 | seaborn | 1 | |
96,483 | 77 | 12 | 34 | 329 | 23 | 0 | 162 | 333 | get_time_params | ADS v1. (#31533)
* ADS v1.
* Using QueryBuilder to automatically be aware of filters selected. Removed code to submit SnQL query.
* Incorporated PR feedback; using timeseries_query instead of QueryBuilder.
* Added ADS call.
* Failed attempt at writing an unit test :(
* Made get_anomalies() a helped func... | https://github.com/getsentry/sentry.git | def get_time_params(start, end):
anomaly_detection_range = end - start
if anomaly_detection_range > timedelta(days=14):
snuba_range = timedelta(days=90)
granularity = 3600
elif anomaly_detection_range > timedelta(days=1):
granularity = 1200
snuba_range = timedelta(days... | 205 | organization_transaction_anomaly_detection.py | Python | src/sentry/api/endpoints/organization_transaction_anomaly_detection.py | d1314a15f4e591c93c796f79696e779329cbf369 | sentry | 7 | |
138,371 | 12 | 11 | 7 | 69 | 10 | 0 | 12 | 31 | test_status_invalid_runtime_env | [serve] Catch `RuntimeEnvSetupError` when checking status (#31282)
When the task `run_graph` is submitted, fetching the object ref result can raise `RayTaskError` if the task fails or `RuntimeEnvSetupError` if setting up the runtime env for the task fails. We want to deal with the latter case as well. | https://github.com/ray-project/ray.git | def test_status_invalid_runtime_env(ray_start_stop):
config_file_name = os.path.join(
os.path.dirname(__file__), "test_config_files", "bad_runtime_env.yaml"
)
subprocess.check_output(["serve", "deploy", config_file_name])
| 45 | test_cli.py | Python | python/ray/serve/tests/test_cli.py | fe7ef833783c7e2e24dc5acd78ecced61ea53b0b | ray | 1 | |
264,447 | 8 | 8 | 2 | 43 | 7 | 1 | 8 | 13 | meta | Closes #8600: Document built-in template tags & filters | https://github.com/netbox-community/netbox.git | def meta(model, attr):
return getattr(model._meta, attr, '')
@register.filter() | @register.filter() | 19 | filters.py | Python | netbox/utilities/templatetags/builtins/filters.py | 7c105019d8ae9205051c302e7499b33a455f9176 | netbox | 1 |
46,403 | 20 | 14 | 9 | 93 | 16 | 0 | 21 | 72 | reflect_tables | Add map_index and run_id to TaskFail (#22260)
TaskFail entities always belong to a TaskInstance. The PK for TaskInstance has changed, so we need to update TaskFail to have the new columns. | https://github.com/apache/airflow.git | def reflect_tables(models, session):
import sqlalchemy.schema
metadata = sqlalchemy.schema.MetaData(session.bind)
for model in models:
try:
metadata.reflect(only=[model.__tablename__], extend_existing=True, resolve_fks=False)
except exc.InvalidRequestError:
co... | 59 | db.py | Python | airflow/utils/db.py | f06b3955b1d937138fb38021a6a373b94ae8f9e8 | airflow | 3 | |
291,831 | 64 | 11 | 31 | 292 | 31 | 0 | 66 | 464 | _data_to_save | Add `translation_key` property to entites (#82701)
* Add translation_key attribute to entity state
* Update accuweather test
* Index entity translation keys by platform
* Store translation key in entity registry | https://github.com/home-assistant/core.git | def _data_to_save(self) -> dict[str, Any]:
data: dict[str, Any] = {}
data["entities"] = [
{
"area_id": entry.area_id,
"capabilities": entry.capabilities,
"config_entry_id": entry.config_entry_id,
"device_class": entry.... | 177 | entity_registry.py | Python | homeassistant/helpers/entity_registry.py | 8e617bbc1d3ef07254a4151f2d014a86e6e8d05a | core | 2 | |
118,984 | 12 | 9 | 7 | 85 | 11 | 0 | 12 | 61 | test_startup_shutdown | AppSession: handle script events on the main thread (#4467)
Refactors AppSession to handle all ScriptRunner events on the main thread.
- ScriptRunner no longer takes an `enqueue` callback param. Instead, it signals that it wants to enqueue a new ForwardMsg via the `ScriptRunnerEvent.ENQUEUE_FORWARD_MSG` event. (Thi... | https://github.com/streamlit/streamlit.git | def test_startup_shutdown(self):
scriptrunner = TestScriptRunner("good_script.py")
scriptrunner.start()
scriptrunner.join()
self._assert_no_exceptions(scriptrunner)
self._assert_control_events(scriptrunner, [ScriptRunnerEvent.SHUTDOWN])
self._assert_text_deltas(... | 49 | script_runner_test.py | Python | lib/tests/streamlit/scriptrunner/script_runner_test.py | 3326118e83ffe87623ea440d0ead245f21106a27 | streamlit | 1 | |
94,333 | 47 | 20 | 38 | 265 | 29 | 0 | 66 | 615 | test_category_match_group | test(event_manager): Fix incorrect invocations of manager.save (#36615) | https://github.com/getsentry/sentry.git | def test_category_match_group(self):
from sentry.grouping.enhancer import Enhancements
enhancement = Enhancements.from_config_string(
,
)
event = make_event(
platform="native",
exception={
"values": [
{
... | 154 | test_event_manager.py | Python | tests/sentry/event_manager/test_event_manager.py | 39cfdcb446e74732c67ce07d7dd8d8d5ace471b1 | sentry | 1 | |
181,847 | 29 | 15 | 13 | 108 | 11 | 0 | 31 | 178 | _update_val | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | https://github.com/EpistasisLab/tpot.git | def _update_val(self, val, result_score_list):
self._update_pbar()
if val == "Timeout":
self._update_pbar(
pbar_msg=(
"Skipped pipeline #{0} due to time out. "
"Continuing to the next pipeline.".format(self._pbar.n)
... | 60 | base.py | Python | tpot/base.py | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot | 2 | |
277,072 | 18 | 12 | 6 | 73 | 12 | 0 | 19 | 49 | getfullargspec | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def getfullargspec(obj):
decorators, target = tf.__internal__.decorator.unwrap(obj)
for d in decorators:
if d.decorator_argspec is not None:
return _convert_maybe_argspec_to_fullargspec(d.decorator_argspec)
return _getfullargspec(target)
| 45 | tf_inspect.py | Python | keras/utils/tf_inspect.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 3 | |
165,238 | 27 | 11 | 15 | 120 | 20 | 0 | 37 | 176 | _aggregate_with_numba | BUG/REF: Use lru_cache instead of NUMBA_FUNC_CACHE (#46086) | https://github.com/pandas-dev/pandas.git | def _aggregate_with_numba(self, data, func, *args, engine_kwargs=None, **kwargs):
starts, ends, sorted_index, sorted_data = self._numba_prep(data)
numba_.validate_udf(func)
numba_agg_func = numba_.generate_numba_agg_func(
func, **get_jit_arguments(engine_kwargs, kwargs)
... | 81 | groupby.py | Python | pandas/core/groupby/groupby.py | 696a8e90e2112e263c84bfe87168649c3f5234e6 | pandas | 1 | |
313,672 | 6 | 11 | 3 | 37 | 4 | 0 | 6 | 19 | cover_platform_only | Speed up mqtt tests (#73423)
Co-authored-by: jbouwh <jan@jbsoft.nl>
Co-authored-by: Jan Bouwhuis <jbouwh@users.noreply.github.com> | https://github.com/home-assistant/core.git | def cover_platform_only():
with patch("homeassistant.components.mqtt.PLATFORMS", [Platform.COVER]):
yield
| 18 | test_cover.py | Python | tests/components/mqtt/test_cover.py | 51b4d15c8cb83bb715222841aa48e83f77ef38ff | core | 1 | |
267,890 | 8 | 7 | 3 | 48 | 7 | 0 | 8 | 14 | get_config_handler_type_map | 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_config_handler_type_map() -> t.Dict[t.Type[HostConfig], t.Type[CoverageHandler]]:
return get_type_map(CoverageHandler, HostConfig)
| 31 | coverage.py | Python | test/lib/ansible_test/_internal/commands/integration/coverage.py | 3eb0485dd92c88cc92152d3656d94492db44b183 | ansible | 1 | |
296,469 | 8 | 6 | 3 | 25 | 4 | 0 | 8 | 22 | code_format | Replace Alarm Control Panel FORMAT_ constants with CodeFormat enum (#69861) | https://github.com/home-assistant/core.git | def code_format(self) -> CodeFormat | None:
return self._attr_code_format
| 14 | __init__.py | Python | homeassistant/components/alarm_control_panel/__init__.py | 1e4aacaeb12b11090813cb19f1282b6c46705977 | core | 1 | |
317,566 | 16 | 9 | 23 | 62 | 7 | 0 | 19 | 34 | test_saving_state_with_sqlalchemy_exception | Use recorder get_instance function to improve typing (#75567) | https://github.com/home-assistant/core.git | def test_saving_state_with_sqlalchemy_exception(hass, hass_recorder, caplog):
hass = hass_recorder()
entity_id = "test.recorder"
state = "restoring_from_db"
attributes = {"test_attr": 5, "test_attr_10": "nice"}
| 151 | test_init.py | Python | tests/components/recorder/test_init.py | 606d5441573f52de961010551b34d23aef3317dc | core | 1 | |
286,355 | 11 | 9 | 5 | 35 | 4 | 0 | 12 | 35 | clean_fraction | [SDK] Allow silencing verbose output in commands that use stocks/load (#3180)
* remove verbose on load
* Revert implementation of the verbosity setting in stocks controller
* Edit docstrings to comply with pydocstyle linting rules
* Fix typos in variable names and help text
* Add verbosity setting to forex... | https://github.com/OpenBB-finance/OpenBBTerminal.git | def clean_fraction(num, denom):
try:
return num / denom
except TypeError:
return "N/A"
| 19 | stocks_helper.py | Python | openbb_terminal/stocks/stocks_helper.py | 47549cbd9f52a436c06b040fda5b88a7d2bf700a | OpenBBTerminal | 2 | |
287,770 | 9 | 9 | 2 | 31 | 4 | 0 | 9 | 15 | test_get_provider | Clean up Speech-to-text integration and add tests (#79012) | https://github.com/home-assistant/core.git | async def test_get_provider(hass, test_provider):
assert test_provider == async_get_provider(hass, "test")
| 17 | test_init.py | Python | tests/components/stt/test_init.py | 57746642349a3ca62959de4447a4eb5963a84ae1 | core | 1 | |
35,696 | 51 | 11 | 6 | 108 | 11 | 1 | 70 | 145 | update_keys_to_ignore | Add Data2Vec (#15507)
* Add data2vec model cloned from roberta
* Add checkpoint conversion script
* Fix copies
* Update docs
* Add checkpoint conversion script
* Remove fairseq data2vec_text script and fix format
* Add comment on where to get data2vec_text.py
* Remove mock implementation cheat.py ... | https://github.com/huggingface/transformers.git | def update_keys_to_ignore(self, config, del_keys_to_ignore):
if not config.tie_word_embeddings:
# must make a new list, or the class variable gets modified!
self._keys_to_ignore_on_save = [k for k in self._keys_to_ignore_on_save if k not in del_keys_to_ignore]
self._... | @add_start_docstrings(
"The bare Data2VecText Model for text transformer outputting raw hidden-states without any specific head on top.",
DATA2VECTEXT_START_DOCSTRING,
) | 52 | modeling_data2vec_text.py | Python | src/transformers/models/data2vec/modeling_data2vec_text.py | df5a4094a6e3f98f2cb2058cdb688fcc3f453220 | transformers | 6 |
244,125 | 42 | 14 | 15 | 223 | 19 | 0 | 61 | 169 | _expand_onehot_labels | [Fix] Fix reduction=mean in CELoss. (#7449)
* [Fix] Fix ignore in CELoss.
* add ut
* fix and add comments
* add avg_non_ignore option
* bce avg
* fix lint | https://github.com/open-mmlab/mmdetection.git | def _expand_onehot_labels(labels, label_weights, label_channels, ignore_index):
bin_labels = labels.new_full((labels.size(0), label_channels), 0)
valid_mask = (labels >= 0) & (labels != ignore_index)
inds = torch.nonzero(
valid_mask & (labels < label_channels), as_tuple=False)
if inds.nume... | 147 | cross_entropy_loss.py | Python | mmdet/models/losses/cross_entropy_loss.py | 3b2e9655631a2edd28bb94c640bd6a74c0bfad55 | mmdetection | 3 | |
156,839 | 66 | 12 | 20 | 180 | 20 | 0 | 89 | 221 | solve | Update `da.linalg.solve` for SciPy 1.9.0 compatibility (#9350) | https://github.com/dask/dask.git | def solve(a, b, sym_pos=None, assume_a="gen"):
if sym_pos is not None:
warnings.warn(
"The sym_pos keyword is deprecated and should be replaced by using ``assume_a = 'pos'``."
"``sym_pos`` will be removed in a future version.",
category=FutureWarning,
)
... | 105 | linalg.py | Python | dask/array/linalg.py | 386b4753f1aa5d96230c814391fde50758b8f533 | dask | 5 | |
100,335 | 25 | 13 | 9 | 152 | 10 | 0 | 30 | 108 | set_info_text | 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 set_info_text(self):
if not self.vars["enabled"].get():
msg = f"{self.tabname.title()} disabled"
elif self.vars["enabled"].get() and not self.vars["ready"].get():
msg = f"Waiting for {self.tabname}..."
else:
msg = f"Displaying {self.tabname}"
... | 69 | display_page.py | Python | lib/gui/display_page.py | c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf | faceswap | 4 | |
100,296 | 20 | 10 | 6 | 87 | 13 | 0 | 22 | 72 | stream | alignments tool - Don't re-analyze video if metadata in alignments | https://github.com/deepfakes/faceswap.git | def stream(self, skip_list=None):
loader = ImagesLoader(self.folder, queue_size=32, count=self._count)
if skip_list is not None:
loader.add_skip_list(skip_list)
for filename, image in loader.load():
yield filename, image
| 55 | media.py | Python | tools/alignments/media.py | 30872ef265c0fc29465f4c3a0778d0049f8c3897 | faceswap | 3 | |
109,422 | 21 | 11 | 7 | 80 | 10 | 0 | 23 | 84 | set_boxstyle | Harmonize docstrings for boxstyle/connectionstyle/arrowstyle.
- Rely on `__init_subclass__` to avoid the need for the out-of-order
`interpd.update`/`dedent_interpd`.
- Use consistent wording for all setters, and add ACCEPTS list in all
cases.
- Move get_boxstyle right next to set_boxstyle (consistently with the
... | https://github.com/matplotlib/matplotlib.git | def set_boxstyle(self, boxstyle=None, **kwargs):
if boxstyle is None:
return BoxStyle.pprint_styles()
self._bbox_transmuter = (
BoxStyle(boxstyle, **kwargs)
if isinstance(boxstyle, str) else boxstyle)
self.stale = True
| 51 | patches.py | Python | lib/matplotlib/patches.py | 0dc472b4c7cdcc1e88228988fff17762c90f1cb9 | matplotlib | 3 | |
176,967 | 55 | 15 | 14 | 138 | 15 | 1 | 92 | 227 | global_efficiency | added examples to efficiency_measures.py (#5643)
* added example on efficiency
* added example on global_efficiency
* added example on local_efficiency
* adjused round up | https://github.com/networkx/networkx.git | def global_efficiency(G):
n = len(G)
denom = n * (n - 1)
if denom != 0:
lengths = nx.all_pairs_shortest_path_length(G)
g_eff = 0
for source, targets in lengths:
for target, distance in targets.items():
if distance > 0:
g_eff += 1 /... | @not_implemented_for("directed") | 76 | efficiency_measures.py | Python | networkx/algorithms/efficiency_measures.py | 435b4622d106d14a3627e162ee163b113bac9854 | networkx | 5 |
276,721 | 35 | 10 | 11 | 121 | 6 | 0 | 54 | 103 | conv_input_length | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def conv_input_length(output_length, filter_size, padding, stride):
if output_length is None:
return None
assert padding in {"same", "valid", "full"}
if padding == "same":
pad = filter_size // 2
elif padding == "valid":
pad = 0
elif padding == "full":
pad = filte... | 70 | conv_utils.py | Python | keras/utils/conv_utils.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 5 | |
38,141 | 54 | 13 | 20 | 155 | 13 | 0 | 68 | 184 | get_checkpoint_callback | 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 get_checkpoint_callback(output_dir, metric, save_top_k=1, lower_is_better=False):
if metric == "rouge2":
exp = "{val_avg_rouge2:.4f}-{step_count}"
elif metric == "bleu":
exp = "{val_avg_bleu:.4f}-{step_count}"
elif metric == "loss":
exp = "{val_avg_loss:.4f}-{step_count}"
... | 83 | callbacks.py | Python | examples/research_projects/seq2seq-distillation/callbacks.py | afe5d42d8d1d80af911ed980c2936bfe887078f6 | transformers | 5 | |
20,529 | 6 | 8 | 2 | 33 | 4 | 0 | 6 | 12 | remove_quotes | check point progress on only bringing in pip==22.0.4 (#4966)
* vendor in pip==22.0.4
* updating vendor packaging version
* update pipdeptree to fix pipenv graph with new version of pip.
* Vendoring of pip-shims 0.7.0
* Vendoring of requirementslib 1.6.3
* Update pip index safety restrictions patch for p... | https://github.com/pypa/pipenv.git | def remove_quotes(s, l, t):
return t[0][1:-1]
| 21 | actions.py | Python | pipenv/patched/notpip/_vendor/pyparsing/actions.py | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | pipenv | 1 | |
292,450 | 7 | 8 | 3 | 28 | 3 | 0 | 7 | 21 | async_will_remove_from_hass | Add dlna_dms integration to support DLNA Digital Media Servers (#66437) | https://github.com/home-assistant/core.git | async def async_will_remove_from_hass(self) -> None:
await self.device_disconnect()
| 14 | dms.py | Python | homeassistant/components/dlna_dms/dms.py | b19bf9b147f4321e89d1f7f01e68337f2102f460 | core | 1 | |
181,757 | 8 | 8 | 3 | 37 | 6 | 0 | 8 | 17 | test_read_config_file_2 | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | https://github.com/EpistasisLab/tpot.git | def test_read_config_file_2():
tpot_obj = TPOTRegressor()
assert_raises(ValueError, tpot_obj._read_config_file, "tests/test_config.py.bad")
| 20 | tpot_tests.py | Python | tests/tpot_tests.py | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot | 1 | |
288,105 | 8 | 9 | 3 | 32 | 5 | 0 | 8 | 22 | available | Add light platform for switchbee integration (#78382)
* Added Light platform for switchbee integration
* added light to .coveragerc
* Applied code review feedback from other PR
* Fixes based on previous reviewes
* fixed small mistake
* added test coverage for light
* aligned code with other PR
* r... | https://github.com/home-assistant/core.git | def available(self) -> bool:
return self._is_online and super().available
| 18 | entity.py | Python | homeassistant/components/switchbee/entity.py | de3a1f444ce6f2ab4ae4094a86defeb4290d6f3f | core | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.