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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
130,603 | 14 | 9 | 8 | 55 | 10 | 0 | 14 | 36 | get_blocks_with_metadata | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | https://github.com/ray-project/ray.git | def get_blocks_with_metadata(self) -> List[Tuple[ObjectRef[Block], BlockMetadata]]:
self.get_blocks() # Force bulk evaluation in LazyBlockList.
return list(self.iter_blocks_with_metadata())
| 33 | block_list.py | Python | python/ray/data/impl/block_list.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 1 | |
163,783 | 7 | 7 | 5 | 26 | 5 | 0 | 7 | 21 | _standardize_dtype | REF: share IntegerArray/FloatingArray coerce_to_array (#45596) | https://github.com/pandas-dev/pandas.git | def _standardize_dtype(cls, dtype) -> NumericDtype:
raise AbstractMethodError(cls)
| 15 | numeric.py | Python | pandas/core/arrays/numeric.py | fbc2ab6da69bb2ba18629aa20f1f2fe5fc85d3df | pandas | 1 | |
166,972 | 42 | 12 | 15 | 198 | 18 | 1 | 64 | 146 | array_likes | DOC: Added docstrings to fixtures defined in array module (#47211) | https://github.com/pandas-dev/pandas.git | def array_likes(request):
# GH#24539 recognize e.g xarray, dask, ...
arr = np.array([1, 2, 3], dtype=np.int64)
name = request.param
if name == "memoryview":
data = memoryview(arr)
elif name == "array":
# stdlib array
import array
data = array.array("i", arr)
... | @pytest.mark.parametrize("dtype", ["M8[ns]", "m8[ns]"]) | 99 | test_datetimelike.py | Python | pandas/tests/arrays/test_datetimelike.py | 89be1f053b695c4ce1c0569f737caf3f03c12128 | pandas | 5 |
189,387 | 2 | 6 | 8 | 13 | 2 | 0 | 2 | 9 | test_npm_login_always_auth_error_ignored | Ignore errors setting always-auth in npm config set
The release of NPM 9 has dropped the support of deprecated or unsupported
parameters in the `npm config set` command. This includes the `always-auth`
parameter. Since `always-auth=true` is being set internally via the
`aws codeartifact login --tool npm` command, this... | https://github.com/aws/aws-cli.git | def test_npm_login_always_auth_error_ignored(self):
| 63 | test_codeartifact_login.py | Python | tests/functional/codeartifact/test_codeartifact_login.py | bc5de54af76aca8eda1666ff274b19b31f080fde | aws-cli | 1 | |
153,230 | 12 | 11 | 5 | 59 | 10 | 0 | 13 | 56 | get_path | FIX-#4177: Support read_feather from pathlike objects. (#4179)
Signed-off-by: mvashishtha <mahesh@ponder.io> | https://github.com/modin-project/modin.git | def get_path(cls, file_path):
if isinstance(file_path, str) and S3_ADDRESS_REGEX.search(file_path):
return file_path
else:
return os.path.abspath(file_path)
| 36 | file_dispatcher.py | Python | modin/core/io/file_dispatcher.py | c4e419b7b8ed52f010ac74ff5db9e2e66adae2dc | modin | 3 | |
9,935 | 10 | 9 | 4 | 55 | 10 | 0 | 12 | 40 | Call | feat: star routing (#3900)
* feat(proto): adjust proto for star routing (#3844)
* feat(proto): adjust proto for star routing
* feat(proto): generate proto files
* feat(grpc): refactor grpclet interface (#3846)
* feat: refactor connection pool for star routing (#3872)
* feat(k8s): add more labels to k8s ... | https://github.com/jina-ai/jina.git | def Call(self, request_iterator, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
| 31 | jina_pb2_grpc.py | Python | jina/proto/jina_pb2_grpc.py | 933415bfa1f9eb89f935037014dfed816eb9815d | jina | 1 | |
46,560 | 26 | 14 | 7 | 122 | 13 | 0 | 28 | 57 | pool_import | More explicit messages for pools and exceptions (#22569) | https://github.com/apache/airflow.git | def pool_import(args):
if not os.path.exists(args.file):
raise SystemExit(f"Missing pools file {args.file}")
pools, failed = pool_import_helper(args.file)
if len(failed) > 0:
raise SystemExit(f"Failed to update pool(s): {', '.join(failed)}")
print(f"Uploaded {len(pools)} pool(s)")
| 54 | pool_command.py | Python | airflow/cli/commands/pool_command.py | 7418720ce173ca5d0c5f5197c168e43258af8cc3 | airflow | 3 | |
209,109 | 19 | 9 | 2 | 44 | 8 | 0 | 20 | 29 | calc_tcpao_traffic_key | Support TCP-MD5 and TCP-AO (#3358)
Support TCP-MD5 and TCP-AO | https://github.com/secdev/scapy.git | def calc_tcpao_traffic_key(p, alg, master_key, sisn, disn):
# type: (Packet, TCPAOAlg, bytes, int, int) -> bytes
return alg.kdf(master_key, build_context_from_packet(p, sisn, disn))
| 30 | tcpao.py | Python | scapy/contrib/tcpao.py | 20ac1d00389d0735e6d8cd1347f0a53f478144ba | scapy | 1 | |
281,462 | 24 | 10 | 37 | 220 | 15 | 0 | 63 | 126 | print_help | 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... | https://github.com/OpenBB-finance/OpenBBTerminal.git | def print_help(self):
has_account_start = "[unvl]" if self.address_type != "account" else ""
has_account_end = "[unvl]" if self.address_type != "account" else ""
has_token_start = "[unvl]" if self.address_type != "token" else ""
has_token_end = "[unvl]" if self.address_type != ... | 88 | onchain_controller.py | Python | gamestonk_terminal/cryptocurrency/onchain/onchain_controller.py | 82747072c511beb1b2672846ae2ee4aec53eb562 | OpenBBTerminal | 7 | |
278,615 | 6 | 7 | 2 | 32 | 4 | 1 | 6 | 11 | preprocess_input | Remove pylint comments.
PiperOrigin-RevId: 452353044 | https://github.com/keras-team/keras.git | def preprocess_input(x, data_format=None):
return x
@keras_export("keras.applications.efficientnet.decode_predictions") | @keras_export("keras.applications.efficientnet.decode_predictions") | 12 | efficientnet.py | Python | keras/applications/efficientnet.py | 3613c3defc39c236fb1592c4f7ba1a9cc887343a | keras | 1 |
160,873 | 50 | 11 | 17 | 181 | 17 | 0 | 78 | 258 | round | ENH: Adding __array_ufunc__ capability to MaskedArrays.
This enables any ufunc numpy operations that are called on a
MaskedArray to use the masked version of that function automatically
without needing to resort to np.ma.func() calls. | https://github.com/numpy/numpy.git | def round(self, decimals=0, out=None):
stored_out = None
if isinstance(out, MaskedArray):
stored_out = out
out = getdata(out)
result = self._data.round(decimals=decimals, out=out).view(type(self))
if result.ndim > 0:
result._mask = self._mask
... | 112 | core.py | Python | numpy/ma/core.py | 6d77c591c59b5678f14ae5af2127eebb7d2415bc | numpy | 6 | |
107,368 | 4 | 9 | 2 | 30 | 4 | 0 | 4 | 18 | minorformatter | MNT: make colorbars locators and formatters properties | https://github.com/matplotlib/matplotlib.git | def minorformatter(self):
return self._long_axis().get_minor_formatter()
| 16 | colorbar.py | Python | lib/matplotlib/colorbar.py | 6010bb43ed01c48c7c403569dd210490b236a853 | matplotlib | 1 | |
320,084 | 38 | 13 | 13 | 141 | 15 | 0 | 39 | 157 | test_basic_parse_docx | Enables some basic live testing against a tika server with actual sample documents to catch some more errors mocking won't catch | https://github.com/paperless-ngx/paperless-ngx.git | def test_basic_parse_docx(self):
test_file = self.SAMPLE_DIR / Path("sample.docx")
self.parser.parse(
test_file,
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
)
self.assertEqual(
self.parser.text,
"Th... | 81 | test_live_tika.py | Python | src/paperless_tika/tests/test_live_tika.py | 9c0c734b34881e23ffe31cfd7bc6cc1606cca400 | paperless-ngx | 1 | |
55,959 | 4 | 7 | 2 | 22 | 3 | 0 | 4 | 18 | BlockDocumentReference | Nested Block Schemas (PrefectHQ/orion#1846)
* Adds models and migration for block schema and block document references
* Adds customization to the generation of a block schema's fields
* Adds ability to reconstruct block schema fields on read
* Adds ability to reconstruct block schema when read by checksum
... | https://github.com/PrefectHQ/prefect.git | def BlockDocumentReference(self):
return self.orm.BlockDocumentReference
| 12 | interface.py | Python | src/prefect/orion/database/interface.py | a05e44c89acf0b6073ac876479be24a5e51d7754 | prefect | 1 | |
107,160 | 30 | 11 | 9 | 127 | 16 | 1 | 34 | 93 | test_constrained_layout3 | ENH: implement and use base layout_engine for more flexible layout. | https://github.com/matplotlib/matplotlib.git | def test_constrained_layout3():
fig, axs = plt.subplots(2, 2, layout="constrained")
for nn, ax in enumerate(axs.flat):
pcm = example_pcolor(ax, fontsize=24)
if nn == 3:
pad = 0.08
else:
pad = 0.02 # default
fig.colorbar(pcm, ax=ax, pad=pad)
@image... | @image_comparison(['constrained_layout4.png']) | 74 | test_constrainedlayout.py | Python | lib/matplotlib/tests/test_constrainedlayout.py | ec4dfbc3c83866f487ff0bc9c87b0d43a1c02b22 | matplotlib | 3 |
167,071 | 6 | 8 | 5 | 33 | 7 | 0 | 6 | 20 | _is_boolean | ENH: Incorproate ArrowDtype into ArrowExtensionArray (#47034) | https://github.com/pandas-dev/pandas.git | def _is_boolean(self) -> bool:
return pa.types.is_boolean(self.pyarrow_dtype)
| 19 | dtype.py | Python | pandas/core/arrays/arrow/dtype.py | f30c7d78237007c2a4ee30e78d4cdcac7caa83f6 | pandas | 1 | |
174,310 | 21 | 16 | 13 | 130 | 13 | 0 | 25 | 101 | _iter_egg_info_extras | An importlib.metadata-based backend
This is not tested at all, but passed Mypy. | https://github.com/pypa/pip.git | def _iter_egg_info_extras(self) -> Iterable[str]:
requires_txt = self._dist.read_text("requires.txt")
if requires_txt is None:
return
for line in requires_txt.splitlines():
line = line.strip()
if line.startswith("[") and line.endswith("]"):
... | 73 | importlib.py | Python | src/pip/_internal/metadata/importlib.py | 60a7ad3a276d568d056dafc38e95e0d5f6ff2c7c | pip | 5 | |
249,092 | 22 | 11 | 14 | 160 | 13 | 0 | 23 | 112 | test_limit | Use literals in place of `HTTPStatus` constants in tests (#13469) | https://github.com/matrix-org/synapse.git | def test_limit(self) -> None:
channel = self.make_request(
"GET",
self.url + "?limit=5",
access_token=self.admin_user_tok,
)
self.assertEqual(200, channel.code, msg=channel.json_body)
self.assertEqual(channel.json_body["total"], 20)
... | 98 | test_event_reports.py | Python | tests/rest/admin/test_event_reports.py | c97042f7eef3748e17c90e48a4122389a89c4735 | synapse | 1 | |
20,361 | 9 | 8 | 2 | 47 | 9 | 0 | 12 | 26 | _draw_text | 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 _draw_text(self, pos, text, font, text_fg, text_bg):
self.drawables.append((pos, text, font, text_fg, text_bg))
| 34 | img.py | Python | pipenv/patched/notpip/_vendor/pygments/formatters/img.py | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | pipenv | 1 | |
167,015 | 54 | 16 | 26 | 213 | 23 | 0 | 75 | 368 | _get_data_from_filepath | Raise `FileNotFoundError` in `read_json` if input looks like file path but file is missing (#46718)
* raise FileNotFoundError in _get_data_from_filepath()
* update tests test_read_non_existent + test_read_expands_user_home_dir
* add changelog entry in doc/source/whatsnew/v1.5.0.rst
* use pandas.io.common._com... | https://github.com/pandas-dev/pandas.git | def _get_data_from_filepath(self, filepath_or_buffer):
# if it is a string but the file does not exist, it might be a JSON string
filepath_or_buffer = stringify_path(filepath_or_buffer)
if (
not isinstance(filepath_or_buffer, str)
or is_url(filepath_or_buffer)
... | 130 | _json.py | Python | pandas/io/json/_json.py | 67045903306ac4a1cab108177e92df30d99912b4 | pandas | 9 | |
189,698 | 6 | 9 | 18 | 29 | 4 | 0 | 6 | 20 | get_lines | Improved structure of the :mod:`.mobject` module (#2476)
* group graphing and update its references
* group text and update its references
* group opengl and update its references
* group three_d and update its references
* group geometry and update (most) references
* move some chaning.py + updater fil... | https://github.com/ManimCommunity/manim.git | def get_lines(self) -> VGroup:
return VGroup(*self.lines)
| 16 | line.py | Python | manim/mobject/geometry/line.py | e040bcacd38378386749db18aeba575b93f4ebca | manim | 1 | |
107,140 | 52 | 12 | 24 | 213 | 15 | 0 | 80 | 400 | set_layout_engine | ENH: implement and use base layout_engine for more flexible layout. | https://github.com/matplotlib/matplotlib.git | def set_layout_engine(self, layout=None, **kwargs):
if layout is None:
if mpl.rcParams['figure.autolayout']:
layout = 'tight'
elif mpl.rcParams['figure.constrained_layout.use']:
layout = 'constrained'
else:
self._layout... | 117 | figure.py | Python | lib/matplotlib/figure.py | ec4dfbc3c83866f487ff0bc9c87b0d43a1c02b22 | matplotlib | 8 | |
83,021 | 23 | 11 | 12 | 157 | 16 | 0 | 26 | 89 | test_subscribe_to_stream_post_policy_admins_stream | streams: Add notifications for posting policy changes.
An explanatory note on the changes in zulip.yaml and
curl_param_value_generators is warranted here. In our automated
tests for our curl examples, the test for the API endpoint that
changes the posting permissions of a stream comes before our
existing curl test for... | https://github.com/zulip/zulip.git | def test_subscribe_to_stream_post_policy_admins_stream(self) -> None:
member = self.example_user("AARON")
stream = self.make_stream("stream1")
do_change_stream_post_policy(stream, Stream.STREAM_POST_POLICY_ADMINS, acting_user=member)
result = self.common_subscribe_to_streams(mem... | 92 | test_subs.py | Python | zerver/tests/test_subs.py | c30458e1740c7878e436037f61431884e54b349d | zulip | 1 | |
48,676 | 13 | 11 | 6 | 60 | 7 | 0 | 14 | 68 | __getattr__ | Fix infinite recursion with deepcopy on Request (#8684) | https://github.com/encode/django-rest-framework.git | def __getattr__(self, attr):
try:
_request = self.__getattribute__("_request")
return getattr(_request, attr)
except AttributeError:
return self.__getattribute__(attr)
| 35 | request.py | Python | rest_framework/request.py | d507cd851c4b1185e3dc720de9ba6a642459d738 | django-rest-framework | 2 | |
88,596 | 35 | 12 | 12 | 171 | 16 | 0 | 55 | 165 | test_file_not_found_error | ref(stacktrace_link): Add more than one code mapping in the tests (#41409)
Include more than one code mapping in the setup code. Cleaning up a bit how we tag the transactions.
This makes the PR for WOR-2395 a little easier to read. | https://github.com/getsentry/sentry.git | def test_file_not_found_error(self):
response = self.get_success_response(
self.organization.slug, self.project.slug, qs_params={"file": self.filepath}
)
assert response.data["config"] == self.expected_configurations(self.code_mapping1)
assert not response.data["sour... | 95 | test_project_stacktrace_link.py | Python | tests/sentry/api/endpoints/test_project_stacktrace_link.py | 2e0d2c856eb17a842c67d88363bed92c99578c20 | sentry | 1 | |
291,219 | 10 | 7 | 4 | 35 | 5 | 0 | 10 | 32 | state | Add type hints to template states (#82582)
* Add type hints to template states
* Undo rename
* Remove invalid mypy issue link | https://github.com/home-assistant/core.git | def state(self) -> str: # type: ignore[override]
self._collect_state()
return self._state.state
| 19 | template.py | Python | homeassistant/helpers/template.py | aa02a53ac667d08c66a536baf139993bcfe4d7d6 | core | 1 | |
249,509 | 23 | 14 | 17 | 161 | 25 | 0 | 24 | 275 | test_need_validated_email | Support enabling/disabling pushers (from MSC3881) (#13799)
Partial implementation of MSC3881 | https://github.com/matrix-org/synapse.git | def test_need_validated_email(self):
with self.assertRaises(SynapseError) as cm:
self.get_success_or_raise(
self.hs.get_pusherpool().add_or_update_pusher(
user_id=self.user_id,
access_token=self.token_id,
kind="emai... | 99 | test_email.py | Python | tests/push/test_email.py | 8ae42ab8fa3c6b52d74c24daa7ca75a478fa4fbb | synapse | 1 | |
6,454 | 37 | 17 | 12 | 211 | 21 | 0 | 49 | 133 | flatten_dict | Fix python 3 compatibility issues (#1838)
* Use time.process_time instead of time.clock for Python 3.8 compatibility.
* Import ABC from collections.abc for Python 3.10 compatibility | https://github.com/ludwig-ai/ludwig.git | def flatten_dict(d, parent_key="", sep="."):
items = []
for k, v in d.items():
new_key = parent_key + sep + k if parent_key else k
if isinstance(v, collections.abc.MutableMapping):
items.extend(flatten_dict(v, new_key, sep=sep).items())
elif isinstance(v, list):
... | 134 | data_utils.py | Python | ludwig/utils/data_utils.py | 6a63fd367b20c90206212241eed27616bf28a3b8 | ludwig | 6 | |
176,647 | 11 | 13 | 6 | 69 | 7 | 0 | 13 | 48 | is_weakly_connected | Added examples in weakly_connected.py (#5593)
* documentation
* added examples
* Update branchings.py
* Update branchings.py
* simplified | https://github.com/networkx/networkx.git | def is_weakly_connected(G):
if len(G) == 0:
raise nx.NetworkXPointlessConcept(
)
return len(list(weakly_connected_components(G))[0]) == len(G)
| 40 | weakly_connected.py | Python | networkx/algorithms/components/weakly_connected.py | 680557b4fe8a86a36288e3cf89bbc52728f496fa | networkx | 2 | |
269,957 | 14 | 14 | 8 | 75 | 9 | 0 | 17 | 65 | _is_generator_like | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _is_generator_like(data):
return (
hasattr(data, "__next__")
or hasattr(data, "next")
or isinstance(
data, (Sequence, tf.compat.v1.data.Iterator, tf.data.Iterator)
)
)
| 47 | callbacks.py | Python | keras/callbacks.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 3 | |
178,524 | 47 | 12 | 16 | 170 | 15 | 0 | 59 | 219 | onModuleSourceCode | Plugins: Slight more helpful error message in case tensorflow works | https://github.com/Nuitka/Nuitka.git | def onModuleSourceCode(self, module_name, source_code):
if module_name != "tensorflow":
return source_code
source_lines = source_code.splitlines()
found_insert = False
for i, l in enumerate(source_lines):
if l.startswith("def ") and "_running_from_pip_pa... | 95 | TensorflowPlugin.py | Python | nuitka/plugins/standard/TensorflowPlugin.py | ab7014c6457b2b65010aea41512ca75d93847c9a | Nuitka | 6 | |
297,431 | 64 | 13 | 33 | 273 | 24 | 1 | 103 | 507 | _async_update_input_state | Fix HomeKit media players when entity has duplicate sources (#83890)
fixes #83852 fixes #83698 | https://github.com/home-assistant/core.git | def _async_update_input_state(self, hk_state, new_state):
# Set active input
if not self.support_select_source or not self.sources:
return
source = new_state.attributes.get(self.source_key)
source_name = cleanup_name_for_homekit(source)
_LOGGER.debug("%s: Set... | @TYPES.register("ActivityRemote") | 159 | type_remotes.py | Python | homeassistant/components/homekit/type_remotes.py | 692a73255520997a99124e33f1b20b8c99fa40cd | core | 6 |
317,252 | 13 | 10 | 6 | 64 | 12 | 0 | 13 | 52 | async_save_entity_map | Restore accessory state into pairing using new HKC methods (#75276) | https://github.com/home-assistant/core.git | def async_save_entity_map(self) -> None:
entity_storage: EntityMapStorage = self.hass.data[ENTITY_MAP]
entity_storage.async_create_or_update_map(
self.unique_id, self.config_num, self.entity_map.serialize()
)
| 40 | connection.py | Python | homeassistant/components/homekit_controller/connection.py | b9c8d65940ec47a82332b8b1a67301da018ccadf | core | 1 | |
189,458 | 29 | 12 | 17 | 155 | 23 | 0 | 34 | 193 | _gen_line_numbers | Hide more private methods from the docs. (#2468)
* hide privs from text_mobject.py
* hide privs from tex_mobject.py
* hide privs from code_mobject.py
* hide privs from svg_mobject.py
* remove SVGPath and utils from __init__.py
* don't import string_to_numbers
* hide privs from geometry.py
* hide p... | https://github.com/ManimCommunity/manim.git | def _gen_line_numbers(self):
line_numbers_array = []
for line_no in range(0, self.code_json.__len__()):
number = str(self.line_no_from + line_no)
line_numbers_array.append(number)
line_numbers = Paragraph(
*list(line_numbers_array),
line_s... | 100 | code_mobject.py | Python | manim/mobject/svg/code_mobject.py | 902e7eb4f0147b5882a613b67467e38a1d47f01e | manim | 3 | |
310,110 | 20 | 11 | 12 | 105 | 13 | 0 | 22 | 82 | test_setup_no_systems_recognized | Get rid of name collision in iaqualink tests (#63642) | https://github.com/home-assistant/core.git | async def test_setup_no_systems_recognized(hass, config_entry):
config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.iaqualink.AqualinkClient.login",
return_value=None,
), patch(
"homeassistant.components.iaqualink.AqualinkClient.get_systems",
return_val... | 61 | test_init.py | Python | tests/components/iaqualink/test_init.py | 7520a3fd01c025a89d85ec996a8b39ff501a3eb0 | core | 1 | |
48,246 | 11 | 7 | 11 | 55 | 5 | 1 | 11 | 16 | prepare_build_cache_command | Improve caching for multi-platform images. (#23562)
This is another attempt to improve caching performance for
multi-platform images as the previous ones were undermined by a
bug in buildx multiplatform cache-to implementattion that caused
the image cache to be overwritten between platforms,
when multiple images w... | https://github.com/apache/airflow.git | def prepare_build_cache_command() -> List[str]:
return ["buildx", "build", "--builder", "airflow_cache", "--progress=tty"]
@lru_cache(maxsize=None) | @lru_cache(maxsize=None) | 22 | run_utils.py | Python | dev/breeze/src/airflow_breeze/utils/run_utils.py | 9a6baab5a271b28b6b3cbf96ffa151ac7dc79013 | airflow | 1 |
138,050 | 21 | 12 | 8 | 140 | 14 | 1 | 23 | 62 | test_strategy | [air/tune] Internal resource management 1 - Ray AIR resource manager implementation (#30777)
Prerequisite to #30016
This PR adds a new Ray AIR resource manager to replace the PlacementGroupManager of Ray Tune. Details can be found in #30016.
Specifically, this PR
- Adds the main resource manager abstractions
-... | https://github.com/ray-project/ray.git | def test_strategy(ray_start_4_cpus, strategy):
manager = FixedResourceManager()
req = ResourceRequest([{"CPU": 2}], strategy=strategy)
if strategy.startswith("STRICT_"):
with pytest.raises(RuntimeError):
manager.request_resources(req)
else:
manager.request_resources(re... | @pytest.mark.parametrize("strategy", ["STRICT_PACK", "PACK", "SPREAD", "STRICT_SPREAD"]) | 59 | test_resource_manager_fixed.py | Python | python/ray/air/tests/test_resource_manager_fixed.py | edb17fd2069844f12237c85ba6607afae536401d | ray | 2 |
20,586 | 49 | 16 | 15 | 155 | 11 | 0 | 61 | 236 | __getitem__ | 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 __getitem__(self, key):
# convert single arg keys to tuples
try:
if isinstance(key, str_type):
key = (key,)
iter(key)
except TypeError:
key = (key, key)
if len(key) > 2:
raise TypeError(
"only ... | 93 | core.py | Python | pipenv/patched/notpip/_vendor/pyparsing/core.py | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | pipenv | 5 | |
63,937 | 44 | 20 | 23 | 257 | 14 | 0 | 88 | 65 | set_payment_terms_statuses | feat: Payment Terms Status report
- calculate status at runtime for payment terms based on invoices
- invoices are used in FIFO method | https://github.com/frappe/erpnext.git | def set_payment_terms_statuses(sales_orders, invoices):
for so in sales_orders:
for inv in [x for x in invoices if x.sales_order == so.name and x.invoice_amount > 0]:
if so.payment_amount - so.paid_amount > 0:
amount = so.payment_amount - so.paid_amount
if inv.invoice_amount >= amount:
inv.invoice... | 158 | payment_terms_status_for_sales_order.py | Python | erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.py | 1bac7930834d6f688950e836c45305a62e7ecb3f | erpnext | 10 | |
177,600 | 10 | 12 | 5 | 76 | 11 | 0 | 11 | 54 | completed_annotations | feat: DEV-469: Skip queue (#1693)
* DEV-469 Skip queue project setting
* DEV-469 review fixes
* Merge migrations (DEV-469)
* Update requirements-test.txt
* Update requirements-test.txt
* Update test_exception.py
* Revert "Update test_exception.py"
This reverts commit b9c686c9bacaf298bafe3a207352cc... | https://github.com/heartexlabs/label-studio.git | def completed_annotations(self):
if self.project.skip_queue == self.project.SkipQueue.IGNORE_SKIPPED:
return self.annotations.filter(Q(ground_truth=False))
else:
return self.annotations.filter(Q_finished_annotations)
| 46 | models.py | Python | label_studio/tasks/models.py | 074af782e6f351c711f18d8ad6a05aa4f632339c | label-studio | 2 | |
291,939 | 9 | 7 | 4 | 35 | 5 | 0 | 9 | 30 | async_post_interval_update | Add Connectivity sensor to SIA (#64305)
* implemented connectivity sensor
* further cleanup off update code
* cleanup and tighter behaviour for attributes
* added seperate connectivity class to binary sensor
* callbacks and keys
* redid name and unique_id logic, non-breaking result
* using entry more... | https://github.com/home-assistant/core.git | def async_post_interval_update(self, _) -> None:
self._attr_is_on = False
self.async_write_ha_state()
| 20 | binary_sensor.py | Python | homeassistant/components/sia/binary_sensor.py | af4e37339a39badd5596e8bc9ba86d6c1994aa1b | core | 1 | |
186,372 | 32 | 17 | 9 | 130 | 18 | 0 | 38 | 191 | _verify_no_matching_http_header | Various clean-ups in certbot-apache. Use f-strings. (#9132)
* Various clean-ups in certbot-apache. Use f-strings.
* Smaller tweaks | https://github.com/certbot/certbot.git | def _verify_no_matching_http_header(self, ssl_vhost, header_substring):
header_path = self.parser.find_dir("Header", None,
start=ssl_vhost.path)
if header_path:
# "Existing Header directive for virtualhost"
pat = '(?:[ "]|^)(%s)... | 79 | configurator.py | Python | certbot-apache/certbot_apache/_internal/configurator.py | eeca208c8f57304590ac1af80b496e61021aaa45 | certbot | 4 | |
129,112 | 3 | 6 | 3 | 15 | 3 | 0 | 3 | 6 | unsquash_action | [RLlib] Issue 21109: Action unsquashing causes inf/NaN actions for unbounded action spaces. (#21110) | https://github.com/ray-project/ray.git | def unsquash_action(action, action_space_struct):
| 21 | space_utils.py | Python | rllib/utils/spaces/space_utils.py | 35af30a4461410a9031f61c6a1d5a14d84706eda | ray | 1 | |
247,426 | 7 | 7 | 8 | 24 | 3 | 0 | 7 | 21 | mark_new_data | Spread out sending device lists to remote hosts (#12132) | https://github.com/matrix-org/synapse.git | def mark_new_data(self) -> None:
self._new_data_to_send = True
| 13 | per_destination_queue.py | Python | synapse/federation/sender/per_destination_queue.py | 423cca9efe06d78aaca5f62fb74ee7e5bceebe49 | synapse | 1 | |
279,091 | 47 | 13 | 14 | 100 | 14 | 0 | 53 | 168 | _on_gcp | Adding tf.distribtue.experimental.PreemptionCheckpointHandler related util.
PiperOrigin-RevId: 456391378 | https://github.com/keras-team/keras.git | def _on_gcp():
gce_metadata_endpoint = "http://" + os.environ.get(
_GCE_METADATA_URL_ENV_VARIABLE, "metadata.google.internal"
)
try:
# Timeout in 5 seconds, in case the test environment has connectivity
# issue. There is not default timeout, which means it might block
#... | 57 | distributed_file_utils.py | Python | keras/distribute/distributed_file_utils.py | dee67880be30eb1a5c2dfc7b4e60b32cd4789fbe | keras | 2 | |
127,553 | 90 | 17 | 42 | 513 | 33 | 0 | 126 | 579 | testClusterAutoscaling | Migrate the deprecated placement_group option to PlacementGroupSchedulingStrategy (#28437)
placement_group option is deprecated, use PlacementGroupSchedulingStrategy instead. | https://github.com/ray-project/ray.git | def testClusterAutoscaling(self):
self.cluster.update_config(
{
"provider": {"head_resources": {"CPU": 4, "GPU": 0}},
}
)
self.cluster.start()
self.cluster.connect(client=True, timeout=120)
self.assertGreater(ray.cluster_resources... | 300 | test_multinode_sync.py | Python | python/ray/tune/tests/test_multinode_sync.py | 57cdbb1769a9c32972ba0ec9e7e857eeea961869 | ray | 5 | |
259,219 | 52 | 10 | 7 | 185 | 17 | 1 | 80 | 108 | test_ohe_infrequent_mixed | ENH Adds infrequent categories to OneHotEncoder (#16018)
* ENH Completely adds infrequent categories
* STY Linting
* STY Linting
* DOC Improves wording
* DOC Lint
* BUG Fixes
* CLN Address comments
* CLN Address comments
* DOC Uses math to description float min_frequency
* DOC Adds comment r... | https://github.com/scikit-learn/scikit-learn.git | def test_ohe_infrequent_mixed():
# X[:, 0] 1 and 2 are infrequent
# X[:, 1] nothing is infrequent
X = np.c_[[0, 1, 3, 3, 3, 3, 2, 0, 3], [0, 0, 0, 0, 1, 1, 1, 1, 1]]
ohe = OneHotEncoder(max_categories=3, drop="if_binary", sparse=False)
ohe.fit(X)
X_test = [[3, 0], [1, 1]]
X_trans = o... | @pytest.mark.filterwarnings("ignore::FutureWarning:sklearn") | 122 | test_encoders.py | Python | sklearn/preprocessing/tests/test_encoders.py | 7f0006c8aad1a09621ad19c3db19c3ff0555a183 | scikit-learn | 1 |
192,152 | 86 | 14 | 19 | 350 | 40 | 0 | 115 | 215 | store_model_weights | Implement is_qat in TorchVision (#5299)
* Add is_qat support using a method getter
* Switch to an internal _fuse_modules
* Fix linter.
* Pass is_qat=False on PTQ
* Fix bug on ra_sampler flag.
* Set is_qat=True for QAT | https://github.com/pytorch/vision.git | def store_model_weights(model, checkpoint_path, checkpoint_key="model", strict=True):
# Store the new model next to the checkpoint_path
checkpoint_path = os.path.abspath(checkpoint_path)
output_dir = os.path.dirname(checkpoint_path)
# Deep copy to avoid side-effects on the model object.
model ... | 211 | utils.py | Python | references/classification/utils.py | 8a16e12f3a7f10d124b26aeb7975cd2bf4a81695 | vision | 3 | |
198,088 | 15 | 11 | 5 | 53 | 6 | 0 | 17 | 37 | _imaginary_unit_as_coefficient | add fast path for as_coefficient for imaginary unit | https://github.com/sympy/sympy.git | def _imaginary_unit_as_coefficient(arg):
if getattr(arg, 'is_real', True):
return None
else:
return arg.as_coefficient(S.ImaginaryUnit)
###############################################################################
########################## TRIGONOMETRIC FUNCTIONS #######################... | 29 | trigonometric.py | Python | sympy/functions/elementary/trigonometric.py | 91dac5cfd79ca65e7bcffd4af710efea8f7408d1 | sympy | 2 | |
21,829 | 8 | 7 | 5 | 25 | 4 | 0 | 8 | 22 | is_kv_sep | Update tomlkit==0.9.2
Used:
python -m invoke vendoring.update --package=tomlkit | https://github.com/pypa/pipenv.git | def is_kv_sep(self) -> bool:
return self in self.KV
| 14 | toml_char.py | Python | pipenv/vendor/tomlkit/toml_char.py | 8faa74cdc9da20cfdcc69f5ec29b91112c95b4c9 | pipenv | 1 | |
27,992 | 16 | 12 | 6 | 69 | 5 | 0 | 18 | 68 | preprocess_GIF | Better media thumbnails including WebP support (#9988)
* Add thumbnail app
* Update get_thumbnail_size method and add tests
* Add logic for creating thumbnails
* Update logic for getting thumbnail
* Allow defining format for tumbnail generation
* Clear handle_thumbnail views
* Add prepare_image_proxy... | https://github.com/saleor/saleor.git | def preprocess_GIF(self, image):
if "transparency" in image.info:
save_kwargs = {"transparency": image.info["transparency"]}
else:
save_kwargs = {}
return (image, save_kwargs)
| 39 | utils.py | Python | saleor/thumbnail/utils.py | 5d1a36b9aaf408016957db04f86397b2e53c2500 | saleor | 2 | |
186,359 | 37 | 12 | 13 | 154 | 15 | 0 | 48 | 170 | _get_vhost_names | Various clean-ups in certbot-apache. Use f-strings. (#9132)
* Various clean-ups in certbot-apache. Use f-strings.
* Smaller tweaks | https://github.com/certbot/certbot.git | def _get_vhost_names(self, path):
servername_match = self.parser.find_dir(
"ServerName", None, start=path, exclude=False)
serveralias_match = self.parser.find_dir(
"ServerAlias", None, start=path, exclude=False)
serveraliases = []
for alias in serverali... | 97 | configurator.py | Python | certbot-apache/certbot_apache/_internal/configurator.py | eeca208c8f57304590ac1af80b496e61021aaa45 | certbot | 3 | |
133,655 | 16 | 9 | 5 | 64 | 7 | 0 | 21 | 56 | forward | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | https://github.com/ray-project/ray.git | def forward(self, x, sample_theta=False):
x = self._check_inputs(x)
theta = self.sample_theta() if sample_theta else self.theta
scores = x @ theta
return scores
| 40 | bandit_torch_model.py | Python | rllib/agents/bandit/bandit_torch_model.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 2 | |
108,793 | 11 | 11 | 5 | 71 | 9 | 0 | 13 | 64 | disconnect | Support multi-figure MultiCursor; prepare improving its signature.
Support MultiCursor with Axes spread over different figures.
As a consequence, the first parameter of MultiCursor (`canvas`) has
become meaningless (requiring the user to pass in
`[ax.figure.canvas for ax in axes]` seems pointless); just ignore that
a... | https://github.com/matplotlib/matplotlib.git | def disconnect(self):
for canvas, info in self._canvas_infos.items():
for cid in info["cids"]:
canvas.mpl_disconnect(cid)
info["cids"].clear()
| 41 | widgets.py | Python | lib/matplotlib/widgets.py | c978fac5c540da07b573fd677bc90224bdbac48f | matplotlib | 3 | |
30,925 | 33 | 13 | 10 | 158 | 13 | 0 | 55 | 101 | get_tree_starting_at | Clean imports to fix test_fetcher (#17531)
* Clean imports to fix test_fetcher
* Add dependencies printer
* Update utils/tests_fetcher.py
Co-authored-by: lewtun <lewis.c.tunstall@gmail.com>
* Fix Perceiver import
Co-authored-by: lewtun <lewis.c.tunstall@gmail.com> | https://github.com/huggingface/transformers.git | def get_tree_starting_at(module, edges):
vertices_seen = [module]
new_edges = [edge for edge in edges if edge[0] == module and edge[1] != module]
tree = [module]
while len(new_edges) > 0:
tree.append(new_edges)
final_vertices = list(set(edge[1] for edge in new_edges))
vertic... | 103 | tests_fetcher.py | Python | utils/tests_fetcher.py | c4e58cd8bac8f68a1dca0e2e5a2d167111f6a652 | transformers | 9 | |
101,381 | 23 | 12 | 15 | 143 | 17 | 0 | 36 | 92 | _get_io_sizes | Bugfix: convert - Gif Writer
- Fix non-launch error on Gif Writer
- convert plugins - linting
- convert/fs_media/preview/queue_manager - typing
- Change convert items from dict to Dataclass | https://github.com/deepfakes/faceswap.git | def _get_io_sizes(self) -> Dict[str, int]:
input_shape = self._model.model.input_shape
input_shape = [input_shape] if not isinstance(input_shape, list) else input_shape
output_shape = self._model.model.output_shape
output_shape = [output_shape] if not isinstance(output_shape, li... | 94 | convert.py | Python | scripts/convert.py | 1022651eb8a7741014f5d2ec7cbfe882120dfa5f | faceswap | 3 | |
294,874 | 21 | 12 | 8 | 79 | 11 | 0 | 22 | 94 | update_zones | Add overlay options to Tado (#65886)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com> | https://github.com/home-assistant/core.git | def update_zones(self):
try:
zone_states = self.tado.getZoneStates()["zoneStates"]
except RuntimeError:
_LOGGER.error("Unable to connect to Tado while updating zones")
return
for zone in zone_states:
self.update_zone(int(zone))
| 44 | __init__.py | Python | homeassistant/components/tado/__init__.py | e76170fbfd691432e51a4e37235a5300cf741749 | core | 3 | |
100,816 | 6 | 6 | 3 | 22 | 4 | 0 | 6 | 20 | session_id | Refactoring and TravisCI to Github Actions (#1239)
* refactor training
* travis to actions | https://github.com/deepfakes/faceswap.git | def session_id(self) -> int:
return self._session_id
| 12 | model.py | Python | plugins/train/model/_base/model.py | ff6b0209dd5ad57b81b0aca570df7f39a7119bfb | faceswap | 1 | |
81,164 | 17 | 10 | 5 | 76 | 8 | 0 | 17 | 56 | get_delayed_update_fields | Delay update of artifacts and error fields until final job save (#11832)
* Delay update of artifacts until final job save
Save tracebacks from receptor module to callback object
Move receptor traceback check up to be more logical
Use new mock_me fixture to avoid DB call with me method
Update the special ru... | https://github.com/ansible/awx.git | def get_delayed_update_fields(self):
self.extra_update_fields['emitted_events'] = self.event_ct
if 'got an unexpected keyword argument' in self.extra_update_fields.get('result_traceback', ''):
self.delay_update(result_traceback=ANSIBLE_RUNNER_NEEDS_UPDATE_MESSAGE)
return sel... | 42 | callback.py | Python | awx/main/tasks/callback.py | 452744b67e02823879e722fe574984a2d760ed60 | awx | 2 | |
22,867 | 32 | 15 | 16 | 214 | 10 | 0 | 60 | 239 | search_in_toc | VoiceAssistant
This is Voice Assistant coded using Python which can do the following: -
1. Speak Text entered by User.
2. Search anything on Google.
3. Search anything on Wikipedia.
4. Read an MS Word(docx) document.
5. Read a book(PDF).
6. Can be used as a Dictator. | https://github.com/geekcomputers/Python.git | def search_in_toc(toc, key, totalpg):
for i in range(len(toc) - 1):
topic = toc[i]
if i != len(toc) - 2:
if topic[1] == key:
nexttopic = toc[i + 1]
return (topic[2], nexttopic[2])
elif topic[1].lower() == key:
next... | 143 | textRead.py | Python | VoiceAssistant/Project_Basic_struct/textRead.py | 39c49e07066b2a53e176d555af6a7bf8aabb8a9c | Python | 7 | |
122,423 | 61 | 12 | 13 | 192 | 34 | 0 | 74 | 145 | global_array_to_host_local_array | [JAX] Add RunTimeError to host_local_array_to_global_array
PiperOrigin-RevId: 485657586 | https://github.com/google/jax.git | def global_array_to_host_local_array(global_inputs, global_mesh, pspecs):
if not jax.config.jax_array:
raise RuntimeError(
"Please enable `jax_array` to use `global_array_to_host_local_array`. "
"You can use jax.config.update('jax_array', True) or set the "
"environment variable JAX_AR... | 72 | multihost_utils.py | Python | jax/experimental/multihost_utils.py | b467feb250c8920850118ebec19e6eff4634d5f9 | jax | 2 | |
101,624 | 6 | 6 | 3 | 26 | 5 | 0 | 6 | 20 | bin_names | Overhaul sort:
- Standardize image data reading and writing
- Optimize loading (just one pass required)
- Make all sort groups binnable (to greater or lesser results)
- Add sort by pitch
- Deprecate multiple options
- linting, docs + locales | https://github.com/deepfakes/faceswap.git | def bin_names(self) -> List[str]:
return self._bin_names
| 15 | sort_methods.py | Python | tools/sort/sort_methods.py | 98d01760e469fd2108eed8d0b0a1ba6297c3177c | faceswap | 1 | |
81,239 | 33 | 12 | 6 | 111 | 11 | 0 | 38 | 64 | to_host_path | Only do substitutions for container path conversions with resolved paths (#12313)
* Resolve paths as much as possible before doing replacements
* Move unused method out of main code, test symlink | https://github.com/ansible/awx.git | def to_host_path(path, private_data_dir):
if not os.path.isabs(private_data_dir):
raise RuntimeError('The private_data_dir path must be absolute')
if CONTAINER_ROOT != path and Path(CONTAINER_ROOT) not in Path(path).resolve().parents:
raise RuntimeError(f'Cannot convert path {path} unless i... | 63 | test_tasks.py | Python | awx/main/tests/unit/test_tasks.py | 4543f6935f4d2e00af20fff6a973cd4e3fa61524 | awx | 4 | |
267,795 | 31 | 12 | 7 | 93 | 11 | 0 | 38 | 95 | completions | 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 completions(self) -> t.List[str]:
completions = self.matches
continuation = '' if self.list_mode else self.continuation
if not self.preserve:
# include the existing prefix to avoid rewriting the word undergoing completion
completions = [f'{self.consumed}{com... | 47 | parsers.py | Python | test/lib/ansible_test/_internal/cli/argparsing/parsers.py | 3eb0485dd92c88cc92152d3656d94492db44b183 | ansible | 4 | |
95,947 | 26 | 14 | 13 | 173 | 13 | 0 | 53 | 176 | test_quantize_time_jitter | fix(sessions): Prevent query mutation behavior in `_prepare_query_params` (#31422)
* fix(sessions): Prevent query mutation behavior in `_prepare_query_params`
Fixes the behavior of `_prepare_query_params`
that mutates the conditions passed from the query.
* Add test that validates the change | https://github.com/getsentry/sentry.git | def test_quantize_time_jitter(self):
i = j = None
starting_key = quantize_time(self.now, 0, duration=10)
for i in range(11):
current_key = quantize_time(self.now + timedelta(seconds=i), 0, duration=10)
if current_key != starting_key:
break
... | 113 | test_snuba.py | Python | tests/sentry/utils/test_snuba.py | 51403cc4c85c9c595a3b2d0ab5c2c1c4e33a3a1e | sentry | 5 | |
105,528 | 5 | 6 | 19 | 19 | 5 | 0 | 5 | 8 | _parse_parallel_sentences | Fix: wmt datasets - fix CWMT zh subsets (#4871)
fix cwmt zh subsets | https://github.com/huggingface/datasets.git | def _parse_parallel_sentences(f1, f2, filename1, filename2):
| 178 | wmt_utils.py | Python | datasets/wmt14/wmt_utils.py | 54b532a8a2f5353fdb0207578162153f7b2da2ec | datasets | 5 | |
247,241 | 11 | 10 | 5 | 65 | 8 | 0 | 11 | 43 | test_join_local_ratelimit | Add type hints to `tests/rest/client` (#12108)
* Add type hints to `tests/rest/client`
* newsfile
* fix imports
* add `test_account.py`
* Remove one type hint in `test_report_event.py`
* change `on_create_room` to `async`
* update new functions in `test_third_party_rules.py`
* Add `test_filter.py`... | https://github.com/matrix-org/synapse.git | def test_join_local_ratelimit(self) -> None:
for _ in range(3):
self.helper.create_room_as(self.user_id)
self.helper.create_room_as(self.user_id, expect_code=429)
| 40 | test_rooms.py | Python | tests/rest/client/test_rooms.py | 2ffaf30803f93273a4d8a65c9e6c3110c8433488 | synapse | 2 | |
91,255 | 33 | 12 | 16 | 166 | 14 | 0 | 46 | 202 | _get_crash_rate_alert_metrics_aggregation_value_v2 | fix(cra-metrics): Count all users in metrics alerts (#34957)
Use conditional aggregates in order to get both the total user count and
the number of crashed users in the same snuba query.
To maintain compatibility until existing subscriptions have been
migrated, make the subscription processor able to handle both ... | https://github.com/getsentry/sentry.git | def _get_crash_rate_alert_metrics_aggregation_value_v2(self, subscription_update):
row = subscription_update["values"]["data"][0]
total_session_count = row["count"]
crash_count = row["crashed"]
if total_session_count == 0:
self.reset_trigger_counts()
met... | 96 | subscription_processor.py | Python | src/sentry/incidents/subscription_processor.py | 65f43fd4e0f1821b468547fc08136bbad9cd8446 | sentry | 4 | |
243,958 | 61 | 9 | 9 | 132 | 18 | 0 | 76 | 158 | _do_evaluate | [Fix] cannot to save the best checkpoint when the key_score is None (#7101) | https://github.com/open-mmlab/mmdetection.git | def _do_evaluate(self, runner):
if not self._should_evaluate(runner):
return
from mmdet.apis import single_gpu_test
results = single_gpu_test(runner.model, self.dataloader, show=False)
runner.log_buffer.output['eval_iter_num'] = len(self.dataloader)
key_scor... | 80 | eval_hooks.py | Python | mmdet/core/evaluation/eval_hooks.py | 82e5cce9ad550571f3a1c55c29203c09682a0079 | mmdetection | 4 | |
101,266 | 49 | 16 | 17 | 340 | 34 | 0 | 57 | 413 | _show_mesh | lib.align updates:
- alignments.py
- Add typed dicts for imported alignments
- Explicitly check for presence of thumb value in alignments dict
- linting
- detected_face.py
- Typing
- Linting
- Legacy support for pre-aligned face
- Update dependencies to new property names | https://github.com/deepfakes/faceswap.git | def _show_mesh(self, mesh_ids, face_index, detected_face, top_left):
state = "normal" if (self._tk_vars["selected_editor"].get() != "Mask" or
self._optional_annotations["mesh"]) else "hidden"
kwargs = dict(polygon=dict(fill="", width=2, outline=self._canvas.control_... | 212 | viewport.py | Python | tools/manual/faceviewer/viewport.py | 5e73437be47f2410439a3c6716de96354e6a0c94 | faceswap | 6 | |
189,920 | 3 | 9 | 2 | 31 | 5 | 0 | 3 | 17 | _update_colors | Fix :meth:`BarChart.change_bar_values` not updating when height is 0. (#2638)
* Refactor bar creation into a separate function
The function is _create_bar.
* Add insert methods for OpenGLMobject/Mobject
* Add self._update_colors, improve docs and fix bug
Create temporary bar, replace the previous location... | https://github.com/ManimCommunity/manim.git | def _update_colors(self):
self.bars.set_color_by_gradient(*self.bar_colors)
| 17 | probability.py | Python | manim/mobject/graphing/probability.py | 4cb43a2dc8d871ec8c8af0645eba5da00d3b2d4f | manim | 1 | |
125,824 | 41 | 12 | 9 | 196 | 20 | 0 | 48 | 75 | test_one_hot_encoder_with_max_categories | [AIR] Rename `limit` parameter as `max_categories` (#26977) | https://github.com/ray-project/ray.git | def test_one_hot_encoder_with_max_categories():
col_a = ["red", "green", "blue", "red"]
col_b = ["warm", "cold", "hot", "cold"]
col_c = [1, 10, 5, 10]
in_df = pd.DataFrame.from_dict({"A": col_a, "B": col_b, "C": col_c})
ds = ray.data.from_pandas(in_df)
encoder = OneHotEncoder(["B", "C"], m... | 113 | test_preprocessors.py | Python | python/ray/data/tests/test_preprocessors.py | 55988992b9814352150d253eaedcdfe73c96dc41 | ray | 1 | |
310,282 | 8 | 7 | 3 | 25 | 4 | 0 | 8 | 22 | is_on | Add siren platform to devolo Home Control (#53400)
* Rework mocking
* Add siren platform
* Rebase with dev
* React on change of default tone
* Fix linting error | https://github.com/home-assistant/core.git | def is_on(self) -> bool:
return self._value != 0
| 14 | siren.py | Python | homeassistant/components/devolo_home_control/siren.py | 144371d8437b7288288c4c421804f1fc52e500fd | core | 1 | |
244,084 | 18 | 13 | 7 | 106 | 12 | 0 | 21 | 54 | get_uncertainty | [Enhance] Take point sample related functions out of mask_point_head (#7353)
add point sample
replace function in mask_point_head | https://github.com/open-mmlab/mmdetection.git | def get_uncertainty(mask_pred, labels):
if mask_pred.shape[1] == 1:
gt_class_logits = mask_pred.clone()
else:
inds = torch.arange(mask_pred.shape[0], device=mask_pred.device)
gt_class_logits = mask_pred[inds, labels].unsqueeze(1)
return -torch.abs(gt_class_logits)
| 67 | point_sample.py | Python | mmdet/models/utils/point_sample.py | c576e5d570bf64a99e2c6817ed7b5c0084a44a55 | mmdetection | 2 | |
176,536 | 97 | 13 | 206 | 478 | 30 | 0 | 161 | 523 | draw_networkx | Change default value of arrowstyle for undirected graphs (#5514)
* Change default value of arrowstyle for undirected graphs
* Update networkx/drawing/nx_pylab.py
Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com> | https://github.com/networkx/networkx.git | def draw_networkx(G, pos=None, arrows=None, with_labels=True, **kwds):
r
import matplotlib.pyplot as plt
valid_node_kwds = (
"nodelist",
"node_size",
"node_color",
"node_shape",
"alpha",
"cmap",
"vmin",
"vmax",
"ax",
"linewidth... | 284 | nx_pylab.py | Python | networkx/drawing/nx_pylab.py | 7c6524c9e9f91d2e0ecd18389677f6f43651411d | networkx | 13 | |
126,725 | 22 | 12 | 7 | 123 | 18 | 0 | 26 | 87 | resolve_async_tasks | [Serve] Use Async Handle for DAG Execution (#27411) | https://github.com/ray-project/ray.git | async def resolve_async_tasks(self):
scanner = _PyObjScanner(source_type=asyncio.Task)
tasks = scanner.find_nodes((self.args, self.kwargs))
if len(tasks) > 0:
resolved = await asyncio.gather(*tasks)
replacement_table = dict(zip(tasks, resolved))
self... | 75 | router.py | Python | python/ray/serve/_private/router.py | efee158cecc49fbec5527e75e17faadba4fac48d | ray | 2 | |
137,985 | 22 | 15 | 14 | 115 | 18 | 0 | 23 | 145 | test_gymnasium_old_api_but_wrapped | [RLlib] gymnasium support (new `Env.reset()/step()/seed()/render()` APIs). (#28369) | https://github.com/ray-project/ray.git | def test_gymnasium_old_api_but_wrapped(self):
from gymnasium.wrappers import EnvCompatibility
register_env(
"test",
lambda env_ctx: EnvCompatibility(GymnasiumOldAPI(env_ctx)),
)
algo = (
PPOConfig()
.environment(env="test")
... | 67 | test_gym_env_apis.py | Python | rllib/tests/backward_compat/test_gym_env_apis.py | 8e680c483ce326cefc62e44f68ab1a6948b1c3d2 | ray | 1 | |
293,173 | 19 | 12 | 6 | 75 | 6 | 0 | 24 | 74 | get_suggested | Add config flow for switch.light (#67447)
* Add config flow for switch.light
* Refactor according to code review
* Setup light switch from config entry
* Improve async_resolve_entity
* Prepare for multiple steps
* Remove name and options flow from switch light
* Check type before adding description t... | https://github.com/home-assistant/core.git | def get_suggested(schema, key):
for k in schema.keys():
if k == key:
if k.description is None or "suggested_value" not in k.description:
return None
return k.description["suggested_value"]
| 45 | test_config_flow.py | Python | tests/components/switch/test_config_flow.py | 0c129145486764ca481d167ccdd97c97f775c200 | core | 5 | |
294,633 | 29 | 13 | 11 | 123 | 16 | 1 | 31 | 95 | test_form_no_route_to_host | Generic IP Camera configflow 2 (#52360)
Co-authored-by: J. Nick Koston <nick@koston.org> | https://github.com/home-assistant/core.git | async def test_form_no_route_to_host(hass, fakeimg_png, user_flow):
with patch(
"homeassistant.components.generic.config_flow.av.open",
side_effect=OSError(errno.EHOSTUNREACH, "No route to host"),
):
result2 = await hass.config_entries.flow.async_configure(
user_flow["fl... | @respx.mock | 65 | test_config_flow.py | Python | tests/components/generic/test_config_flow.py | c1a2be72fc8b76b55cfde1823c5688100e397369 | core | 1 |
101,218 | 13 | 13 | 4 | 73 | 9 | 0 | 14 | 42 | frame_has_faces | lib.align updates:
- alignments.py
- Add typed dicts for imported alignments
- Explicitly check for presence of thumb value in alignments dict
- linting
- detected_face.py
- Typing
- Linting
- Legacy support for pre-aligned face
- Update dependencies to new property names | https://github.com/deepfakes/faceswap.git | def frame_has_faces(self, frame_name):
retval = bool(self._data.get(frame_name, {}).get("faces", []))
logger.trace("'%s': %s", frame_name, retval)
return retval
| 44 | alignments.py | Python | lib/align/alignments.py | 5e73437be47f2410439a3c6716de96354e6a0c94 | faceswap | 1 | |
186,612 | 10 | 7 | 8 | 50 | 7 | 0 | 10 | 24 | parsing_hooks | Fully type certbot-nginx module (#9124)
* Work in progress
* Fix type
* Work in progress
* Work in progress
* Work in progress
* Work in progress
* Work in progress
* Oups.
* Fix typing in UnspacedList
* Fix logic
* Finish typing
* List certbot-nginx as fully typed in tox
* Fix lint... | https://github.com/certbot/certbot.git | def parsing_hooks(cls) -> Tuple[Type["Block"], Type["Sentence"], Type["Statements"]]:
return Block, Sentence, Statements
| 30 | parser_obj.py | Python | certbot-nginx/certbot_nginx/_internal/parser_obj.py | 16aad35d31a887dab157f9d4f5e0fe9218d06064 | certbot | 1 | |
247,207 | 34 | 11 | 25 | 227 | 22 | 0 | 45 | 303 | test_delete_email | Add type hints to `tests/rest/client` (#12108)
* Add type hints to `tests/rest/client`
* newsfile
* fix imports
* add `test_account.py`
* Remove one type hint in `test_report_event.py`
* change `on_create_room` to `async`
* update new functions in `test_third_party_rules.py`
* Add `test_filter.py`... | https://github.com/matrix-org/synapse.git | def test_delete_email(self) -> None:
# Add a threepid
self.get_success(
self.store.user_add_threepid(
user_id=self.user_id,
medium="email",
address=self.email,
validated_at=0,
added_at=0,
)
... | 142 | test_account.py | Python | tests/rest/client/test_account.py | 2ffaf30803f93273a4d8a65c9e6c3110c8433488 | synapse | 1 | |
261,904 | 77 | 18 | 26 | 344 | 23 | 0 | 112 | 298 | split_dataset | Fix the bug in split dataset function (#1251)
* Fix the bug in split_dataset
* Make eval_split_size configurable
* Change test_loader to use load_tts_samples function
* Change eval_split_portion to eval_split_size and permits to set the absolute number of samples in eval
* Fix samplers unit test
* Add d... | https://github.com/coqui-ai/TTS.git | def split_dataset(items, eval_split_max_size=None, eval_split_size=0.01):
speakers = [item["speaker_name"] for item in items]
is_multi_speaker = len(set(speakers)) > 1
if eval_split_size > 1:
eval_split_size = int(eval_split_size)
else:
if eval_split_max_size:
eval_split... | 217 | __init__.py | Python | TTS/tts/datasets/__init__.py | 28a746497560dc3f1f3415827ef38d7d9d72dbbf | TTS | 8 | |
23,119 | 44 | 14 | 23 | 287 | 29 | 0 | 63 | 340 | newShape | Code formate, Make it more standardized. Delete useless file. | https://github.com/PaddlePaddle/PaddleOCR.git | def newShape(self, value=True):
if len(self.labelHist) > 0:
self.labelDialog = LabelDialog(
parent=self, listItem=self.labelHist)
if value:
text = self.labelDialog.popUp(text=self.prevLabelText)
self.lastLabel = text
else:
... | 174 | PPOCRLabel.py | Python | PPOCRLabel/PPOCRLabel.py | 5fbe11905fa37407f6436200a6dacf46faf7138c | PaddleOCR | 5 | |
288,708 | 5 | 8 | 2 | 41 | 7 | 1 | 5 | 10 | mock_api_get_fixture | Move AirNow test fixtures to `conftest.py` (#79902)
* Move AirNow test fixtures to `conftest.py`
* Unnecessary fixture
* Better
* Linting | https://github.com/home-assistant/core.git | def mock_api_get_fixture(data):
return AsyncMock(return_value=data)
@pytest.fixture(name="setup_airnow") | @pytest.fixture(name="setup_airnow") | 13 | conftest.py | Python | tests/components/airnow/conftest.py | 8471a71b60de3fa5974a8871e359ace96ade82f3 | core | 1 |
111,793 | 12 | 9 | 4 | 53 | 9 | 0 | 13 | 45 | _resample | Lightning implementation for retiarii oneshot nas (#4479) | https://github.com/microsoft/nni.git | def _resample(self):
result = self.controller.resample()
for name, module in self.nas_modules:
module.sampled = result[name]
| 32 | sampling.py | Python | nni/retiarii/oneshot/pytorch/sampling.py | 8b2eb425274cdb4537fbce4a315aec12a378d6db | nni | 2 | |
127,998 | 112 | 23 | 60 | 465 | 43 | 0 | 186 | 1,257 | to_dict | [AIR] Maintain checkpoint type information during serialization (#28387)
These changes are needed to fix the errors described in #28134.
Signed-off-by: Balaji Veeramani <bveeramani@berkeley.edu>
Co-authored-by: Amog Kamsetty <amogkam@users.noreply.github.com> | https://github.com/ray-project/ray.git | def to_dict(self) -> dict:
if self._data_dict:
# If the checkpoint data is already a dict, return
checkpoint_data = self._data_dict
elif self._obj_ref:
# If the checkpoint data is an object reference, resolve
checkpoint_data = ray.get(self._obj_re... | 280 | checkpoint.py | Python | python/ray/air/checkpoint.py | 5034544d5df5d7d9596b261d7bdffdd28e76fe2b | ray | 13 | |
31,031 | 7 | 7 | 4 | 38 | 5 | 0 | 9 | 37 | as_target_processor | M-CTC-T Model (#16402)
* added cbs to notebooks, made copy-paste error fix in generation_utils
* initial push for mctc model
* mctc feature extractor done
* added processor, tokenizer and their tests for MCTC. Have added an MCTC modeling test, adjusting model code accordingly.
* added processor, tokenizer ... | https://github.com/huggingface/transformers.git | def as_target_processor(self):
self.current_processor = self.tokenizer
yield
self.current_processor = self.feature_extractor
| 21 | processing_mctct.py | Python | src/transformers/models/mctct/processing_mctct.py | 119e3c0fc83db5803d20d0749eef1220f27cfdc8 | transformers | 1 | |
88,586 | 27 | 12 | 10 | 200 | 26 | 0 | 35 | 113 | test_get_replays_activity_field | bug(replays): Add activity to valid field set (#41388)
closes: https://github.com/getsentry/replay-backend/issues/204 | https://github.com/getsentry/sentry.git | def test_get_replays_activity_field(self):
project = self.create_project(teams=[self.team])
replay1_id = uuid.uuid4().hex
seq1_timestamp = datetime.datetime.now() - datetime.timedelta(seconds=22)
seq2_timestamp = datetime.datetime.now() - datetime.timedelta(seconds=5)
s... | 123 | test_organization_replay_index.py | Python | tests/sentry/replays/test_organization_replay_index.py | 212f58bf21b08b9c8bb8b231307f1790591cfaf9 | sentry | 1 | |
250,121 | 7 | 8 | 6 | 36 | 3 | 0 | 7 | 21 | test_request_from_getPeer | Require types in tests.storage. (#14646)
Adds missing type hints to `tests.storage` package
and does not allow untyped definitions. | https://github.com/matrix-org/synapse.git | def test_request_from_getPeer(self) -> None:
self._runtest({}, "127.0.0.1", {})
| 20 | test_client_ips.py | Python | tests/storage/test_client_ips.py | 3ac412b4e2f8c5ba11dc962b8a9d871c1efdce9b | synapse | 1 | |
68,832 | 27 | 12 | 7 | 105 | 12 | 0 | 32 | 25 | is_negative_with_precision | fix: Respect system precision for user facing balance qty values (#30837)
* fix: Respect system precision for user facing balance qty values
- `get_precision` -> `set_precision`
- Use system wide currency precision for `stock_value`
- Round of qty defiiciency as per user defined precision (system flt precision), ... | https://github.com/frappe/erpnext.git | def is_negative_with_precision(neg_sle, is_batch=False):
if not neg_sle:
return False
field = "cumulative_total" if is_batch else "qty_after_transaction"
precision = cint(frappe.db.get_default("float_precision")) or 2
qty_deficit = flt(neg_sle[0][field], precision)
return qty_deficit < 0 and abs(qty_deficit... | 65 | stock_ledger.py | Python | erpnext/stock/stock_ledger.py | d6078aa911a135ab7bfd99c3246c44f992225ce8 | erpnext | 5 | |
118,509 | 6 | 6 | 3 | 19 | 3 | 0 | 6 | 20 | clear | st.memo/singleton: cache-specific clear() functionality (#4184)
Gives `@st.memo` and `@st.singleton` a per-cache `clear()` function, similar to Python's [functools.lru_cache API](https://docs.python.org/3/library/functools.html#functools.lru_cache).
You can use it like this:
```python
@st.experimental_memo
def... | https://github.com/streamlit/streamlit.git | def clear(self) -> None:
raise NotImplementedError
| 10 | cache_utils.py | Python | lib/streamlit/caching/cache_utils.py | b7f417f86ed4ca12c522d8ae5c147f932ffc7d40 | streamlit | 1 | |
37,476 | 20 | 12 | 5 | 79 | 9 | 0 | 23 | 42 | require_torch_up_to_2_gpus | Update all require decorators to use skipUnless when possible (#16999) | https://github.com/huggingface/transformers.git | def require_torch_up_to_2_gpus(test_case):
if not is_torch_available():
return unittest.skip("test requires PyTorch")(test_case)
import torch
return unittest.skipUnless(torch.cuda.device_count() < 3, "test requires 0 or 1 or 2 GPUs")(test_case)
| 44 | testing_utils.py | Python | src/transformers/testing_utils.py | 57e6464ac9a31156f1c93e59107323e6ec01309e | transformers | 2 | |
30,537 | 25 | 11 | 9 | 86 | 11 | 1 | 26 | 59 | invalid_tess_config | tests: Extract some test fixtures for better clarity | https://github.com/ocrmypdf/OCRmyPDF.git | def invalid_tess_config(outdir):
cfg_file = outdir / 'test.cfg'
with cfg_file.open('w') as f:
f.write(
)
yield cfg_file
@pytest.mark.slow # This test sometimes times out in CI
@pytest.mark.parametrize('renderer', RENDERERS) | @pytest.mark.slow # This test sometimes times out in CI
@pytest.mark.parametrize('renderer', RENDERERS) | 28 | test_main.py | Python | tests/test_main.py | 5d0cc0a092f93640e1d83baaf1c738768481d208 | OCRmyPDF | 1 |
320,926 | 10 | 13 | 4 | 72 | 13 | 0 | 10 | 26 | test_message_hiding | Add a MessageInfo data class
Preparation for #7246 | https://github.com/qutebrowser/qutebrowser.git | def test_message_hiding(qtbot, view):
with qtbot.wait_signal(view._clear_timer.timeout):
view.show_message(message.MessageInfo(usertypes.MessageLevel.info, 'test'))
assert not view._messages
| 42 | test_messageview.py | Python | tests/unit/mainwindow/test_messageview.py | 5616a99eff34f7074641d1391ed77d6b4b743529 | qutebrowser | 1 | |
42,796 | 26 | 12 | 12 | 117 | 16 | 0 | 33 | 133 | test_pod_template_file_system | Use KubernetesHook to create api client in KubernetesPodOperator (#20578)
Add support for k8s hook in KPO; use it always (even when no conn id); continue to consider the core k8s settings that KPO already takes into account but emit deprecation warning about them.
KPO historically takes into account a few settings ... | https://github.com/apache/airflow.git | def test_pod_template_file_system(self):
fixture = sys.path[0] + '/tests/kubernetes/basic_pod.yaml'
k = KubernetesPodOperator(
task_id="task" + self.get_current_task_name(),
in_cluster=False,
pod_template_file=fixture,
do_xcom_push=True,
)... | 70 | test_kubernetes_pod_operator.py | Python | kubernetes_tests/test_kubernetes_pod_operator.py | 60eb9e106f5915398eafd6aa339ec710c102dc09 | airflow | 1 | |
3,894 | 24 | 12 | 11 | 93 | 18 | 0 | 24 | 63 | stream_slices | 🎉 New Source: Orb (#9985)
* V1 of source_orb connector
* add boostrap.md file
* add clause on Pagination to bootstrap.md
* add SUMMARY documentation
* add lookback_window_days connector parameter
* Add support for start_date parameter
* Add ability to transform record in order to un-nest IDs
* Ad... | https://github.com/airbytehq/airbyte.git | def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, Any]]]:
# TODO: self.authenticator should optionally pull from self._session.auth
customers_stream = Customers(authenticator=self._session.auth)
for customer in customers_stream.read_records(sync_mode=SyncMode.full_refr... | 57 | source.py | Python | airbyte-integrations/connectors/source-orb/source_orb/source.py | 1e0ac30ebdcfce55a5644bcd486044da45c93dd6 | airbyte | 2 | |
293,855 | 160 | 17 | 156 | 1,276 | 62 | 0 | 355 | 1,697 | test_delete_duplicates_non_identical | Simplify time zone setting in tests (#68330)
* Simplify timezone setting in tests
* Fix typo
* Adjust caldav tests
* Adjust input_datetime tests
* Adjust time_date tests
* Adjust tod tests
* Adjust helper tests
* Adjust recorder tests
* Adjust risco tests
* Adjust aemet tests
* Adjust flu... | https://github.com/home-assistant/core.git | def test_delete_duplicates_non_identical(caplog, tmpdir):
test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db")
dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}"
module = "tests.components.recorder.models_schema_23"
importlib.import_module(module)
old_models = sys.modules[module]
pe... | 730 | test_statistics.py | Python | tests/components/recorder/test_statistics.py | cf4033b1bc853fc70828c6128ac91cdfb1d5bdaf | core | 3 | |
308,983 | 11 | 12 | 7 | 48 | 8 | 0 | 11 | 65 | on_value_update | Handle zwave_js metadata/value updates when the unit changes (#63579)
* Handle zwave_js metadata updates when the unit changes
* Use value updated event instead of metadata updated event so we don't get an invalid state value
* update comments and formatting
* simplify
* Update tests/components/zwave_js/te... | https://github.com/home-assistant/core.git | def on_value_update(self) -> None:
self._attr_native_unit_of_measurement = (
NumericSensorDataTemplate()
.resolve_data(self.info.primary_value)
.unit_of_measurement
)
| 28 | sensor.py | Python | homeassistant/components/zwave_js/sensor.py | 9e4e43cf77a210edd046a1476ece99854763e1e8 | core | 1 | |
270,347 | 30 | 11 | 7 | 82 | 12 | 0 | 36 | 83 | _copy_weights_to_distributed_model | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _copy_weights_to_distributed_model(original_model, mode):
strategy = original_model._distribution_strategy
distributed_model = get_distributed_model(original_model, mode)
if strategy:
# Copy the weights from the original model to each of the replicated
# models.
orig_model_w... | 50 | distributed_training_utils_v1.py | Python | keras/distribute/distributed_training_utils_v1.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.