complexity int64 1 139 | fun_name stringlengths 1 80 | code stringlengths 101 62.2k | commit_id stringlengths 40 40 | ast_errors stringlengths 0 3.11k | ast_levels int64 6 36 | file_name stringlengths 5 79 | n_ast_nodes int64 17 19.2k | commit_message stringlengths 3 15.3k | d_id int64 12 121k | n_ast_errors int64 0 9 | n_whitespaces int64 4 10.8k | token_counts int64 5 3.06k | vocab_size int64 4 1.11k | id int64 20 338k | n_words int64 4 4.82k | repo stringlengths 3 22 | n_identifiers int64 2 176 | path stringlengths 7 134 | language stringclasses 1
value | nloc int64 1 413 | documentation dict | url stringlengths 31 59 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | test_task_name_consume_folder | def test_task_name_consume_folder(self):
result1 = TaskResult.objects.create(
task_id=str(uuid.uuid4()),
task_name="documents.tasks.some_task",
status=celery.states.SUCCESS,
task_args="\"('/consume/anothertest.pdf',)\"",
task_kwargs="\"{'overr... | 5b66ef0a748fd5570361a2a1ed6147e0462568d2 | 13 | test_api.py | 186 | Updates how task_args and task_kwargs are parsed, adds testing to cover everything I can think of | 117,052 | 0 | 145 | 112 | 24 | 320,067 | 27 | paperless-ngx | 29 | src/documents/tests/test_api.py | Python | 14 | {
"docstring": "\n GIVEN:\n - Attempted celery task\n - Task was created through the consume folder\n WHEN:\n - API call is made to get tasks\n THEN:\n - Returned data include the filename\n ",
"language": "en",
"n_whitespaces": 102,
"n_wor... | https://github.com/paperless-ngx/paperless-ngx.git | |
2 | _prepare_registry | def _prepare_registry(self):
# noqa
cur = self.internal_registry.cursor()
if ('models',) not in list(cur.execute("SELECT name FROM sqlite_master WHERE type='table';")):
cur.execute() # TODO: dtype_dict?
self.internal_registry.commit()
| 30877cf7ead465750763822b3c88f970c870d9dd | 11 | mlflow_integration.py | 84 | feat: add mlflow, mysql, base handlers | 25,156 | 0 | 67 | 45 | 21 | 114,339 | 22 | mindsdb | 8 | mindsdb/integrations/mlflow_handler/mlflow/mlflow_integration.py | Python | 5 | {
"docstring": " Checks that sqlite records of registered models exists, otherwise creates it. create table models (model_name text, format text, target text, url text)",
"language": "en",
"n_whitespaces": 22,
"n_words": 22,
"vocab_size": 19
} | https://github.com/mindsdb/mindsdb.git | |
1 | _get_threads | def _get_threads(self) -> MultiThread:
# TODO Check if multiple threads actually speeds anything up
save_queue = queue_manager.get_queue("convert_out")
patch_queue = queue_manager.get_queue("patch")
return MultiThread(self._converter.process, patch_queue, save_queue,
... | 1022651eb8a7741014f5d2ec7cbfe882120dfa5f | 9 | convert.py | 80 | 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 | 20,797 | 0 | 87 | 47 | 25 | 101,382 | 26 | faceswap | 12 | scripts/convert.py | Python | 11 | {
"docstring": " Get the threads for patching the converted faces onto the frames.\n\n Returns\n :class:`lib.multithreading.MultiThread`\n The threads that perform the patching of swapped faces onto the output frames\n ",
"language": "en",
"n_whitespaces": 59,
"n_words": 26,
"v... | https://github.com/deepfakes/faceswap.git | |
7 | parseline | def parseline(self, line):
line = line.strip()
if not line:
return None, None, line
elif line[0] == '?':
line = 'help ' + line[1:]
elif line[0] == '!':
if hasattr(self, 'do_shell'):
line = 'shell ' + line[1:]
else:
... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 14 | cmd.py | 211 | add python 3.10.4 for windows | 56,361 | 0 | 203 | 129 | 41 | 221,346 | 66 | XX-Net | 11 | python3.10.4/Lib/cmd.py | Python | 15 | {
"docstring": "Parse the line into a command name and a string containing\n the arguments. Returns a tuple containing (command, args, line).\n 'command' and 'args' may be None if the line couldn't be parsed.\n ",
"language": "en",
"n_whitespaces": 54,
"n_words": 32,
"vocab_size": 24
} | https://github.com/XX-net/XX-Net.git | |
5 | _get_animated_artists | def _get_animated_artists(self):
return tuple([a for ax_ in self.ax.get_figure().get_axes()
for a in ax_.get_children()
if a.get_animated() and a not in self.artists])
| 334cc617b8ed3b6b4ec6cb64ff16a040ef454149 | 14 | widgets.py | 78 | Fix z_order | 22,584 | 0 | 75 | 48 | 15 | 107,070 | 19 | matplotlib | 11 | lib/matplotlib/widgets.py | Python | 4 | {
"docstring": "\n Convenience method to get all animated artists of a figure, except\n those already present in self.artists. 'z_order' is ignored.\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 19,
"vocab_size": 19
} | https://github.com/matplotlib/matplotlib.git | |
1 | test_message | def test_message(self) -> None:
room_id = self.helper.create_room_as(
self.other_user_id, tok=self.other_access_token
)
# The user should be in the room.
self.helper.join(room_id, self.banned_user_id, tok=self.banned_access_token)
# Sending a message shoul... | 1901cb1d4a8b7d9af64493fbd336e9aa2561c20c | 12 | test_shadow_banned.py | 192 | Add type hints to `tests/rest/client` (#12084) | 71,479 | 0 | 210 | 118 | 46 | 247,069 | 53 | synapse | 24 | tests/rest/client/test_shadow_banned.py | Python | 18 | {
"docstring": "Messages from shadow-banned users don't actually get sent.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/matrix-org/synapse.git | |
7 | _get_streams | def _get_streams(self):
params = self.session.http.get(self.url, schema=validate.Schema(
re.compile(
r,
re.VERBOSE | re.DOTALL,
),
validate.none_or_all(
validate.get("json"),
validate.parse_json(),
... | 08209aecf41706dc1eb0171466d88d7fb02aefca | 20 | mediaklikk.py | 609 | plugins: refactor validation schemas
Refactor validation schemas of plugins where schemas are not defined as
class attributes or where no major changes are needed:
- Use `validate.none_or_all(...)`
- Replace `validate.transform(pattern.search)` with `pattern` and fix
schemas using `validate.regex(pattern)` where a ... | 45,798 | 0 | 698 | 367 | 88 | 187,530 | 114 | streamlink | 44 | src/streamlink/plugins/mediaklikk.py | Python | 52 | {
"docstring": "\n mtva_player_manager\\.player\\s*\\(\\s*\n document\\.getElementById\\(\\s*\"\\w+\"\\s*\\)\\s*,\\s*\n (?P<json>{.*?})\\s*\n \\)\\s*;\n ",
"language": "en",
"n_whitespaces": 104,
"n_words": 4,
"... | https://github.com/streamlink/streamlink.git | |
1 | test_upload_file_with_supplied_mimetype | def test_upload_file_with_supplied_mimetype(self) -> None:
fp = StringIO("zulip!")
fp.name = "pasted_file"
result = self.api_post(
self.example_user("hamlet"), "/api/v1/user_uploads?mimetype=image/png", {"file": fp}
)
uri = self.assert_json_success(result)["u... | a142fbff85302c5e3acb2e204eca2e9c75dbc74b | 11 | test_upload.py | 114 | tests: Refactor away result.json() calls with helpers.
Signed-off-by: Zixuan James Li <p359101898@gmail.com> | 17,798 | 0 | 82 | 62 | 19 | 84,169 | 22 | zulip | 12 | zerver/tests/test_upload.py | Python | 13 | {
"docstring": "\n When files are copied into the system clipboard and pasted for upload\n the filename may not be supplied so the extension is determined from a\n query string parameter.\n ",
"language": "en",
"n_whitespaces": 57,
"n_words": 28,
"vocab_size": 26
} | https://github.com/zulip/zulip.git | |
1 | write_graph6 | def write_graph6(G, path, nodes=None, header=True):
return write_graph6_file(G, path, nodes=nodes, header=header)
@not_implemented_for("directed")
@not_implemented_for("multigraph") | 9b63ca1a0d46a1f50bcc59eda52be02721a134db | @not_implemented_for("directed")
@not_implemented_for("multigraph") | 8 | graph6.py | 67 | Remove old Appveyor cruft (#5924)
* Remove old Appveyor cruft
* Fix Windows issue | 42,276 | 1 | 16 | 31 | 11 | 177,121 | 12 | networkx | 7 | networkx/readwrite/graph6.py | Python | 2 | {
"docstring": "Write a simple undirected graph to a path in graph6 format.\n\n Parameters\n ----------\n G : Graph (undirected)\n\n path : str\n The path naming the file to which to write the graph.\n\n nodes: list or iterable\n Nodes are labeled 0...n-1 in the order provided. If None the... | https://github.com/networkx/networkx.git |
1 | test_forked_graph_cleanup | def test_forked_graph_cleanup(self) -> None:
r
# Create the room graph
event_id_a = self.create_and_send_event(self.room_id, self.user)
event_id_b = self.create_and_send_event(self.room_id, self.user)
event_id_sf1 = self.create_and_send_event(
self.room_id, self.user... | 3ac412b4e2f8c5ba11dc962b8a9d871c1efdce9b | 11 | test_cleanup_extrems.py | 327 | Require types in tests.storage. (#14646)
Adds missing type hints to `tests.storage` package
and does not allow untyped definitions. | 73,272 | 0 | 350 | 220 | 61 | 250,105 | 105 | synapse | 19 | tests/storage/test_cleanup_extrems.py | Python | 46 | {
"docstring": "Test that extremities are correctly calculated in the presence of\n soft failed events.\n\n Tests a graph like, where time flows down the page:\n\n A B\n / \\ /\n / \\ /\n SF1 SF2\n | |\n SF3 |\n... | https://github.com/matrix-org/synapse.git | |
3 | _test_settings_get | def _test_settings_get(self, key, default=None, prefixed=None):
settings_dict = self.connection.settings_dict
val = settings_dict["TEST"].get(key, default)
if val is None and prefixed:
val = TEST_DATABASE_PREFIX + settings_dict[prefixed]
return val
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 10 | creation.py | 83 | Refs #33476 -- Reformatted code with Black. | 51,003 | 0 | 71 | 53 | 20 | 205,061 | 25 | django | 10 | django/db/backends/oracle/creation.py | Python | 6 | {
"docstring": "\n Return a value from the test settings dict, or a given default, or a\n prefixed entry from the main settings dict.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 21,
"vocab_size": 15
} | https://github.com/django/django.git | |
4 | throw | def throw(self, typ, val=None, tb=None):
if val is None:
if tb is None:
raise typ
val = typ()
if tb is not None:
val = val.with_traceback(tb)
raise val
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 10 | _collections_abc.py | 78 | add python 3.10.4 for windows | 55,605 | 0 | 104 | 49 | 16 | 219,497 | 28 | XX-Net | 6 | python3.10.4/Lib/_collections_abc.py | Python | 8 | {
"docstring": "Raise an exception in the coroutine.\n Return next yielded value or raise StopIteration.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 13,
"vocab_size": 13
} | https://github.com/XX-net/XX-Net.git | |
1 | count_non_terminated_nodes | def count_non_terminated_nodes() -> int:
provider_config = _generate_provider_config(ray_cluster_namespace="default")
kuberay_node_provider = _get_node_provider(
provider_config=provider_config, cluster_name="raycluster-autoscaler"
)
nodes = kuberay_node_provider.non_terminated_nodes({})
... | c4a259828b9cfbfb4f09059f74808893a6d20b76 | 10 | non_terminated_nodes_count.py | 73 | [kuberay] Update KubeRay operator commit, turn autoscaler RPC drain back on (#27077)
This PR:
- Updates the KubeRay operator commit used in the Ray CI autoscaling test
- Uses the RayCluster autoscaling sample config from the KubeRay repo in place of of a config from the Ray repo
- Turns the autoscaler RPC worker ... | 28,023 | 0 | 43 | 41 | 16 | 125,913 | 18 | ray | 11 | python/ray/tests/kuberay/scripts/non_terminated_nodes_count.py | Python | 10 | {
"docstring": "Get the count of non terminated nodes for the Ray cluster raycluster-autoscaler\n in namespace default.\n ",
"language": "en",
"n_whitespaces": 21,
"n_words": 15,
"vocab_size": 14
} | https://github.com/ray-project/ray.git | |
2 | all_equal | def all_equal(iterable):
g = itertools.groupby(iterable)
return next(g, True) and not next(g, False)
| 8f1ba4de582c5e5282c022a7713a56b47302cabe | 9 | util.py | 48 | Backport parser/alignment optimizations from `feature/refactor-parser` (#10952) | 24,410 | 0 | 21 | 29 | 11 | 111,439 | 12 | spaCy | 6 | spacy/util.py | Python | 3 | {
"docstring": "Return True if all the elements are equal to each other\n (or if the input is an empty sequence), False otherwise.",
"language": "en",
"n_whitespaces": 23,
"n_words": 21,
"vocab_size": 19
} | https://github.com/explosion/spaCy.git | |
1 | pagination_querystring | def pagination_querystring(context, page_number, page_key="p"):
return querystring(context, **{page_key: page_number})
@register.inclusion_tag(
"wagtailadmin/pages/listing/_pagination.html", takes_context=True
) | d10f15e55806c6944827d801cd9c2d53f5da4186 | @register.inclusion_tag(
"wagtailadmin/pages/listing/_pagination.html", takes_context=True
) | 10 | wagtailadmin_tags.py | 59 | Reformat with black | 15,657 | 1 | 19 | 24 | 12 | 71,277 | 12 | wagtail | 8 | wagtail/admin/templatetags/wagtailadmin_tags.py | Python | 2 | {
"docstring": "\n Print out a querystring with an updated page number:\n\n {% if page.has_next_page %}\n <a href=\"{% pagination_link page.next_page_number %}\">Next page</a>\n {% endif %}\n ",
"language": "en",
"n_whitespaces": 54,
"n_words": 22,
"vocab_size": 20
} | https://github.com/wagtail/wagtail.git |
3 | test_knn_imputer_keep_empty_features | def test_knn_imputer_keep_empty_features(keep_empty_features):
X = np.array([[1, np.nan, 2], [3, np.nan, np.nan]])
imputer = KNNImputer(keep_empty_features=keep_empty_features)
for method in ["fit_transform", "transform"]:
X_imputed = getattr(imputer, method)(X)
if keep_empty_features... | d8fa96c29828e3ca79ddd5d7466521ac4d95213c | 15 | test_impute.py | 168 | ENH keep features with all missing values during imputation (#24770)
Co-authored-by: Chiara Marmo <cmarmo@users.noreply.github.com>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
Co-authored-by: Vitor SRG <vitorssrg@gmail.... | 76,878 | 0 | 105 | 110 | 33 | 261,584 | 39 | scikit-learn | 13 | sklearn/impute/tests/test_impute.py | Python | 10 | {
"docstring": "Check the behaviour of `keep_empty_features` for `KNNImputer`.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/scikit-learn/scikit-learn.git | |
2 | test_batch_idx | def test_batch_idx(self) -> int:
if self.trainer is None:
return 0
return self.trainer.test_loop.epoch_loop.batch_progress.current.processed
| 8a549a550cb10189ff1db382f546a40cd1c6c5b3 | 11 | base.py | 51 | Integrate progress tracking into the progress bar (#11213) | 69,648 | 0 | 44 | 31 | 11 | 241,678 | 12 | lightning | 9 | pytorch_lightning/callbacks/progress/base.py | Python | 8 | {
"docstring": "The number of batches processed during testing.\n\n Use this to update your progress bar.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 14,
"vocab_size": 14
} | https://github.com/Lightning-AI/lightning.git | |
2 | _get_one_trial_job | def _get_one_trial_job(self):
if not self.generated_hyper_configs:
ret = {
'parameter_id': '-1_0_0',
'parameter_source': 'algorithm',
'parameters': ''
}
self.send(CommandType.NoMoreTrialJobs, nni.dump(ret))
... | 98c1a77f61900d486f46d284c49fb65675dbee6a | 11 | bohb_advisor.py | 164 | Support multiple HPO experiments in one process (#4855) | 24,770 | 0 | 217 | 95 | 26 | 112,855 | 39 | nni | 12 | nni/algorithms/hpo/bohb_advisor/bohb_advisor.py | Python | 18 | {
"docstring": "get one trial job, i.e., one hyperparameter configuration.\n\n If this function is called, Command will be sent by BOHB:\n a. If there is a parameter need to run, will return \"NewTrialJob\" with a dict:\n {\n 'parameter_id': id of new hyperparameter\n 'param... | https://github.com/microsoft/nni.git | |
2 | get_menu_item | def get_menu_item(self, order=None):
return ModelAdminMenuItem(self, order or self.get_menu_order())
| b8a9a2d319b06fc2318d68d05b5a6cdf85b5b33d | 10 | options.py | 38 | Deprecate wagtail.contrib.modeladmin.menus.SubMenu in favour of wagtail.admin.menu.Menu
The Menu class was not originally designed to accept menu items at constructor time (instead requiring them to be passed via hooks); ModelAdmin's SubMenu class patched this functionality in, and the documentation for extending admi... | 16,727 | 0 | 22 | 23 | 8 | 77,976 | 8 | wagtail | 5 | wagtail/contrib/modeladmin/options.py | Python | 2 | {
"docstring": "\n Utilised by Wagtail's 'register_menu_item' hook to create a menu item\n to access the listing view, or can be called by ModelAdminGroup\n to create a submenu\n ",
"language": "en",
"n_whitespaces": 54,
"n_words": 25,
"vocab_size": 20
} | https://github.com/wagtail/wagtail.git | |
1 | get_failure | def get_failure(self, d, exc):
deferred: Deferred[Any] = ensureDeferred(d)
self.pump()
return self.failureResultOf(deferred, exc)
| 33ebee47e4e96a2b6fdf72091769e59034dc550f | 8 | unittest.py | 56 | Remove redundant `get_success` calls in test code (#12346)
There are a bunch of places we call get_success on an immediate value, which is unnecessary. Let's rip them out, and remove the redundant functionality in get_success and friends. | 71,975 | 0 | 40 | 35 | 12 | 247,885 | 12 | synapse | 10 | tests/unittest.py | Python | 4 | {
"docstring": "\n Run a Deferred and get a Failure from it. The failure must be of the type `exc`.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 17,
"vocab_size": 16
} | https://github.com/matrix-org/synapse.git | |
4 | get_client_ip | def get_client_ip(request, additional_headers=()):
HTTP_HEADERS = (
'HTTP_X_REAL_IP',
'HTTP_X_FORWARDED_FOR',
'REMOTE_ADDR',
*additional_headers
)
for header in HTTP_HEADERS:
if header in request.META:
client_ip = request.META[header].split(',')[0]
... | a38a880e67d78eba52f19cc4c2613e9399939c2f | 16 | request.py | 128 | Refactor source IP resolution logic | 78,016 | 0 | 164 | 71 | 41 | 265,175 | 48 | netbox | 11 | netbox/utilities/request.py | Python | 18 | {
"docstring": "\n Return the client (source) IP address of the given request.\n ",
"language": "en",
"n_whitespaces": 17,
"n_words": 10,
"vocab_size": 9
} | https://github.com/netbox-community/netbox.git | |
6 | save_video_meta_data | def save_video_meta_data(self, pts_time, keyframes):
if pts_time[0] != 0:
pts_time, keyframes = self._pad_leading_frames(pts_time, keyframes)
sample_filename = next(fname for fname in self.data)
basename = sample_filename[:sample_filename.rfind("_")]
logger.debug("s... | 5e73437be47f2410439a3c6716de96354e6a0c94 | 15 | alignments.py | 353 | 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 | 20,631 | 0 | 512 | 189 | 128 | 101,210 | 194 | faceswap | 26 | lib/align/alignments.py | Python | 28 | {
"docstring": " Save video meta data to the alignments file.\n\n If the alignments file does not have an entry for every frame (e.g. if Extract Every N\n was used) then the frame is added to the alignments file with no faces, so that they video\n meta data can be stored.\n\n Parameters\n ... | https://github.com/deepfakes/faceswap.git | |
1 | unweighted_minimum_spanning_digraph | def unweighted_minimum_spanning_digraph(tree, children=iter, shapes=None, attr=None):
return edges2dot(
edge_closure(
tree, lambda node: unweighted_minimum_spanning_dict(tree, children)[node]
),
shapes,
attr,
)
##################################################... | 692adaff901dd9daf29400fdf3385130aefbfb2a | 13 | util.py | 67 | Fix some tests in Wordnet-related DocStrings | 7,568 | 0 | 72 | 44 | 26 | 42,483 | 27 | nltk | 10 | nltk/util.py | Python | 8 | {
"docstring": "\n\n Build a Minimum Spanning Tree (MST) of an unweighted graph,\n by traversing the nodes of a tree in breadth-first order,\n discarding eventual cycles.\n\n Return a representation of this MST as a string in the DOT graph language,\n which can be converted to an image by the 'dot' pro... | https://github.com/nltk/nltk.git | |
3 | _gorg | def _gorg(cls):
assert isinstance(cls, GenericMeta)
if hasattr(cls, '_gorg'):
return cls._gorg
while cls.__origin__ is not None:
cls = cls.__origin__
return cls
_PROTO_WHITELIST = ['Callable', 'Awaitable',
'Iterable', 'Iterator', 'AsyncIterable', 'AsyncIterator... | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | 9 | typing_extensions.py | 124 | 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... | 3,622 | 0 | 120 | 40 | 31 | 20,942 | 35 | pipenv | 7 | pipenv/patched/notpip/_vendor/typing_extensions.py | Python | 7 | {
"docstring": "This function exists for compatibility with old typing versions.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/pypa/pipenv.git | |
4 | lemmas | def lemmas(self, lang="eng"):
if lang == "eng":
return self._lemmas
elif self._name:
self._wordnet_corpus_reader._load_lang_data(lang)
lemmark = []
lemmy = self.lemma_names(lang)
for lem in lemmy:
temp = Lemma(
... | 75f4e2183a80904dd3a6f958072ae2d063b51fad | 17 | wordnet.py | 150 | Handle wordnet synsets that were lost in mapping | 7,561 | 0 | 299 | 94 | 32 | 42,476 | 38 | nltk | 18 | nltk/corpus/reader/wordnet.py | Python | 19 | {
"docstring": "Return all the lemma objects associated with the synset",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 8
} | https://github.com/nltk/nltk.git | |
1 | test_cross_validation | def test_cross_validation(self):
testargs = .split()
with mock.patch.dict(os.environ, {"TESTING_MOCKED_DATALOADERS": "0"}):
output = subprocess.run(
self._launch_args + testargs, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
).stdout
... | 23c0341262bd396a3ba9265614b3818d6e08a6c1 | 14 | test_examples.py | 148 | Refactor tests to use accelerate launch (#373)
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> | 121,085 | 0 | 97 | 92 | 23 | 337,588 | 25 | accelerate | 23 | tests/test_examples.py | Python | 11 | {
"docstring": "\n examples/by_feature/cross_validation.py\n --num_folds 2\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 3,
"vocab_size": 3
} | https://github.com/huggingface/accelerate.git | |
1 | parse_headers | def parse_headers(fp, _class=HTTPMessage):
headers = _read_headers(fp)
hstring = b''.join(headers).decode('iso-8859-1')
return email.parser.Parser(_class=_class).parsestr(hstring)
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 11 | client.py | 78 | add python 3.10.4 for windows | 54,906 | 0 | 23 | 46 | 10 | 217,736 | 11 | XX-Net | 13 | python3.10.4/Lib/http/client.py | Python | 4 | {
"docstring": "Parses only RFC2822 headers from a file pointer.\n\n email Parser wants to see strings rather than bytes.\n But a TextIOWrapper around self.rfile would buffer too many bytes\n from the stream, bytes which we later need to read as bytes.\n So we read the correct bytes here, as bytes, for em... | https://github.com/XX-net/XX-Net.git | |
1 | is_executable | def is_executable(path):
# This function's signature needs to be repeated
# as the first line of its docstring.
# This method is reused by the basic module,
# the repetition helps the basic module's html documentation come out right.
# http://www.sphinx-doc.org/en/master/usage/extensions/autodoc.htm... | fee90b15a25b588bfb8a9ff047e851d43e78511f | 11 | file.py | 63 | Misc typo fixes in module_utils (#76564) | 78,454 | 0 | 109 | 34 | 60 | 266,521 | 79 | ansible | 8 | lib/ansible/module_utils/common/file.py | Python | 2 | {
"docstring": "is_executable(path)\n\n is the given path executable?\n\n :arg path: The path of the file to check.\n\n Limitations:\n\n * Does not account for FSACLs.\n * Most times we really want to know \"Can the current user execute this\n file\". This function does not tell us that, only if ... | https://github.com/ansible/ansible.git | |
1 | project_group_token | def project_group_token(self, group_tokens):
# [B, num_output_groups, C] <- [B, num_group_tokens, C]
projected_group_tokens = self.mlp_inter(group_tokens)
projected_group_tokens = self.norm_post_tokens(projected_group_tokens)
return projected_group_tokens
| 6c8f4c9a938a09749ea1b19a5fa2a8dd27e99a29 | 8 | modeling_groupvit.py | 45 | Adding GroupViT Models (#17313)
* add group vit and fixed test (except slow)
* passing slow test
* addressed some comments
* fixed test
* fixed style
* fixed copy
* fixed segmentation output
* fixed test
* fixed relative path
* fixed copy
* add ignore non auto configured
* fixed docstr... | 5,800 | 0 | 54 | 26 | 14 | 31,755 | 19 | transformers | 6 | src/transformers/models/groupvit/modeling_groupvit.py | Python | 4 | {
"docstring": "\n Args:\n group_tokens (torch.Tensor): group tokens, [batch_size, num_group_tokens, channels]\n\n Returns:\n projected_group_tokens (torch.Tensor): [batch_size, num_output_groups, channels]\n ",
"language": "en",
"n_whitespaces": 58,
"n_words": 14,
"... | https://github.com/huggingface/transformers.git | |
1 | write_media_player_states | def write_media_player_states(self) -> None:
dispatcher_send(self.hass, SONOS_MEDIA_UPDATED, self.soco.uid)
| cfd763db40544c31077b46631bbdd9655581dfe9 | 9 | media.py | 36 | Refactor Sonos media metadata handling (#66840)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io> | 91,764 | 0 | 21 | 22 | 7 | 292,690 | 7 | core | 7 | homeassistant/components/sonos/media.py | Python | 3 | {
"docstring": "Send a signal to media player(s) to write new states.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | https://github.com/home-assistant/core.git | |
1 | select_option | def select_option(self, selector, value):
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
select = Select(self.selenium.find_element(By.CSS_SELECTOR, selector))
select.select_by_value(value)
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | tests.py | 79 | Refs #33476 -- Reformatted code with Black. | 50,427 | 0 | 52 | 53 | 15 | 203,524 | 17 | django | 16 | django/contrib/admin/tests.py | Python | 5 | {
"docstring": "\n Select the <OPTION> with the value `value` inside the <SELECT> widget\n identified by the CSS selector `selector`.\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 17,
"vocab_size": 14
} | https://github.com/django/django.git | |
2 | _random_choice | def _random_choice(self) -> List[int]:
retval = [random.choice(indices) for indices in self._indices]
logger.debug(retval)
return retval
| 1022651eb8a7741014f5d2ec7cbfe882120dfa5f | 9 | preview.py | 57 | 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 | 20,835 | 0 | 42 | 35 | 13 | 101,421 | 14 | faceswap | 11 | tools/preview/preview.py | Python | 5 | {
"docstring": " list: Random indices from the :attr:`_indices` group ",
"language": "en",
"n_whitespaces": 8,
"n_words": 7,
"vocab_size": 7
} | https://github.com/deepfakes/faceswap.git | |
1 | test_has_related_field_in_list_display_fk | def test_has_related_field_in_list_display_fk(self):
state = State.objects.create(name="Karnataka")
City.objects.create(state=state, name="Bangalore")
response = self.client.get(reverse("admin:admin_views_city_changelist"), {})
response.context["cl"].list_display = ["id", "name... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | tests.py | 200 | Refs #33476 -- Reformatted code with Black. | 52,071 | 0 | 81 | 114 | 18 | 207,724 | 25 | django | 16 | tests/admin_views/tests.py | Python | 8 | {
"docstring": "Joins shouldn't be performed for <FK>_id fields in list display.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/django/django.git | |
1 | exit_with_error | def exit_with_error(message, code=1, **kwargs):
kwargs.setdefault("style", "red")
app.console.print(message, **kwargs)
raise typer.Exit(code)
| c0cb1fee460c1bded9e3eb741ad7979402844bf8 | 8 | base.py | 66 | Update `set` command; allow CLI `console` object to be patched | 11,226 | 0 | 22 | 39 | 10 | 55,137 | 10 | prefect | 10 | src/prefect/cli/base.py | Python | 4 | {
"docstring": "\n Utility to print a stylized error message and exit with a non-zero code\n ",
"language": "en",
"n_whitespaces": 20,
"n_words": 13,
"vocab_size": 12
} | https://github.com/PrefectHQ/prefect.git | |
4 | trigger_tool | def trigger_tool(self, name, sender=None, canvasevent=None, data=None):
tool = self.get_tool(name)
if tool is None:
return
if sender is None:
sender = self
if isinstance(tool, backend_tools.ToolToggleBase):
self._handle_toggle(tool, canvasev... | eec341a3a5918a59b212afffc2f9285bada1f276 | 9 | backend_managers.py | 153 | Remove several unused variables | 23,434 | 0 | 145 | 101 | 35 | 109,095 | 48 | matplotlib | 18 | lib/matplotlib/backend_managers.py | Python | 12 | {
"docstring": "\n Trigger a tool and emit the ``tool_trigger_{name}`` event.\n\n Parameters\n ----------\n name : str\n Name of the tool.\n sender : object\n Object that wishes to trigger the tool.\n canvasevent : Event\n Original Canvas even... | https://github.com/matplotlib/matplotlib.git | |
7 | save_file | def save_file(self, name, file_path, file_name=None):
files_metadata = self.get_files()
if name in [x['name'] for x in files_metadata]:
raise Exception(f'File already exists: {name}')
if file_name is None:
file_name = Path(file_path).name
file_dir = Non... | 7f0d38c3925c981d015e8624662c8e0c13aa4d97 | 13 | file_controller.py | 417 | get company_id from context | 26,200 | 0 | 534 | 247 | 83 | 118,262 | 105 | mindsdb | 48 | mindsdb/interfaces/file/file_controller.py | Python | 38 | {
"docstring": " Save the file to our store\n\n Args:\n name (str): with that name file will be available in sql api\n file_name (str): file name\n file_path (str): path to the file\n\n Returns:\n int: id of 'file' record in db\n ... | https://github.com/mindsdb/mindsdb.git | |
2 | get_source_link | def get_source_link(browser):
source = []
try:
source.append(
browser.find_element(
By.XPATH, read_xpath(get_source_link.__name__, "image")
).get_attribute("src")
)
except NoSuchElementException:
source.append(
browser.find_el... | 2a157d452611d37cf50ccb7d56ff1a06e9790ecb | 17 | clarifai_util.py | 167 | PR - Fix `extract_text_from_element()`and `find_element*()` to `find_element()` (#6438)
* Updated getUserData() and find_element*
Signed-off-by: elulcao <elulcao@icloud.com>
Thanks @breuerfelix for reviewing, 🚀
People in this thread please let me know if something is not OK, IG changed a lot these days. 🤗 @her | 821 | 0 | 199 | 98 | 18 | 5,791 | 31 | InstaPy | 11 | instapy/clarifai_util.py | Python | 20 | {
"docstring": "Checks to see if a post is an image. If so, returns list with image\n source URL.\n If a NoSuchElement exception occurs, checks post for video and returns\n the source URLs\n for both the video and the video's keyframe.",
"language": "en",
"n_whitespaces": 50,
"n_words": 39,
"vocab... | https://github.com/InstaPy/InstaPy.git | |
1 | test_changelist_with_no_change_url | def test_changelist_with_no_change_url(self):
o = UnchangeableObject.objects.create()
response = self.client.get(
reverse("admin:admin_views_unchangeableobject_changelist")
)
# Check the format of the shown object -- shouldn't contain a change link
self.asser... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | tests.py | 74 | Refs #33476 -- Reformatted code with Black. | 52,142 | 0 | 103 | 42 | 29 | 207,873 | 32 | django | 12 | tests/admin_views/tests.py | Python | 8 | {
"docstring": "\n ModelAdmin.changelist_view shouldn't result in a NoReverseMatch if url\n for change_view is removed from get_urls (#20934).\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 15
} | https://github.com/django/django.git | |
1 | test_cancellation_while_waiting_for_write_lock | def test_cancellation_while_waiting_for_write_lock(self):
rwlock = ReadWriteLock()
key = "key"
# 1. A reader takes the lock and blocks.
reader_d, _, unblock_reader = self._start_blocking_reader(
rwlock, key, "read completed"
)
# 2. A writer waits fo... | 605d161d7d585847fd1bb98d14d5281daeac8e86 | 9 | test_rwlock.py | 385 | Add cancellation support to `ReadWriteLock` (#12120)
Also convert `ReadWriteLock` to use async context managers.
Signed-off-by: Sean Quah <seanq@element.io> | 71,756 | 0 | 721 | 220 | 120 | 247,581 | 293 | synapse | 25 | tests/util/test_rwlock.py | Python | 37 | {
"docstring": "Test cancellation while waiting for a write lock.\n\n Tests that cancelling a waiting writer:\n * does not cancel the reader or writer it is waiting on\n * does not cancel the next writer waiting on it\n * does not allow the next writer to acquire the lock before an earl... | https://github.com/matrix-org/synapse.git | |
1 | current_year | def current_year(context):
context["current_year"] = datetime.datetime.now().year
return context
| bbf17ea692e437cec908eae6759ffff8092fb42e | 10 | pandas_web.py | 40 | WEB: Add new footer to web (#48557) | 40,398 | 0 | 28 | 22 | 7 | 169,203 | 7 | pandas | 5 | web/pandas_web.py | Python | 3 | {
"docstring": "\n Add the current year to the context, so it can be used for the copyright\n note, or other places where it is needed.\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 23,
"vocab_size": 20
} | https://github.com/pandas-dev/pandas.git | |
10 | remove_field | def remove_field(self, model, field):
# Special-case implicit M2M tables
if field.many_to_many and field.remote_field.through._meta.auto_created:
return self.delete_model(field.remote_field.through)
# It might not actually have a column behind it
if field.db_paramete... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 13 | schema.py | 304 | Refs #33476 -- Reformatted code with Black. | 50,985 | 0 | 346 | 190 | 79 | 204,933 | 97 | django | 32 | django/db/backends/base/schema.py | Python | 21 | {
"docstring": "\n Remove a field from a model. Usually involves deleting a column,\n but for M2Ms may involve deleting a table.\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 19,
"vocab_size": 15
} | https://github.com/django/django.git | |
2 | get_characters_loss | def get_characters_loss(ops, docs, prediction, nr_char):
target_ids = numpy.vstack([doc.to_utf8_array(nr_char=nr_char) for doc in docs])
target_ids = target_ids.reshape((-1,))
target = ops.asarray(to_categorical(target_ids, n_classes=256), dtype="f")
target = target.reshape((-1, 256 * nr_char))
... | 91ccacea12a46c62ccb5e7f6de891a37cb71e184 | 12 | multi_task.py | 175 | Auto-format code with black (#10209)
* Auto-format code with black
* add black requirement to dev dependencies and pin to 22.x
* ignore black dependency for comparison with setup.cfg
Co-authored-by: explosion-bot <explosion-bot@users.noreply.github.com>
Co-authored-by: svlandeg <svlandeg@github.com> | 24,357 | 0 | 69 | 112 | 31 | 111,194 | 42 | spaCy | 22 | spacy/ml/models/multi_task.py | Python | 9 | {
"docstring": "Compute a loss based on a number of characters predicted from the docs.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 12
} | https://github.com/explosion/spaCy.git | |
1 | test_k_fold_cv | def test_k_fold_cv():
boston = load_boston()
clf = make_pipeline(
OneHotEncoder(
categorical_features='auto',
sparse=False,
minimum_fraction=0.05
),
LinearRegression()
)
cross_val_score(clf, boston.data, boston.target, cv=KFold(n_splits=1... | 388616b6247ca4ea8de4e2f340d6206aee523541 | 12 | one_hot_encoder_tests.py | 92 | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 43,446 | 0 | 89 | 60 | 19 | 181,658 | 20 | tpot | 17 | tests/one_hot_encoder_tests.py | Python | 11 | {
"docstring": "Test OneHotEncoder with categorical_features='auto'.",
"language": "en",
"n_whitespaces": 3,
"n_words": 4,
"vocab_size": 4
} | https://github.com/EpistasisLab/tpot.git | |
1 | _create_mock_app_session | def _create_mock_app_session(*args, **kwargs):
mock_id = mock.PropertyMock(
return_value="mock_id:%s" % ServerTestCase._next_session_id
)
ServerTestCase._next_session_id += 1
mock_session = mock.MagicMock(AppSession, autospec=True, *args, **kwargs)
type(mock... | 704eab3478cf69847825b23dabf15813a8ac9fa2 | 11 | server_test_case.py | 93 | Rename and refactor `Report` machinery (#4141)
This refactor renames (almost) everything related to the outdated "report" concept with more precise concepts that we use throughout our code, primarily "script run", "session", and "app". | 26,306 | 0 | 84 | 57 | 19 | 118,583 | 24 | streamlit | 15 | lib/tests/server_test_case.py | Python | 8 | {
"docstring": "Create a mock AppSession. Each mocked instance will have\n its own unique ID.",
"language": "en",
"n_whitespaces": 19,
"n_words": 13,
"vocab_size": 13
} | https://github.com/streamlit/streamlit.git | |
5 | _check_folder | def _check_folder(self) -> None:
err = None
if not self._faces_dir:
err = "ERROR: Output faces folder not provided."
elif not os.path.isdir(self._faces_dir):
logger.debug("Creating folder: '%s'", self._faces_dir)
os.makedirs(self._faces_dir)
e... | a9908b46f77dc66ac7efe7100ea0eed4b1f2b460 | 12 | jobs.py | 161 | Alignments tool - Replace 'extract-large' with 'min-size' | 20,125 | 0 | 163 | 90 | 34 | 100,667 | 48 | faceswap | 15 | tools/alignments/jobs.py | Python | 14 | {
"docstring": " Check that the faces folder doesn't pre-exist and create. ",
"language": "en",
"n_whitespaces": 10,
"n_words": 9,
"vocab_size": 9
} | https://github.com/deepfakes/faceswap.git | |
1 | stable_semver | def stable_semver():
from packaging.version import Version
return Version(__version__).base_version
| 1d82b8822120db088bfeb6c8eae7ec8df9703783 | 8 | version.py | 32 | Updated distutils.Version to packaging.Version | 62,618 | 0 | 17 | 18 | 8 | 230,977 | 8 | plotly.py | 6 | packages/python/plotly/plotly/version.py | Python | 3 | {
"docstring": "\n Get the stable portion of the semantic version string (the first three\n numbers), without any of the trailing labels\n\n '3.0.0rc11' -> '3.0.0'\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 22,
"vocab_size": 19
} | https://github.com/plotly/plotly.py.git | |
1 | test_column_feature_type_mismatch_fill | def test_column_feature_type_mismatch_fill():
cat_feat = category_feature()
bin_feat = binary_feature()
input_features = [cat_feat]
output_features = [bin_feat]
config = {"input_features": input_features, "output_features": output_features}
# Construct dataframe with int-like column repres... | 1e6dbeff57fc5065b97dd018b904b9907468676f | @pytest.mark.parametrize("format", ["file", "df"]) | 17 | test_preprocessing.py | 230 | Treat dataset columns as object dtype during first pass of handle_missing_values (#2398) | 1,273 | 1 | 140 | 125 | 56 | 7,805 | 66 | ludwig | 29 | tests/integration_tests/test_preprocessing.py | Python | 15 | {
"docstring": "Tests that we are able to fill missing values even in columns where the column dtype and desired feature\n dtype do not match.",
"language": "en",
"n_whitespaces": 25,
"n_words": 23,
"vocab_size": 22
} | https://github.com/ludwig-ai/ludwig.git |
1 | test_xsum_summarization_same_as_fairseq | def test_xsum_summarization_same_as_fairseq(self):
model = BartForConditionalGeneration.from_pretrained("facebook/bart-large-xsum").to(torch_device)
tok = self.default_tokenizer
PGE_ARTICLE =
EXPECTED_SUMMARY = (
"California's largest power company has begun shutting off e... | afe5d42d8d1d80af911ed980c2936bfe887078f6 | 12 | test_modeling_bart.py | 220 | Black preview (#17217)
* Black preview
* Fixup too!
* Fix check copies
* Use the same version as the CI
* Bump black | 6,963 | 0 | 343 | 143 | 53 | 38,308 | 61 | transformers | 33 | tests/models/bart/test_modeling_bart.py | Python | 31 | {
"docstring": " PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.",
"language": "en... | https://github.com/huggingface/transformers.git | |
2 | test_get_nodes_for_order_with_uuid_id | def test_get_nodes_for_order_with_uuid_id(order_list):
# given
global_ids = [to_global_id("Order", order.pk) for order in order_list]
# Make sure function works even if duplicated ids are provided
global_ids.append(to_global_id("Order", order_list[0].pk))
# when
orders = get_nodes(global_... | 41b87559118f560c223f83d405efe9b406701d17 | 11 | test_graphql.py | 86 | Migrate order id from int to UUID (#9324)
* Add migration to change order id from int to UUID (#9281)
* Change order token to uuid
* Migrate order id to uuid
* Fix failing tests
* Apply code review suggestions
* Fix payment migration dependencies
* Fix typo in order migration name
* Handle old ord... | 4,964 | 0 | 64 | 50 | 32 | 26,316 | 37 | saleor | 10 | saleor/graphql/core/tests/test_graphql.py | Python | 5 | {
"docstring": "Ensure that `get_nodes` returns correct nodes, when the new uuid order id\n is used.",
"language": "en",
"n_whitespaces": 16,
"n_words": 14,
"vocab_size": 14
} | https://github.com/saleor/saleor.git | |
4 | string_to_tokentype | def string_to_tokentype(s):
if isinstance(s, _TokenType):
return s
if not s:
return Token
node = Token
for item in s.split('.'):
node = getattr(node, item)
return node
# Map standard token types to short names, used in CSS class naming.
# If you add a new item, please ... | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | 10 | token.py | 841 | 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... | 3,398 | 0 | 1,759 | 45 | 205 | 20,500 | 221 | pipenv | 77 | pipenv/patched/notpip/_vendor/pygments/token.py | Python | 9 | {
"docstring": "\n Convert a string into a token type::\n\n >>> string_to_token('String.Double')\n Token.Literal.String.Double\n >>> string_to_token('Token.Literal.Number')\n Token.Literal.Number\n >>> string_to_token('')\n Token\n\n Tokens that are already tokens are r... | https://github.com/pypa/pipenv.git | |
1 | get_emp_list | def get_emp_list(sal_struct, cond, end_date, payroll_payable_account):
return frappe.db.sql(
% cond,
{
"sal_struct": tuple(sal_struct),
"from_date": end_date,
"payroll_payable_account": payroll_payable_account,
},
as_dict=True,
)
| 494bd9ef78313436f0424b918f200dab8fc7c20b | 11 | payroll_entry.py | 70 | style: format code with black | 14,375 | 0 | 9 | 45 | 17 | 66,909 | 19 | erpnext | 10 | erpnext/payroll/doctype/payroll_entry/payroll_entry.py | Python | 21 | {
"docstring": "\n\t\t\tselect\n\t\t\t\tdistinct t1.name as employee, t1.employee_name, t1.department, t1.designation\n\t\t\tfrom\n\t\t\t\t`tabEmployee` t1, `tabSalary Structure Assignment` t2\n\t\t\twhere\n\t\t\t\tt1.name = t2.employee\n\t\t\t\tand t2.docstatus = 1\n\t\t\t\tand t1.status != 'Inactive'\n\t\t%s order ... | https://github.com/frappe/erpnext.git | |
1 | match_tree_files | def match_tree_files(self, root, on_error=None, follow_links=None):
files = util.iter_tree_files(root, on_error=on_error, follow_links=follow_links)
return self.match_files(files)
# Alias `match_tree_files()` as `match_tree()`.
match_tree = match_tree_files
| 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | 9 | pathspec.py | 65 | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 29,176 | 0 | 47 | 39 | 19 | 130,251 | 20 | ray | 10 | python/ray/_private/thirdparty/pathspec/pathspec.py | Python | 3 | {
"docstring": "\n Walks the specified root path for all files and matches them to this\n path-spec.\n\n *root* (:class:`str`; or :class:`pathlib.PurePath`) is the root\n directory to search for files.\n\n *on_error* (:class:`~collections.abc.Callable` or :data:`None`)\n opti... | https://github.com/ray-project/ray.git | |
13 | cycle | def cycle(parser, token):
# Note: This returns the exact same node on each {% cycle name %} call;
# that is, the node object returned from {% cycle a b c as name %} and the
# one returned from {% cycle name %} are the exact same object. This
# shouldn't cause problems (heh), but if it does, now you... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | @register.tag | 16 | defaulttags.py | 428 | Refs #33476 -- Reformatted code with Black. | 51,453 | 1 | 661 | 247 | 155 | 206,265 | 291 | django | 20 | django/template/defaulttags.py | Python | 39 | {
"docstring": "\n Cycle among the given strings each time this tag is encountered.\n\n Within a loop, cycles among the given strings each time through\n the loop::\n\n {% for o in some_list %}\n <tr class=\"{% cycle 'row1' 'row2' %}\">\n ...\n </tr>\n {% en... | https://github.com/django/django.git |
2 | cmpfiles | def cmpfiles(a, b, common, shallow=True):
res = ([], [], [])
for x in common:
ax = os.path.join(a, x)
bx = os.path.join(b, x)
res[_cmp(ax, bx, shallow)].append(x)
return res
# Compare two files.
# Return:
# 0 for equal
# 1 for different
# 2 for funny cases (c... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 12 | filecmp.py | 115 | add python 3.10.4 for windows | 54,725 | 0 | 95 | 73 | 38 | 217,342 | 50 | XX-Net | 14 | python3.10.4/Lib/filecmp.py | Python | 7 | {
"docstring": "Compare common files in two directories.\n\n a, b -- directory names\n common -- list of file names found in both directories\n shallow -- if true, do comparison based solely on stat() information\n\n Returns a tuple of three lists:\n files that compare equal\n files that are dif... | https://github.com/XX-net/XX-Net.git | |
5 | _set_partitions | def _set_partitions(n):
p = [0]*n
q = [0]*n
nc = 1
yield nc, q
while nc != n:
m = n
while 1:
m -= 1
i = q[m]
if p[i] != 1:
break
q[m] = 0
i += 1
q[m] = i
m += 1
nc += m - n
p[... | f3b08522003f40868afb20304fc0fa5b16d13f6a | 11 | iterables.py | 191 | Cleanup documentation | 48,426 | 0 | 253 | 119 | 31 | 197,279 | 77 | sympy | 7 | sympy/utilities/iterables.py | Python | 24 | {
"docstring": "Cycle through all partions of n elements, yielding the\n current number of partitions, ``m``, and a mutable list, ``q``\n such that ``element[i]`` is in part ``q[i]`` of the partition.\n\n NOTE: ``q`` is modified in place and generally should not be changed\n between function calls.\n\n ... | https://github.com/sympy/sympy.git | |
1 | standard_b64decode | def standard_b64decode(s):
return b64decode(s)
_urlsafe_encode_translation = bytes.maketrans(b'+/', b'-_')
_urlsafe_decode_translation = bytes.maketrans(b'-_', b'+/')
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 7 | base64.py | 59 | add python 3.10.4 for windows | 56,186 | 0 | 16 | 11 | 11 | 221,074 | 12 | XX-Net | 7 | python3.10.4/Lib/base64.py | Python | 2 | {
"docstring": "Decode bytes encoded with the standard Base64 alphabet.\n\n Argument s is a bytes-like object or ASCII string to decode. The result\n is returned as a bytes object. A binascii.Error is raised if the input\n is incorrectly padded. Characters that are not in the standard alphabet\n are di... | https://github.com/XX-net/XX-Net.git | |
2 | __repr__ | def __repr__(self):
if self._other is _SENTINEL:
return "<ANY>"
return repr(self._other)
ANY = _HA_ANY()
| 3884e16b46f438e4a13bcab4fe0df3b2188de767 | 8 | common.py | 49 | Add tests.common.ANY (#84240) | 96,599 | 0 | 44 | 22 | 12 | 297,632 | 13 | core | 7 | tests/common.py | Python | 4 | {
"docstring": "Return repr() other to not show up in pytest quality diffs.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | https://github.com/home-assistant/core.git | |
3 | _set_execing_flag | def _set_execing_flag(self):
if self._execing:
raise RuntimeError("Nested set_execing_flag call")
self._execing = True
try:
yield
finally:
self._execing = False
| 2a0ec52386e6d1594aa5cfe39bef2bfb89a59416 | 10 | script_runner.py | 58 | Saner "execution control request" handling (#4383)
### Background
Currently, a `ForwardMsg` enqueued from an `st.foo()` call results in a twisty path:
1. `st.foo()` retrieves the current `ScriptRunContext` and calls its `enqueue` function
1. `ScriptRunContext.enqueue` calls the `AppSession.enqueue` callback
2.... | 26,433 | 0 | 85 | 31 | 15 | 118,799 | 17 | streamlit | 4 | lib/streamlit/script_runner.py | Python | 8 | {
"docstring": "A context for setting the ScriptRunner._execing flag.\n\n Used by _maybe_handle_execution_control_request to ensure that\n we only handle requests while we're inside an exec() call\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 23,
"vocab_size": 23
} | https://github.com/streamlit/streamlit.git | |
2 | column_sql | def column_sql(self, model, field, include_default=False):
# Get the column's type and use that as the basis of the SQL.
db_params = field.db_parameters(connection=self.connection)
column_db_type = db_params["type"]
# Check for fields that aren't actually columns (e.g. M2M).
... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 10 | schema.py | 111 | Refs #33476 -- Reformatted code with Black. | 50,974 | 0 | 238 | 70 | 52 | 204,917 | 67 | django | 12 | django/db/backends/base/schema.py | Python | 14 | {
"docstring": "\n Return the column definition for a field. The field must already have\n had set_attributes_from_name() called.\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 15
} | https://github.com/django/django.git | |
2 | _set_output | def _set_output(self):
now = datetime.now().strftime("%Y%m%d_%H%M%S")
folder_name = f"drawn_landmarks_{now}"
if self._frames.is_video:
dest_folder = os.path.dirname(self._frames.folder)
else:
dest_folder = self._frames.folder
output_folder = os.pa... | a9908b46f77dc66ac7efe7100ea0eed4b1f2b460 | 12 | jobs.py | 139 | Alignments tool - Replace 'extract-large' with 'min-size' | 20,126 | 0 | 113 | 80 | 22 | 100,668 | 28 | faceswap | 18 | tools/alignments/jobs.py | Python | 11 | {
"docstring": " Set the output folder path.\n\n If annotating a folder of frames, output will be placed in a sub folder within the frames\n folder. If annotating a video, output will be a folder next to the original video.\n\n Returns\n -------\n str\n Full path to the o... | https://github.com/deepfakes/faceswap.git | |
1 | test_gymnasium_old_api_but_wrapped | 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")
... | 8e680c483ce326cefc62e44f68ab1a6948b1c3d2 | 15 | test_gym_env_apis.py | 115 | [RLlib] gymnasium support (new `Env.reset()/step()/seed()/render()` APIs). (#28369) | 31,268 | 0 | 145 | 67 | 22 | 137,985 | 23 | ray | 18 | rllib/tests/backward_compat/test_gym_env_apis.py | Python | 14 | {
"docstring": "Tests a gymnasium Env that uses the old API, but is correctly wrapped.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 13
} | https://github.com/ray-project/ray.git | |
1 | test_stacking_classifier_base_regressor | def test_stacking_classifier_base_regressor():
X_train, X_test, y_train, y_test = train_test_split(
scale(X_iris), y_iris, stratify=y_iris, random_state=42
)
clf = StackingClassifier(estimators=[("ridge", Ridge())])
clf.fit(X_train, y_train)
clf.predict(X_test)
clf.predict_proba(X_t... | b1807ff8ead319a08294beeaae90c3f03b2bb8ac | 13 | test_stacking.py | 121 | 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> | 76,836 | 0 | 57 | 79 | 25 | 261,492 | 26 | scikit-learn | 19 | sklearn/ensemble/tests/test_stacking.py | Python | 9 | {
"docstring": "Check that a regressor can be used as the first layer in `StackingClassifier`.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 13
} | https://github.com/scikit-learn/scikit-learn.git | |
5 | error | def error(self, flow):
if (
self.not_in_timeout(self.last_trigger, self.timeout)
and flow.error is not None
and not isinstance(flow.error, HttpSyntaxException)
):
self.last_trigger = time.time()
logger.error(f"Watchdog triggered! Caus... | 8c2428c9d355ca5fbc3dd90e9820ceb1cc795837 | 22 | watchdog.py | 246 | [autofix.ci] apply automated fixes | 74,071 | 0 | 300 | 121 | 45 | 253,414 | 55 | mitmproxy | 22 | examples/contrib/webscanner_helper/watchdog.py | Python | 18 | {
"docstring": "Checks if the watchdog will be triggered.\n\n Only triggers watchdog for timeouts after last reset and if flow.error is set (shows that error is a server\n error). Ignores HttpSyntaxException Errors since this can be triggered on purpose by web application scanner.\n\n Args:\n ... | https://github.com/mitmproxy/mitmproxy.git | |
7 | device_class | def device_class(self) -> CoverDeviceClass:
if isinstance(self.node, Awning):
return CoverDeviceClass.AWNING
if isinstance(self.node, Blind):
return CoverDeviceClass.BLIND
if isinstance(self.node, GarageDoor):
return CoverDeviceClass.GARAGE
if... | 10dc38e0ec27f7bef990ee431459342f9c3c52b4 | 8 | cover.py | 148 | Adjust CoverEntity property type hints in components (#73943)
* Adjust CoverEntity property type hints in components
* Revert changes to rflink
* Revert changes to wilight | 113,101 | 0 | 158 | 96 | 19 | 314,495 | 36 | core | 17 | homeassistant/components/velux/cover.py | Python | 15 | {
"docstring": "Define this cover as either awning, blind, garage, gate, shutter or window.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | https://github.com/home-assistant/core.git | |
6 | validate_syllables | def validate_syllables(self, syllable_list):
valid_syllables = []
front = ""
vowel_pattern = re.compile("|".join(self.vowels))
for i, syllable in enumerate(syllable_list):
if syllable in punctuation:
valid_syllables.append(syllable)
co... | ea006df9885bd1e5f439cd05359d047d83276b73 | 18 | sonority_sequencing.py | 202 | Greatly improve SyllableTokenizer time performance on some edge cases
Mainly when tokenizing numbers | 7,584 | 0 | 338 | 120 | 34 | 42,516 | 55 | nltk | 17 | nltk/tokenize/sonority_sequencing.py | Python | 21 | {
"docstring": "\n Ensures each syllable has at least one vowel.\n If the following syllable doesn't have vowel, add it to the current one.\n\n :param syllable_list: Single word or token broken up into syllables.\n :type syllable_list: list(str)\n :return: Single word or token broke... | https://github.com/nltk/nltk.git | |
1 | test_check_dataframe_with_only_boolean | def test_check_dataframe_with_only_boolean():
pd = importorskip("pandas", minversion="1.0")
df = pd.DataFrame({"bool": pd.Series([True, False, True], dtype="boolean")})
array = check_array(df, dtype=None)
assert array.dtype == np.float64
assert_array_equal(array, [[True], [False], [True]])
| 8d7935827d01d95239710c9c519bb1905f46b645 | 14 | test_validation.py | 126 | ENH check_array returns numeric array w/ mixed typed dataframes (#22237)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> | 75,889 | 0 | 43 | 78 | 23 | 259,742 | 25 | scikit-learn | 13 | sklearn/utils/tests/test_validation.py | Python | 6 | {
"docstring": "Check that dataframe with boolean return a float array with dtype=None",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 10
} | https://github.com/scikit-learn/scikit-learn.git | |
5 | get_used_alternative_items | def get_used_alternative_items(purchase_order=None, work_order=None):
cond = ""
if purchase_order:
cond = "and ste.purpose = 'Send to Subcontractor' and ste.purchase_order = '{0}'".format(
purchase_order
)
elif work_order:
cond = "and ste.purpose = 'Material Transfer for Manufacture' and ste.work_order = '... | 494bd9ef78313436f0424b918f200dab8fc7c20b | 12 | stock_entry.py | 137 | style: format code with black | 14,612 | 0 | 42 | 82 | 40 | 67,755 | 64 | erpnext | 13 | erpnext/stock/doctype/stock_entry/stock_entry.py | Python | 28 | {
"docstring": " select sted.original_item, sted.uom, sted.conversion_factor,\n\t\t\tsted.item_code, sted.item_name, sted.conversion_factor,sted.stock_uom, sted.description\n\t\tfrom\n\t\t\t`tabStock Entry` ste, `tabStock Entry Detail` sted\n\t\twhere\n\t\t\tsted.parent = ste.name and ste.docstatus = 1 and sted.origi... | https://github.com/frappe/erpnext.git | |
5 | generate_schema | def generate_schema(route, viewset=None, view=None, view_function=None, patterns=None):
from django.urls import path
from drf_spectacular.generators import SchemaGenerator
from rest_framework import routers
from rest_framework.viewsets import ViewSetMixin
if viewset:
assert issubclass(... | 4319707cbd0d7783596fd4a4b7e707d55f97f629 | 14 | __init__.py | 231 | feat(apidocs): Added the framework for schema tests (#38422)
The functions shown, gives us a way to test any changes we make to SentrySchema | 17,986 | 0 | 163 | 149 | 57 | 85,409 | 74 | sentry | 30 | tests/sentry/apidocs/__init__.py | Python | 20 | {
"docstring": "\n Taken from drf_spectacular tests\n https://github.com/tfranzel/drf-spectacular/blob/590a2f7f053fbe83446aa453cb4d4a3025410609/tests/__init__.py#L64\n ",
"language": "en",
"n_whitespaces": 15,
"n_words": 5,
"vocab_size": 5
} | https://github.com/getsentry/sentry.git | |
1 | mock_4x4x4_devices | def mock_4x4x4_devices(one_device_per_chip):
return mock_devices(4, 4, 4, 'TPU v4', one_device_per_chip)
| 3f9e45e0c5b035de27b14588cd3b4cfd5f3c1f04 | 8 | mesh_utils_test.py | 31 | [mesh_utils] Support creating device meshes for hybrid networks
Also makes some NFCs to other mesh_utils code.
PiperOrigin-RevId: 442581767 | 26,800 | 0 | 11 | 19 | 8 | 120,213 | 9 | jax | 3 | tests/mesh_utils_test.py | Python | 2 | {
"docstring": "Hard-coded reproduction of jax.devices() output on 4x4x4.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/google/jax.git | |
36 | categorize_changes | def categorize_changes(args, paths, verbose_command=None): # type: (TestConfig, t.List[str], t.Optional[str]) -> ChangeDescription
mapper = PathMapper(args)
commands = {
'sanity': set(),
'units': set(),
'integration': set(),
'windows-integration': set(),
'network-i... | a06fa496d3f837cca3c437ab6e9858525633d147 | 20 | __init__.py | 1,067 | ansible-test - Code cleanup and refactoring. (#77169)
* Remove unnecessary PyCharm ignores.
* Ignore intentional undefined attribute usage.
* Add missing type hints. Fix existing type hints.
* Fix docstrings and comments.
* Use function to register completion handler.
* Pass strings to display functions.
* Fix C... | 78,529 | 0 | 1,141 | 637 | 206 | 266,714 | 412 | ansible | 55 | test/lib/ansible_test/_internal/classification/__init__.py | Python | 83 | {
"docstring": "Categorize the given list of changed paths and return a description of the changes.",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 12
} | https://github.com/ansible/ansible.git | |
1 | test_grouped_annotation_in_group_by | def test_grouped_annotation_in_group_by(self):
qs = (
Book.objects.annotate(xprice=F("price"))
.filter(rating=4.0)
.values("rating", "xprice")
.annotate(count=Count("publisher_id", distinct=True))
.values("count", "rating")
.order_... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 23 | tests.py | 168 | Refs #33476 -- Reformatted code with Black. | 49,825 | 0 | 192 | 102 | 24 | 200,902 | 28 | django | 17 | tests/aggregation/tests.py | Python | 16 | {
"docstring": "\n An annotation included in values() before an aggregate should be\n included in the group by clause.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 16,
"vocab_size": 14
} | https://github.com/django/django.git | |
7 | get_admin_log | def get_admin_log(parser, token):
tokens = token.contents.split()
if len(tokens) < 4:
raise template.TemplateSyntaxError(
"'get_admin_log' statements require two arguments"
)
if not tokens[1].isdigit():
raise template.TemplateSyntaxError(
"First argument ... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 13 | log.py | 204 | Refs #33476 -- Reformatted code with Black. | 50,415 | 0 | 240 | 124 | 46 | 203,510 | 76 | django | 14 | django/contrib/admin/templatetags/log.py | Python | 24 | {
"docstring": "\n Populate a template variable with the admin log for the given criteria.\n\n Usage::\n\n {% get_admin_log [limit] as [varname] for_user [context_var_containing_user_obj] %}\n\n Examples::\n\n {% get_admin_log 10 as admin_log for_user 23 %}\n {% get_admin_log 10 as admin... | https://github.com/django/django.git | |
3 | binned | def binned(self) -> List[List[str]]:
if not self._binned:
self._binned = self._binning()
logger.debug({f"bin_{idx}": len(bin_) for idx, bin_ in enumerate(self._binned)})
return self._binned
| 98d01760e469fd2108eed8d0b0a1ba6297c3177c | 14 | sort_methods.py | 98 | 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 | 21,024 | 0 | 62 | 58 | 18 | 101,616 | 19 | faceswap | 12 | tools/sort/sort_methods.py | Python | 7 | {
"docstring": " list: List of bins (list) containing the filenames belonging to the bin. The binning\n process is called when this property is first accessed",
"language": "en",
"n_whitespaces": 30,
"n_words": 23,
"vocab_size": 21
} | https://github.com/deepfakes/faceswap.git | |
11 | _make_estimator | def _make_estimator(self, append=True, random_state=None):
estimator = clone(self.base_estimator_)
estimator.set_params(**{p: getattr(self, p) for p in self.estimator_params})
# TODO: Remove in v1.2
# criterion "mse" and "mae" would cause warnings in every call to
# Dec... | e5736afb316038c43301d2c53ce39f9a89b64495 | 15 | _base.py | 288 | API Deprecate max_feature=`auto` for tree classes (#22476)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> | 75,735 | 0 | 347 | 175 | 62 | 259,364 | 96 | scikit-learn | 20 | sklearn/ensemble/_base.py | Python | 19 | {
"docstring": "Make and configure a copy of the `base_estimator_` attribute.\n\n Warning: This method should be used to properly instantiate new\n sub-estimators.\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 20,
"vocab_size": 20
} | https://github.com/scikit-learn/scikit-learn.git | |
14 | lattice_reference | def lattice_reference(G, niter=5, D=None, connectivity=True, seed=None):
import numpy as np
from networkx.utils import cumulative_distribution, discrete_sequence
local_conn = nx.connectivity.local_edge_connectivity
if len(G) < 4:
raise nx.NetworkXError("Graph has less than four nodes.")
... | bd56814a8e9c988fc3d12801315226f249af1419 | @py_random_state(3)
@not_implemented_for("directed")
@not_implemented_for("multigraph") | 17 | smallworld.py | 829 | Keep omega within [-1, 1] bounds (#5216)
* Adjusted calculation of small-world metric omega to be within the correct bounds
* Update docstring to reflect that there is no hard bound on omega
* add release note
* maint: rm print statements from tests.
* Update release file per comment
Co-authored-by: Dan... | 41,846 | 1 | 976 | 516 | 216 | 176,340 | 339 | networkx | 57 | networkx/algorithms/smallworld.py | Python | 50 | {
"docstring": "Latticize the given graph by swapping edges.\n\n Parameters\n ----------\n G : graph\n An undirected graph with 4 or more nodes.\n\n niter : integer (optional, default=1)\n An edge is rewired approximatively niter times.\n\n D : numpy.array (optional, default=None)\n ... | https://github.com/networkx/networkx.git |
1 | transpose_output | def transpose_output(self, X):
X = X.reshape(-1, self.num_heads, X.shape[1], X.shape[2])
X = X.transpose(0, 2, 1, 3)
return X.reshape(X.shape[0], X.shape[1], -1)
| f0be7e672bc0a7c77005d5c79452d796cfe1a06b | 10 | mxnet.py | 103 | Refactor Multihead Attn, Self Attn, and Transformer (#2096)
* multihead attn
* self attn and pos encoding
* simplify
* before EncoderBlock
* before tmencoder
* before decoder block
* before training
* transformer code
* rm seq2seq encoder old
* fix bahdanau attn map
* transformer done, pe... | 74,224 | 0 | 47 | 71 | 16 | 253,767 | 19 | d2l-en | 7 | d2l/mxnet.py | Python | 4 | {
"docstring": "Reverse the operation of transpose_qkv.\n \n Defined in :numref:`sec_multihead-attention`",
"language": "en",
"n_whitespaces": 18,
"n_words": 8,
"vocab_size": 8
} | https://github.com/d2l-ai/d2l-en.git | |
1 | test_decoder_model_past_with_large_inputs | def test_decoder_model_past_with_large_inputs(self):
config_and_inputs = self.model_tester.prepare_config_and_inputs_for_decoder()
self.model_tester.create_and_check_decoder_model_past_large_inputs(*config_and_inputs)
| 8635407bc724c45142c1f91dbc9ef3ea681e1a56 | 9 | test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py | 43 | Fix tf.concatenate + test past_key_values for TF models (#15774)
* fix wrong method name tf.concatenate
* add tests related to causal LM / decoder
* make style and quality
* clean-up
* Fix TFBertModel's extended_attention_mask when past_key_values is provided
* Fix tests
* fix copies
* More tf.int... | 6,470 | 0 | 27 | 24 | 6 | 35,527 | 6 | transformers | 6 | templates/adding_a_new_model/cookiecutter-template-{{cookiecutter.modelname}}/test_modeling_tf_{{cookiecutter.lowercase_modelname}}.py | Python | 3 | {
"docstring": "Similar to `test_causal_lm_model_past_with_large_inputs` but with cross-attention",
"language": "en",
"n_whitespaces": 5,
"n_words": 6,
"vocab_size": 6
} | https://github.com/huggingface/transformers.git | |
11 | get_dependencies_from_index | def get_dependencies_from_index(dep, sources=None, pip_options=None, wheel_cache=None):
session, finder = get_finder(sources=sources, pip_options=pip_options)
dep.is_direct = True
requirements = None
setup_requires = {}
with temp_environ(), ExitStack() as stack:
if not wheel_cache:
... | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | 16 | dependencies.py | 333 | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | 4,270 | 0 | 231 | 202 | 57 | 22,226 | 88 | pipenv | 38 | pipenv/vendor/requirementslib/models/dependencies.py | Python | 21 | {
"docstring": "Retrieves dependencies for the given install requirement from the pip\n resolver.\n\n :param dep: A single InstallRequirement\n :type dep: :class:`~pipenv.patched.pip._internal.req.req_install.InstallRequirement`\n :param sources: Pipfile-formatted sources, defaults to None\n :type sour... | https://github.com/pypa/pipenv.git | |
6 | _get_sourcefile | def _get_sourcefile(bytecode_path):
if len(bytecode_path) == 0:
return None
rest, _, extension = bytecode_path.rpartition('.')
if not rest or extension.lower()[-3:-1] != 'py':
return bytecode_path
try:
source_path = source_from_cache(bytecode_path)
except (NotImplemented... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 12 | _bootstrap_external.py | 135 | add python 3.10.4 for windows | 55,163 | 0 | 87 | 81 | 29 | 218,147 | 38 | XX-Net | 13 | python3.10.4/Lib/importlib/_bootstrap_external.py | Python | 11 | {
"docstring": "Convert a bytecode file path to a source path (if possible).\n\n This function exists purely for backwards-compatibility for\n PyImport_ExecCodeModuleWithFilenames() in the C API.\n\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 23,
"vocab_size": 20
} | https://github.com/XX-net/XX-Net.git | |
1 | reset_display_options | def reset_display_options() -> None:
pd.reset_option("^display.", silent=True)
# -----------------------------------------------------------------------------
# Comparators
| f538568afc2c76c2d738d32e3544cf9fe6742960 | 8 | __init__.py | 34 | TYP: misc return type annotations (#47558) | 40,037 | 0 | 14 | 17 | 9 | 167,566 | 10 | pandas | 4 | pandas/_testing/__init__.py | Python | 5 | {
"docstring": "\n Reset the display options for printing and representing objects.\n ",
"language": "en",
"n_whitespaces": 16,
"n_words": 9,
"vocab_size": 9
} | https://github.com/pandas-dev/pandas.git | |
1 | test_edit_save_as_delete_inline | def test_edit_save_as_delete_inline(self):
post_data = self.inline_post_data.copy()
post_data.update(
{
"_saveasnew": "Save+as+new",
"article_set-1-section": "1",
"article_set-2-section": "1",
"article_set-2-DELETE": "1... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 14 | tests.py | 176 | Refs #33476 -- Reformatted code with Black. | 52,139 | 0 | 209 | 99 | 32 | 207,868 | 38 | django | 20 | tests/admin_views/tests.py | Python | 16 | {
"docstring": "\n Should be able to \"Save as new\" while also deleting an inline.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 12
} | https://github.com/django/django.git | |
5 | _compute_fans | def _compute_fans(shape):
if len(shape) < 1: # Just to avoid errors for constants.
fan_in = fan_out = 1
elif len(shape) == 1:
fan_in = fan_out = shape[0]
elif len(shape) == 2:
fan_in = shape[0]
fan_out = shape[1]
else:
# Assuming convolution kernels (2D, 3D,... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | @test_combinations.generate(test_combinations.combine(mode=["graph", "eager"])) | 12 | initializers_test.py | 198 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,963 | 1 | 176 | 102 | 48 | 272,135 | 77 | keras | 12 | keras/initializers/initializers_test.py | Python | 15 | {
"docstring": "Computes the number of input and output units for a weight shape.\n\n Args:\n shape: Integer shape tuple or TF tensor shape.\n\n Returns:\n A tuple of integer scalars (fan_in, fan_out).\n ",
"language": "en",
"n_whitespaces": 48,
"n_words": 29,
"vocab_size": 26
} | https://github.com/keras-team/keras.git |
6 | sparse_categorical_matches | def sparse_categorical_matches(y_true, y_pred):
reshape_matches = False
y_pred = tf.convert_to_tensor(y_pred)
y_true = tf.convert_to_tensor(y_true)
y_true_org_shape = tf.shape(y_true)
y_pred_rank = y_pred.shape.ndims
y_true_rank = y_true.shape.ndims
# If the shape of y_true is (num_sam... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 13 | metrics_utils.py | 297 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81,817 | 0 | 198 | 187 | 66 | 276,986 | 98 | keras | 24 | keras/utils/metrics_utils.py | Python | 21 | {
"docstring": "Creates float Tensor, 1.0 for label-prediction match, 0.0 for mismatch.\n\n You can provide logits of classes as `y_pred`, since argmax of\n logits and probabilities are same.\n\n Args:\n y_true: Integer ground truth values.\n y_pred: The prediction values.\n\n Returns:\n Ma... | https://github.com/keras-team/keras.git | |
6 | query_yes_no | def query_yes_no(question, default="yes"):
valid = {"yes": "yes", "y": "yes", "ye": "yes", "no": "no", "n": "no"}
prompt = {None: " [y/n] ", "yes": " [Y/n] ", "no": " [y/N] "}.get(default, None)
if not prompt:
raise ValueError("invalid default answer: '%s'" % default)
reply = None
w... | 7bf15bf33644ef13e34dff63beaf8d19387219be | 13 | updateHostsFile.py | 245 | Use https in more places | 27,310 | 0 | 189 | 132 | 62 | 123,265 | 86 | hosts | 18 | updateHostsFile.py | Python | 17 | {
"docstring": "\n Ask a yes/no question via input() and get answer from the user.\n\n Inspired by the following implementation:\n\n https://code.activestate.com/recipes/577058/\n\n Parameters\n ----------\n question : str\n The question presented to the user.\n default : str, default \"ye... | https://github.com/StevenBlack/hosts.git | |
7 | wait_start_success | def wait_start_success(self) -> None:
if not self.args.noblock_on_start:
raise ValueError(
f'{self.wait_start_success!r} should only be called when `noblock_on_start` is set to True'
)
try:
if self.uses_before_pea is not None:
... | 933415bfa1f9eb89f935037014dfed816eb9815d | 13 | __init__.py | 173 | 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 ... | 1,759 | 0 | 251 | 99 | 36 | 9,892 | 49 | jina | 12 | jina/peapods/pods/__init__.py | Python | 22 | {
"docstring": "Block until all peas starts successfully.\n\n If not successful, it will raise an error hoping the outer function to catch it\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 21,
"vocab_size": 20
} | https://github.com/jina-ai/jina.git | |
40 | nD | def nD(i=None, brute=None, *, n=None, m=None):
from sympy.integrals.integrals import integrate
from sympy.functions.special.polynomials import laguerre
from sympy.abc import x | e0dc14eca132f37c5f49369eb4051eae37c9b119 | 6 | numbers.py | 67 | Refactored import ordering in functions | 48,287 | 0 | 30 | 562 | 14 | 197,011 | 18 | sympy | 14 | sympy/functions/combinatorial/numbers.py | Python | 67 | {
"docstring": "return the number of derangements for: ``n`` unique items, ``i``\n items (as a sequence or multiset), or multiplicities, ``m`` given\n as a sequence or multiset.\n\n Examples\n ========\n\n >>> from sympy.utilities.iterables import generate_derangements as enum\n >>> from sympy.funct... | https://github.com/sympy/sympy.git | |
1 | test_tf_non_distributed | def test_tf_non_distributed(ray_start_4_cpus):
trainer = TorchTrainer(
tf_quick_start_train_func, scaling_config=dict(num_workers=1)
)
trainer.fit()
# TODO: Refactor as a backend test. | b9a4f64f32389a1f76a7f74103b4d5da089ebb2b | 12 | test_examples.py | 46 | [AIR/train] Use new Train API (#25735)
Uses the new AIR Train API for examples and tests.
The `Result` object gets a new attribute - `log_dir`, pointing to the Trial's `logdir` allowing users to access tensorboard logs and artifacts of other loggers.
This PR only deals with "low hanging fruit" - tests that need ... | 27,594 | 0 | 34 | 26 | 16 | 124,395 | 16 | ray | 9 | python/ray/train/tests/test_examples.py | Python | 5 | {
"docstring": "Make sure Ray Train works without TF MultiWorkerMirroredStrategy.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/ray-project/ray.git | |
7 | load_accelerator_state | def load_accelerator_state(input_dir, models, optimizers, process_index, scaler=None):
# Model states
for i, model in enumerate(models):
weights_name = f"{MODEL_NAME}.bin" if i == 0 else f"{MODEL_NAME}_{i}.bin"
input_model_file = os.path.join(input_dir, weights_name)
models[i].load_... | fb5ed62c102c0323486b89805e1888495de3db15 | 12 | checkpointing.py | 421 | Convert documentation to the new front (#271)
* Main conversion
* Doc styling
* Style
* New front deploy
* Fixes
* Fixes
* Fix new docstrings
* Style | 121,002 | 0 | 233 | 235 | 70 | 337,288 | 109 | accelerate | 37 | src/accelerate/checkpointing.py | Python | 23 | {
"docstring": "\n Loads states of the models, optimizers, scaler, and RNG generators from a given directory.\n\n Args:\n input_dir (`str` or `os.PathLike`):\n The name of the folder to load all relevant weights and states.\n model_stmodelsates (`List[torch.nn.Module]`):\n A ... | https://github.com/huggingface/accelerate.git | |
7 | __call__ | def __call__(self, results):
if random.random() < self.shift_ratio:
img_shape = results['img'].shape[:2]
random_shift_x = random.randint(-self.max_shift_px,
self.max_shift_px)
random_shift_y = random.randint(-self.max_shif... | 86037650f243a1ab0a515a22e831ea5dcddd6a7d | 14 | transforms.py | 604 | Unified name of orig as ori (#7456) | 70,237 | 0 | 861 | 393 | 115 | 244,099 | 193 | mmdetection | 37 | mmdet/datasets/pipelines/transforms.py | Python | 38 | {
"docstring": "Call function to random shift images, bounding boxes.\n\n Args:\n results (dict): Result dict from loading pipeline.\n\n Returns:\n dict: Shift results.\n ",
"language": "en",
"n_whitespaces": 63,
"n_words": 20,
"vocab_size": 20
} | https://github.com/open-mmlab/mmdetection.git | |
10 | svd | 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... | 40747ae50620631941e43dbbd5baaccab669922f | 17 | linalg.py | 635 | clarify svd documentation
`u @ np.diag(s) @ vh` can only reproduce the original matrix when `full_matrices` is `False`, otherwise dimension does not match. | 38,474 | 0 | 658 | 399 | 116 | 160,044 | 215 | numpy | 48 | numpy/linalg/linalg.py | Python | 49 | {
"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... | https://github.com/numpy/numpy.git | |
1 | test_create_placeholder_if_not_exist_in_template | def test_create_placeholder_if_not_exist_in_template(self):
page = create_page('Test', 'col_two.html', 'en')
# I need to make it seem like the user added another placeholder to the SAME template.
page._template_cache = 'col_three.html'
request = self.get_request(page=page)
... | c1290c9ff89cb00caa5469129fd527e9d82cd820 | 10 | test_templatetags.py | 188 | ci: Added codespell (#7355)
Co-authored-by: Christian Clauss <cclauss@me.com>
* ci: codespell config taken from #7292 | 17,398 | 0 | 187 | 109 | 41 | 82,432 | 52 | django-cms | 19 | cms/tests/test_templatetags.py | Python | 16 | {
"docstring": "\n Tests that adding a new placeholder to an existing page's template\n creates the placeholder.\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 14,
"vocab_size": 14
} | https://github.com/django-cms/django-cms.git | |
6 | extra_state_attributes | def extra_state_attributes(self) -> dict[str, int | float | None] | None:
# Only add attributes to the original sensor
if self.entity_description.key != "days_until_expiration":
return None
if self.coordinator.data is None:
return None
attrs = {
... | d15d081646c26d32f860d8f84b4f29d848dab148 | 13 | sensor.py | 212 | Add data update coordinator to Whois (#64846)
Co-authored-by: Joakim Sørensen <joasoe@gmail.com> | 109,631 | 0 | 191 | 133 | 41 | 310,960 | 55 | core | 21 | homeassistant/components/whois/sensor.py | Python | 16 | {
"docstring": "Return the state attributes of the monitored installation.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 7
} | https://github.com/home-assistant/core.git | |
8 | populate_deserializable_objects | def populate_deserializable_objects():
global LOCAL
if not hasattr(LOCAL, 'ALL_OBJECTS'):
LOCAL.ALL_OBJECTS = {}
LOCAL.GENERATED_WITH_V2 = None
if LOCAL.ALL_OBJECTS and LOCAL.GENERATED_WITH_V2 == tf.__internal__.tf2.enabled(
):
# Objects dict is already generated for the proper TF version:
#... | 85ccb4e108551b7444213276ffb4c4c09f22f886 | @keras_export('keras.layers.serialize') | 14 | serialization.py | 659 | Refactor `merge.py` into smaller logically organized files hosted under a `merging` directory.
PiperOrigin-RevId: 424162837 | 79,730 | 1 | 353 | 387 | 141 | 268,861 | 231 | keras | 54 | keras/layers/serialization.py | Python | 50 | {
"docstring": "Populates dict ALL_OBJECTS with every built-in layer.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/keras-team/keras.git |
2 | get_ordering | def get_ordering(self):
ordering = self.get_validated_ordering()
return [values[0] + name for name, values in ordering.items()]
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 9 | views.py | 53 | Reformat with black | 15,950 | 0 | 35 | 32 | 14 | 73,082 | 14 | wagtail | 7 | wagtail/contrib/forms/views.py | Python | 3 | {
"docstring": "Return the field or fields to use for ordering the queryset",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 10
} | https://github.com/wagtail/wagtail.git | |
1 | test_metrics_folder | def test_metrics_folder():
with _ray_start(include_dashboard=True) as context:
session_dir = context["session_dir"]
assert os.path.exists(
f"{session_dir}/metrics/grafana/provisioning/dashboards/default.yml"
)
assert os.path.exists(
f"{session_dir}/metric... | 42da4445e7a3cb358a1a02ae433a004e9fa836b5 | 12 | test_metrics_head.py | 126 | Export default configurations for grafana and prometheus (#28286) | 28,528 | 0 | 130 | 62 | 17 | 127,793 | 24 | ray | 8 | python/ray/tests/test_metrics_head.py | Python | 14 | {
"docstring": "\n Tests that the default dashboard files get created.\n ",
"language": "en",
"n_whitespaces": 15,
"n_words": 8,
"vocab_size": 8
} | https://github.com/ray-project/ray.git | |
6 | logical_or | def logical_or(self, other, context=None):
if context is None:
context = getcontext()
other = _convert_other(other, raiseit=True)
if not self._islogical() or not other._islogical():
return context._raise_error(InvalidOperation)
# fill to context.prec
... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 14 | _pydecimal.py | 197 | add python 3.10.4 for windows | 55,652 | 0 | 139 | 122 | 45 | 219,615 | 54 | XX-Net | 23 | python3.10.4/Lib/_pydecimal.py | Python | 9 | {
"docstring": "Applies an 'or' operation between self and other's digits.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/XX-net/XX-Net.git | |
5 | parse_header | def parse_header(line):
parts = _parseparam(';' + line)
key = parts.__next__()
pdict = {}
for p in parts:
i = p.find('=')
if i >= 0:
name = p[:i].strip().lower()
value = p[i+1:].strip()
if len(value) >= 2 and value[0] == value[-1] == '"':
... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 17 | cgi.py | 224 | add python 3.10.4 for windows | 56,315 | 0 | 165 | 128 | 43 | 221,279 | 61 | XX-Net | 16 | python3.10.4/Lib/cgi.py | Python | 14 | {
"docstring": "Parse a Content-type like header.\n\n Return the main content-type and a dictionary of options.\n\n ",
"language": "en",
"n_whitespaces": 20,
"n_words": 14,
"vocab_size": 13
} | https://github.com/XX-net/XX-Net.git | |
2 | test_unmovable_translation_pages | def test_unmovable_translation_pages(self):
self.login()
# BlogIndex needs translated pages before child pages can be translated
self.fr_blog_index = self.en_blog_index.copy_for_translation(self.fr_locale)
self.de_blog_index = self.en_blog_index.copy_for_translation(self.de_loc... | 4cc10322a1c86c1137f5042a13d94d8017498bf7 | 14 | test_wagtail_hooks.py | 423 | Sync tree: cascade unpublish, move and delete (#7984)
* Add construct_synced_page_tree_list hook and use in page unpublish view
* Implement construct_synced_page_tree_list in simple_translation
but only when sync page tree is enabled
* Add hook documentation
* Add construct_synced_page_tree_list hook tests... | 16,633 | 0 | 541 | 264 | 108 | 77,194 | 157 | wagtail | 29 | wagtail/contrib/simple_translation/tests/test_wagtail_hooks.py | Python | 35 | {
"docstring": "\n Test that moving a page with WAGTAILSIMPLETRANSLATION_SYNC_PAGE_TREE\n disabled doesn't apply to its translations.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 13,
"vocab_size": 13
} | https://github.com/wagtail/wagtail.git | |
4 | canberra_distance | def canberra_distance(self, p):
s, p = Point._normalize_dimension(self, Point(p))
if self.is_zero and p.is_zero:
raise ValueError("Cannot project to the zero vector.")
return Add(*((abs(a - b)/(abs(a) + abs(b))) for a, b in zip(s, p)))
| 498015021131af4dbb07eb110e5badaba8250c7b | 15 | point.py | 120 | Updated import locations | 47,777 | 0 | 70 | 75 | 31 | 196,277 | 31 | sympy | 13 | sympy/geometry/point.py | Python | 5 | {
"docstring": "The Canberra Distance from self to point p.\n\n Returns the weighted sum of horizontal and vertical distances to\n point p.\n\n Parameters\n ==========\n\n p : Point\n\n Returns\n =======\n\n canberra_distance : The weighted sum of horizontal and... | https://github.com/sympy/sympy.git | |
8 | test_sac_compilation | def test_sac_compilation(self):
config = sac.DEFAULT_CONFIG.copy()
config["Q_model"] = sac.DEFAULT_CONFIG["Q_model"].copy()
config["num_workers"] = 0 # Run locally.
config["n_step"] = 3
config["twin_q"] = True
config["learning_starts"] = 0
config["priori... | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | 18 | test_sac.py | 735 | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 30,126 | 0 | 1,496 | 447 | 177 | 133,858 | 285 | ray | 47 | rllib/agents/sac/tests/test_sac.py | Python | 74 | {
"docstring": "Tests whether an SACTrainer can be built with all frameworks.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/ray-project/ray.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.