complexity int64 1 56 | n_identifiers int64 1 114 | code stringlengths 19 12.7k | path stringlengths 8 134 | n_ast_nodes int64 12 2.35k | ast_errors stringlengths 0 4.01k | repo stringlengths 3 28 | documentation dict | n_words int64 2 866 | language stringclasses 1
value | vocab_size int64 2 323 | commit_id stringlengths 40 40 | file_name stringlengths 5 79 | id int64 243 338k | nloc int64 1 228 | token_counts int64 5 1.4k | fun_name stringlengths 1 77 | url stringlengths 31 60 | commit_message stringlengths 3 15.3k | n_whitespaces int64 1 3.23k | n_ast_errors int64 0 20 | d_id int64 74 121k | ast_levels int64 4 29 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 8 | def test_caching(self):
# The first user ignores a user.
self._update_ignore_list("@other:test")
self.assert_ignored(self.user, {"@other:test"})
self.assert_ignorers("@other:test", {self.user})
# The second user ignores them.
self._update_ignore_list("@other:tes... | tests/storage/test_account_data.py | 177 | synapse | {
"docstring": "Ensure that caching works properly between different users.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 38 | Python | 25 | dda9b7fc4d2e6ca84a1a994a7ff1943b590e71df | test_account_data.py | 247,675 | 10 | 97 | test_caching | https://github.com/matrix-org/synapse.git | Use the ignored_users table to test event visibility & sync. (#12225)
Instead of fetching the raw account data and re-parsing it. The
ignored_users table is a denormalised version of the account data
for quick searching. | 129 | 0 | 71,828 | 9 | |
4 | 11 | def _assign_default_kwargs(kws, call_func, source_func):
# This exists so that axes-level functions and figure-level functions can
# both call a Plotter method while having the default kwargs be defined in
# the signature of the axes-level function.
# An alternative would be to have a decorator on ... | seaborn/utils.py | 97 | seaborn | {
"docstring": "Assign default kwargs for call_func using values from source_func.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 105 | Python | 68 | 6460a21555ba6557e1f6f06f4d677d9c19148169 | utils.py | 42,076 | 7 | 58 | _assign_default_kwargs | https://github.com/mwaskom/seaborn.git | Workaround for matplotlib rc_context issue (#2925)
* Workaround for matplotlib rc_context issue
Fixes #2914
* Add some additional comments about this workaround | 159 | 0 | 7,476 | 12 | |
1 | 2 | def test_is_anonymous_authenticated_methods(self):
| tests/auth_tests/test_checks.py | 13 | django | {
"docstring": "\n <User Model>.is_anonymous/is_authenticated must not be methods.\n ",
"language": "en",
"n_whitespaces": 21,
"n_words": 6,
"vocab_size": 6
} | 2 | Python | 2 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | test_checks.py | 201,183 | 26 | 99 | test_is_anonymous_authenticated_methods | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 9 | 0 | 49,893 | 6 | |
1 | 4 | def trace_symbol(self) -> Any:
raise NotImplementedError()
| nni/common/serializer.py | 23 | nni | {
"docstring": "\n Symbol object. Could be a class or a function.\n ``get_hybrid_cls_or_func_name`` and ``import_cls_or_func_from_hybrid_name`` is a pair to\n convert the symbol into a string and convert the string back to symbol.\n ",
"language": "en",
"n_whitespaces": 58,
"n_words"... | 6 | Python | 6 | 21abc280257fb8868be61264abe42534aa09188b | serializer.py | 111,886 | 7 | 12 | trace_symbol | https://github.com/microsoft/nni.git | Fix #4434: support pickle in serializer (#4552) | 20 | 0 | 24,497 | 7 | |
2 | 8 | def print_colored(text, color="OK", bold=False):
color = _COLORS.get(color, color)
fmt = '' if not bold else _COLORS['BOLD']
print(f"{color}{fmt}{text}{_COLORS['ENDC']}")
| tests/simple_tests.py | 91 | faceswap | {
"docstring": " Print colored text\n This might not work on windows,\n although travis runs windows stuff in git bash, so it might ?\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 21,
"vocab_size": 20
} | 17 | Python | 16 | 98a65277d8c55cfcbdbfa629f790a8f8731621a8 | simple_tests.py | 100,861 | 4 | 40 | print_colored | https://github.com/deepfakes/faceswap.git | Fix AMD Tests + docs | 29 | 0 | 20,312 | 11 | |
9 | 15 | def _light_internal_color_mode(self) -> str:
if (color_mode := self.color_mode) is None:
# Backwards compatibility for color_mode added in 2021.4
# Add warning in 2021.6, remove in 2021.10
supported = self._light_internal_supported_color_modes
if ColorMo... | homeassistant/components/light/__init__.py | 150 | core | {
"docstring": "Return the color mode of the light with backwards compatibility.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | 72 | Python | 38 | 47d0598e75487f63901931875f69f802a477df13 | __init__.py | 288,598 | 14 | 95 | _light_internal_color_mode | https://github.com/home-assistant/core.git | Use Kelvin as the preferred color temperature unit (#79591)
* Use Kelvin as the preferred white temperature unit
* Update homekit
* Adjust tests | 241 | 0 | 87,754 | 10 | |
1 | 6 | def test_backend_has_no_autograd_key_but_provides_entries(self) -> None:
yaml_str =
output_error = self.get_errors_from_gen_backend_stubs(yaml_str)
self.assertExpectedInline(output_error, ) # noqa: B950
# in an operator group, currently all operators must either be registered to the backe... | tools/test/test_gen_backend_stubs.py | 50 | pytorch | {
"docstring": "\\\nbackend: Vulkan\ncpp_namespace: torch_vulkan\nsupported:\n- add\nautograd:\n- subFound an invalid operator name: add",
"language": "en",
"n_whitespaces": 9,
"n_words": 16,
"vocab_size": 14
} | 38 | Python | 35 | bb5b4cceb6f737448eaaa6817cd773b6f4b0e77d | test_gen_backend_stubs.py | 102,167 | 10 | 26 | test_backend_has_no_autograd_key_but_provides_entries | https://github.com/pytorch/pytorch.git | Revert "Revert D32498569: allow external backend codegen to toggle whether to generate out= and inplace kernels" (#69950)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69950
This reverts commit f6cad53443704dfe5a20cc62bee14d91e3bffcaa.
Test Plan: Imported from OSS
Reviewed By: albanD
Diff... | 66 | 0 | 21,482 | 8 | |
1 | 11 | def test_dict_failure(self):
with pytest.raises(validate.ValidationError) as cm:
validate.validate(validate.union({"foo": int}), "value")
assert_validationerror(cm.value, )
| tests/test_api_validate.py | 75 | streamlink | {
"docstring": "\n ValidationError(UnionSchema):\n Could not validate union\n Context(dict):\n Unable to validate union 'foo'\n Context(type):\n Type of 'value' should be int, but is str\n ",
"language": "en",
"n_whitespace... | 11 | Python | 11 | d09112ab1f6db6aa605650fe1ff6a3028344f90d | test_api_validate.py | 187,200 | 11 | 42 | test_dict_failure | https://github.com/streamlink/streamlink.git | plugin.api.validate: rewrite tests
Completely rewrite tests using pytest, with full coverage | 35 | 0 | 45,739 | 14 | |
1 | 28 | def test_submit_event(session, create_task_instance):
# Make a trigger
trigger = Trigger(classpath="airflow.triggers.testing.SuccessTrigger", kwargs={})
trigger.id = 1
session.add(trigger)
session.commit()
# Make a TaskInstance that's deferred and waiting on it
task_instance = create_ta... | tests/models/test_trigger.py | 237 | airflow | {
"docstring": "\n Tests that events submitted to a trigger re-wake their dependent\n task instances.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 12,
"vocab_size": 12
} | 87 | Python | 69 | bab740c0a49b828401a8baf04eb297d083605ae8 | test_trigger.py | 47,418 | 17 | 141 | test_submit_event | https://github.com/apache/airflow.git | Fix trigger event payload is not persisted in db (#22944)
Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com>
Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com> | 157 | 0 | 9,106 | 11 | |
1 | 43 | def test_fsspec_filesystem(ray_start_regular_shared, tmp_path):
df1 = pd.DataFrame({"one": [1, 2, 3], "two": ["a", "b", "c"]})
table = pa.Table.from_pandas(df1)
path1 = os.path.join(str(tmp_path), "test1.parquet")
pq.write_table(table, path1)
df2 = pd.DataFrame({"one": [4, 5, 6], "two": ["e", "... | python/ray/data/tests/test_dataset_formats.py | 538 | @pytest.mark.parametrize(
"fs,data_path",
[
(None, lazy_fixture("local_path")),
(lazy_fixture("local_fs"), lazy_fixture("local_path")),
(lazy_fixture("s3_fs"), lazy_fixture("s3_path")),
(
lazy_fixture("s3_fs_with_space"),
lazy_fixture("s3_path_with_space")... | ray | {
"docstring": "Same as `test_parquet_write` but using a custom, fsspec filesystem.\n\n TODO (Alex): We should write a similar test with a mock PyArrow fs, but\n unfortunately pa.fs._MockFileSystem isn't serializable, so this may require\n some effort.\n ",
"language": "en",
"n_whitespaces": 45,
"n_... | 106 | Python | 83 | 85d6946c9524d8544e69262f737018151efb1567 | test_dataset_formats.py | 144,772 | 22 | 266 | test_fsspec_filesystem | https://github.com/ray-project/ray.git | Split test_dataset.py into two (#22303) | 240 | 1 | 33,307 | 12 |
8 | 17 | def dtype(x, *, canonicalize=False):
if x is None:
raise ValueError(f"Invalid argument to dtype: {x}.")
elif isinstance(x, type) and x in python_scalar_dtypes:
dt = python_scalar_dtypes[x]
elif type(x) in python_scalar_dtypes:
dt = python_scalar_dtypes[type(x)]
elif jax.core.is_opaque_dtype(getat... | jax/_src/dtypes.py | 193 | jax | {
"docstring": "Return the dtype object for a value or type, optionally canonicalized based on X64 mode.",
"language": "en",
"n_whitespaces": 14,
"n_words": 15,
"vocab_size": 15
} | 76 | Python | 57 | 6d2aaac2454117d54997243714c1a009827707ca | dtypes.py | 122,245 | 15 | 112 | dtype | https://github.com/google/jax.git | implement bint arrays (opaque dtypes), add padding rules
Co-authored-by: Sharad Vikram <sharad.vikram@gmail.com> | 121 | 0 | 27,139 | 12 | |
3 | 11 | def calc_position(self, x):
if x < self.x[0]:
return None
elif x > self.x[-1]:
return None
i = self.__search_index(x)
dx = x - self.x[i]
position = self.a[i] + self.b[i] * dx + \
self.c[i] * dx ** 2.0 + self.d[i] * dx ** 3.0
... | PathPlanning/CubicSpline/cubic_spline_planner.py | 141 | PythonRobotics | {
"docstring": "\n Calc `y` position for given `x`.\n\n if `x` is outside the data point's `x` range, return None.\n\n Returns\n -------\n y : float\n y position for given x.\n ",
"language": "en",
"n_whitespaces": 81,
"n_words": 27,
"vocab_size": 22
} | 45 | Python | 29 | def289b723e9216830c2a7b2577cb31b55710167 | cubic_spline_planner.py | 19,355 | 10 | 97 | calc_position | https://github.com/AtsushiSakai/PythonRobotics.git | enhance cubic spline path doc (#698)
* enhance cublic spline path doc
* enhance cublic spline path doc
* enhance cublic spline path doc
* enhance cublic spline path doc
* enhance cublic spline path doc
* enhance cublic spline path doc
* enhance cublic spline path doc
* enhance cublic spline path d... | 127 | 0 | 2,943 | 12 | |
5 | 31 | def _enable_ocsp_stapling(self, ssl_vhost, unused_options):
min_apache_ver = (2, 3, 3)
if self.get_version() < min_apache_ver:
raise errors.PluginError(
"Unable to set OCSP directives.\n"
"Apache version is below 2.3.3.")
if "socache_shmcb_mo... | certbot-apache/certbot_apache/_internal/configurator.py | 311 | certbot | {
"docstring": "Enables OCSP Stapling\n\n In OCSP, each client (e.g. browser) would have to query the\n OCSP Responder to validate that the site certificate was not revoked.\n\n Enabling OCSP Stapling, would allow the web-server to query the OCSP\n Responder, and staple its response to the... | 108 | Python | 89 | eeca208c8f57304590ac1af80b496e61021aaa45 | configurator.py | 186,377 | 26 | 182 | _enable_ocsp_stapling | https://github.com/certbot/certbot.git | Various clean-ups in certbot-apache. Use f-strings. (#9132)
* Various clean-ups in certbot-apache. Use f-strings.
* Smaller tweaks | 518 | 0 | 45,473 | 12 | |
5 | 33 | def test_upgrade(tctx, proto):
if proto != "websocket":
tctx.options.websocket = False
if proto != "tcp":
tctx.options.rawtcp = False
tctx.server.address = ("example.com", 80)
tctx.server.state = ConnectionState.OPEN
http_flow = Placeholder(HTTPFlow)
playbook = Playbook(htt... | test/mitmproxy/proxy/layers/http/test_http.py | 428 | mitmproxy | {
"docstring": "Test a HTTP -> WebSocket upgrade with different protocols enabled",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 143 | Python | 70 | b3587b52b25077f68116b9852b041d33e7fc6601 | test_http.py | 251,864 | 63 | 256 | test_upgrade | https://github.com/mitmproxy/mitmproxy.git | make it black! | 656 | 0 | 73,865 | 22 | |
2 | 12 | def copy(self) -> "ExecutionPlan":
plan_copy = ExecutionPlan(
self._in_blocks, self._in_stats, run_by_consumer=self._run_by_consumer
)
if self._snapshot_blocks is not None:
# Copy over the existing snapshot.
plan_copy._snapshot_blocks = self._snapshot... | python/ray/data/_internal/plan.py | 118 | ray | {
"docstring": "Create a shallow copy of this execution plan.\n\n This copy can be executed without mutating the original, but clearing the copy\n will also clear the original.\n\n Returns:\n A shallow copy of this execution plan.\n ",
"language": "en",
"n_whitespaces": 73,
... | 36 | Python | 30 | 8553df49bba654a9edd6befce198be90d6524fca | plan.py | 125,418 | 18 | 72 | copy | https://github.com/ray-project/ray.git | Make execution plan/blocklist aware of the memory ownership and who runs the plan (#26650)
Having the indicator about who's running the stage and who created a blocklist will enable the eager memory releasing.
This is an alternative with better abstraction to https://github.com/ray-project/ray/pull/26196.
Note: ... | 129 | 0 | 27,862 | 10 | |
2 | 6 | def test_select_on_save_lying_update(self):
# Change the manager to not return "row matched" for update().
# We are going to change the Article's _base_manager class
# dynamically. This is a bit of a hack, but it seems hard to
# test this properly otherwise. Article's manager, b... | tests/basic/tests.py | 29 | django | {
"docstring": "\n select_on_save works correctly if the database doesn't return correct\n information about matched rows from UPDATE.\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 15
} | 56 | Python | 47 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 201,891 | 23 | 125 | test_select_on_save_lying_update | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 105 | 0 | 50,017 | 8 | |
3 | 15 | def generate_config():
config_path = get_config_file()
if config_path.exists():
overwrite_config = input("Config file already exists. Overwrite? (y/N): ")
if overwrite_config.lower() != "y":
print("Exiting...")
return None
with open(config_path, "w", encoding=... | spotdl/utils/console.py | 134 | spotify-downloader | {
"docstring": "\n Generate the config file if it doesn't exist\n This is done before the argument parser so it doesn't requires `operation`\n and `query` to be passed.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 25,
"vocab_size": 22
} | 39 | Python | 34 | deca40c2e26afed62e1f9ec4be14aff9e125929b | console.py | 30,423 | 11 | 71 | generate_config | https://github.com/spotDL/spotify-downloader.git | moved console actions to a new file | 100 | 0 | 5,567 | 12 | |
3 | 7 | def timezone(self):
if not settings.USE_TZ:
return None
elif self.settings_dict["TIME_ZONE"] is None:
return timezone.utc
else:
return timezone_constructor(self.settings_dict["TIME_ZONE"])
| django/db/backends/base/base.py | 70 | django | {
"docstring": "\n Return a tzinfo of the database connection time zone.\n\n This is only used when time zone support is enabled. When a datetime is\n read from the database, it is always returned in this time zone.\n\n When the database backend supports time zones, it doesn't matter which... | 16 | Python | 14 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | base.py | 204,817 | 7 | 40 | timezone | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 77 | 0 | 50,902 | 12 | |
7 | 37 | def check_video_data(path_control_data, path_video_gen):
# movie file specification
path_sec_gen = Path(path_video_gen).parent.absolute() / "sections"
control_data = load_control_data(path_control_data)
movie_meta_gen = get_video_metadata(path_video_gen)
movie_meta_exp = control_data["movie_met... | tests/utils/video_tester.py | 444 | manim | {
"docstring": "Compare control data with generated output.\n Used abbreviations:\n exp -> expected\n gen -> generated\n sec -> section\n meta -> metadata\n ",
"language": "en",
"n_whitespaces": 57,
"n_words": 20,
"vocab_size": 16
} | 160 | Python | 107 | 7a13f0e969e6a70af9084cdbf41cea49c7f1813c | video_tester.py | 189,828 | 32 | 185 | check_video_data | https://github.com/ManimCommunity/manim.git | Migrate from os.path to pathlib in Testing Scripts (#2685)
* updated styling
* final commit
* fixed style
* removed exist_ok=true
* added parents=True
* potentially .exists() is the problem
* fixed style'
* fixed style on revisions
* style check processed
* Update tests/helpers/graphical_uni... | 355 | 0 | 46,227 | 16 | |
11 | 31 | def remove_categories(self, removals, inplace=no_default):
if inplace is not no_default:
warn(
"The `inplace` parameter in pandas.Categorical."
"remove_categories is deprecated and will be removed in "
"a future version. Removing unused catego... | pandas/core/arrays/categorical.py | 300 | pandas | {
"docstring": "\n Remove the specified categories.\n\n `removals` must be included in the old categories. Values which were in\n the removed categories will be set to NaN\n\n Parameters\n ----------\n removals : category or list of categories\n The categories which... | 121 | Python | 84 | 2f8d0a36703e81e4dca52ca9fe4f58c910c1b304 | categorical.py | 168,200 | 28 | 181 | remove_categories | https://github.com/pandas-dev/pandas.git | PERF cache find_stack_level (#48023)
cache stacklevel | 420 | 0 | 40,226 | 14 | |
2 | 8 | def enter(self, *path):
return Meta(self._meta, path=self._path + [str(p) for p in path])
| src/sentry/utils/meta.py | 52 | sentry | {
"docstring": "\n Enters into sub meta data at the specified path. This always returns a\n new ``Meta`` object, regardless whether the path already exists.\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 22,
"vocab_size": 21
} | 12 | Python | 12 | 522d6f27c28dc5fd4d996ed605865c42fbda0da8 | meta.py | 93,031 | 2 | 33 | enter | https://github.com/getsentry/sentry.git | ref: replace legacy compat.map with list comprehensions (#36372) | 26 | 0 | 18,968 | 12 | |
9 | 26 | def data_for_grouping(dtype):
pa_dtype = dtype.pyarrow_dtype
if pa.types.is_boolean(pa_dtype):
A = False
B = True
C = True
elif pa.types.is_floating(pa_dtype):
A = -1.1
B = 0.0
C = 1.1
elif pa.types.is_signed_integer(pa_dtype):
A = -1
... | pandas/tests/extension/test_arrow.py | 424 | @pytest.fixture | pandas | {
"docstring": "\n Data for factorization, grouping, and unique tests.\n\n Expected to be like [B, B, NA, NA, A, A, B, C]\n\n Where A < B < C and NA is missing\n ",
"language": "en",
"n_whitespaces": 42,
"n_words": 29,
"vocab_size": 24
} | 128 | Python | 55 | b81f4318fc0d796760d16237a8f616dad73912eb | test_arrow.py | 167,622 | 37 | 281 | data_for_grouping | https://github.com/pandas-dev/pandas.git | ENH/TST: Add BaseGroupbyTests tests for ArrowExtensionArray (#47515) | 338 | 1 | 40,070 | 12 |
4 | 12 | def _end_of_line(self, y):
self._update_max_yx()
last = self.maxx
while True:
if curses.ascii.ascii(self.win.inch(y, last)) != curses.ascii.SP:
last = min(self.maxx, last+1)
break
elif last == 0:
break
l... | python3.10.4/Lib/curses/textpad.py | 116 | XX-Net | {
"docstring": "Go to the location of the first blank on the given line,\n returning the index of the last non-blank character.",
"language": "en",
"n_whitespaces": 26,
"n_words": 20,
"vocab_size": 15
} | 31 | Python | 23 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | textpad.py | 222,302 | 11 | 72 | _end_of_line | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 144 | 0 | 56,535 | 13 | |
1 | 5 | def hw_version(self) -> str | None:
return self.status.get("FIRMWARE")
| homeassistant/components/apcupsd/__init__.py | 35 | core | {
"docstring": "Return the firmware version of the UPS, if available.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 8
} | 8 | Python | 8 | 52307708c843b947a2d631f2fe7ddaa8bd9a90d7 | __init__.py | 288,026 | 3 | 19 | hw_version | https://github.com/home-assistant/core.git | Refactor apcupsd to use config flow (#64809)
* Add Config Flow to APCUPSd integration and remove YAML support.
* Hide the binary sensor if user does not select STATFLAG resource.
* Add tests for config flows.
* Simplify config flow code.
* Spell fix.
* Fix pylint warnings.
* Simplify the code for con... | 22 | 0 | 87,207 | 8 | |
1 | 9 | def print_help(self):
help_text = f
console.print(text=help_text, menu="Stocks - Options - Pricing")
| gamestonk_terminal/stocks/options/pricing_controller.py | 60 | OpenBBTerminal | {
"docstring": "Print help\n[param]Ticker: [/param]{self.ticker or None}\n[param]Expiry: [/param]{self.selected_date or None}\n[cmds]\n add add an expected price to the list\n rmv remove an expected price from the list\n\n show show the listed of expected prices\n rnval ... | 11 | Python | 10 | 82747072c511beb1b2672846ae2ee4aec53eb562 | pricing_controller.py | 281,554 | 12 | 22 | print_help | https://github.com/OpenBB-finance/OpenBBTerminal.git | Terminal Wide Rich (#1161)
* My idea for how we handle Rich moving forward
* remove independent consoles
* FIxed pylint issues
* add a few vars
* Switched print to console
* More transitions
* Changed more prints
* Replaced all prints
* Fixing tabulate
* Finished replace tabulate
* Finish... | 32 | 0 | 83,851 | 10 | |
5 | 14 | def version_parts(self, best=False):
# type: (bool) -> Tuple[str, str, str]
version_str = self.version(best=best)
if version_str:
version_regex = re.compile(r"(\d+)\.?(\d+)?\.?(\d+)?")
matches = version_regex.match(version_str)
if matches:
... | pipenv/patched/notpip/_vendor/distro.py | 122 | pipenv | {
"docstring": "\n Return the version of the OS distribution, as a tuple of version\n numbers.\n\n For details, see :func:`distro.version_parts`.\n ",
"language": "en",
"n_whitespaces": 46,
"n_words": 17,
"vocab_size": 14
} | 40 | Python | 29 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | distro.py | 20,062 | 9 | 70 | version_parts | https://github.com/pypa/pipenv.git | 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... | 138 | 0 | 3,208 | 12 | |
4 | 11 | def _validate_estimators(self):
if len(self.estimators) == 0:
raise ValueError(
"Invalid 'estimators' attribute, 'estimators' should be a "
"non-empty list of (string, estimator) tuples."
)
names, estimators = zip(*self.estimators)
... | sklearn/ensemble/_stacking.py | 118 | scikit-learn | {
"docstring": "Overload the method of `_BaseHeterogeneousEnsemble` to be more\n lenient towards the type of `estimators`.\n\n Regressors can be accepted for some cases such as ordinal regression.\n ",
"language": "en",
"n_whitespaces": 46,
"n_words": 25,
"vocab_size": 22
} | 60 | Python | 49 | b1807ff8ead319a08294beeaae90c3f03b2bb8ac | _stacking.py | 261,489 | 15 | 65 | _validate_estimators | https://github.com/scikit-learn/scikit-learn.git | ENH StackingClassifier allows regressors in its first layer (#24538)
Co-authored-by: Tom Dupré la Tour <tom.duprelatour.10@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> | 213 | 0 | 76,834 | 11 | |
1 | 6 | def head(self, url, **kwargs):
r
kwargs.setdefault("allow_redirects", False)
return self.request("HEAD", url, **kwargs)
| pipenv/patched/pip/_vendor/requests/sessions.py | 52 | pipenv | {
"docstring": "Sends a HEAD request. Returns :class:`Response` object.\n\n :param url: URL for the new :class:`Request` object.\n :param \\*\\*kwargs: Optional arguments that ``request`` takes.\n :rtype: requests.Response\n ",
"language": "en",
"n_whitespaces": 52,
"n_words": 24,
... | 11 | Python | 10 | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | sessions.py | 22,110 | 9 | 32 | head | https://github.com/pypa/pipenv.git | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | 31 | 0 | 4,186 | 8 | |
1 | 18 | def test_consent(self) -> None:
# Have the admin user accept the terms.
self.get_success(self.store.user_set_consent_version(self.admin_user, "1.0"))
# First, cheekily accept the terms and create a room
self.get_success(self.store.user_set_consent_version(self.other_user, "1.0"... | tests/rest/admin/test_user.py | 225 | synapse | {
"docstring": "Test that sending a message is not subject to the privacy policies.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | 75 | Python | 56 | 901b264c0c88f39cbfb8b2229e0dc57968882658 | test_user.py | 246,185 | 15 | 137 | test_consent | https://github.com/matrix-org/synapse.git | Add type hints to `tests/rest/admin` (#11851) | 224 | 0 | 71,079 | 10 | |
1 | 17 | def dry_run_migrations() -> None:
url = db_interface.database_config.connection_url
context.script.version_locations = [db_interface.orm.versions_dir]
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
include_schemas=True,
dialect_... | src/prefect/orion/database/migrations/env.py | 113 | prefect | {
"docstring": "\n Perform a dry run of migrations.\n\n This will create the sql statements without actually running them against the\n database and output them to stdout.\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 24,
"vocab_size": 22
} | 21 | Python | 20 | 36e7e0838aeaffc9492b330297e4905f3ab4b11f | env.py | 53,274 | 18 | 68 | dry_run_migrations | https://github.com/PrefectHQ/prefect.git | code review revisions pt3 | 81 | 0 | 10,769 | 11 | |
1 | 24 | def test_fk_with_to_field(self):
modeladmin = EmployeeAdmin(Employee, site)
request = self.request_factory.get("/", {})
request.user = self.alfred
changelist = modeladmin.get_changelist_instance(request)
# Make sure the correct queryset is returned
queryset = c... | tests/admin_filters/tests.py | 741 | django | {
"docstring": "\n A filter on a FK respects the FK's to_field attribute (#17972).\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 11,
"vocab_size": 11
} | 111 | Python | 55 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 207,124 | 36 | 447 | test_fk_with_to_field | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 384 | 0 | 51,871 | 11 | |
1 | 4 | def placeholder_value(self, placeholder_context=None):
return self._value
| keras/mixed_precision/autocast_variable.py | 24 | keras | {
"docstring": "Use the AutoCastVariable value itself as a placeholder.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 5 | Python | 5 | ed99e34f279a2d2d6a44af87ee64f8fc98c7e8b9 | autocast_variable.py | 280,806 | 2 | 14 | placeholder_value | https://github.com/keras-team/keras.git | Implement TraceType for AutoCastVariable to support tracing with tf.function layering efforts.
PiperOrigin-RevId: 498447924 | 19 | 0 | 83,439 | 6 | |
2 | 33 | def save_config(self) -> TritonArtifact:
device = self.device
if self.inference_stage != PREDICTOR:
device = "cpu"
self.config = TritonConfig(
self.full_model_name,
self.input_features,
self.output_features,
self.max_batch_size... | ludwig/utils/triton_utils.py | 231 | @dataclass | ludwig | {
"docstring": "Save the Triton config.\n\n Return the appropriate artifact.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 8,
"vocab_size": 7
} | 52 | Python | 44 | ed8d9cf20843744f18593b22fb6a30eaf5f325eb | triton_utils.py | 7,512 | 31 | 144 | save_config | https://github.com/ludwig-ai/ludwig.git | Triton ensemble export (#2251) | 308 | 1 | 1,224 | 13 |
1 | 5 | def abort(self):
self._ssl_protocol._abort()
self._closed = True
| python3.10.4/Lib/asyncio/sslproto.py | 33 | XX-Net | {
"docstring": "Close the transport immediately.\n\n Buffered data will be lost. No more data will be received.\n The protocol's connection_lost() method will (eventually) be\n called with None as its argument.\n ",
"language": "en",
"n_whitespaces": 57,
"n_words": 28,
"vocab_size... | 6 | Python | 6 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | sslproto.py | 220,732 | 3 | 18 | abort | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 27 | 0 | 56,106 | 8 | |
5 | 15 | def clone(self):
attrs = {}
for field_name in getattr(self, 'clone_fields', []):
field = self._meta.get_field(field_name)
field_value = field.value_from_object(self)
if field_value not in (None, ''):
attrs[field_name] = field_value
#... | netbox/netbox/models/__init__.py | 140 | netbox | {
"docstring": "\n Return a dictionary of attributes suitable for creating a copy of the current instance. This is used for pre-\n populating an object creation form in the UI.\n ",
"language": "en",
"n_whitespaces": 49,
"n_words": 27,
"vocab_size": 23
} | 42 | Python | 31 | f9d81fd36232e9bf3f60a215d2c6a405b9b342fb | __init__.py | 265,188 | 10 | 85 | clone | https://github.com/netbox-community/netbox.git | Closes #9414: Add clone() method to NetBoxModel for copying instance attributes | 143 | 0 | 78,019 | 13 | |
6 | 16 | def preprocess_datasets(self) -> None:
# Evaluate all datasets.
self.datasets = {k: d() if callable(d) else d for k, d in self.datasets.items()}
if self.preprocessor:
train_dataset = self.datasets.get(TRAIN_DATASET_KEY, None)
if train_dataset:
se... | python/ray/train/base_trainer.py | 166 | ray | {
"docstring": "Called during fit() to preprocess dataset attributes with preprocessor.\n\n .. note:: This method is run on a remote process.\n\n This method is called prior to entering the training_loop.\n\n If the ``Trainer`` has both a datasets dict and\n a preprocessor, the datasets di... | 83 | Python | 61 | f15ed3836d710f655856d5cd1dbbf40b08953f86 | base_trainer.py | 126,801 | 26 | 101 | preprocess_datasets | https://github.com/ray-project/ray.git | [air] Render trainer docstring signatures (#27590)
Signed-off-by: Richard Liaw <rliaw@berkeley.edu> | 240 | 0 | 28,271 | 13 | |
10 | 37 | def get_fixers(self):
pre_order_fixers = []
post_order_fixers = []
for fix_mod_path in self.fixers:
mod = __import__(fix_mod_path, {}, {}, ["*"])
fix_name = fix_mod_path.rsplit(".", 1)[-1]
if fix_name.startswith(self.FILE_PREFIX):
fix_... | python3.10.4/Lib/lib2to3/refactor.py | 403 | XX-Net | {
"docstring": "Inspects the options to load the requested patterns and handlers.\n\n Returns:\n (pre_order, post_order), where pre_order is the list of fixers that\n want a pre-order AST traversal, and post_order is the list that want\n post-order traversal.\n ",
"language"... | 108 | Python | 81 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | refactor.py | 218,885 | 30 | 245 | get_fixers | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 446 | 0 | 55,529 | 15 | |
2 | 8 | def for_each_coloraxis(self, fn, selector=None, row=None, col=None) -> "Figure":
for obj in self.select_coloraxes(selector=selector, row=row, col=col):
fn(obj)
return self
| packages/python/plotly/plotly/graph_objs/_figure.py | 73 | plotly.py | {
"docstring": "\n Apply a function to all coloraxis objects that satisfy the\n specified selection criteria\n\n Parameters\n ----------\n fn:\n Function that inputs a single coloraxis object.\n selector: dict, function, or None (default None)\n Dict to ... | 17 | Python | 17 | c95b4fa4388f29e50b6966e45c94c5980013a01d | _figure.py | 240,291 | 32 | 48 | for_each_coloraxis | https://github.com/plotly/plotly.py.git | type annotations for chainable Figure methods | 49 | 0 | 68,402 | 9 | |
1 | 23 | def test_run_query_with_multiple_groupby_orderby_null_values_in_first_entity(self):
self.setup_orderby_data()
self.store_transaction_metric(200, tags={"transaction": "baz_transaction"})
query = MetricsQueryBuilder(
self.params,
f"project:{self.project.slug}",
... | tests/sentry/search/events/test_builder.py | 357 | sentry | {
"docstring": "But if the null value is in the first entity, it won't show up in the groupby values, which means the\n transaction will be missing",
"language": "en",
"n_whitespaces": 31,
"n_words": 25,
"vocab_size": 21
} | 76 | Python | 48 | bf416f7ad23d7537a84c9727cfe1c0a7effd27bb | test_builder.py | 87,131 | 46 | 209 | test_run_query_with_multiple_groupby_orderby_null_values_in_first_entity | https://github.com/getsentry/sentry.git | feat(discover): Only transform when ordering project (#39468)
- This updates the querybuilder with a orderby resolver so we can
implement more custom orderbys(orderbies?) in the future
- This changes the project field to just select the project_id only,
which results in needing a new post-processing capability to t... | 582 | 0 | 18,229 | 12 | |
1 | 20 | def test_get_blame_for_file(self, get_jwt):
responses.add(
method=responses.POST,
url="https://api.github.com/app/installations/1/access_tokens",
body='{"token": "12345token", "expires_at": "2030-01-01T00:00:00Z"}',
content_type="application/json",
)
... | tests/sentry/integrations/github/test_client.py | 220 | sentry | {
"docstring": "query {{\n repository(name: foo, owner: Test-Organization) {{\n ref(qualifiedName: {ref}) {{\n target {{\n ... on Commit {{\n blame(path: {path}) {{\n ranges {{\n ... | 85 | Python | 59 | bdcd185bc020080da29961b9c60a5a0dabd3ab03 | test_client.py | 86,044 | 47 | 104 | test_get_blame_for_file | https://github.com/getsentry/sentry.git | feat(commit-context): Process commit context task (#38984)
## Objective:
We want to use the GitHub blame API to determine who is the committer
for the first in_app stacktrace frame and assign them as a Suspect
Commit GroupOwner.
This task is feature flagged for an internal release. | 1,022 | 0 | 18,075 | 11 | |
3 | 8 | def tosequence(x):
if isinstance(x, np.ndarray):
return np.asarray(x)
elif isinstance(x, Sequence):
return x
else:
return list(x)
| sklearn/utils/__init__.py | 66 | scikit-learn | {
"docstring": "Cast iterable x to a Sequence, avoiding a copy if possible.\n\n Parameters\n ----------\n x : iterable\n The iterable to be converted.\n\n Returns\n -------\n x : Sequence\n If `x` is a NumPy array, it returns it as a `ndarray`. If `x`\n is a `Sequence`, `x` is r... | 15 | Python | 12 | 8abc6d890e8bb4be7abe2984b3f373585f8f3c57 | __init__.py | 258,993 | 7 | 40 | tosequence | https://github.com/scikit-learn/scikit-learn.git | DOC Ensure that tosequence passes numpydoc validation (#22494)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> | 48 | 0 | 75,512 | 10 | |
1 | 2 | def type(self):
return self["type"]
| packages/python/plotly/plotly/graph_objs/bar/_error_x.py | 22 | plotly.py | {
"docstring": "\n Determines the rule used to generate the error bars. If\n *constant`, the bar lengths are of a constant value. Set this\n constant in `value`. If \"percent\", the bar lengths correspond\n to a percentage of underlying data. Set this percentage in\n `value`. If \"s... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _error_x.py | 228,646 | 2 | 11 | type | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 60,319 | 7 | |
5 | 46 | def _fit_multiclass(self, X, y, alpha, C, learning_rate, sample_weight, max_iter):
# Precompute the validation split using the multiclass labels
# to ensure proper balancing of the classes.
validation_mask = self._make_validation_split(y)
# Use joblib to fit OvA in parallel.
... | sklearn/linear_model/_stochastic_gradient.py | 355 | scikit-learn | {
"docstring": "Fit a multi-class classifier by combining binary classifiers\n\n Each binary classifier predicts one class versus all others. This\n strategy is called OvA (One versus All) or OvR (One versus Rest).\n ",
"language": "en",
"n_whitespaces": 51,
"n_words": 30,
"vocab_size": 2... | 161 | Python | 106 | 5f75acdd12d77b973471961ad716367c6199d01c | _stochastic_gradient.py | 258,738 | 38 | 243 | _fit_multiclass | https://github.com/scikit-learn/scikit-learn.git | MNT Bump joblib version dependency to 1.0.0 (#22365) | 652 | 0 | 75,397 | 14 | |
17 | 36 | def approximants(l, X=Symbol('x'), simplify=False):
from sympy.simplify import simplify as simp
from sympy.simplify.radsimp import denom
p1, q1 = [S.One], [S.Zero]
p2, q2 = [S.Zero], [S.One]
while len(l):
b = 0
while l[b]==0:
b += 1
if b == len(l):
... | sympy/series/approximants.py | 689 | sympy | {
"docstring": "\n Return a generator for consecutive Pade approximants for a series.\n It can also be used for computing the rational generating function of a\n series when possible, since the last approximant returned by the generator\n will be the generating function (if any).\n\n Explanation\n =... | 173 | Python | 96 | f757f3daae6e11ea0cfb7dadc133274d8d74315f | approximants.py | 196,814 | 96 | 447 | approximants | https://github.com/sympy/sympy.git | Reordered imports 2 | 541 | 0 | 48,194 | 16 | |
8 | 15 | def deserialize(obj):
if isinstance(obj, ObjectIDType):
return ray.get(obj)
elif isinstance(obj, (tuple, list)) and any(
isinstance(o, ObjectIDType) for o in obj
):
return ray.get(list(obj))
elif isinstance(obj, dict) and any(
isinstance(val, ObjectIDType) for val in... | modin/core/execution/ray/common/utils.py | 177 | modin | {
"docstring": "\n Deserialize a Ray object.\n\n Parameters\n ----------\n obj : ObjectIDType, iterable of ObjectIDType, or mapping of keys to ObjectIDTypes\n Object(s) to deserialize.\n\n Returns\n -------\n obj\n The deserialized object.\n ",
"language": "en",
"n_whitespace... | 40 | Python | 27 | b22b93df20ad25ae7a11f0c89d32fb2f234d4641 | utils.py | 153,841 | 13 | 113 | deserialize | https://github.com/modin-project/modin.git | FIX-#4464: Refactor Ray utils and quick fix groupby.count failing on virtual partitions (#4490)
Co-authored-by: Devin Petersohn <devin-petersohn@users.noreply.github.com>
Signed-off-by: jeffreykennethli <jkli@ponder.io> | 103 | 0 | 35,654 | 18 | |
1 | 4 | async def async_added_to_hass(self) -> None:
await self._async_restore_state()
await super().async_added_to_hass()
| homeassistant/components/here_travel_time/sensor.py | 43 | core | {
"docstring": "Wait for start so origin and destination entities can be resolved.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 9 | Python | 8 | dffdc78915ad9d25f54be90ef62659b2c68de347 | sensor.py | 291,798 | 6 | 38 | async_added_to_hass | https://github.com/home-assistant/core.git | Make HERETravelTimeSensor extend RestoreSensor (#82400) | 30 | 0 | 90,902 | 10 | |
1 | 22 | def test_rtl_language_detection(self):
parser = RasterisedDocumentParser(None)
with mock.patch.object(
parser,
"construct_ocrmypdf_parameters",
wraps=parser.construct_ocrmypdf_parameters,
) as wrapped:
parser.parse(
os.pat... | src/paperless_tesseract/tests/test_parser.py | 157 | paperless-ngx | {
"docstring": "\n GIVEN:\n - File with text in an RTL language\n WHEN:\n - Document is parsed\n THEN:\n - Text from the document is extracted\n ",
"language": "en",
"n_whitespaces": 84,
"n_words": 22,
"vocab_size": 19
} | 75 | Python | 62 | a2b7687c3b88aadc55ec38a2249c299eaefd394d | test_parser.py | 320,554 | 16 | 91 | test_rtl_language_detection | https://github.com/paperless-ngx/paperless-ngx.git | In the case of an RTL language being extracted via pdfminer.six, fall back to forced OCR, which handles RTL text better | 305 | 0 | 117,215 | 13 | |
3 | 7 | def _get_experiencer_side_only(self, opt):
base_datatype = self._get_base_datatype(opt)
return (
opt.get('train_experiencer_only', DEFAULT_TRAIN_EXPERIENCER_ONLY)
and base_datatype == 'train'
) or base_datatype != 'train'
| parlai/tasks/empathetic_dialogues/agents.py | 62 | ParlAI | {
"docstring": "\n Determine which side(s) of the conversation to use.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 8
} | 19 | Python | 16 | 4f7b38e7970424e4329cb57ab65710291a50f3f7 | agents.py | 194,827 | 6 | 35 | _get_experiencer_side_only | https://github.com/facebookresearch/ParlAI.git | [Empathetic Dialogues] Switch to DialogTeacher (#4405)
* Start revising ED teacher
* Convert over ED teacher
* Silly
* Minor
* Remove episode_done
* More cleanup
* Fix
* Test fix
* Force new CI check
* Note
* Cleanup
* Update parlai/tasks/empathetic_dialogues/agents.py
Co-authored-b... | 69 | 0 | 47,102 | 11 | |
10 | 49 | def generate_level_targets(self, img_size, text_polys, ignore_polys):
h, w = img_size
lv_size_divs = self.level_size_divisors
lv_proportion_range = self.level_proportion_range
lv_text_polys = [[] for i in range(len(lv_size_divs))]
lv_ignore_polys = [[] for i in range(len... | ppocr/data/imaug/fce_targets.py | 586 | PaddleOCR | {
"docstring": "Generate ground truth target on each level.\n\n Args:\n img_size (list[int]): Shape of input image.\n text_polys (list[list[ndarray]]): A list of ground truth polygons.\n ignore_polys (list[list[ndarray]]): A list of ignored polygons.\n Returns:\n ... | 191 | Python | 96 | 9f62b610dea6161627200ed85d92e19b1923279a | fce_targets.py | 23,192 | 39 | 384 | generate_level_targets | https://github.com/PaddlePaddle/PaddleOCR.git | add fcenet | 716 | 0 | 4,536 | 15 | |
2 | 15 | def test_driver_3():
args_list = [
'tests/tests.csv',
'-is', ',',
'-target', 'class',
'-g', '1',
'-p', '2',
'-cv', '3',
'-s',' 45',
'-config', 'TPOT light',
'-v', '2'
... | tests/driver_tests.py | 231 | tpot | {
"docstring": "Assert that the tpot_driver() in TPOT driver outputs normal result with verbosity = 2.",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 14
} | 64 | Python | 53 | 388616b6247ca4ea8de4e2f340d6206aee523541 | driver_tests.py | 181,598 | 23 | 125 | test_driver_3 | https://github.com/EpistasisLab/tpot.git | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 265 | 0 | 43,387 | 17 | |
2 | 6 | def _has_nchw_support():
explicitly_on_cpu = _is_current_explicit_device("CPU")
gpus_available = bool(_get_available_gpus())
return not explicitly_on_cpu and gpus_available
# VARIABLE MANIPULATION
| keras/backend.py | 47 | keras | {
"docstring": "Check whether the current scope supports NCHW ops.\n\n TensorFlow does not support NCHW on CPU. Therefore we check if we are not\n explicitly put on\n CPU, and have GPUs available. In this case there will be soft-placing on the\n GPU device.\n\n Returns:\n bool: if the current sc... | 16 | Python | 13 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | backend.py | 269,606 | 4 | 24 | _has_nchw_support | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 27 | 0 | 80,226 | 10 | |
1 | 11 | def _search(self, check_return_type=True) -> Union[SourceReadList, DestinationReadList, ConnectionReadList]:
return self._search_fn(self.api_instance, self.search_payload, _check_return_type=check_return_type)
| octavia-cli/octavia_cli/apply/resources.py | 53 | airbyte | {
"docstring": "Run search of a resources on the remote Airbyte instance.\n\n Returns:\n Union[SourceReadList, DestinationReadList, ConnectionReadList]: Search results\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 16,
"vocab_size": 16
} | 11 | Python | 11 | 56bf982cb96f831fe04f5e44a92ee4a669b9e16a | resources.py | 4,247 | 7 | 36 | _search | https://github.com/airbytehq/airbyte.git | 🐙 octavia-cli: `apply` connections (#10881) | 25 | 0 | 641 | 8 | |
1 | 43 | def test_in_non_semver_projects_resolved_in_next_release_is_equated_to_in_release(self):
release_1 = self.create_release(
date_added=timezone.now() - timedelta(minutes=45), version="foobar 1"
)
release_2 = self.create_release(version="foobar 2")
self.create_release(v... | tests/snuba/api/endpoints/test_organization_group_index.py | 407 | sentry | {
"docstring": "\n Test that ensures that if we basically know the next release when clicking on Resolved\n In Next Release because that release exists, then we can short circuit setting\n GroupResolution to type \"inNextRelease\", and then having `clear_exrired_resolutions` run\n once a n... | 81 | Python | 59 | 096b5511e244eecd8799b2a0324655207ce8985e | test_organization_group_index.py | 90,257 | 33 | 249 | test_in_non_semver_projects_resolved_in_next_release_is_equated_to_in_release | https://github.com/getsentry/sentry.git | ref(tests): Remove `get_valid_response()` (#34822) | 368 | 0 | 18,657 | 17 | |
4 | 18 | def schreier_vector(self, alpha):
n = self.degree
v = [None]*n
v[alpha] = -1
orb = [alpha]
used = [False]*n
used[alpha] = True
gens = self.generators
r = len(gens)
for b in orb:
for i in range(r):
temp = gens[i]... | sympy/combinatorics/perm_groups.py | 169 | sympy | {
"docstring": "Computes the schreier vector for ``alpha``.\n\n Explanation\n ===========\n\n The Schreier vector efficiently stores information\n about the orbit of ``alpha``. It can later be used to quickly obtain\n elements of the group that send ``alpha`` to a particular element... | 51 | Python | 35 | 498015021131af4dbb07eb110e5badaba8250c7b | perm_groups.py | 196,118 | 17 | 108 | schreier_vector | https://github.com/sympy/sympy.git | Updated import locations | 226 | 0 | 47,618 | 13 | |
2 | 13 | def test_workers_threads(self):
default_workers = 1
for i in range(1, 64):
with mock.patch(
"paperless.settings.multiprocessing.cpu_count",
) as cpu_count:
cpu_count.return_value = i
default_threads = default_threads_per_... | src/paperless/tests/test_settings.py | 99 | paperless-ngx | {
"docstring": "\n GIVEN:\n - Certain CPU counts\n WHEN:\n - Threads per worker is calculated\n THEN:\n - Threads per worker less than or equal to CPU count\n - At least 1 thread per worker\n ",
"language": "en",
"n_whitespaces": 104,
"n_wo... | 28 | Python | 25 | edaaedae36ee2bb99859b1ca22455b3b7381d0bd | test_settings.py | 319,864 | 10 | 59 | test_workers_threads | https://github.com/paperless-ngx/paperless-ngx.git | Reduces webserver and task worker count to 1 by default | 146 | 0 | 117,009 | 13 | |
1 | 17 | def test_query_product_type_for_federation(api_client, product, channel_USD):
product_type = product.product_type
product_type_id = graphene.Node.to_global_id("ProductType", product_type.pk)
variables = {
"representations": [
{
"__typename": "ProductType",
... | saleor/graphql/product/tests/queries/test_product_type_query.py | 161 | saleor | {
"docstring": "\n query GetProductTypeInFederation($representations: [_Any]) {\n _entities(representations: $representations) {\n __typename\n ... on ProductType {\n id\n name\n }\n }\n }\n ",
"language": "en",
"n_whitespaces": 94,
"n_... | 46 | Python | 33 | d90be220d6b687d08153934a51354011a3cb5ca1 | test_product_type_query.py | 29,297 | 31 | 94 | test_query_product_type_for_federation | https://github.com/saleor/saleor.git | 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 | 186 | 0 | 5,212 | 12 | |
1 | 9 | def _clear_combo_focus(self, *args) -> None: # pylint: disable=unused-argument
logger.debug("Clearing scale combo focus")
self._scale.selection_clear()
self._scale.winfo_toplevel().focus_set()
logger.debug("Cleared scale combo focus")
| lib/training/preview_tk.py | 76 | faceswap | {
"docstring": " Remove the highlighting and stealing of focus that the combobox annoyingly\n implements. ",
"language": "en",
"n_whitespaces": 20,
"n_words": 12,
"vocab_size": 11
} | 18 | Python | 15 | 7da2cc3dd266aabebf41a31384cc2e0e7e5af6e5 | preview_tk.py | 101,547 | 7 | 41 | _clear_combo_focus | https://github.com/deepfakes/faceswap.git | Training - Use custom preview pop-out | 54 | 0 | 20,957 | 10 | |
1 | 39 | def test_remote_workspace_value():
HOST = __default_host__
client = JinaDClient(host=HOST, port=8000)
workspace_id = client.workspaces.create(paths=[os.path.join(cur_dir, 'yamls')])
flow_id = client.flows.create(
workspace_id=workspace_id, filename='flow_workspace_validate.yml'
)
ar... | tests/distributed/test_topologies/test_topologies.py | 301 | @pytest.mark.parametrize('gpus', ['all', '2']) | jina | {
"docstring": "\n This tests the value set in `self.workspace` in a remote Flow.\n It should always be `/workspace/ExecutorName/...\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 16,
"vocab_size": 15
} | 46 | Python | 38 | 2efe175c975975532f6e3fd326ed280addf20eba | test_topologies.py | 11,257 | 21 | 168 | test_remote_workspace_value | https://github.com/jina-ai/jina.git | fix: return responses (#4343) | 140 | 1 | 2,028 | 13 |
1 | 10 | def test__yes_version_less_than():
mock_version = MagicMock(return_value="0.9.0")
with patch("salt.modules.chocolatey.chocolatey_version", mock_version):
result = chocolatey._yes()
expected = []
# Did it return correctly
assert result == expected
# Did it populate __... | tests/pytests/unit/modules/test_chocolatey.py | 85 | salt | {
"docstring": "\n Test _yes when Chocolatey version is less than 0.9.9\n ",
"language": "en",
"n_whitespaces": 16,
"n_words": 9,
"vocab_size": 9
} | 32 | Python | 22 | 1ff576163e64dac4ea1005121b32a1b3a4168f70 | test_chocolatey.py | 215,701 | 7 | 45 | test__yes_version_less_than | https://github.com/saltstack/salt.git | move chocolatey exec module tests to pytest | 83 | 0 | 54,109 | 10 | |
8 | 15 | def setimage(self, im, extents=None):
# following c code
self.im = im
if extents:
(x0, y0, x1, y1) = extents
else:
(x0, y0, x1, y1) = (0, 0, 0, 0)
if x0 == 0 and x1 == 0:
self.state.xsize, self.state.ysize = self.im.size
els... | src/PIL/ImageFile.py | 282 | Pillow | {
"docstring": "\n Called from ImageFile to set the core output image for the codec\n\n :param im: A core image object\n :param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle\n for this tile\n :returns: None\n ",
"language": "en",
"n_whitespaces": 83,
... | 91 | Python | 54 | a0e1fde1eddf45f26653e2ff6080d31e177adbec | ImageFile.py | 242,434 | 20 | 184 | setimage | https://github.com/python-pillow/Pillow.git | Added PyEncoder | 282 | 0 | 69,856 | 11 | |
1 | 9 | def get_parent_customer_groups(customer_group):
lft, rgt = frappe.db.get_value("Customer Group", customer_group, ["lft", "rgt"])
return frappe.db.sql(
,
(lft, rgt),
as_dict=True,
)
| erpnext/setup/doctype/customer_group/customer_group.py | 72 | erpnext | {
"docstring": "select name from `tabCustomer Group`\n\t\twhere lft <= %s and rgt >= %s\n\t\torder by lft asc",
"language": "en",
"n_whitespaces": 14,
"n_words": 17,
"vocab_size": 15
} | 17 | Python | 17 | 494bd9ef78313436f0424b918f200dab8fc7c20b | customer_group.py | 67,481 | 9 | 45 | get_parent_customer_groups | https://github.com/frappe/erpnext.git | style: format code with black | 10 | 0 | 14,539 | 10 | |
1 | 21 | def test_unassignment(self, mock_func):
notification = UnassignedActivityNotification(
Activity(
project=self.project,
group=self.group,
user=self.user,
type=ActivityType.ASSIGNED,
data={"assignee": ""},
... | tests/sentry/integrations/slack/notifications/test_unassigned.py | 171 | sentry | {
"docstring": "\n Test that a Slack message is sent with the expected payload when an issue is unassigned\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 16,
"vocab_size": 15
} | 42 | Python | 34 | 1730c481f1a8a71446326fa1ff72e10663016385 | test_unassigned.py | 99,587 | 19 | 93 | test_unassignment | https://github.com/getsentry/sentry.git | fix(notifications): Use `metrics_key` (#34572) | 235 | 0 | 19,665 | 14 | |
2 | 10 | def to_tuple(x):
warnings.warn(
"to_tuple is deprecated and will be removed in NetworkX 3.0.",
DeprecationWarning,
stacklevel=2,
)
if not isinstance(x, (tuple, list)):
return x
return tuple(map(to_tuple, x))
| networkx/utils/misc.py | 70 | networkx | {
"docstring": "Converts lists to tuples.\n\n .. deprecated:: 2.8\n\n to_tuple is deprecated and will be removed in NetworkX 3.0.\n\n Examples\n --------\n >>> from networkx.utils import to_tuple\n >>> a_list = [1, 2, [1, 4]]\n >>> to_tuple(a_list)\n (1, 2, (1, 4))\n ",
"language": "en... | 26 | Python | 25 | 6801db694e6a3603ab943079c3399baa0c5ff686 | misc.py | 176,466 | 9 | 44 | to_tuple | https://github.com/networkx/networkx.git | Deprecate `to_tuple` (#5430)
* Add _to_tuple private fn to node_link.py.
* Deprecate utils.misc.to_tuple.
* Add deprecation note.
* Add release note. | 69 | 0 | 41,921 | 9 | |
2 | 16 | def heldout_score(clf, X_test, y_test):
score = np.zeros((n_estimators,), dtype=np.float64)
for i, y_pred in enumerate(clf.staged_decision_function(X_test)):
score[i] = binomial_deviance(y_test, y_pred.ravel())
return score
| examples/ensemble/plot_gradient_boosting_oob.py | 91 | scikit-learn | {
"docstring": "compute deviance scores on ``X_test`` and ``y_test``.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | 19 | Python | 17 | 2c1581c32e641e535305647eb57a1787bcf803f0 | plot_gradient_boosting_oob.py | 261,569 | 5 | 59 | heldout_score | https://github.com/scikit-learn/scikit-learn.git | DOC Fix FutureWarning in ensemble/plot_gradient_boosting_oob.py (#24948) | 38 | 0 | 76,867 | 12 | |
2 | 4 | def battery_level(self) -> int | None:
if not self._data:
return None
return self._data.battery_level
| homeassistant/components/life360/device_tracker.py | 41 | core | {
"docstring": "Return the battery level of the device.\n\n Percentage from 0-100.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 10,
"vocab_size": 9
} | 13 | Python | 12 | 343508a0151378ec4958bd04fa87ca772aaf0e4e | device_tracker.py | 303,407 | 8 | 24 | battery_level | https://github.com/home-assistant/core.git | Fix Life360 recovery from server errors (#76231) | 45 | 0 | 102,227 | 7 | |
1 | 16 | def test_ticket_11293_q_immutable(self):
q1 = Q(isbn="")
q2 = Q(authors__count__gt=1)
query = Book.objects.annotate(Count("authors"))
query.filter(q1 | q2)
self.assertEqual(len(q2.children), 1)
| tests/aggregation_regress/tests.py | 97 | django | {
"docstring": "\n Splitting a q object to parts for where/having doesn't alter\n the original q-object.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 13,
"vocab_size": 13
} | 16 | Python | 14 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 200,943 | 6 | 56 | test_ticket_11293_q_immutable | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 58 | 0 | 49,831 | 11 | |
4 | 18 | def on_advance_end(self) -> None:
# -----------------------------------------
# VALIDATE IF NEEDED + CHECKPOINT CALLBACK
# -----------------------------------------
should_check_val = self._should_check_val_fx(self.batch_idx, self.batch_progress.is_last_batch)
if should_... | pytorch_lightning/loops/epoch/training_epoch_loop.py | 157 | lightning | {
"docstring": "Runs validation and Checkpointing if necessary.\n\n Raises:\n StopIteration: if :attr:`done` evaluates to ``True`` to finish this epoch\n ",
"language": "en",
"n_whitespaces": 42,
"n_words": 17,
"vocab_size": 15
} | 112 | Python | 84 | 59a7ba760548baadf6dbb30864b54cb01c7225a3 | training_epoch_loop.py | 241,703 | 17 | 87 | on_advance_end | https://github.com/Lightning-AI/lightning.git | Move `epoch_{start,end}` hooks from `TrainingEpochLoop` to `FitLoop` (#11201) | 301 | 0 | 69,658 | 10 | |
1 | 16 | def test_get_feature_names_invalid_dtypes(names, dtypes):
pd = pytest.importorskip("pandas")
X = pd.DataFrame([[1, 2], [4, 5], [5, 6]], columns=names)
msg = re.escape(
"Feature names only support names that are all strings. "
f"Got feature names with dtypes: {dtypes}."
)
with p... | sklearn/utils/tests/test_validation.py | 123 | scikit-learn | {
"docstring": "Get feature names errors when the feature names have mixed dtypes",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 9
} | 41 | Python | 34 | 9f9f1684e91fbfffbc446f786a8c64628b752efb | test_validation.py | 261,047 | 9 | 74 | test_get_feature_names_invalid_dtypes | https://github.com/scikit-learn/scikit-learn.git | MAINT Clean deprecation for 1.2: validation (#24493)
* cln deprecations
* cln
* fix tst switch to pytest.raises | 80 | 0 | 76,648 | 11 | |
10 | 48 | def svd(a, full_matrices=True, compute_uv=True, hermitian=False):
import numpy as _nx
a, wrap = _makearray(a)
if hermitian:
# note: lapack svd returns eigenvalues with s ** 2 sorted descending,
# but eig returns s sorted ascending, so we re-order the eigenvalues
# and related a... | numpy/linalg/linalg.py | 635 | numpy | {
"docstring": "\n Singular Value Decomposition.\n\n When `a` is a 2D array, and when `full_matrices` is `False`,\n it is factorized as ``u @ np.diag(s) @ vh = (u * s) @ vh``,\n where `u` and `vh` are 2D unitary arrays and `s` is a 1D\n array of `a`'s singular values. When `a` is higher-dimensional, SV... | 215 | Python | 116 | 40747ae50620631941e43dbbd5baaccab669922f | linalg.py | 160,044 | 49 | 399 | svd | https://github.com/numpy/numpy.git | clarify svd documentation
`u @ np.diag(s) @ vh` can only reproduce the original matrix when `full_matrices` is `False`, otherwise dimension does not match. | 658 | 0 | 38,474 | 17 | |
4 | 13 | def trace_with_input_signature(self):
if self._layer_inputs[0] is None:
return
args, kwargs = self._layer_inputs
if self._expects_training_arg:
args, kwargs = self._call_spec.set_arg_value(
"training", False, args, kwargs, inputs_in_args=True
... | keras/saving/saved_model/save_impl.py | 124 | keras | {
"docstring": "Trace with the layer/models inferred input signature if possible.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 49 | Python | 41 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | save_impl.py | 276,110 | 10 | 78 | trace_with_input_signature | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 165 | 0 | 81,562 | 11 | |
1 | 19 | def test_perfect_horizontal_line():
X = np.arange(100)[:, None]
y = np.zeros((100,))
estimator = LinearRegression()
ransac_estimator = RANSACRegressor(estimator, random_state=0)
ransac_estimator.fit(X, y)
assert_allclose(ransac_estimator.estimator_.coef_, 0.0)
assert_allclose(ransac_e... | sklearn/linear_model/tests/test_ransac.py | 160 | @pytest.mark.parametrize(
"old_loss, new_loss",
[
("absolute_loss", "squared_error"),
("squared_loss", "absolute_error"),
],
) | scikit-learn | {
"docstring": "Check that we can fit a line where all samples are inliers.\n Non-regression test for:\n https://github.com/scikit-learn/scikit-learn/issues/19497\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 16,
"vocab_size": 16
} | 37 | Python | 33 | 1c24595c74e0bea246737b19f8fdfc8a1ffa2282 | test_ransac.py | 258,465 | 8 | 76 | test_perfect_horizontal_line | https://github.com/scikit-learn/scikit-learn.git | MAINT rename base_estimator to estimator in RANSACRegressor (#22062) | 81 | 1 | 75,246 | 9 |
5 | 28 | def sync_transactions(bank, bank_account):
last_transaction_date = frappe.db.get_value("Bank Account", bank_account, "last_integration_date")
if last_transaction_date:
start_date = formatdate(last_transaction_date, "YYYY-MM-dd")
else:
start_date = formatdate(add_months(today(), -12), "YYYY-MM-dd")
end_date = ... | erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py | 296 | erpnext | {
"docstring": "Sync transactions based on the last integration date as the start date, after sync is completed\n\tadd the transaction date of the oldest transaction as the last integration date.",
"language": "en",
"n_whitespaces": 27,
"n_words": 29,
"vocab_size": 20
} | 85 | Python | 62 | 494bd9ef78313436f0424b918f200dab8fc7c20b | plaid_settings.py | 66,003 | 26 | 178 | sync_transactions | https://github.com/frappe/erpnext.git | style: format code with black | 59 | 0 | 14,088 | 15 | |
15 | 17 | def select_related_descend(field, restricted, requested, load_fields, reverse=False):
if not field.remote_field:
return False
if field.remote_field.parent_link and not reverse:
return False
if restricted:
if reverse and field.related_query_name() not in requested:
re... | django/db/models/query_utils.py | 195 | django | {
"docstring": "\n Return True if this field should be used to descend deeper for\n select_related() purposes. Used by both the query construction code\n (sql.query.fill_related_selections()) and the model instance creation code\n (query.get_klass_info()).\n\n Arguments:\n * field - the field to be... | 85 | Python | 48 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | query_utils.py | 205,802 | 21 | 123 | select_related_descend | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 264 | 0 | 51,220 | 17 | |
2 | 13 | def test_notification_permission_workaround():
try:
notifications = QWebEnginePage.Feature.Notifications
except AttributeError:
pytest.skip("No Notifications member")
permissions = webenginetab._WebEnginePermissions
assert permissions._options[notifications] == 'content.notificatio... | tests/unit/browser/webengine/test_webenginetab.py | 82 | qutebrowser | {
"docstring": "Make sure the value for QWebEnginePage::Notifications is correct.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 23 | Python | 20 | 0877fb0d78635692e481c8bde224fac5ad0dd430 | test_webenginetab.py | 321,330 | 8 | 46 | test_notification_permission_workaround | https://github.com/qutebrowser/qutebrowser.git | Run scripts/dev/rewrite_enums.py | 55 | 0 | 117,667 | 11 | |
1 | 14 | def test_get_settings_request_context_use_default(self):
request = self.get_request(site=self.other_site)
context = Context({"request": request})
# This should use the default site, ignoring the site in the request
template = Template(
"{% load wagtailsettings_tags ... | wagtail/contrib/settings/tests/test_templates.py | 96 | wagtail | {
"docstring": "\n Check that the {% get_settings use_default_site=True %} option\n overrides a request in the context.\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 14,
"vocab_size": 13
} | 38 | Python | 31 | d10f15e55806c6944827d801cd9c2d53f5da4186 | test_templates.py | 73,525 | 9 | 53 | test_get_settings_request_context_use_default | https://github.com/wagtail/wagtail.git | Reformat with black | 120 | 0 | 16,042 | 11 | |
1 | 4 | def adj(self):
return MultiAdjacencyView(self._adj)
| networkx/classes/multigraph.py | 24 | networkx | {
"docstring": "Graph adjacency object holding the neighbors of each node.\n\n This object is a read-only dict-like structure with node keys\n and neighbor-dict values. The neighbor-dict is keyed by neighbor\n to the edgekey-data-dict. So `G.adj[3][2][0]['color'] = 'blue'` sets\n the col... | 4 | Python | 4 | 8f4c99debc9440728c5e85f8bffa5d26b232eb6f | multigraph.py | 176,417 | 2 | 13 | adj | https://github.com/networkx/networkx.git | Multigraph docs update (#5389)
* Updated MultiDiGraph documentation to include more examples of actually
using parallel edges, and fixed references to things like G[u, v] where
G[u, v, k] is required for a MultiDigraph. Have not made parallel
changes in MultiGraph which should maybe also be made?
Docs tests pass... | 18 | 0 | 41,882 | 8 | |
7 | 21 | def _check_m2m_through_same_relationship(cls):
errors = []
seen_intermediary_signatures = []
fields = cls._meta.local_many_to_many
# Skip when the target model wasn't found.
fields = (f for f in fields if isinstance(f.remote_field.model, ModelBase))
# Skip wh... | django/db/models/base.py | 215 | django | {
"docstring": "Check if no relationship model is used by more than one m2m field.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 13
} | 88 | Python | 53 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | base.py | 205,412 | 26 | 136 | _check_m2m_through_same_relationship | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 460 | 0 | 51,119 | 18 | |
1 | 32 | def forward(self, query, key, value, pos_emb, mask):
q, k, v = self.forward_qkv(query, key, value)
q = q.transpose(1, 2) # (batch, time1, head, d_k)
n_batch_pos = pos_emb.size(0)
p = self.linear_pos(pos_emb).view(n_batch_pos, -1, self.h, self.d_k)
p = p.transpose(1, 2)... | ppg_extractor/encoder/attention.py | 293 | MockingBird | {
"docstring": "Compute 'Scaled Dot Product Attention' with rel. positional encoding.\n\n :param torch.Tensor query: (batch, time1, size)\n :param torch.Tensor key: (batch, time2, size)\n :param torch.Tensor value: (batch, time2, size)\n :param torch.Tensor pos_emb: (batch, time1, size)\n ... | 130 | Python | 71 | b617a87ee40ab384767a27335313c2c65ee094ec | attention.py | 161,087 | 15 | 189 | forward | https://github.com/babysor/MockingBird.git | Init ppg extractor and ppg2mel (#375)
* Init ppg extractor and ppg2mel
* add preprocess and training
* FIx known issues
* Update __init__.py
Allow to gen audio
* Fix length issue
* Fix bug of preparing fid
* Fix sample issues
* Add UI usage of PPG-vc | 298 | 0 | 38,899 | 11 | |
1 | 6 | def on_page_context(self, context, page, config, nav):
return context
| mkdocs/plugins.py | 24 | mkdocs | {
"docstring": "\n The `page_context` event is called after the context for a page is created\n and can be used to alter the context for that specific page only.\n\n Parameters:\n context: dict of template context variables\n page: `mkdocs.nav.Page` instance\n con... | 8 | Python | 8 | f79b34d174e41084391868e7b503f5c61b8b1bdf | plugins.py | 224,449 | 2 | 16 | on_page_context | https://github.com/mkdocs/mkdocs.git | Move plugin events docs into source code + refactor
* Create real (no-op) methods for each event in the base class.
* Refactor event dispatcher to not check for methods' existence, instead just call them.
* Move documentation from Markdown into docstrings of these methods.
* Activate the 'mkdocstrings' plugin.
* Use '... | 22 | 0 | 57,294 | 6 | |
7 | 58 | def _read(cls, path_or_buf, **kwargs):
path_or_buf = cls.get_path_or_buffer(path_or_buf)
if isinstance(path_or_buf, str):
if not cls.file_exists(path_or_buf):
return cls.single_worker_read(path_or_buf, **kwargs)
path_or_buf = cls.get_path(path_or_buf)
... | modin/core/io/text/json_dispatcher.py | 641 | modin | {
"docstring": "\n Read data from `path_or_buf` according to the passed `read_json` `kwargs` parameters.\n\n Parameters\n ----------\n path_or_buf : str, path object or file-like object\n `path_or_buf` parameter of `read_json` function.\n **kwargs : dict\n Para... | 157 | Python | 106 | 97769988a6f19e4b76f34238c97bf159ee7626a5 | json_dispatcher.py | 153,549 | 48 | 398 | _read | https://github.com/modin-project/modin.git | REFACTOR-#3853: interacting with Dask interface through 'DaskWrapper' class (#3854)
Co-authored-by: Devin Petersohn <devin-petersohn@users.noreply.github.com>
Co-authored-by: Dmitry Chigarev <dchigarev@users.noreply.github.com>
Co-authored-by: Yaroslav Igoshev <Poolliver868@mail.ru>
Signed-off-by: Anatoly Myachev <... | 655 | 0 | 35,438 | 16 | |
5 | 21 | def write_shared_locations(self, paths, dry_run=False):
shared_path = os.path.join(self.path, 'SHARED')
logger.info('creating %s', shared_path)
if dry_run:
return None
lines = []
for key in ('prefix', 'lib', 'headers', 'scripts', 'data'):
path = p... | .venv/lib/python3.8/site-packages/pip/_vendor/distlib/database.py | 239 | transferlearning | {
"docstring": "\n Write shared location information to the SHARED file in .dist-info.\n :param paths: A dictionary as described in the documentation for\n :meth:`shared_locations`.\n :param dry_run: If True, the action is logged but no file is actually\n written.\n ... | 52 | Python | 44 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | database.py | 61,979 | 15 | 139 | write_shared_locations | https://github.com/jindongwang/transferlearning.git | upd; format | 186 | 0 | 12,792 | 13 | |
3 | 7 | def get_body_encoding(self):
assert self.body_encoding != SHORTEST
if self.body_encoding == QP:
return 'quoted-printable'
elif self.body_encoding == BASE64:
return 'base64'
else:
return encode_7or8bit
| python3.10.4/Lib/email/charset.py | 61 | XX-Net | {
"docstring": "Return the content-transfer-encoding used for body encoding.\n\n This is either the string `quoted-printable' or `base64' depending on\n the encoding used, or it is a function in which case you should call\n the function with a single argument, the Message object being\n en... | 21 | Python | 16 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | charset.py | 223,651 | 8 | 34 | get_body_encoding | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 89 | 0 | 57,033 | 9 | |
2 | 19 | def manage_matplotlib_context() -> Any:
originalRcParams = matplotlib.rcParams.copy()
# Credits for this style go to the ggplot and seaborn packages.
# We copied the style file to remove dependencies on the Seaborn package.
# Check it out, it's an awesome library for plotting
customRcParam... | src/pandas_profiling/visualisation/context.py | 503 | ydata-profiling | {
"docstring": "Return a context manager for temporarily changing matplotlib unit registries and rcParams.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | 184 | Python | 139 | 11e1a8a3fa8d13513fe926b731fb907a066af2a1 | context.py | 191,835 | 62 | 273 | manage_matplotlib_context | https://github.com/ydataai/ydata-profiling.git | fix: change context managed backend (#1149) | 662 | 0 | 46,847 | 15 | |
1 | 3 | def force_update(self) -> bool:
return False
| homeassistant/components/life360/device_tracker.py | 19 | core | {
"docstring": "Return True if state updates should be forced.\n\n Overridden because CoordinatorEntity sets `should_poll` to False,\n which causes TrackerEntity to set `force_update` to True.\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 23,
"vocab_size": 21
} | 6 | Python | 6 | e3fb04e1166d15f576d4b6fdec962f13871aaafe | device_tracker.py | 306,735 | 7 | 10 | force_update | https://github.com/home-assistant/core.git | Add comment to life360 device tracker (#77879) | 20 | 0 | 105,519 | 6 | |
3 | 65 | def glm_dataset(global_random_seed, request):
data_type, model = request.param
# Make larger dim more than double as big as the smaller one.
# This helps when constructing singular matrices like (X, X).
if data_type == "long":
n_samples, n_features = 12, 4
else:
n_samples, n_fea... | sklearn/linear_model/_glm/tests/test_glm.py | 766 | @pytest.mark.parametrize("solver", SOLVERS)
@pytest.mark.parametrize("fit_intercept", [False, True]) | scikit-learn | {
"docstring": "Dataset with GLM solutions, well conditioned X.\n\n This is inspired by ols_ridge_dataset in test_ridge.py.\n\n The construction is based on the SVD decomposition of X = U S V'.\n\n Parameters\n ----------\n type : {\"long\", \"wide\"}\n If \"long\", then n_samples > n_features.\... | 284 | Python | 172 | 9d863aba2b6dab9c9cbbcf2f7c3b7a99b6ad168f | test_glm.py | 260,403 | 77 | 495 | glm_dataset | https://github.com/scikit-learn/scikit-learn.git | TST tight tests for GLMs (#23619)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> | 716 | 1 | 76,228 | 15 |
3 | 13 | def get_telemetry_id() -> Optional[Text]:
try:
telemetry_config = (
rasa_utils.read_global_config_value(CONFIG_FILE_TELEMETRY_KEY) or {}
)
return telemetry_config.get(CONFIG_TELEMETRY_ID)
except Exception as e: # skipcq:PYL-W0703
logger.debug(f"Unable to retrie... | rasa/telemetry.py | 84 | rasa | {
"docstring": "Return the unique telemetry identifier for this Rasa Open Source install.\n\n The identifier can be any string, but it should be a UUID.\n\n Returns:\n The identifier, if it is configured correctly.\n ",
"language": "en",
"n_whitespaces": 47,
"n_words": 31,
"vocab_size": 27
} | 28 | Python | 27 | 6339856514897056716bb531acb8489c9cf05d26 | telemetry.py | 159,326 | 16 | 46 | get_telemetry_id | https://github.com/RasaHQ/rasa.git | Add support for different recipes (#10641)
* Add support for different recipes
Fixes https://github.com/RasaHQ/rasa/issues/10473
* Update docs/docs/graph-recipe.mdx
Co-authored-by: Joe Juzl <joejuzl@gmail.com> | 84 | 0 | 38,198 | 12 | |
3 | 13 | def get_changelist_form(self, request, **kwargs):
defaults = {
"formfield_callback": partial(self.formfield_for_dbfield, request=request),
**kwargs,
}
if defaults.get("fields") is None and not modelform_defines_fields(
defaults.get("form")
):
... | django/contrib/admin/options.py | 117 | django | {
"docstring": "\n Return a Form class for use in the Formset on the changelist page.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 12
} | 27 | Python | 26 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | options.py | 203,409 | 10 | 70 | get_changelist_form | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 113 | 0 | 50,357 | 12 | |
1 | 13 | def get_all_sales_person(date_range, company, field=None, limit=0):
date_condition = get_date_condition(date_range, "sales_order.transaction_date")
return frappe.db.sql(
.format(
date_condition=date_condition
),
(company, cint(limit)),
as_dict=1,
)
| erpnext/startup/leaderboard.py | 80 | erpnext | {
"docstring": "\n\t\tselect sales_team.sales_person as name, sum(sales_order.base_net_total) as value\n\t\tfrom `tabSales Order` as sales_order join `tabSales Team` as sales_team\n\t\t\ton sales_order.name = sales_team.parent and sales_team.parenttype = 'Sales Order'\n\t\twhere sales_order.docstatus = 1\n\t\t\tand s... | 18 | Python | 18 | 494bd9ef78313436f0424b918f200dab8fc7c20b | leaderboard.py | 67,565 | 19 | 53 | get_all_sales_person | https://github.com/frappe/erpnext.git | style: format code with black | 9 | 0 | 14,557 | 10 | |
6 | 32 | def load_digits(*, n_class=10, return_X_y=False, as_frame=False):
data, fdescr = load_gzip_compressed_csv_data(
data_file_name="digits.csv.gz", descr_file_name="digits.rst", delimiter=","
)
target = data[:, -1].astype(int, copy=False)
flat_data = data[:, :-1]
images = flat_data.view()... | sklearn/datasets/_base.py | 324 | scikit-learn | {
"docstring": "Load and return the digits dataset (classification).\n\n Each datapoint is a 8x8 image of a digit.\n\n ================= ==============\n Classes 10\n Samples per class ~180\n Samples total 1797\n Dimensionality 6... | 97 | Python | 64 | 39c341ad91b545c895ede9c6240a04659b82defb | _base.py | 258,753 | 36 | 212 | load_digits | https://github.com/scikit-learn/scikit-learn.git | DOC Ensures that load_digits passes numpydoc validation (#22392) | 285 | 0 | 75,403 | 11 | |
2 | 11 | def test_family_deprecation(est, family):
with pytest.warns(FutureWarning, match="`family` was deprecated"):
if isinstance(family, str):
assert est.family == family
else:
assert est.family.__class__ == family.__class__
assert est.family.power == family.power
| sklearn/linear_model/_glm/tests/test_glm.py | 92 | scikit-learn | {
"docstring": "Test backward compatibility of the family property.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | 24 | Python | 20 | 75a94f518f7bd7d0bf581ffb67d9f961e3c4efbc | test_glm.py | 259,455 | 7 | 56 | test_family_deprecation | https://github.com/scikit-learn/scikit-learn.git | ENH migrate GLMs / TweedieRegressor to linear loss (#22548)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> | 77 | 0 | 75,785 | 13 | |
3 | 16 | async def async_start(self) -> None:
_LOGGER.info("Starting Home Assistant")
setattr(self.loop, "_thread_ident", threading.get_ident())
self.state = CoreState.starting
self.bus.async_fire(EVENT_CORE_CONFIG_UPDATE)
self.bus.async_fire(EVENT_HOMEASSISTANT_START)
... | homeassistant/core.py | 101 | async def async_start(self) -> None:
"""Finalize startup from inside the event loop.
This method is a coroutine.
"""
_LOGGER.info("Starting Home Assistant")
setattr(self.loop, "_thread_ident", threading.get_ident())
self.state = CoreState.starting
self.bus.async... | core | {
"docstring": "Finalize startup from inside the event loop.\n\n This method is a coroutine.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 12,
"vocab_size": 12
} | 24 | Python | 24 | b0cee0bc46cbd7efe0e6421da18d91595c7a25ad | core.py | 297,831 | 34 | 150 | async_start | https://github.com/home-assistant/core.git | String formatting and max line length - Part 1 (#84390)
Co-authored-by: Erik Montnemery <erik@montnemery.com> | 95 | 1 | 96,788 | 8 |
4 | 9 | def get_module_by_name(model, module_name):
name_list = module_name.split(".")
for name in name_list[:-1]:
if hasattr(model, name):
model = getattr(model, name)
else:
return None, None
if hasattr(model, name_list[-1]):
leaf_module = getattr(model, name_li... | nni/compression/pytorch/utils/pruning.py | 131 | nni | {
"docstring": "\n Get a module specified by its module name\n Parameters\n ----------\n model : pytorch model\n the pytorch model from which to get its module\n module_name : str\n the name of the required module\n Returns\n -------\n module, module\n the parent module of... | 35 | Python | 24 | d68c786ff81bad19c04619d6a999ff34aaa724e7 | pruning.py | 113,688 | 12 | 82 | get_module_by_name | https://github.com/microsoft/nni.git | [Compression] remove pruning v1 & refactor directory (#5228) | 107 | 0 | 25,005 | 12 | |
2 | 6 | def _get_chromecast(self) -> pychromecast.Chromecast:
if self._chromecast is None:
raise HomeAssistantError("Chromecast is not available.")
return self._chromecast
| homeassistant/components/cast/media_player.py | 46 | core | {
"docstring": "Ensure chromecast is available, to facilitate type checking.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 15 | Python | 13 | ed60611b07e38e7009c6cc266c14625a751e7b32 | media_player.py | 304,531 | 5 | 26 | _get_chromecast | https://github.com/home-assistant/core.git | Improve type hint in cast media_player entity (#77025)
* Improve type hint in cast media_player entity
* Update docstring | 47 | 0 | 103,338 | 10 | |
2 | 6 | def is_wheel_installed() -> bool:
try:
import pipenv.vendor.wheel as wheel # noqa: F401
except ImportError:
return False
return True
| pipenv/patched/notpip/_internal/utils/misc.py | 42 | pipenv | {
"docstring": "\n Return whether the wheel package is installed.\n ",
"language": "en",
"n_whitespaces": 14,
"n_words": 7,
"vocab_size": 7
} | 18 | Python | 17 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | misc.py | 19,993 | 9 | 24 | is_wheel_installed | https://github.com/pypa/pipenv.git | 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... | 45 | 0 | 3,167 | 9 | |
7 | 14 | def test_pick_two_individuals_eligible_for_crossover():
ind1 = creator.Individual.from_string(
'BernoulliNB(input_matrix, BernoulliNB__alpha=1.0, BernoulliNB__fit_prior=True)',
tpot_obj._pset
)
ind2 = creator.Individual.from_string(
'BernoulliNB(input_matrix, BernoulliNB__alpha... | tests/tpot_tests.py | 301 | tpot | {
"docstring": "Assert that pick_two_individuals_eligible_for_crossover() picks the correct pair of nodes to perform crossover with",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 13
} | 102 | Python | 56 | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot_tests.py | 181,704 | 28 | 182 | test_pick_two_individuals_eligible_for_crossover | https://github.com/EpistasisLab/tpot.git | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 259 | 0 | 43,491 | 12 | |
4 | 37 | def test_qgelu(self):
shapes = ((4,), (4, 4), (4, 4, 4), (4, 4, 4, 4))
dtypes = (torch.quint8, torch.qint8)
memory_formats = (torch.channels_last, torch.contiguous_format)
test_cases = itertools.product(shapes, dtypes, memory_formats)
for shape, dtype, memory_format in test_cases... | test/quantization/core/test_quantized_op.py | 327 | pytorch | {
"docstring": "Tests the correctness of the quantized::qlayer_norm op.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 6
} | 87 | Python | 67 | 32bf5e0ef9177a9f8e65cea6cdf6d17e2cc5eaff | test_quantized_op.py | 102,401 | 21 | 224 | test_qgelu | https://github.com/pytorch/pytorch.git | Add native impl of gelu for QuantizedCPU (#69968)
Summary:
Add native implementation of gelu for quantized CPU.
cc jerryzh168 jianyuh raghuramank100 jamesr66a vkuzo
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69968
Reviewed By: ejguan
Differential Revision: D33187095
Pulled By: vkuzo
fbshipit-... | 377 | 0 | 21,520 | 13 | |
4 | 29 | def _upsample_conv_2d(x, w, k=None, factor=2, gain=1):
assert isinstance(factor, int) and factor >= 1
# Check weight shape.
assert len(w.shape) == 4
convH = w.shape[2]
convW = w.shape[3]
inC = w.shape[1]
assert convW == convH
# Setup filter kernel.
if k is None:
k = ... | src/diffusers/models/unet_sde_score_estimation.py | 538 | diffusers | {
"docstring": "Fused `upsample_2d()` followed by `Conv2d()`.\n\n Args:\n Padding is performed only once at the beginning, not between the operations. The fused op is considerably more\n efficient than performing the same calculation using standard TensorFlow ops. It supports gradients of arbitrary\n orde... | 182 | Python | 102 | 3e2cff4da25642e964c48fa44d7c00d3314b1ce8 | unet_sde_score_estimation.py | 335,695 | 25 | 356 | _upsample_conv_2d | https://github.com/huggingface/diffusers.git | better names and more cleanup | 281 | 0 | 120,826 | 14 | |
4 | 21 | def _get_supported_devices(self) -> List[plaidml._DeviceConfig]:
experimental_setting = plaidml.settings.experimental
plaidml.settings.experimental = False
devices = plaidml.devices(self._ctx, limit=100, return_all=True)[0]
plaidml.settings.experimental = experimental_setting
... | lib/gpu_stats/amd.py | 178 | faceswap | {
"docstring": " Obtain GPU devices from PlaidML that are marked as \"supported\".\n\n Returns\n -------\n list_LOGGER.\n The :class:`plaidml._DeviceConfig` objects for all supported GPUs that PlaidML has\n discovered.\n ",
"language": "en",
"n_whitespaces": 75,
... | 39 | Python | 29 | bdbbad4d310fb606b6f412aa81e9f57ccd994e97 | amd.py | 100,548 | 18 | 106 | _get_supported_devices | https://github.com/deepfakes/faceswap.git | Refactor lib.gpu_stats (#1218)
* inital gpu_stats refactor
* Add dummy CPU Backend
* Update Sphinx documentation | 135 | 0 | 20,012 | 19 | |
1 | 5 | def save_object(self, object_form, request):
return object_form.save()
| netbox/netbox/views/generic/bulk_views.py | 27 | netbox | {
"docstring": "\n Provide a hook to modify the object immediately before saving it (e.g. to encrypt secret data).\n\n Args:\n object_form: The model form instance\n request: The current request\n ",
"language": "en",
"n_whitespaces": 70,
"n_words": 26,
"vocab_size":... | 6 | Python | 6 | 80f5c96af3e78232ffe2bcce7c27995612964596 | bulk_views.py | 266,159 | 2 | 16 | save_object | https://github.com/netbox-community/netbox.git | Document save_object() on BulkImportView | 20 | 0 | 78,320 | 7 | |
3 | 54 | def forward(self, feats, img_metas):
batch_size = len(img_metas)
mask_features, multi_scale_memorys = self.pixel_decoder(feats)
# multi_scale_memorys (from low resolution to high resolution)
decoder_inputs = []
decoder_positional_encodings = []
for i in range(sel... | mmdet/models/dense_heads/mask2former_head.py | 632 | mmdetection | {
"docstring": "Forward function.\n\n Args:\n feats (list[Tensor]): Multi scale Features from the\n upstream network, each is a 4D-tensor.\n img_metas (list[dict]): List of image information.\n\n Returns:\n tuple: A tuple contains two elements.\n\n ... | 201 | Python | 121 | 14f0e9585c15c28f0c31dcc3ea352449bbe5eb96 | mask2former_head.py | 244,142 | 50 | 412 | forward | https://github.com/open-mmlab/mmdetection.git | [Feature] Add Mask2Former to mmdet (#6938)
update doc
update doc format
deepcopy pixel_decoder cfg
move mask_pseudo_sampler cfg to config file
move part of postprocess from head to detector
fix bug in postprocessing
move class setting from head to config file
remove if else
move mask2bbox to ma... | 828 | 0 | 70,258 | 16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.