complexity int64 1 56 | n_identifiers int64 1 114 | code stringlengths 19 12.7k | path stringlengths 8 134 | n_ast_nodes int64 12 2.35k | ast_errors stringlengths 0 4.01k | repo stringlengths 3 28 | documentation dict | n_words int64 2 866 | language stringclasses 1
value | vocab_size int64 2 323 | commit_id stringlengths 40 40 | file_name stringlengths 5 79 | id int64 243 338k | nloc int64 1 228 | token_counts int64 5 1.4k | fun_name stringlengths 1 77 | url stringlengths 31 60 | commit_message stringlengths 3 15.3k | n_whitespaces int64 1 3.23k | n_ast_errors int64 0 20 | d_id int64 74 121k | ast_levels int64 4 29 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 4 | def _get_class_labels_from_estimator(estimator):
return estimator.classes_ if hasattr(estimator, "classes_") else None
| mlflow/sklearn/utils.py | 33 | mlflow | {
"docstring": "\n Extracts class labels from `estimator` if `estimator.classes` is available.\n ",
"language": "en",
"n_whitespaces": 16,
"n_words": 9,
"vocab_size": 9
} | 9 | Python | 9 | 1ddb2c9b5ace0fa605195a4b14c595e274a8c384 | utils.py | 19,200 | 2 | 19 | _get_class_labels_from_estimator | https://github.com/mlflow/mlflow.git | Use `len(classes_)` instead of `len(set(y_true))` (#5275)
* Use n_classes instead of len(set(y_true))
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
* fix attribute
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
* use classes_
Signed-off-by: harupy <17039389+harupy@u... | 15 | 0 | 2,911 | 9 | |
5 | 20 | def get_search_choices(self):
if not self._search_choice_options:
# Organize choices by category
categories = defaultdict(dict)
for app_label, models in registry['search'].items():
for name, cls in models.items():
title = cls.mode... | netbox/netbox/search/backends.py | 181 | netbox | {
"docstring": "Return the set of choices for individual object types, organized by category.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | 58 | Python | 43 | ffce5d968d8a77c97852999b6ef916e80c1de55f | backends.py | 265,845 | 13 | 110 | get_search_choices | https://github.com/netbox-community/netbox.git | 8927 plugin search (#10489)
* #7016 base search classes
* 7016 add search indexes
* 7016 add search indexes
* 7016 add search indexes
* 7016 add search indexes
* 7016 add search indexes
* 7016 add search indexes
* 8927 refactor search
* 8927 refactor search
* 8927 refactor search
* 8927 r... | 239 | 0 | 78,214 | 17 | |
2 | 3 | def betas_for_alpha_bar(num_diffusion_timesteps, max_beta=0.999):
| modules/image/text_to_image/stable_diffusion/diffusers/schedulers/scheduling_ddim.py | 18 | PaddleHub | {
"docstring": "\n Create a beta schedule that discretizes the given alpha_t_bar function, which defines the cumulative product of\n (1-beta) over time from t = [0,1].\n\n :param num_diffusion_timesteps: the number of betas to produce. :param alpha_bar: a lambda that takes an argument t\n from 0 to 1 and\... | 3 | Python | 3 | a6790a651a12eb391060e533868bf0ba197f6f7e | scheduling_ddim.py | 50,754 | 8 | 74 | betas_for_alpha_bar | https://github.com/PaddlePaddle/PaddleHub.git | Add stable diffusion module | 6 | 0 | 10,206 | 6 | |
2 | 20 | def left_integral3D(facets, index, expr, vertices, hp_param, degree):
value = S.Zero
facet = facets[index]
x0 = vertices[facet[0]]
facet_len = len(facet)
for i, fac in enumerate(facet):
side = (vertices[fac], vertices[facet[(i + 1) % facet_len]])
value += distance_to_side(x0, si... | sympy/integrals/intpoly.py | 149 | sympy | {
"docstring": "Computes the left integral of Eq 10 in Chin et al.\n\n Explanation\n ===========\n\n For the 3D case, this is the sum of the integral values over constituting\n line segments of the face (which is accessed by facets[index]) multiplied\n by the distance between the first point of facet a... | 46 | Python | 37 | 7d773eb18daaef3c54f34d1ac6cbc5b83a5bb16c | intpoly.py | 198,386 | 10 | 103 | left_integral3D | https://github.com/sympy/sympy.git | Cleanup loops and ranges | 92 | 0 | 48,898 | 14 | |
3 | 14 | def pad_list(xs, pad_value):
n_batch = len(xs)
max_len = max(x.size(0) for x in xs)
pad = xs[0].new(n_batch, max_len, *xs[0].size()[1:]).fill_(pad_value)
for i in range(n_batch):
pad[i, :xs[i].size(0)] = xs[i]
return pad
| ppg2mel/utils/nets_utils.py | 140 | MockingBird | {
"docstring": "Perform padding for the list of tensors.\n\n Args:\n xs (List): List of Tensors [(T_1, `*`), (T_2, `*`), ..., (T_B, `*`)].\n pad_value (float): Value for padding.\n\n Returns:\n Tensor: Padded tensor (B, Tmax, `*`).\n\n Examples:\n >>> x = [torch.ones(4), torch.one... | 28 | Python | 22 | b617a87ee40ab384767a27335313c2c65ee094ec | nets_utils.py | 161,060 | 7 | 91 | pad_list | https://github.com/babysor/MockingBird.git | Init ppg extractor and ppg2mel (#375)
* Init ppg extractor and ppg2mel
* add preprocess and training
* FIx known issues
* Update __init__.py
Allow to gen audio
* Fix length issue
* Fix bug of preparing fid
* Fix sample issues
* Add UI usage of PPG-vc | 53 | 0 | 38,876 | 15 | |
2 | 7 | def _genName(cls, name):
if not name:
name = "frame_" + str(uuid.uuid4()).replace("-", "")
# TODO: reword name in case of caller's mistake
return name
| modin/experimental/core/execution/native/implementations/omnisci_on_native/base_worker.py | 62 | modin | {
"docstring": "\n Generate or mangle a table name.\n\n Parameters\n ----------\n name : str or None\n Table name to mangle or None to generate a unique\n table name.\n\n Returns\n -------\n str\n Table name.\n ",
"language": "... | 23 | Python | 21 | 1c0935c1bc0856d43f69c1e32498636ee24ebc85 | base_worker.py | 154,395 | 4 | 33 | _genName | https://github.com/modin-project/modin.git | FEAT-#4913: Enabling pyhdk (#4900)
Co-authored-by: ienkovich <ilya.enkovich@intel.com>
Signed-off-by: izamyati <igor.zamyatin@intel.com> | 62 | 0 | 35,956 | 15 | |
4 | 19 | def _canonicalize(self, parents):
for field in dataclasses.fields(self):
value = getattr(self, field.name)
if isinstance(value, (Path, str)) and utils.is_path_like(field.type):
setattr(self, field.name, utils.resolve_path(value, self._base_path))
else... | nni/experiment/config/base.py | 122 | nni | {
"docstring": "\n To be overrided by subclass.\n\n Convert the config object to canonical format.\n\n The default implementation will:\n\n 1. Resolve all ``PathLike`` fields to absolute path\n 2. Call ``_canonicalize([self] + parents)`` on all children config objects, including tho... | 26 | Python | 26 | 3f6a8274a97bf003b5eadc05faa324162b7f4123 | base.py | 111,629 | 7 | 80 | _canonicalize | https://github.com/microsoft/nni.git | Some string changes around experiment module (#4442) | 103 | 0 | 24,461 | 14 | |
3 | 27 | def test_iforest_sparse(global_random_seed):
rng = check_random_state(global_random_seed)
X_train, X_test = train_test_split(diabetes.data[:50], random_state=rng)
grid = ParameterGrid({"max_samples": [0.5, 1.0], "bootstrap": [True, False]})
for sparse_format in [csc_matrix, csr_matrix]:
X_... | sklearn/ensemble/tests/test_iforest.py | 221 | scikit-learn | {
"docstring": "Check IForest for various parameter settings on sparse input.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 65 | Python | 47 | 6ca1f5e4d0d16bc9a7f28582079a15e14f012719 | test_iforest.py | 259,992 | 17 | 144 | test_iforest_sparse | https://github.com/scikit-learn/scikit-learn.git | TST use global_random_seed in sklearn/ensemble/tests/test_iforest.py (#22901)
Co-authored-by: jeremie du boisberranger <jeremiedbb@yahoo.fr>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> | 230 | 0 | 76,025 | 15 | |
19 | 40 | def get_approvers(doctype, txt, searchfield, start, page_len, filters):
if not filters.get("employee"):
frappe.throw(_("Please select Employee first."))
approvers = []
department_details = {}
department_list = []
employee = frappe.get_value(
"Employee",
filters.get("employee"),
["employee_name", "departm... | erpnext/hr/doctype/department_approver/department_approver.py | 728 | erpnext | {
"docstring": "select name from `tabDepartment` where lft <= %s\n\t\t\tand rgt >= %s\n\t\t\tand disabled=0\n\t\t\torder by lft descselect user.name, user.first_name, user.last_name from\n\t\t\t\ttabUser user, `tabDepartment Approver` approver where\n\t\t\t\tapprover.parent = %s\n\t\t\t\tand user.name like %s\n\t\t\t... | 198 | Python | 115 | 494bd9ef78313436f0424b918f200dab8fc7c20b | department_approver.py | 66,060 | 69 | 420 | get_approvers | https://github.com/frappe/erpnext.git | style: format code with black | 137 | 0 | 14,097 | 16 | |
10 | 22 | def _add_name_vhost_if_necessary(self, vhost):
need_to_save = False
# See if the exact address appears in any other vhost
# Remember 1.1.1.1:* == 1.1.1.1 -> hence any()
for addr in vhost.addrs:
# In Apache 2.2, when a NameVirtualHost directive is not
# s... | certbot-apache/certbot_apache/_internal/configurator.py | 216 | certbot | {
"docstring": "Add NameVirtualHost Directives if necessary for new vhost.\n\n NameVirtualHosts was a directive in Apache < 2.4\n https://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost\n\n :param vhost: New virtual host that was recently created.\n :type vhost: :class:`~certbot_ap... | 97 | Python | 71 | eeca208c8f57304590ac1af80b496e61021aaa45 | configurator.py | 186,364 | 17 | 130 | _add_name_vhost_if_necessary | https://github.com/certbot/certbot.git | Various clean-ups in certbot-apache. Use f-strings. (#9132)
* Various clean-ups in certbot-apache. Use f-strings.
* Smaller tweaks | 381 | 0 | 45,461 | 16 | |
11 | 52 | def line_search(self, X, y, sample_weight):
# line search parameters
beta, sigma = 0.5, 0.00048828125 # 1/2, 1/2**11
eps = 16 * np.finfo(self.loss_value.dtype).eps
t = 1 # step size
# gradient_times_newton = self.gradient @ self.coef_newton
# was computed in i... | sklearn/linear_model/_glm/_newton_solver.py | 645 | scikit-learn | {
"docstring": "Backtracking line search.\n\n Sets:\n - self.coef_old\n - self.coef\n - self.loss_value_old\n - self.loss_value\n - self.gradient_old\n - self.gradient\n - self.raw_prediction\n ",
"language": "en",
"n_white... | 339 | Python | 201 | ff9344f3d8d11d38fa3a2497199113e5bac9537c | _newton_solver.py | 261,382 | 70 | 350 | line_search | https://github.com/scikit-learn/scikit-learn.git | FEA add (single) Cholesky Newton solver to GLMs (#24637)
* FEA add NewtonSolver, CholeskyNewtonSolver and QRCholeskyNewtonSolver
* ENH better singular hessian special solve
* CLN fix some typos found by reviewer
* TST assert ConvergenceWarning is raised
* MNT add BaseCholeskyNewtonSolver
* WIP colinear design in ... | 1,364 | 0 | 76,792 | 16 | |
15 | 48 | def _yield_distributions(self):
# We need to check if we've seen some resources already, because on
# some Linux systems (e.g. some Debian/Ubuntu variants) there are
# symlinks which alias other files in the environment.
seen = set()
for path in self.path:
fi... | pipenv/patched/pip/_vendor/distlib/database.py | 457 | pipenv | {
"docstring": "\n Yield .dist-info and/or .egg(-info) distributions.\n ",
"language": "en",
"n_whitespaces": 20,
"n_words": 5,
"vocab_size": 5
} | 159 | Python | 115 | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | database.py | 21,982 | 42 | 277 | _yield_distributions | https://github.com/pypa/pipenv.git | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | 1,081 | 0 | 4,098 | 20 | |
14 | 26 | def test_mutNodeReplacement():
pipeline_string = (
'LogisticRegression(PolynomialFeatures'
'(input_matrix, PolynomialFeatures__degree=2, PolynomialFeatures__include_bias=False, '
'PolynomialFeatures__interaction_only=False), LogisticRegression__C=10.0, '
'LogisticRegression__du... | tests/tpot_tests.py | 302 | tpot | {
"docstring": "Assert that mutNodeReplacement() returns the correct type of mutation node in a fixed pipeline.",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 14
} | 134 | Python | 75 | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot_tests.py | 181,804 | 23 | 193 | test_mutNodeReplacement | https://github.com/EpistasisLab/tpot.git | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 292 | 0 | 43,590 | 15 | |
1 | 21 | def _async_update(self) -> None:
super()._async_update()
node = self.gateway.sensors[self.node_id]
child = node.children[self.child_id]
position: str = child.values[self.value_type]
latitude, longitude, _ = position.split(",")
self._latitude = float(latitude)
... | homeassistant/components/mysensors/device_tracker.py | 126 | core | {
"docstring": "Update the controller with the latest value from a device.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | 26 | Python | 21 | df2d0cd3e3ade2339a18415f92c85810308a9926 | device_tracker.py | 298,235 | 9 | 77 | _async_update | https://github.com/home-assistant/core.git | Refactor mysensors device tracker (#84747) | 82 | 0 | 97,180 | 9 | |
1 | 8 | def from_builtin(cls, func):
warnings.warn("inspect.Signature.from_builtin() is deprecated since "
"Python 3.5, use Signature.from_callable()",
DeprecationWarning, stacklevel=2)
return _signature_from_builtin(cls, func)
| python3.10.4/Lib/inspect.py | 48 | XX-Net | {
"docstring": "Constructs Signature for the given builtin function.\n\n Deprecated since Python 3.5, use `Signature.from_callable()`.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 13,
"vocab_size": 13
} | 17 | Python | 17 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | inspect.py | 218,367 | 5 | 28 | from_builtin | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 80 | 0 | 55,261 | 9 | |
2 | 17 | def update_step(self, grad, variable):
lr = tf.cast(self.learning_rate, variable.dtype)
var_key = self._var_key(variable)
rho = self.rho
accumulated_grad = self._accumulated_grads[self._index_dict[var_key]]
accumulated_delta_var = self._accumulated_delta_vars[
... | keras/optimizers/optimizer_experimental/adadelta.py | 97 | keras | {
"docstring": "Update step given gradient and the associated model variable.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 22 | Python | 18 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | adadelta.py | 275,240 | 33 | 211 | update_step | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 82 | 0 | 81,342 | 9 | |
2 | 4 | def export(self, view_data):
if view_data is not None: # pragma: NO COVER
self.transport.export(view_data)
| python/ray/_private/prometheus_exporter.py | 38 | ray | {
"docstring": "export send the data to the transport class\n in order to be sent to Prometheus in a sync or async way.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 21,
"vocab_size": 17
} | 13 | Python | 13 | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | prometheus_exporter.py | 130,175 | 3 | 22 | export | https://github.com/ray-project/ray.git | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 39 | 0 | 29,142 | 10 | |
1 | 7 | def job_hook(**kwargs):
cmd = " ".join(kwargs["entrypoint"])
print(f"hook intercepted: {cmd}")
sys.exit(0)
| python/ray/_private/test_utils.py | 59 | ray | {
"docstring": "Function called by reflection by test_cli_integration.",
"language": "en",
"n_whitespaces": 5,
"n_words": 6,
"vocab_size": 5
} | 10 | Python | 10 | 517f78e2b810e506d61884c79d768a37a34f0f9c | test_utils.py | 140,506 | 4 | 29 | job_hook | https://github.com/ray-project/ray.git | [minor] Add a job submission hook by env var (#25343) | 22 | 0 | 31,979 | 10 | |
5 | 14 | def get_dataset_info(tasks):
curr_task_info = []
for task in tasks:
# adding the name + attempted link
tname = taskname(task)
tsite = task_site + to_sublink(tname)
curr_task_info.append(f"- [{tname}]({tsite})")
# adding link
links = make_task_links(task)
... | parlai/scripts/generate_model_card.py | 170 | ParlAI | {
"docstring": "\n dataset info comes from guessing where it would be at the tasks site and the\n task_list.py + anything else from the user.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 22,
"vocab_size": 19
} | 58 | Python | 42 | 81f722d29045a7a5841d0931a082ded1d1f13863 | generate_model_card.py | 194,780 | 11 | 82 | get_dataset_info | https://github.com/facebookresearch/ParlAI.git | autoformat (#4378) | 141 | 0 | 47,073 | 14 | |
5 | 9 | def widget_to_element(self, widget):
if self.AllKeysDict is None or len(self.AllKeysDict) == 0:
return None
for key, element in self.AllKeysDict.items():
if element.Widget == widget:
return element
return None
| PySimpleGUI.py | 80 | PySimpleGUI | {
"docstring": "\n Returns the element that matches a supplied tkinter widget.\n If no matching element is found, then None is returned.\n\n\n :return: Element that uses the specified widget\n :rtype: Element | None\n ",
"language": "en",
"n_whitespaces": 73,
"n_words":... | 26 | Python | 19 | 9b814f003b0685757d76ce56ee9c98eae114d346 | PySimpleGUI.py | 212,818 | 7 | 50 | widget_to_element | https://github.com/PySimpleGUI/PySimpleGUI.git | Added key and widget Element properties, new focus methods Element.get_next_focus, Element.get_previous_focus. New Window method Window.widget_to_element | 91 | 0 | 53,428 | 10 | |
3 | 17 | def _get_fallback_devices(self) -> List[plaidml._DeviceConfig]:
# Try get a supported device
experimental_setting = plaidml.settings.experimental
plaidml.settings.experimental = False
devices = plaidml.devices(self._ctx, limit=100, return_all=True)[0]
# Try get any devi... | lib/gpu_stats/amd.py | 201 | faceswap | {
"docstring": " Called if a GPU has not been discovered. Return any devices we can run on.\n\n Returns\n -------\n list:\n The :class:`pladml._DeviceConfig` fallaback objects that PlaidML has discovered.\n ",
"language": "en",
"n_whitespaces": 66,
"n_words": 26,
"vocab_... | 70 | Python | 44 | 98a65277d8c55cfcbdbfa629f790a8f8731621a8 | amd.py | 100,857 | 20 | 109 | _get_fallback_devices | https://github.com/deepfakes/faceswap.git | Fix AMD Tests + docs | 197 | 0 | 20,308 | 14 | |
1 | 5 | def nargs_error(name, takes, given):
return TypeError(f"{name}() takes {takes} positional arguments but "
f"{given} were given")
| lib/matplotlib/_api/__init__.py | 43 | matplotlib | {
"docstring": "Generate a TypeError to be raised by function calls with wrong arity.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | 15 | Python | 15 | 973e475ef85524c5e9cef0638c90ca9a159935e4 | __init__.py | 110,159 | 3 | 18 | nargs_error | https://github.com/matplotlib/matplotlib.git | Factor out error generation for function calls with wrong nargs.
... matching the wording for standard functions.
Note that nargs_error returns the exception without raising it itself to
make the control flow clearer on the caller side. | 41 | 0 | 23,954 | 10 | |
1 | 7 | def test_tabular_model_form_meta_readonly_field(self):
response = self.client.get(reverse("admin:admin_inlines_someparentmodel_add"))
self.assertContains(
response,
'<img src="/static/admin/img/icon-unknown.svg" '
'class="help help-tooltip" width="10" height=... | tests/admin_inlines/tests.py | 75 | django | {
"docstring": "\n Tabular inlines use ModelForm.Meta.help_texts and labels for read-only\n fields.\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 9,
"vocab_size": 9
} | 29 | Python | 24 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 207,170 | 10 | 39 | test_tabular_model_form_meta_readonly_field | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 119 | 0 | 51,888 | 11 | |
1 | 2 | def tiling(self):
return self["tiling"]
| packages/python/plotly/plotly/graph_objs/_icicle.py | 22 | plotly.py | {
"docstring": "\n The 'tiling' property is an instance of Tiling\n that may be specified as:\n - An instance of :class:`plotly.graph_objs.icicle.Tiling`\n - A dict of string/value properties that will be passed\n to the Tiling constructor\n\n Supported dict prope... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _icicle.py | 227,197 | 2 | 11 | tiling | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 58,870 | 7 | |
1 | 5 | def _execute_impl(self, *args, **kwargs):
return self._deployment_handle
| python/ray/serve/pipeline/deployment_node.py | 27 | ray | {
"docstring": "Executor of DeploymentNode getting called each time on dag.execute.\n\n The execute implementation is recursive, that is, the method nodes will receive\n whatever this method returns. We return a handle here so method node can\n directly call upon.\n ",
"language": "en",
... | 6 | Python | 6 | b4d9fcdbf8be4c0f4985c29b251d2585cf269f76 | deployment_node.py | 138,734 | 2 | 16 | _execute_impl | https://github.com/ray-project/ray.git | [Serve] Fix surprious `__call__` invocation in Deployment DAG's exec_impl (#24199) | 20 | 0 | 31,508 | 6 | |
1 | 9 | def get_image_copy(self, color_format):
logger.trace("Requested color format '%s' for frame '%s'", color_format, self._filename)
image = getattr(self, f"_image_as_{color_format.lower()}")()
return image
| plugins/extract/pipeline.py | 66 | faceswap | {
"docstring": " Get a copy of the image in the requested color format.\n\n Parameters\n ----------\n color_format: ['BGR', 'RGB', 'GRAY']\n The requested color format of :attr:`image`\n\n Returns\n -------\n :class:`numpy.ndarray`:\n A copy of :attr:`im... | 18 | Python | 17 | d9c84a5f9f6ff22d6f91594f218bea15764de96b | pipeline.py | 100,903 | 4 | 33 | get_image_copy | https://github.com/deepfakes/faceswap.git | Add Laplacian Pyramid Loss | 46 | 0 | 20,352 | 13 | |
2 | 4 | def subst_vars (s, local_vars):
check_environ() | python3.10.4/Lib/distutils/util.py | 21 | XX-Net | {
"docstring": "Perform shell/Perl-style variable substitution on 'string'. Every\n occurrence of '$' followed by a name is considered a variable, and\n variable is substituted by the value found in the 'local_vars'\n dictionary, or in 'os.environ' if it's not in 'local_vars'.\n 'os.environ' is first che... | 5 | Python | 5 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | util.py | 223,399 | 7 | 39 | subst_vars | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 11 | 0 | 56,886 | 7 | |
1 | 6 | def test_empty_lsb_djob_rankfile():
with pytest.raises(ValueError, match="The environment variable `LSB_DJOB_RANKFILE` is empty"):
LSFEnvironment()
| tests/plugins/environments/test_lsf_environment.py | 40 | lightning | {
"docstring": "Test an error when the LSB_DJOB_RANKFILE is not populated.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 11 | Python | 11 | dbf1acd5a553ffc1546734be164cc89cef2b741d | test_lsf_environment.py | 241,632 | 3 | 20 | test_empty_lsb_djob_rankfile | https://github.com/Lightning-AI/lightning.git | Modify LSFEnvironment to use more reliable environment variable (#10825)
Co-authored-by: thomas chaton <thomas@grid.ai>
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com> | 24 | 0 | 69,633 | 11 | |
2 | 8 | def get_user_timezone() -> str:
dotenv.load_dotenv(USER_ENV_FILE)
user_tz = os.getenv("OPENBB_TIMEZONE")
if user_tz:
return user_tz
return ""
| openbb_terminal/helper_funcs.py | 53 | OpenBBTerminal | {
"docstring": "Get user timezone if it is a valid one\n\n Returns\n -------\n str\n user timezone based on .env file\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 18,
"vocab_size": 16
} | 14 | Python | 12 | f18c44b0668ef8e40d14d79780558521b2c02304 | helper_funcs.py | 285,666 | 13 | 28 | get_user_timezone | https://github.com/OpenBB-finance/OpenBBTerminal.git | New path for styles and add timezone as environment variable (#2509)
* add log path
* add test to check if log file is in correct dir
* env path
* black
* mypy fix
* add styles folder and styles from repo
* add timezone as env variable
* fix changes with main
* fix test
* flake8
* fix lin... | 36 | 0 | 85,370 | 9 | |
1 | 5 | def validator_xml_findtext(xpath) -> AllSchema:
return AllSchema(
validator_xml_find(xpath),
validator_getattr("text"),
)
| src/streamlink/plugin/api/validate/_validators.py | 39 | streamlink | {
"docstring": "\n Find an XML element via xpath and extract its text.\n ",
"language": "en",
"n_whitespaces": 17,
"n_words": 10,
"vocab_size": 10
} | 9 | Python | 9 | 120c10302381600abb4044083ce0a106b31df8f0 | _validators.py | 187,103 | 8 | 22 | validator_xml_findtext | https://github.com/streamlink/streamlink.git | plugin.api.validate: turn module into package
Turn module into package with multiple logical sub-modules:
- Define a public interface in the package's `__init__` module
- Split validation schemas, validators and validate logic
- schemas: classes which register attributes used by their
respective `validate` imple... | 32 | 0 | 45,687 | 10 | |
1 | 11 | def get_instance_data_location() -> DataLocation:
return DataLocation(
name=prefect.settings.from_env().orion.data.name,
base_path=prefect.settings.from_env().orion.data.base_path,
scheme=prefect.settings.from_env().orion.data.scheme.lower(),
)
| src/prefect/orion/schemas/data.py | 101 | prefect | {
"docstring": "\n Return the current data location configured for this Orion instance\n ",
"language": "en",
"n_whitespaces": 17,
"n_words": 10,
"vocab_size": 10
} | 10 | Python | 10 | 1d4218a287ef343f32f1e32482592b471be5df1d | data.py | 53,408 | 9 | 63 | get_instance_data_location | https://github.com/PrefectHQ/prefect.git | Move `prefect.settings` to `prefect.settings.from_env()` | 40 | 0 | 10,792 | 16 | |
1 | 24 | def test_reupload_different_file_size_and_file_hash(self):
# Build a fake file, and create it through the admin view
# since self.document doesn't have a file_size set.
fake_file = SimpleUploadedFile("some_file.txt", b"this is the content")
post_data = {
"title": "My... | wagtail/documents/tests/test_admin_views.py | 227 | wagtail | {
"docstring": "\n Checks that reuploading the document file with a different file\n changes the file size and file hash (see #5704).\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 19,
"vocab_size": 15
} | 69 | Python | 58 | d10f15e55806c6944827d801cd9c2d53f5da4186 | test_admin_views.py | 74,800 | 20 | 135 | test_reupload_different_file_size_and_file_hash | https://github.com/wagtail/wagtail.git | Reformat with black | 259 | 0 | 16,322 | 12 | |
2 | 58 | def __call__(self, feat_maps, comp_attribs):
assert isinstance(feat_maps, paddle.Tensor)
assert comp_attribs.ndim == 3
assert comp_attribs.shape[2] == 8
sorted_dist_inds_batch = []
local_graph_batch = []
knn_batch = []
node_feat_batch = []
node_... | ppocr/modeling/heads/local_graph.py | 607 | PaddleOCR | {
"docstring": "Generate local graphs as GCN input.\n\n Args:\n feat_maps (Tensor): The feature maps to extract the content\n features of text components.\n comp_attribs (ndarray): The text component attributes.\n\n Returns:\n local_graphs_node_feat (Tenso... | 146 | Python | 103 | 1f9400dd7374ce9cc47981372e324ff412e53ba3 | local_graph.py | 25,205 | 48 | 406 | __call__ | https://github.com/PaddlePaddle/PaddleOCR.git | add drrg | 845 | 0 | 4,867 | 14 | |
1 | 9 | def emit_message(self):
message = self.as_airbyte_message().json(exclude_unset=True)
filtered_message = filter_secrets(message)
print(filtered_message)
| airbyte-cdk/python/airbyte_cdk/utils/traced_exception.py | 53 | airbyte | {
"docstring": "\n Prints the exception as an AirbyteTraceMessage.\n Note that this will be called automatically on uncaught exceptions when using the airbyte_cdk entrypoint.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 21,
"vocab_size": 20
} | 9 | Python | 8 | 73c7fad7fce952a8c3ba827ca858e4280bd846f3 | traced_exception.py | 5,030 | 4 | 30 | emit_message | https://github.com/airbytehq/airbyte.git | CDK: emit `AirbyteTraceMessage` with exception trace information (#12593) | 37 | 0 | 709 | 10 | |
1 | 24 | def test_purge_room_and_block(self) -> None:
# Test that room is not purged
with self.assertRaises(AssertionError):
self._is_purged(self.room_id)
# Test that room is not blocked
self._is_blocked(self.room_id, expect=False)
# Assert one user in room
... | tests/rest/admin/test_room.py | 298 | synapse | {
"docstring": "Test to purge a room and block it.\n Members will not be moved to a new room and will not receive a message.\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 23,
"vocab_size": 16
} | 57 | Python | 46 | c97042f7eef3748e17c90e48a4122389a89c4735 | test_room.py | 249,156 | 22 | 183 | test_purge_room_and_block | https://github.com/matrix-org/synapse.git | Use literals in place of `HTTPStatus` constants in tests (#13469) | 231 | 0 | 72,663 | 12 | |
1 | 4 | def get_element_html_by_id(id, html):
return get_element_html_by_attribute('id', id, html)
| yt_dlp/utils.py | 29 | yt-dlp | {
"docstring": "Return the html of the tag with the specified ID in the passed HTML document",
"language": "en",
"n_whitespaces": 14,
"n_words": 15,
"vocab_size": 12
} | 7 | Python | 7 | 6f32a0b5b70fe0f8b14c2946b40840b795044662 | utils.py | 162,151 | 2 | 17 | get_element_html_by_id | https://github.com/yt-dlp/yt-dlp.git | [utils] Improve parsing for nested HTML elements (#2129)
and add functions to return the HTML of elements
Authored by: zmousm | 13 | 0 | 39,167 | 8 | |
1 | 3 | def prereleases(self, value):
# type: (bool) -> None
| .venv/lib/python3.8/site-packages/pip/_vendor/packaging/specifiers.py | 16 | transferlearning | {
"docstring": "\n Sets whether or not pre-releases as a whole are allowed by this\n specifier.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 13,
"vocab_size": 13
} | 8 | Python | 8 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | specifiers.py | 62,884 | 1 | 8 | prereleases | https://github.com/jindongwang/transferlearning.git | upd; format | 22 | 0 | 13,060 | 6 | |
1 | 4 | def receive_parameter(self) -> ParameterRecord | None:
raise NotImplementedError()
| nni/runtime/trial_command_channel/base.py | 26 | nni | {
"docstring": "Get the next parameter record from NNI manager.\n\n Returns\n -------\n :class:`~nni.typehint.ParameterRecord`\n The next parameter record.\n Could be ``None`` if no more parameter is available.\n ",
"language": "en",
"n_whitespaces": 74,
"n_word... | 8 | Python | 8 | 7f1495c8b338c547005770cb83f2f7f4b88798f3 | base.py | 113,798 | 10 | 14 | receive_parameter | https://github.com/microsoft/nni.git | Trial command channel (#5254) | 22 | 0 | 25,031 | 7 | |
3 | 6 | def rebuild_cablepaths(instance, raw=False, **kwargs):
if not raw:
peer_termination = instance.get_peer_termination()
# if peer_termination:
# rebuild_paths(peer_termination)
| netbox/circuits/signals.py | 43 | netbox | {
"docstring": "\n Rebuild any CablePaths which traverse the peer CircuitTermination.\n ",
"language": "en",
"n_whitespaces": 15,
"n_words": 8,
"vocab_size": 8
} | 15 | Python | 13 | 5667a9c456e0514a2d00d6475e7013748b4a7c1e | signals.py | 264,829 | 5 | 31 | rebuild_cablepaths | https://github.com/netbox-community/netbox.git | Refactor CablePath.from_origin() | 46 | 0 | 77,847 | 10 | |
3 | 11 | def register_handler(key, handler):
| sympy/assumptions/ask.py | 32 | """
Register a handler in the ask system. key must be a string and handler athe ask system. key must be a | sympy | {
"docstring": "\n Register a handler in the ask system. key must be a string and handler a",
"language": "en",
"n_whitespaces": 18,
"n_words": 15,
"vocab_size": 12
} | 3 | Python | 3 | ad766d1c02943e86f50559abfd0c72e582c9ca6a | ask.py | 196,755 | 16 | 77 | register_handler | https://github.com/sympy/sympy.git | Update the AskHandler deprecation warnings
n.b., the issue number in the original warning message was wrong. It should
have been #20837. | 6 | 2 | 48,151 | 7 |
2 | 22 | def test_float32_float64_equivalence(is_sparse):
rng = np.random.RandomState(0)
X = rng.rand(10, 2)
if is_sparse:
X[X < 0.8] = 0
X = sp.csr_matrix(X)
km64 = BisectingKMeans(n_clusters=3, random_state=0).fit(X)
km32 = BisectingKMeans(n_clusters=3, random_state=0).fit(X.astype(n... | sklearn/cluster/tests/test_bisect_k_means.py | 167 | scikit-learn | {
"docstring": "Check that the results are the same between float32 and float64.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 10
} | 31 | Python | 24 | 0822851f5cb17827939a7d7b4f8c84f43184ae89 | test_bisect_k_means.py | 259,765 | 10 | 108 | test_float32_float64_equivalence | https://github.com/scikit-learn/scikit-learn.git | FEA Bisecting K-Means (#20031)
Co-authored-by: Gael Varoquaux <gael.varoquaux@normalesup.org>
Co-authored-by: Tom Dupré la Tour <tom.dupre-la-tour@m4x.org>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> | 69 | 0 | 75,910 | 11 | |
1 | 23 | def delete_tasks_annotations(project, queryset, **kwargs):
task_ids = queryset.values_list('id', flat=True)
annotations = Annotation.objects.filter(task__id__in=task_ids)
count = annotations.count()
annotations_ids = list(annotations.values('id'))
annotations.delete()
emit_webhooks_for_inst... | label_studio/data_manager/actions/basic.py | 158 | label-studio | {
"docstring": " Delete all annotations by tasks ids\n\n :param project: project instance\n :param queryset: filtered tasks db queryset\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 16,
"vocab_size": 14
} | 34 | Python | 29 | 85152f2c8c7f8b301b28fcd771f13b5c166c59eb | basic.py | 177,572 | 10 | 93 | delete_tasks_annotations | https://github.com/heartexlabs/label-studio.git | fix: DEV-1486: fix dm action when deleting all annotations, finished state is not updated (#1923)
Co-authored-by: Max Tkachenko <makseq@gmail.com> | 72 | 0 | 42,445 | 11 | |
4 | 17 | def _check_processes(self):
while True:
with self.server_lock:
for client_id, specific_server in list(self.servers.items()):
if specific_server.poll() is not None:
logger.info(
f"Specific server {client_... | python/ray/util/client/server/proxier.py | 133 | ray | {
"docstring": "\n Keeps the internal servers dictionary up-to-date with running servers.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | 41 | Python | 39 | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | proxier.py | 132,945 | 12 | 72 | _check_processes | https://github.com/ray-project/ray.git | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 280 | 0 | 29,875 | 19 | |
1 | 21 | def bounding_box(self, frame_index, face_index, pnt_x, width, pnt_y, height, aligner="FAN"):
logger.trace("frame_index: %s, face_index %s, pnt_x %s, width %s, pnt_y %s, height %s, "
"aligner: %s", frame_index, face_index, pnt_x, width, pnt_y, height, aligner)
face = self._f... | tools/manual/detected_faces.py | 150 | faceswap | {
"docstring": " Update the bounding box for the :class:`~lib.align.DetectedFace` object at the\n given frame and face indices, with the given dimensions and update the 68 point landmarks\n from the :class:`~tools.manual.manual.Aligner` for the updated bounding box.\n\n Parameters\n ------... | 52 | Python | 30 | 5e73437be47f2410439a3c6716de96354e6a0c94 | detected_faces.py | 101,252 | 10 | 100 | bounding_box | https://github.com/deepfakes/faceswap.git | 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 | 135 | 0 | 20,672 | 9 | |
5 | 13 | def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
if ext == '.rc' or ext == '.res':
# gcc needs '.res' and '.rc' compiled to object files !!!
try:
self.spawn(["windres", "-i", src, "-o", obj])
except DistutilsExecError as msg:
... | python3.10.4/Lib/distutils/cygwinccompiler.py | 149 | XX-Net | {
"docstring": "Compiles the source by spawning GCC and windres if needed.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 63 | Python | 48 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | cygwinccompiler.py | 222,841 | 12 | 89 | _compile | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 225 | 0 | 56,773 | 16 | |
1 | 5 | def __newobj_ex__(cls, args, kwargs):
return cls.__new__(cls, *args, **kwargs)
| python3.10.4/Lib/copyreg.py | 36 | XX-Net | {
"docstring": "Used by pickle protocol 4, instead of __newobj__ to allow classes with\n keyword-only arguments to be pickled correctly.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 18,
"vocab_size": 17
} | 8 | Python | 8 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | copyreg.py | 221,746 | 2 | 23 | __newobj_ex__ | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 14 | 0 | 56,500 | 8 | |
1 | 7 | def mellin_transform(f, x, s, **hints):
r
return MellinTransform(f, x, s).doit(**hints)
| sympy/integrals/transforms.py | 43 | sympy | {
"docstring": "\n Compute the Mellin transform `F(s)` of `f(x)`,\n\n .. math :: F(s) = \\int_0^\\infty x^{s-1} f(x) \\mathrm{d}x.\n\n For all \"sensible\" functions, this converges absolutely in a strip\n `a < \\operatorname{Re}(s) < b`.\n\n Explanation\n ===========\n\n The Mellin transform i... | 10 | Python | 9 | 498015021131af4dbb07eb110e5badaba8250c7b | transforms.py | 196,338 | 42 | 29 | mellin_transform | https://github.com/sympy/sympy.git | Updated import locations | 15 | 0 | 47,838 | 9 | |
2 | 9 | def get_verts(self):
trans = self.get_transform()
path = self.get_path()
polygons = path.to_polygons(trans)
if len(polygons):
return polygons[0]
return []
| lib/matplotlib/patches.py | 72 | matplotlib | {
"docstring": "\n Return a copy of the vertices used in this patch.\n\n If the patch contains Bézier curves, the curves will be interpolated by\n line segments. To access the curves as curves, use `get_path`.\n ",
"language": "en",
"n_whitespaces": 62,
"n_words": 32,
"vocab_size"... | 17 | Python | 14 | 03a0b5ea238014ba87f74ef766928287726aa00a | patches.py | 110,301 | 7 | 42 | get_verts | https://github.com/matplotlib/matplotlib.git | Doc: Fix grammar and spelling | 70 | 0 | 24,041 | 8 | |
1 | 6 | def test_missing_cpp_namespace(self) -> None:
yaml_str =
output_error = self.get_errors_from_gen_backend_stubs(yaml_str)
self.assertExpectedInline(output_error, )
| tools/test/test_gen_backend_stubs.py | 47 | pytorch | {
"docstring": "\\\nbackend: XLA\nsupported:\n- absYou must provide a value for \"cpp_namespace\"",
"language": "en",
"n_whitespaces": 8,
"n_words": 12,
"vocab_size": 12
} | 11 | Python | 10 | bb5b4cceb6f737448eaaa6817cd773b6f4b0e77d | test_gen_backend_stubs.py | 102,162 | 7 | 26 | test_missing_cpp_namespace | https://github.com/pytorch/pytorch.git | Revert "Revert D32498569: allow external backend codegen to toggle whether to generate out= and inplace kernels" (#69950)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69950
This reverts commit f6cad53443704dfe5a20cc62bee14d91e3bffcaa.
Test Plan: Imported from OSS
Reviewed By: albanD
Diff... | 32 | 0 | 21,477 | 8 | |
1 | 2 | def labelside(self):
return self["labelside"]
| packages/python/plotly/plotly/graph_objs/_parcoords.py | 22 | plotly.py | {
"docstring": "\n Specifies the location of the `label`. \"top\" positions labels\n above, next to the title \"bottom\" positions labels below the\n graph Tilted labels with \"labelangle\" may be positioned better\n inside margins when `labelposition` is set to \"bottom\".\n\n The ... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _parcoords.py | 227,541 | 2 | 11 | labelside | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 59,214 | 7 | |
1 | 5 | async def test_find_in_range_altered_inverted(hass):
mqtt_cover = MqttCover(
hass,
{
"name": "cover.test",
"state_topic": "state-topic",
"get_position_topic": None,
"command_topic": "command-topic",
"availability_topic": None,
... | tests/components/mqtt/test_cover.py | 288 | core | {
"docstring": "Test find in range with altered range and inverted.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 8
} | 79 | Python | 58 | 52561ce0769ddcf1e8688c8909692b66495e524b | test_cover.py | 302,086 | 39 | 156 | test_find_in_range_altered_inverted | https://github.com/home-assistant/core.git | Update MQTT tests to use the config entry setup (#72373)
* New testframework and tests for fan platform
* Merge test_common_new to test_common
* Add alarm_control_panel
* Add binary_sensor
* Add button
* Add camera
* Add climate
* Add config_flow
* Add cover
* Add device_tracker_disovery
... | 448 | 0 | 100,923 | 11 | |
1 | 24 | 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... | tests/rest/client/test_shadow_banned.py | 192 | synapse | {
"docstring": "Messages from shadow-banned users don't actually get sent.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 53 | Python | 46 | 1901cb1d4a8b7d9af64493fbd336e9aa2561c20c | test_shadow_banned.py | 247,069 | 18 | 118 | test_message | https://github.com/matrix-org/synapse.git | Add type hints to `tests/rest/client` (#12084) | 210 | 0 | 71,479 | 12 | |
2 | 9 | def vf2pp_isomorphism(G1, G2, node_label=None, default_label=None):
try:
mapping = next(vf2pp_all_isomorphisms(G1, G2, node_label, default_label))
return mapping
except StopIteration:
return None
| networkx/algorithms/isomorphism/vf2pp.py | 61 | networkx | {
"docstring": "Return an isomorphic mapping between `G1` and `G2` if it exists.\n\n Parameters\n ----------\n G1, G2 : NetworkX Graph or MultiGraph instances.\n The two graphs to check for isomorphism.\n\n node_label : str, optional\n The name of the node attribute to be used when comparing... | 18 | Python | 15 | bffcd74649fb95a57fb834846eb3c7d9693c55b8 | vf2pp.py | 177,240 | 6 | 40 | vf2pp_isomorphism | https://github.com/networkx/networkx.git | Preliminary VF2++ Implementation (#5788)
* Preliminary implementation of the candidate node pair ordering of VF2++
* Removed unused lines of code
* Added todos
* Added demo and pseudocode for VF2++
* Pointed out a problem with the pseudocode
* Initialisation of the VF2++ basis structure
* Initialise ... | 48 | 0 | 42,307 | 12 | |
8 | 15 | def url_params_from_lookup_dict(lookups):
params = {}
if lookups and hasattr(lookups, "items"):
for k, v in lookups.items():
if callable(v):
v = v()
if isinstance(v, (tuple, list)):
v = ",".join(str(x) for x in v)
elif isinstance(v... | django/contrib/admin/widgets.py | 171 | django | {
"docstring": "\n Convert the type of lookups specified in a ForeignKey limit_choices_to\n attribute to a dictionary of query parameters\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 17,
"vocab_size": 15
} | 47 | Python | 31 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | widgets.py | 203,569 | 14 | 103 | url_params_from_lookup_dict | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 181 | 0 | 50,449 | 16 | |
1 | 4 | def test_single_gen_next(self) -> None:
id_gen = self._create_id_generator()
| tests/storage/test_id_generators.py | 28 | synapse | {
"docstring": "Check that we correctly increment the current token from the DB.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 10
} | 7 | Python | 7 | 115f0eb2334b13665e5c112bd87f95ea393c9047 | test_id_generators.py | 249,828 | 5 | 26 | test_single_gen_next | https://github.com/matrix-org/synapse.git | Reintroduce #14376, with bugfix for monoliths (#14468)
* Add tests for StreamIdGenerator
* Drive-by: annotate all defs
* Revert "Revert "Remove slaved id tracker (#14376)" (#14463)"
This reverts commit d63814fd736fed5d3d45ff3af5e6d3bfae50c439, which in
turn reverted 36097e88c4da51fce6556a58c49bd675f4cf20ab. This re... | 21 | 0 | 73,158 | 8 | |
13 | 59 | def render(self):
from dcim.models import Cable
from wireless.models import WirelessLink
traced_path = self.origin.trace()
# Iterate through each (terms, cable, terms) segment in the path
for i, segment in enumerate(traced_path):
near_ends, connector, far_e... | netbox/dcim/svg/cables.py | 832 | netbox | {
"docstring": "\n Return an SVG document representing a cable trace.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 8
} | 228 | Python | 141 | bab6fb0de24d568371c8a55bcb22768b2d60f515 | cables.py | 265,020 | 73 | 504 | render | https://github.com/netbox-community/netbox.git | Update SVG trace rendering to support multiple terminations per cable end | 1,582 | 0 | 77,946 | 19 | |
1 | 5 | def _unquote_match(match):
s = match.group(0)
return unquote(s)
# Header decoding is done a bit differently | python3.10.4/Lib/email/quoprimime.py | 35 | XX-Net | {
"docstring": "Turn a match in the form =AB to the ASCII character with value 0xab",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 13
} | 15 | Python | 15 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | quoprimime.py | 223,868 | 3 | 19 | _unquote_match | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 23 | 0 | 57,119 | 8 | |
1 | 2 | def backoff(self):
return self["backoff"]
| packages/python/plotly/plotly/graph_objs/scatter/_line.py | 22 | plotly.py | {
"docstring": "\n Sets the line back off from the end point of the nth line\n segment (in px). This option is useful e.g. to avoid overlap\n with arrowhead markers. With \"auto\" the lines would trim before\n markers if `marker.angleref` is set to \"previous\".\n\n The 'backoff' pr... | 4 | Python | 4 | d5a345d01507f8b6792c51507d1d8f35d7386d29 | _line.py | 231,182 | 2 | 11 | backoff | https://github.com/plotly/plotly.py.git | update to plotly.js 2.16.1 | 18 | 0 | 62,764 | 7 | |
4 | 43 | def _update_png_headers(self):
to_update = [ # Items whose face index has changed
x for x in self._items.file_list_sorted
if x["face_index"] != self._items.items[x["source_filename"]].index(x["face_index"])]
for file_info in tqdm(to_update, desc="Updating PNG Headers",... | tools/alignments/jobs.py | 387 | faceswap | {
"docstring": " Update the EXIF iTXt field of any face PNGs that have had their face index changed.\n\n Notes\n -----\n This could be quicker if parellizing in threads, however, Windows (at least) does not seem\n to like this and has a tendency to throw permission errors, so this remains ... | 95 | Python | 73 | a9908b46f77dc66ac7efe7100ea0eed4b1f2b460 | jobs.py | 100,663 | 25 | 224 | _update_png_headers | https://github.com/deepfakes/faceswap.git | Alignments tool - Replace 'extract-large' with 'min-size' | 511 | 0 | 20,122 | 17 | |
2 | 8 | def copy(self, deep=True): # noqa: PR01, RT01, D200
if deep:
return self.__constructor__(query_compiler=self._query_compiler.copy())
new_obj = self.__constructor__(query_compiler=self._query_compiler)
self._add_sibling(new_obj)
return new_obj
| modin/pandas/base.py | 80 | modin | {
"docstring": "\n Make a copy of the object's metadata.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | 18 | Python | 16 | 605efa618e7994681f57b11d04d417f353ef8d50 | base.py | 153,569 | 6 | 48 | copy | https://github.com/modin-project/modin.git | DOCS-#3099: Fix `BasePandasDataSet` docstrings warnings (#4333)
Co-authored-by: Yaroslav Igoshev <Poolliver868@mail.ru>
Signed-off-by: Alexander Myskov <alexander.myskov@intel.com> | 65 | 0 | 35,450 | 13 | |
1 | 2 | def z(self):
return self["z"]
| packages/python/plotly/plotly/graph_objs/_choropleth.py | 22 | plotly.py | {
"docstring": "\n Sets the color values.\n\n The 'z' property is an array that may be specified as a tuple,\n list, numpy array, or pandas Series\n\n Returns\n -------\n numpy.ndarray\n ",
"language": "en",
"n_whitespaces": 76,
"n_words": 26,
"vocab_size": 26
... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _choropleth.py | 226,452 | 2 | 11 | z | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 58,125 | 7 | |
1 | 15 | def test_self_hosted_rate_limit_check(self, default_rate_limit_mock):
request = self.factory.get("/")
default_rate_limit_mock.return_value = RateLimit(10, 100)
self.middleware.process_view(request, self._test_endpoint, [], {})
assert not request.will_be_rate_limited
def... | tests/sentry/middleware/test_ratelimit_middleware.py | 193 | sentry | {
"docstring": "Check that for self hosted installs we don't rate limit",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 40 | Python | 23 | 2d33f7cba85abb192111733892f0e7ac49812054 | test_ratelimit_middleware.py | 98,629 | 12 | 121 | test_self_hosted_rate_limit_check | https://github.com/getsentry/sentry.git | ref(rate limits): Move settings out of sentry (#33806)
* ref(rate limits): Move settings out of sentry | 144 | 0 | 19,592 | 11 | |
3 | 13 | def get_queryset(self, request):
queryset = SavedFilter.objects.all()
user = request.user
if user.is_superuser:
return queryset
if user.is_anonymous:
return queryset.filter(shared=True)
return queryset.filter(
Q(shared=True) | Q(user=u... | netbox/extras/views.py | 101 | netbox | {
"docstring": "\n Return only shared SavedFilters, or those owned by the current user, unless\n this is a superuser.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 16,
"vocab_size": 16
} | 23 | Python | 18 | 484efdaf75f267a43f9321b938fda1bc967b9e53 | views.py | 265,983 | 10 | 62 | get_queryset | https://github.com/netbox-community/netbox.git | Closes #9623: Implement saved filters (#10801)
* Initial work on saved filters
* Return only enabled/shared filters
* Add tests
* Clean up filtering of usable SavedFilters | 105 | 0 | 78,254 | 11 | |
1 | 2 | def locations(self):
return self["locations"]
| packages/python/plotly/plotly/graph_objs/_choropleth.py | 22 | plotly.py | {
"docstring": "\n Sets the coordinates via location IDs or names. See\n `locationmode` for more info.\n\n The 'locations' property is an array that may be specified as a tuple,\n list, numpy array, or pandas Series\n\n Returns\n -------\n numpy.ndarray\n ",
"... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _choropleth.py | 226,464 | 2 | 11 | locations | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 58,137 | 7 | |
5 | 21 | def get_feature_names_out(self, input_features=None):
powers = self.powers_
input_features = _check_feature_names_in(self, input_features)
feature_names = []
for row in powers:
inds = np.where(row)[0]
if len(inds):
name = " ".join(
... | sklearn/preprocessing/_polynomial.py | 176 | scikit-learn | {
"docstring": "Get output feature names for transformation.\n\n Parameters\n ----------\n input_features : array-like of str or None, default=None\n Input features.\n\n - If `input_features is None`, then `feature_names_in_` is\n used as feature names in. If `f... | 51 | Python | 41 | 279388d9ed2ea83194dd45a2d78161be30b43aa7 | _polynomial.py | 259,120 | 17 | 111 | get_feature_names_out | https://github.com/scikit-learn/scikit-learn.git | DOC Improve get_feature_names_out docstrings (#22718)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> | 258 | 0 | 75,579 | 16 | |
1 | 17 | def squared_hinge(y_true, y_pred):
y_pred = tf.convert_to_tensor(y_pred)
y_true = tf.cast(y_true, y_pred.dtype)
y_true = _maybe_convert_labels(y_true)
return backend.mean(
tf.square(tf.maximum(1.0 - y_true * y_pred, 0.0)), axis=-1
)
@keras_export("keras.metrics.hinge", "keras.losses.h... | keras/losses.py | 125 | @keras_export("keras.metrics.hinge", "keras.losses.hinge")
@tf.__internal__.dispatch.add_dispatch_support | keras | {
"docstring": "Computes the squared hinge loss between `y_true` and `y_pred`.\n\n `loss = mean(square(maximum(1 - y_true * y_pred, 0)), axis=-1)`\n\n Standalone usage:\n\n >>> y_true = np.random.choice([-1, 1], size=(2, 3))\n >>> y_pred = np.random.random(size=(2, 3))\n >>> loss = tf.keras.losses.squa... | 26 | Python | 22 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | losses.py | 274,560 | 7 | 66 | squared_hinge | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 49 | 1 | 81,237 | 13 |
2 | 11 | async def results_directory(self) -> Path:
directory = Path(os.getcwd()) / ".prefect-results"
os.makedirs(directory, exist_ok=True)
for filename in os.listdir(directory):
os.unlink(directory / filename)
return directory
| tests/flow_runners/test_kubernetes.py | 85 | prefect | {
"docstring": "In order to share results reliably with the Kubernetes cluster, we need to be\n somehwere in the user's directory tree for the most cross-platform\n compatibilty. It's challenging to coordinate /tmp/ directories across systems",
"language": "en",
"n_whitespaces": 46,
"n_words": 33,... | 21 | Python | 19 | ab322ef9b1bb65887984854dc39b316f98da3b97 | test_kubernetes.py | 56,186 | 9 | 50 | results_directory | https://github.com/PrefectHQ/prefect.git | Allow Kubernetes users to customize or replace the Job manifest for flow runs
Adding support for either replacing the base `job=` for a KubernetesFlowRunner,
applying a list of RFC 6902 JSON patches provided by `customizations=`, or both.
This implements the core changes, while preserving backwards compatiblity with
t... | 67 | 0 | 11,458 | 11 | |
1 | 2 | def b(self):
return self["b"]
| packages/python/plotly/plotly/graph_objs/_carpet.py | 22 | plotly.py | {
"docstring": "\n A two dimensional array of y coordinates at each carpet point.\n\n The 'b' property is an array that may be specified as a tuple,\n list, numpy array, or pandas Series\n\n Returns\n -------\n numpy.ndarray\n ",
"language": "en",
"n_whitespaces": ... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _carpet.py | 226,416 | 2 | 11 | b | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 58,089 | 7 | |
1 | 2 | def simplify(self):
return self["simplify"]
| packages/python/plotly/plotly/graph_objs/scatter/_line.py | 22 | plotly.py | {
"docstring": "\n Simplifies lines by removing nearly-collinear points. When\n transitioning lines, it may be desirable to disable this so\n that the number of points along the resulting SVG path is\n unaffected.\n\n The 'simplify' property must be specified as a bool\n (eit... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _line.py | 233,420 | 2 | 11 | simplify | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 64,864 | 7 | |
8 | 27 | def set_active(self, index):
if index not in range(len(self.labels)):
raise ValueError(f'Invalid CheckButton index: {index}')
if colors.same_color(
self._crosses.get_facecolor()[index], colors.to_rgba("none")
):
self._crosses.get_facecolor()[inde... | lib/matplotlib/widgets.py | 295 | matplotlib | {
"docstring": "\n Toggle (activate or deactivate) a check button by index.\n\n Callbacks will be triggered if :attr:`eventson` is True.\n\n Parameters\n ----------\n index : int\n Index of the check button to toggle.\n\n Raises\n ------\n ValueError\... | 47 | Python | 37 | 723cd86d7d7bdc14a4d3fc0e08c3a01e72d310b6 | widgets.py | 110,191 | 18 | 174 | set_active | https://github.com/matplotlib/matplotlib.git | Use scatter for check boxes instead of Rectangle
With the current implementation, the boxes get stretched into rectangles
if the aspect ratio is not maintained. To overcome this, the boxes are
now created using scatter instead to maintain their shapes. | 249 | 0 | 23,965 | 17 | |
4 | 10 | def column_partitions(cls, partitions, full_axis=True):
if not isinstance(partitions, list):
partitions = [partitions]
return [
cls._column_partitions_class(col, full_axis=full_axis)
for frame in partitions
for col in frame.T
]
| modin/core/dataframe/pandas/partitioning/partition_manager.py | 74 | modin | {
"docstring": "\n Get the list of `BaseDataframeAxisPartition` objects representing column-wise paritions.\n\n Parameters\n ----------\n partitions : list-like\n List of (smaller) partitions to be combined to column-wise partitions.\n full_axis : bool, default: True\n ... | 24 | Python | 21 | 8d1004fdbdaa05700613c8e6287641a732acf606 | partition_manager.py | 153,178 | 8 | 49 | column_partitions | https://github.com/modin-project/modin.git | FIX-#3675: Expand virtual partitioning utility (#3886)
Co-authored-by: mvashishtha <mahesh@ponder.io>
Co-authored-by: jeffreykennethli <jkli@ponder.io>
Co-authored-by: Anatoly Myachev <anatoly.myachev@intel.com>
Co-authored-by: Vasily Litvinov <vasilij.n.litvinov@intel.com>
Co-authored-by: Alexey Prutskov <alexey.... | 96 | 0 | 35,281 | 9 | |
16 | 13 | def token_kwargs(bits, parser, support_legacy=False):
if not bits:
return {}
match = kwarg_re.match(bits[0])
kwarg_format = match and match[1]
if not kwarg_format:
if not support_legacy:
return {}
if len(bits) < 3 or bits[1] != "as":
return {}
kw... | django/template/base.py | 303 | django | {
"docstring": "\n Parse token keyword arguments and return a dictionary of the arguments\n retrieved from the ``bits`` token list.\n\n `bits` is a list containing the remainder of the token (split by spaces)\n that is to be checked for arguments. Valid arguments are removed from this\n list.\n\n `s... | 95 | Python | 40 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | base.py | 206,187 | 29 | 188 | token_kwargs | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 334 | 0 | 51,399 | 14 | |
1 | 2 | def xpad(self):
return self["xpad"]
| packages/python/plotly/plotly/graph_objs/bar/marker/_colorbar.py | 22 | plotly.py | {
"docstring": "\n Sets the amount of padding (in px) along the x direction.\n\n The 'xpad' property is a number and may be specified as:\n - An int or float in the interval [0, inf]\n\n Returns\n -------\n int|float\n ",
"language": "en",
"n_whitespaces": 87,
... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _colorbar.py | 228,737 | 2 | 11 | xpad | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 60,410 | 7 | |
6 | 6 | async def load(self) -> bool:
if not self.name and self.flow_name:
raise ValueError("Both a deployment name and flow name must be provided.") | src/prefect/deployments.py | 43 | prefect | {
"docstring": "\n Queries the API for a deployment with this name for this flow, and if found, prepopulates\n settings. Returns a boolean specifying whether a load was successful or not.\n ",
"language": "en",
"n_whitespaces": 51,
"n_words": 28,
"vocab_size": 24
} | 21 | Python | 19 | f107fb0dcffae284cbefd7590274087b147c8483 | deployments.py | 58,295 | 34 | 159 | load | https://github.com/PrefectHQ/prefect.git | Implement load and update methods on deployment objects | 46 | 0 | 11,750 | 10 | |
1 | 27 | async def test_homeassistant_bridge_fan_setup(hass):
accessories = await setup_accessories_from_file(
hass, "home_assistant_bridge_fan.json"
)
await setup_test_accessories(hass, accessories)
await assert_devices_and_entities_created(
hass,
DeviceTestInfo(
unique... | tests/components/homekit_controller/specific_devices/test_homeassistant_bridge.py | 257 | core | {
"docstring": "Test that a SIMPLEconnect fan can be correctly setup in HA.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 66 | Python | 50 | f23b1750e85f07091eb896a0b12b8f95e5646338 | test_homeassistant_bridge.py | 288,865 | 46 | 156 | test_homeassistant_bridge_fan_setup | https://github.com/home-assistant/core.git | Migrate HomeKit Controller to use stable identifiers (#80064) | 828 | 0 | 88,014 | 23 | |
1 | 2 | def get_progressbar_class():
@hookspec | src/ocrmypdf/pluginspec.py | 16 | @hookspec | OCRmyPDF | {
"docstring": "Called to obtain a class that can be used to monitor progress.\n\n A progress bar is assumed, but this could be used for any type of monitoring.\n\n The class should follow a tqdm-like protocol. Calling the class should return\n a new progress bar object, which is activated with ``__enter__``... | 3 | Python | 3 | 1950acfbda3a659ca70658c848f900306ab2e35e | pluginspec.py | 30,502 | 1 | 5 | get_progressbar_class | https://github.com/ocrmypdf/OCRmyPDF.git | docs: proofread plugins | 5 | 1 | 5,624 | 6 |
1 | 4 | def test_context_placement_group():
driver_code =
proc = run_string_as_driver_nonblocking(driver_code)
| python/ray/data/tests/test_context_propagation.py | 27 | ray | {
"docstring": "\nimport ray\nfrom ray.data.context import DatasetContext\nfrom ray.util.scheduling_strategies import PlacementGroupSchedulingStrategy\nfrom ray._private.test_utils import placement_group_assert_no_leak\n\nray.init(num_cpus=1)\n\ncontext = DatasetContext.get_current()\n# This placement group will take... | 7 | Python | 6 | 68d4dd3a8b2defa5549cfa70e59aa26f2d4825a3 | test_context_propagation.py | 139,754 | 30 | 23 | test_context_placement_group | https://github.com/ray-project/ray.git | [Datasets] Add explicit resource allocation option via a top-level scheduling strategy (#24438)
Instead of letting Datasets implicitly use cluster resources in the margins of explicit allocations of other libraries, such as Tune, Datasets should provide an option for explicitly allocating resources for a Datasets work... | 13 | 0 | 31,769 | 8 | |
4 | 13 | def child_identifiers(self):
used_names = set()
result = []
for panel in self.children:
base_name = panel.clean_name or "panel"
candidate_name = base_name
suffix = 0
while candidate_name in used_names:
suffix += 1
... | wagtail/admin/panels.py | 113 | wagtail | {
"docstring": "\n A list of identifiers corresponding to child panels in ``self.children``, formed from the clean_name property\n but validated to be unique and non-empty.\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 22,
"vocab_size": 21
} | 40 | Python | 29 | 5521e3b59f45af830ebac3c5686e092616eb82e4 | panels.py | 78,837 | 13 | 66 | child_identifiers | https://github.com/wagtail/wagtail.git | Update panel templates for new designs (EditHandler rewrite)
Co-authored-by: Thibaud Colas <thibaudcolas@gmail.com> | 171 | 0 | 16,826 | 12 | |
1 | 7 | def standard_b64decode(s):
return b64decode(s)
_urlsafe_encode_translation = bytes.maketrans(b'+/', b'-_')
_urlsafe_decode_translation = bytes.maketrans(b'-_', b'+/')
| python3.10.4/Lib/base64.py | 59 | XX-Net | {
"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... | 12 | Python | 11 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | base64.py | 221,074 | 2 | 11 | standard_b64decode | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 16 | 0 | 56,186 | 7 | |
1 | 7 | def test_logout_doesnt_cache(self):
response = self.client.get("/logout/")
self.assertIn("no-store", response.headers["Cache-Control"])
| tests/auth_tests/test_views.py | 54 | django | {
"docstring": "\n The logout() view should send \"no-cache\" headers for reasons described\n in #25490.\n ",
"language": "en",
"n_whitespaces": 34,
"n_words": 12,
"vocab_size": 12
} | 7 | Python | 7 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | test_views.py | 201,610 | 3 | 29 | test_logout_doesnt_cache | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 28 | 0 | 49,975 | 9 | |
4 | 10 | def reset_page_edit_handler_cache(**kwargs):
if kwargs["setting"] == "WAGTAILADMIN_COMMENTS_ENABLED":
set_default_page_edit_handlers(Page)
for model in apps.get_models():
if issubclass(model, Page):
model.get_edit_handler.cache_clear()
| wagtail/admin/edit_handlers.py | 76 | wagtail | {
"docstring": "\n Clear page edit handler cache when global WAGTAILADMIN_COMMENTS_ENABLED settings are changed\n ",
"language": "en",
"n_whitespaces": 18,
"n_words": 11,
"vocab_size": 11
} | 15 | Python | 14 | d10f15e55806c6944827d801cd9c2d53f5da4186 | edit_handlers.py | 71,107 | 6 | 43 | reset_page_edit_handler_cache | https://github.com/wagtail/wagtail.git | Reformat with black | 61 | 0 | 15,624 | 14 | |
5 | 26 | def coefficient_system(f, params):
r
if isinstance(f, Eq):
# got equation, so move all the
# terms to the left hand side
f = f.lhs - f.rhs
syms = set(params)
# e.g. A*exp(x) + B - (exp(x) + y)
fex = _mexpand(f, recursive=True)
# -(exp(x) + y), A*exp(x) + B
_, dep = fe... | sympy/solvers/solvers.py | 180 | sympy | {
"docstring": "Return a set of equations which can be solved to determine\n values for undetermined coefficients in an equation like\n $p(x; a_1, \\ldots, a_k) = q(x)$ where both\n $p$ and $q$ are univariate expressions (polynomial in generators of $x$\n but not necessarily in powers of $x$) that depend ... | 112 | Python | 78 | 44b65804ef1e39f99a890cac82b6d5143251173b | solvers.py | 198,556 | 45 | 107 | coefficient_system | https://github.com/sympy/sympy.git | update free symbol idiom | 223 | 0 | 48,999 | 10 | |
4 | 8 | def _iter_built_with_prepended(installed, infos):
# type: (Candidate, Iterator[IndexCandidateInfo]) -> Iterator[Candidate]
yield installed
versions_found = {installed.version} # type: Set[_BaseVersion]
for version, func in infos:
if version in versions_found:
continue
c... | .venv/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py | 85 | transferlearning | {
"docstring": "Iterator for ``FoundCandidates``.\n\n This iterator is used when the resolver prefers the already-installed\n candidate and NOT to upgrade. The installed candidate is therefore\n always yielded first, and candidates from index come later in their\n normal ordering, except skipped when the ... | 38 | Python | 29 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | found_candidates.py | 61,120 | 11 | 49 | _iter_built_with_prepended | https://github.com/jindongwang/transferlearning.git | upd; format | 111 | 0 | 12,415 | 10 | |
4 | 11 | def patch_response_headers(response, cache_timeout=None):
if cache_timeout is None:
cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
if cache_timeout < 0:
cache_timeout = 0 # Can't have max-age negative
if not response.has_header("Expires"):
response.headers["Expires"] = http_... | django/utils/cache.py | 106 | django | {
"docstring": "\n Add HTTP caching headers to the given HttpResponse: Expires and\n Cache-Control.\n\n Each header is only added if it isn't already set.\n\n cache_timeout is in seconds. The CACHE_MIDDLEWARE_SECONDS setting is used\n by default.\n ",
"language": "en",
"n_whitespaces": 51,
"n_... | 32 | Python | 25 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | cache.py | 206,576 | 8 | 62 | patch_response_headers | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 69 | 0 | 51,574 | 13 | |
1 | 5 | def data(self) -> 'DataRequest._DataContent':
return DataRequest._DataContent(self.proto.data)
| jina/types/request/data.py | 35 | jina | {
"docstring": "Get the data contaned in this data request\n\n :return: the data content as an instance of _DataContent wrapping docs and groundtruths\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 21,
"vocab_size": 18
} | 6 | Python | 6 | 933415bfa1f9eb89f935037014dfed816eb9815d | data.py | 9,959 | 6 | 19 | data | https://github.com/jina-ai/jina.git | 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 ... | 20 | 0 | 1,807 | 9 | |
1 | 12 | def test_export_too_many_fields(self):
payload = self.make_payload("discover", {"field": ["id"] * (MAX_FIELDS + 1)})
with self.feature("organizations:discover-query"):
response = self.get_error_response(self.org.slug, status_code=400, **payload)
assert response.data == {
... | tests/sentry/data_export/endpoints/test_data_export.py | 119 | sentry | {
"docstring": "\n Ensures that if too many fields are requested, returns a 400 status code with the\n corresponding error message.\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 18,
"vocab_size": 18
} | 42 | Python | 41 | 096b5511e244eecd8799b2a0324655207ce8985e | test_data_export.py | 100,174 | 9 | 67 | test_export_too_many_fields | https://github.com/getsentry/sentry.git | ref(tests): Remove `get_valid_response()` (#34822) | 125 | 0 | 19,768 | 13 | |
1 | 12 | def test_delete_missing_current_version(self) -> None:
e = self.get_failure(self.handler.delete_version(self.local_user), SynapseError)
res = e.value.code
self.assertEqual(res, 404)
| tests/handlers/test_e2e_room_keys.py | 68 | synapse | {
"docstring": "Check that we get a 404 on deleting nonexistent current version",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 13 | Python | 12 | 652d1669c5a103b1c20478770c4aaf18849c09a3 | test_e2e_room_keys.py | 250,286 | 5 | 42 | test_delete_missing_current_version | https://github.com/matrix-org/synapse.git | Add missing type hints to tests.handlers. (#14680)
And do not allow untyped defs in tests.handlers. | 41 | 0 | 73,364 | 11 | |
3 | 20 | def test_write_animation_L(tmp_path):
with Image.open("Tests/images/iss634.gif") as orig:
assert orig.n_frames > 1
temp_file = str(tmp_path / "temp.webp")
orig.save(temp_file, save_all=True)
with Image.open(temp_file) as im:
assert im.n_frames == orig.n_frames
... | Tests/test_file_webp_animated.py | 261 | Pillow | {
"docstring": "\n Convert an animated GIF to animated WebP, then compare the frame count, and first\n and last frames to ensure they're visually similar.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 22,
"vocab_size": 19
} | 62 | Python | 48 | e05b8d74819fa18a908ea201a86138ea3168aba9 | test_file_webp_animated.py | 242,282 | 19 | 153 | test_write_animation_L | https://github.com/python-pillow/Pillow.git | libwebp 1.2.2 fixed endian bugs | 266 | 0 | 69,817 | 17 | |
2 | 28 | async def install_protected_system_blocks(session):
for block in [
prefect.blocks.system.JSON,
prefect.blocks.system.DateTime,
prefect.blocks.system.Secret,
prefect.filesystems.LocalFileSystem,
prefect.infrastructure.Process,
]:
block_type = block._to_block_t... | src/prefect/orion/api/block_types.py | 183 | @router.post("/install_system_block_types") | prefect | {
"docstring": "Install block types that the system expects to be present",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 36 | Python | 29 | 1a3a3adf0bf4d83206f0367b98905a9db15cfec4 | block_types.py | 58,977 | 18 | 112 | install_protected_system_blocks | https://github.com/PrefectHQ/prefect.git | Adds ability to delete block types via the CLI (#6849)
* Ensure system blocks are protected on destructive API calls
* Enable deleting block types
* Ensure Block Types are protected against destructive API actions
* Ensure updating protected Block Types on update doesn't impact saving
* ⚫
* isort
* S... | 165 | 1 | 11,846 | 16 |
3 | 7 | def pretty_duration(hours):
seconds = int(3600 * hours)
days, seconds = divmod(seconds, 86400)
hours, seconds = divmod(seconds, 3600)
minutes, seconds = divmod(seconds, 60)
if days > 0:
return "%dd %dh %dm" % (days, hours, minutes)
if hours > 0:
... | homeassistant/components/history_stats/helpers.py | 123 | core | {
"docstring": "Format a duration in days, hours, minutes, seconds.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 48 | Python | 30 | 73a368c24246b081cdb98923ca3180937d436c3b | helpers.py | 296,854 | 10 | 76 | pretty_duration | https://github.com/home-assistant/core.git | Refactor history_stats to minimize database access (part 2) (#70255) | 126 | 0 | 95,828 | 9 | |
1 | 8 | def deserialize(name, custom_objects=None):
return deserialize_keras_object(
name,
module_objects=globals(),
custom_objects=custom_objects,
printable_module_name="loss function",
)
@keras_export("keras.losses.get") | keras/losses.py | 59 | @keras_export("keras.losses.get") | keras | {
"docstring": "Deserializes a serialized loss class/function instance.\n\n Args:\n name: Loss configuration.\n custom_objects: Optional dictionary mapping names (strings) to custom\n objects (classes and functions) to be considered during deserialization.\n\n Returns:\n A Keras `L... | 12 | Python | 12 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | losses.py | 274,546 | 7 | 30 | deserialize | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 48 | 1 | 81,224 | 10 |
1 | 10 | def paths_check(app_configs, **kwargs):
return (
path_check("PAPERLESS_DATA_DIR", settings.DATA_DIR)
+ path_check("PAPERLESS_TRASH_DIR", settings.TRASH_DIR)
+ path_check("PAPERLESS_MEDIA_ROOT", settings.MEDIA_ROOT)
+ path_check("PAPERLESS_CONSUMPTION_DIR", settings.CONSUMPTION_... | src/paperless/checks.py | 88 | @register() | paperless-ngx | {
"docstring": "\n Check the various paths for existence, readability and writeability\n ",
"language": "en",
"n_whitespaces": 16,
"n_words": 9,
"vocab_size": 9
} | 18 | Python | 16 | fc695896dd8b0169001c438054a79e347053fac6 | checks.py | 318,780 | 7 | 47 | paths_check | https://github.com/paperless-ngx/paperless-ngx.git | Format Python code with black | 54 | 1 | 116,915 | 12 |
3 | 12 | def extract_operations(self) -> List[str]:
if not self.step:
return []
try:
operations = re.findall(r'[-+*^/]', self.step)
except TypeError as e:
print(f"TYPE: {type(self.step)}")
print(f"STEP: {self.step}")
raise e
ret... | parlai/tasks/reasoning/reason_types/step_by_step.py | 111 | ParlAI | {
"docstring": "\n Finds all instances of the math operations: -, +, *, ^, / in the step.\n ",
"language": "en",
"n_whitespaces": 30,
"n_words": 15,
"vocab_size": 14
} | 26 | Python | 24 | 0f129e9c38b6b10d80982ecc412785db62842938 | step_by_step.py | 195,437 | 13 | 54 | extract_operations | https://github.com/facebookresearch/ParlAI.git | ROSCOE suite of metrics (#4839)
* ROSCOE suite of metrics
* updating tests
* lint
* fixing protobuf version to stop cleaninstall failures
* updating requirements
* convert to absolute path
* moving tests because of the dependency issues
* adding new dependencies in tests
* add test dependencies... | 116 | 0 | 47,260 | 15 | |
2 | 17 | def _metadata_reader(self) -> ImgMetaType:
for filename, metadata in tqdm(read_image_meta_batch(self._loader.file_list),
total=self._loader.count,
desc=self._description,
leave=False):
... | tools/sort/sort_methods.py | 102 | faceswap | {
"docstring": " Load metadata from saved aligned faces\n\n Yields\n ------\n filename: str\n The filename that has been read\n image: None\n This will always be ``None`` with the metadata reader\n alignments: dict or ``None``\n The alignment data fo... | 20 | Python | 18 | 98d01760e469fd2108eed8d0b0a1ba6297c3177c | sort_methods.py | 101,620 | 18 | 65 | _metadata_reader | https://github.com/deepfakes/faceswap.git | 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 | 170 | 0 | 21,028 | 13 | |
20 | 30 | def _parse_jp2_header(fp):
# Find the JP2 header box
reader = BoxReader(fp)
header = None
mimetype = None
while reader.has_next_box():
tbox = reader.next_box_type()
if tbox == b"jp2h":
header = reader.read_boxes()
break
elif tbox == b"ftyp":
... | src/PIL/Jpeg2KImagePlugin.py | 476 | Pillow | {
"docstring": "Parse the JP2 header box to extract size, component count,\n color space information, and optionally DPI information,\n returning a (size, mode, mimetype, dpi) tuple.",
"language": "en",
"n_whitespaces": 29,
"n_words": 24,
"vocab_size": 23
} | 198 | Python | 101 | ee85e387bab535e2339b9d3cd1ab87c61d23af15 | Jpeg2KImagePlugin.py | 242,745 | 46 | 285 | _parse_jp2_header | https://github.com/python-pillow/Pillow.git | Remove redundant parentheses | 658 | 0 | 69,908 | 18 | |
1 | 7 | def sparsemax_bisect(X, dim=-1, n_iter=50, ensure_sum_one=True):
return SparsemaxBisectFunction.apply(X, dim, n_iter, ensure_sum_one)
| ludwig/utils/entmax/root_finding.py | 47 | ludwig | {
"docstring": "sparsemax: normalizing sparse transform (a la softmax), via bisection.\n\n Solves the projection:\n\n min_p ||x - p||_2 s.t. p >= 0, sum(p) == 1.\n\n Parameters\n ----------\n X : torch.Tensor\n The input tensor.\n\n dim : int\n The dimension along which to app... | 10 | Python | 10 | 20a8a6fdb516e543d4598c852063ba0fb407f3ba | root_finding.py | 6,299 | 2 | 32 | sparsemax_bisect | https://github.com/ludwig-ai/ludwig.git | Removes dependency on entmax from PyPI, adds entmax source to utils (#1778)
* Removes dependency on entmax from PyPi, add entmax source code into utils instead.
* Removes build status and image from README
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
... | 16 | 0 | 957 | 7 | |
2 | 7 | async def async_load(self) -> _T | None:
if self._load_task is None:
self._load_task = self.hass.async_create_task(self._async_load())
return await self._load_task
| homeassistant/helpers/storage.py | 65 | core | {
"docstring": "Load data.\n\n If the expected version and minor version do not match the given versions, the\n migrate function will be invoked with migrate_func(version, minor_version, config).\n\n Will ensure that when a call comes in while another one is in progress,\n the second call ... | 17 | Python | 14 | 16900dcef15bdb9016feabd12bfec94d61ed4df6 | storage.py | 316,852 | 12 | 38 | async_load | https://github.com/home-assistant/core.git | Make Store a generic class (#74617) | 49 | 0 | 115,428 | 12 | |
3 | 17 | def get_ld_headers(file):
# get_ld_headers parsing:
# 1. Find a line that starts with /, ./, or ../ - set as ld_header
# 2. If "INDEX" in occurs in a following line - return ld_header
# 3. get info (lines starting with [0-9])
ldr_headers = []
p = Popen(["/usr/bin/dump", f"-X{AIX_ABI}", "-H"... | python3.10.4/Lib/ctypes/_aix.py | 139 | XX-Net | {
"docstring": "\n Parse the header of the loader section of executable and archives\n This function calls /usr/bin/dump -H as a subprocess\n and returns a list of (ld_header, ld_header_info) tuples.\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 27,
"vocab_size": 22
} | 81 | Python | 64 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | _aix.py | 221,795 | 13 | 79 | get_ld_headers | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 167 | 0 | 56,514 | 14 | |
6 | 24 | def make_variant_item_code(template_item_code, template_item_name, variant):
if variant.item_code:
return
abbreviations = []
for attr in variant.attributes:
item_attribute = frappe.db.sql(
,
{"attribute": attr.attribute, "attribute_value": attr.attribute_value},
as_dict=True,
)
if not item_attri... | erpnext/controllers/item_variant.py | 224 | @frappe.whitelist() | erpnext | {
"docstring": "Uses template's item code and abbreviations to make variant's item codeselect i.numeric_values, v.abbr\n\t\t\tfrom `tabItem Attribute` i left join `tabItem Attribute Value` v\n\t\t\t\ton (i.name=v.parent)\n\t\t\twhere i.name=%(attribute)s and (v.attribute_value=%(attribute_value)s or i.numeric_values ... | 60 | Python | 49 | 494bd9ef78313436f0424b918f200dab8fc7c20b | item_variant.py | 65,630 | 22 | 128 | make_variant_item_code | https://github.com/frappe/erpnext.git | style: format code with black | 37 | 1 | 13,962 | 13 |
1 | 10 | def Generate(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
| server/bloom_inference/pb/generate_pb2_grpc.py | 55 | text-generation-inference | {
"docstring": "/ Generate tokens for a batch without cache\n ",
"language": "en",
"n_whitespaces": 15,
"n_words": 8,
"vocab_size": 8
} | 12 | Python | 10 | 295831a481241d3d06b49f646a40f27b1297fab5 | generate_pb2_grpc.py | 338,490 | 4 | 31 | Generate | https://github.com/huggingface/text-generation-inference.git | Init | 40 | 0 | 121,221 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.