complexity int64 1 56 | n_identifiers int64 1 114 | code stringlengths 19 12.7k | path stringlengths 8 134 | n_ast_nodes int64 12 2.35k | ast_errors stringlengths 0 4.01k | repo stringlengths 3 28 | documentation dict | n_words int64 2 866 | language stringclasses 1
value | vocab_size int64 2 323 | commit_id stringlengths 40 40 | file_name stringlengths 5 79 | id int64 243 338k | nloc int64 1 228 | token_counts int64 5 1.4k | fun_name stringlengths 1 77 | url stringlengths 31 60 | commit_message stringlengths 3 15.3k | n_whitespaces int64 1 3.23k | n_ast_errors int64 0 20 | d_id int64 74 121k | ast_levels int64 4 29 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 9 | def dist_from_wheel_url(name, url, session):
# type: (str, str, PipSession) -> Distribution
with LazyZipOverHTTP(url, session) as wheel:
# For read-only ZIP files, ZipFile only needs methods read,
# seek, seekable and tell, not the whole IO protocol.
zip_file = ZipFile(wheel) # typ... | .venv/lib/python3.8/site-packages/pip/_internal/network/lazy_wheel.py | 66 | transferlearning | {
"docstring": "Return a pkg_resources.Distribution from the given wheel URL.\n\n This uses HTTP range requests to only fetch the potion of the wheel\n containing metadata, just enough for the object to be constructed.\n If such requests are not supported, HTTPRangeRequestUnsupported\n is raised.\n ",
... | 59 | Python | 53 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | lazy_wheel.py | 60,904 | 4 | 37 | dist_from_wheel_url | https://github.com/jindongwang/transferlearning.git | upd; format | 111 | 0 | 12,335 | 10 | |
3 | 6 | def _configure_experiment_defaults(self):
for option in self._exclude_autolog:
if not self.experiment_kwargs.get(option):
self.experiment_kwargs[option] = False
| python/ray/tune/integration/comet.py | 53 | ray | {
"docstring": "Disable the specific autologging features that cause throttling.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 12 | Python | 12 | 3d79815cd08c1be8e56c245e662f34366523847e | comet.py | 129,598 | 4 | 32 | _configure_experiment_defaults | https://github.com/ray-project/ray.git | Comet Integration (#20766)
This PR adds a `CometLoggerCallback` to the Tune Integrations, allowing users to log runs from Ray to [Comet](https://www.comet.ml/site/).
Co-authored-by: Michael Cullan <mjcullan@gmail.com>
Co-authored-by: Antoni Baum <antoni.baum@protonmail.com> | 52 | 0 | 28,986 | 12 | |
2 | 15 | def add_group_component(self, components, name, group):
new_comp = components[components['component'].isin(set(group))].copy()
group_cols = new_comp['col'].unique()
if len(group_cols) > 0:
new_comp = pd.DataFrame({'col': group_cols, 'component': name})
components... | python/prophet/forecaster.py | 134 | prophet | {
"docstring": "Adds a component with given name that contains all of the components\n in group.\n\n Parameters\n ----------\n components: Dataframe with components.\n name: Name of new group component.\n group: List of components that form the group.\n\n Returns\n ... | 27 | Python | 22 | 10310ceb2da05837a198db6714d658a1e0a32478 | forecaster.py | 3,286 | 7 | 81 | add_group_component | https://github.com/facebook/prophet.git | Change deprecated `append` to `concat` (#2114) | 84 | 0 | 429 | 13 | |
3 | 15 | def permission_denied(request, exception, template_name=ERROR_403_TEMPLATE_NAME):
try:
template = loader.get_template(template_name)
except TemplateDoesNotExist:
if template_name != ERROR_403_TEMPLATE_NAME:
# Reraise if it's a missing custom template.
raise
r... | django/views/defaults.py | 128 | django | {
"docstring": "\n Permission denied (403) handler.\n\n Templates: :template:`403.html`\n Context:\n exception\n The message from the exception which triggered the 403 (if one was\n supplied).\n\n If the template does not exist, an Http403 response containing the text\n \"4... | 40 | Python | 36 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | defaults.py | 206,834 | 13 | 74 | permission_denied | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 134 | 0 | 51,740 | 14 | |
1 | 6 | def transpose_qkv(X, num_heads):
# Shape of input `X`:
# (`batch_size`, no. of queries or key-value pairs, `num_hiddens`).
# Shape of output `X`:
# (`batch_size`, no. of queries or key-value pairs, `num_heads`,
# `num_hiddens` / `num_heads`)
X = X.reshape(X.shape[0], X.shape[1], num_heads, ... | d2l/mxnet.py | 111 | d2l-zh | {
"docstring": "Transposition for parallel computation of multiple attention heads.\n\n Defined in :numref:`sec_multihead-attention`",
"language": "en",
"n_whitespaces": 13,
"n_words": 11,
"vocab_size": 11
} | 87 | Python | 37 | b64b41d8c1ac23c43f7a4e3f9f6339d6f0012ab2 | mxnet.py | 158,149 | 4 | 69 | transpose_qkv | https://github.com/d2l-ai/d2l-zh.git | [PaddlePaddle] Merge master into Paddle branch (#1186)
* change 15.2 title in chinese version (#1109)
change title ’15.2. 情感分析:使用递归神经网络‘ to ’15.2. 情感分析:使用循环神经网络‘
* 修改部分语义表述 (#1105)
* Update r0.17.5 (#1120)
* Bump versions in installation
* 94行typo: (“bert.mall”)->(“bert.small”) (#1129)
* line 313: "b... | 132 | 0 | 37,330 | 10 | |
1 | 14 | async def test_device_diagnostics_error(hass, integration):
dev_reg = async_get(hass)
device = dev_reg.async_get_or_create(
config_entry_id=integration.entry_id, identifiers={("test", "test")}
)
with pytest.raises(ValueError):
await async_get_device_diagnostics(hass, integration, de... | tests/components/zwave_js/test_diagnostics.py | 90 | core | {
"docstring": "Test the device diagnostics raises exception when an invalid device is used.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 11
} | 20 | Python | 19 | 11d0dcf7ac4ddc2638f403ef0ee6b796ac5bbceb | test_diagnostics.py | 310,240 | 7 | 53 | test_device_diagnostics_error | https://github.com/home-assistant/core.git | Add zwave_js device diagnostics (#64504)
* Add zwave_js device diagnostics
* Add diagnostics as a dependency in manifest
* Add failure scenario test
* fix device diagnostics helper and remove dependency
* tweak | 49 | 0 | 108,926 | 12 | |
1 | 4 | def set_runtime_library_dirs(self, dirs):
self.runtime_library_dirs = dirs[:]
| python3.10.4/Lib/distutils/ccompiler.py | 28 | XX-Net | {
"docstring": "Set the list of directories to search for shared libraries at\n runtime to 'dirs' (a list of strings). This does not affect any\n standard search path that the runtime linker may search by\n default.\n ",
"language": "en",
"n_whitespaces": 63,
"n_words": 34,
"vocab... | 6 | Python | 6 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | ccompiler.py | 222,570 | 2 | 16 | set_runtime_library_dirs | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 20 | 0 | 56,644 | 8 | |
1 | 3 | def exec(self):
raise NotImplementedError
| ppg2mel/train/solver.py | 16 | MockingBird | {
"docstring": "\n Called by main to execute training/inference\n ",
"language": "en",
"n_whitespaces": 21,
"n_words": 6,
"vocab_size": 6
} | 4 | Python | 4 | b617a87ee40ab384767a27335313c2c65ee094ec | solver.py | 161,034 | 2 | 8 | exec | 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 | 18 | 0 | 38,858 | 6 | |
2 | 16 | def _gen_md5_for_arraylike_obj(md5_gen, data):
import numpy as np
len_bytes = _hash_uint64_ndarray_as_bytes(np.array([len(data)], dtype="uint64"))
md5_gen.update(len_bytes)
if len(data) < EvaluationDataset.NUM_SAMPLE_ROWS_FOR_HASH * 2:
md5_gen.update(_hash_array_like_obj_as_bytes(data))
... | mlflow/models/evaluation/base.py | 163 | mlflow | {
"docstring": "\n Helper method to generate MD5 hash array-like object, the MD5 will calculate over:\n - array length\n - first NUM_SAMPLE_ROWS_FOR_HASH rows content\n - last NUM_SAMPLE_ROWS_FOR_HASH rows content\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 26,
"vocab_size": 20
} | 30 | Python | 28 | 964f5ab75098c55f028f8acfeeae05df35ea68d5 | base.py | 19,026 | 11 | 98 | _gen_md5_for_arraylike_obj | https://github.com/mlflow/mlflow.git | Evaluation Default evaluator (#5092)
* init
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
* update
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
* update
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
* update
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
* update... | 83 | 0 | 2,874 | 13 | |
18 | 35 | def fit(self, X, y, sample_weight=None):
allowed_strategies = ("mean", "median", "quantile", "constant")
if self.strategy not in allowed_strategies:
raise ValueError(
"Unknown strategy type: %s, expected one of %s."
% (self.strategy, allowed_strategie... | sklearn/dummy.py | 646 | scikit-learn | {
"docstring": "Fit the random regressor.\n\n Parameters\n ----------\n X : array-like of shape (n_samples, n_features)\n Training data.\n\n y : array-like of shape (n_samples,) or (n_samples, n_outputs)\n Target values.\n\n sample_weight : array-like of shape ... | 222 | Python | 128 | b28c5bba66529217ceedd497201a684e5d35b73c | dummy.py | 258,973 | 58 | 414 | fit | https://github.com/scikit-learn/scikit-learn.git | FIX DummyRegressor overriding constant (#22486) | 944 | 0 | 75,502 | 17 | |
6 | 15 | def _normalize_mode(im):
if im.mode in RAWMODE:
im.load()
return im
if Image.getmodebase(im.mode) == "RGB":
im = im.convert("P", palette=Image.Palette.ADAPTIVE)
if im.palette.mode == "RGBA":
for rgba in im.palette.colors.keys():
if rgba[3] == 0:
... | src/PIL/GifImagePlugin.py | 173 | Pillow | {
"docstring": "\n Takes an image (or frame), returns an image in a mode that is appropriate\n for saving in a Gif.\n\n It may return the original image, or it may return an image converted to\n palette or 'L' mode.\n\n :param im: Image object\n :returns: Image object\n ",
"language": "en",
"... | 37 | Python | 26 | 76871795f787756ab1978772b53237948bec377a | GifImagePlugin.py | 242,620 | 13 | 103 | _normalize_mode | https://github.com/python-pillow/Pillow.git | Resolved UNDONE by removing code | 148 | 0 | 69,883 | 17 | |
6 | 14 | def iter_tree_files(root, on_error=None, follow_links=None):
if on_error is not None and not callable(on_error):
raise TypeError("on_error:{!r} is not callable.".format(on_error))
if follow_links is None:
follow_links = True
for entry in _iter_tree_entries_next(
os.path.abspat... | python/ray/_private/thirdparty/pathspec/util.py | 136 | ray | {
"docstring": "\n Walks the specified directory for all files.\n\n *root* (:class:`str`) is the root directory to search for files.\n\n *on_error* (:class:`~collections.abc.Callable` or :data:`None`)\n optionally is the error handler for file-system exceptions. It will be\n called with the exception (... | 47 | Python | 37 | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | util.py | 130,275 | 10 | 81 | iter_tree_files | https://github.com/ray-project/ray.git | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 99 | 0 | 29,200 | 12 | |
1 | 2 | def insidetextorientation(self):
return self["insidetextorientation"]
| packages/python/plotly/plotly/graph_objs/_pie.py | 22 | plotly.py | {
"docstring": "\n Controls the orientation of the text inside chart sectors. When\n set to \"auto\", text may be oriented in any direction in order\n to be as big as possible in the middle of a sector. The\n \"horizontal\" option orients text to be parallel with the bottom\n of the... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _pie.py | 227,576 | 2 | 11 | insidetextorientation | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 59,249 | 7 | |
34 | 11 | def forgeHeaders(items=None, base=None):
items = items or {}
for _ in list(items.keys()):
if items[_] is None:
del items[_]
headers = OrderedDict(conf.httpHeaders if base is None else base)
headers.update(items.items())
| lib/request/basic.py | 107 | sqlmap | {
"docstring": "\n Prepare HTTP Cookie, HTTP User-Agent and HTTP Referer headers to use when performing\n the HTTP requests\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 16,
"vocab_size": 13
} | 28 | Python | 23 | 216565fb05166d4bcf80b35a4f8f381e9f6b3d08 | basic.py | 123,858 | 53 | 506 | forgeHeaders | https://github.com/sqlmapproject/sqlmap.git | Fixes #5275 | 61 | 0 | 27,460 | 10 | |
15 | 35 | def update(self, value=None, values=None, disabled=None, visible=None, size=(None, None)):
if not self._widget_was_created(): # if widget hasn't been created yet, then don't allow
return
if values is not None:
self.Values = values
self.TKOptionMenu['menu'].... | PySimpleGUI.py | 452 | PySimpleGUI | {
"docstring": "\n Changes some of the settings for the OptionMenu Element. Must call `Window.Read` or `Window.Finalize` prior\n\n Changes will not be visible in your window until you call window.read or window.refresh.\n\n If you change visibility, your element may MOVE. If you want it to remain... | 160 | Python | 96 | ed2bc288ff17344f6406c49623036620f18e65bb | PySimpleGUI.py | 212,851 | 52 | 270 | update | https://github.com/PySimpleGUI/PySimpleGUI.git | Completed switching all elements over to the new way of handling visiblity | 628 | 0 | 53,459 | 18 | |
1 | 7 | def hermite_prob_poly(n, x=None, polys=False):
r
return named_poly(n, dup_hermite_prob, ZZ,
"probabilist's Hermite polynomial", (x,), polys)
| sympy/polys/orthopolys.py | 47 | sympy | {
"docstring": "Generates the probabilist's Hermite polynomial `He_n(x)`.\n\n Parameters\n ==========\n\n n : int\n Degree of the polynomial.\n x : optional\n polys : bool, optional\n If True, return a Poly, otherwise (default) return an expression.\n ",
"language": "en",
"n_whites... | 14 | Python | 14 | 5c9a4787c032d39abb80aae106030b177263a7cc | orthopolys.py | 199,733 | 14 | 33 | hermite_prob_poly | https://github.com/sympy/sympy.git | Probabilist's Hermite polynomials
The plain or physicist's Hermite polynomials have leading coefficient
2^n, which leads to orthogonality with respect to the simplest possible
form of the weight function exp(-x^2) and is the specific normalisation
appearing in the solution to the Schrödinger equation for the quantum
h... | 30 | 0 | 49,380 | 8 | |
2 | 10 | def dijkstra_predecessor_and_distance(G, source, cutoff=None, weight="weight"):
if source not in G:
raise nx.NodeNotFound(f"Node {source} is not found in the graph")
weight = _weight_function(G, weight)
pred = {source: []} # dictionary of predecessors
return (pred, _dijkstra(G, source, wei... | networkx/algorithms/shortest_paths/weighted.py | 106 | networkx | {
"docstring": "Compute weighted shortest path length and predecessors.\n\n Uses Dijkstra's Method to obtain the shortest weighted paths\n and return dictionaries of predecessors for each node and\n distance for each node from the `source`.\n\n Parameters\n ----------\n G : NetworkX graph\n\n sou... | 38 | Python | 34 | b7d65ffc7183e9a01cdc07b79f8f06403cc4dda4 | weighted.py | 176,660 | 6 | 67 | dijkstra_predecessor_and_distance | https://github.com/networkx/networkx.git | DOC: remove note re: non-existant param (#5648) | 61 | 0 | 42,028 | 11 | |
2 | 12 | def _chunk_positional_ranges(self) -> tuple[tuple[int, int], ...]:
ranges = []
stop = 0
for c in self._data.iterchunks():
start, stop = stop, stop + len(c)
ranges.append((start, stop))
return tuple(ranges)
| pandas/core/arrays/_mixins.py | 99 | pandas | {
"docstring": "\n Return a tuple of tuples each containing the left (inclusive)\n and right (exclusive) positional bounds of each chunk's values\n within the underlying ChunkedArray.\n\n Returns\n -------\n tuple[tuple]\n ",
"language": "en",
"n_whitespaces": 76,
... | 27 | Python | 23 | 2d6a2c3e981208bf67bdd36cca726e8a399e487c | _mixins.py | 165,733 | 16 | 63 | _chunk_positional_ranges | https://github.com/pandas-dev/pandas.git | REF: move ArrowStringArray.__setitem__ and related methods to ArrowExtensionArray (#46439) | 84 | 0 | 39,697 | 12 | |
4 | 24 | def _mesh(self):
y, extendlen = self._proportional_y()
# Use the vmin and vmax of the colorbar, which may not be the same
# as the norm. There are situations where the colormap has a
# narrower range than the colorbar and we want to accommodate the
# extra contours.
... | lib/matplotlib/colorbar.py | 239 | matplotlib | {
"docstring": "\n Return the coordinate arrays for the colorbar pcolormesh/patches.\n\n These are scaled between vmin and vmax, and already handle colorbar\n orientation.\n ",
"language": "en",
"n_whitespaces": 49,
"n_words": 20,
"vocab_size": 17
} | 134 | Python | 92 | fdb4ad372ab66177d99e478385c807e5843d6a0f | colorbar.py | 107,725 | 17 | 152 | _mesh | https://github.com/matplotlib/matplotlib.git | MNT: Use a context manager to change the norm in colorbar code
This removes a deepcopy of the norm in Colorbar, instead updating
the vmin/vmax via the context manager and ignoring any
callback updates in the process. | 429 | 0 | 22,892 | 14 | |
5 | 20 | def try_to_replace(self, provider, other, problems):
rlist = self.reqts[other]
unmatched = set()
for s in rlist:
matcher = self.get_matcher(s)
if not matcher.match(provider.version):
unmatched.add(s)
if unmatched:
# can't repla... | .venv/lib/python3.8/site-packages/pip/_vendor/distlib/locators.py | 202 | transferlearning | {
"docstring": "\n Attempt to replace one provider with another. This is typically used\n when resolving dependencies from multiple sources, e.g. A requires\n (B >= 1.0) while C requires (B >= 1.1).\n\n For successful replacement, ``provider`` must meet all the requirements\n which ... | 59 | Python | 40 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | locators.py | 62,006 | 19 | 126 | try_to_replace | https://github.com/jindongwang/transferlearning.git | upd; format | 284 | 0 | 12,817 | 16 | |
11 | 19 | def set_choices(self, choices, choices_names=None, none_choice_name=None):
self.unselect()
# Validate choices
if choices is None:
raise ValueError('Choices cannot be None.')
if not isinstance(choices, Iterable):
raise ValueErr... | xlib/mp/csw/DynamicSingleSwitch.py | 260 | DeepFaceLive | {
"docstring": "\n set choices, and optional choices_names.\n\n choices_names list/dict/None if list, should match the len of choices\n if dict, should return a str by key of choice\n if None, choices will b... | 97 | Python | 62 | ae8a1e0ff4b13e6e6a0155e346864805b2ca81dd | DynamicSingleSwitch.py | 179,085 | 20 | 160 | set_choices | https://github.com/iperov/DeepFaceLive.git | added Face Animator module | 364 | 0 | 42,898 | 13 | |
2 | 14 | def get_batches_by_oldest(item_code, warehouse):
batches = get_batch_qty(item_code=item_code, warehouse=warehouse)
batches_dates = [
[batch, frappe.get_value("Batch", batch.batch_no, "expiry_date")] for batch in batches
]
batches_dates.sort(key=lambda tup: tup[1])
return batches_dates
@frappe.whitelist() | erpnext/stock/doctype/batch/batch.py | 106 | @frappe.whitelist() | erpnext | {
"docstring": "Returns the oldest batch and qty for the given item_code and warehouse",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 10
} | 25 | Python | 22 | 494bd9ef78313436f0424b918f200dab8fc7c20b | batch.py | 67,582 | 7 | 60 | get_batches_by_oldest | https://github.com/frappe/erpnext.git | style: format code with black | 17 | 1 | 14,565 | 11 |
3 | 11 | def recover_args(flattened_args):
assert (
len(flattened_args) % 2 == 0
), "Flattened arguments need to be even-numbered. See `flatten_args`."
args = []
kwargs = {}
for name_index in range(0, len(flattened_args), 2):
name, arg = flattened_args[name_index], flattened_args[name_in... | python/ray/_private/signature.py | 128 | ray | {
"docstring": "Recreates `args` and `kwargs` from the flattened arg list.\n\n Args:\n flattened_args: List of args and kwargs. This should be the output of\n `flatten_args`.\n\n Returns:\n args: The non-keyword arguments passed into the function.\n kwargs: The keyword arguments ... | 49 | Python | 43 | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | signature.py | 130,222 | 13 | 80 | recover_args | https://github.com/ray-project/ray.git | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 120 | 0 | 29,164 | 12 | |
2 | 8 | def captured_output(stream_name):
# type: (str) -> Iterator[StreamWrapper]
orig_stdout = getattr(sys, stream_name)
setattr(sys, stream_name, StreamWrapper.from_stream(orig_stdout))
try:
yield getattr(sys, stream_name)
finally:
setattr(sys, stream_name, orig_stdout)
| .venv/lib/python3.8/site-packages/pip/_internal/utils/misc.py | 75 | transferlearning | {
"docstring": "Return a context manager used by captured_stdout/stdin/stderr\n that temporarily replaces the sys stream *stream_name* with a StringIO.\n\n Taken from Lib/support/__init__.py in the CPython repo.\n ",
"language": "en",
"n_whitespaces": 33,
"n_words": 24,
"vocab_size": 22
} | 22 | Python | 18 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | misc.py | 61,271 | 7 | 46 | captured_output | https://github.com/jindongwang/transferlearning.git | upd; format | 54 | 0 | 12,482 | 10 | |
1 | 2 | def _recreate_cm(self):
return self
| python3.10.4/Lib/contextlib.py | 16 | XX-Net | {
"docstring": "Return a recreated instance of self.\n\n Allows an otherwise one-shot context manager like\n _GeneratorContextManager to support use as\n a decorator via implicit recreation.\n\n This is a private interface just for _GeneratorContextManager.\n See issue #11647 for de... | 4 | Python | 4 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | contextlib.py | 221,732 | 2 | 8 | _recreate_cm | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 18 | 0 | 56,495 | 6 | |
24 | 40 | def _fill_disk_filename(conn, vm_name, disk, hypervisor, pool_caps):
# Compute the filename without extension since it may not make sense for some pool types
disk["filename"] = "{}_{}".format(vm_name, disk["name"])
# Compute the source file path
base_dir = disk.get("pool", None)
if hypervisor ... | salt/modules/virt.py | 924 | salt | {
"docstring": "\n Compute the disk file name and update it in the disk value.\n ",
"language": "en",
"n_whitespaces": 19,
"n_words": 12,
"vocab_size": 10
} | 328 | Python | 174 | f2a783643de61cac1ff3288b40241e5ce6e1ddc8 | virt.py | 215,962 | 60 | 518 | _fill_disk_filename | https://github.com/saltstack/salt.git | Update to latest ``pyupgrade`` hook. Stop skipping it on CI.
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com> | 1,234 | 0 | 54,284 | 23 | |
1 | 13 | def test_auto_create_auto_join_remote_room(self) -> None:
# Register a first user; this should call _create_and_join_rooms
self.get_success(self.handler.register_user(localpart="jeff"))
_, kwargs = self.room_member_handler.update_membership.call_args
self.assertEqual(kwargs["... | tests/handlers/test_register.py | 232 | synapse | {
"docstring": "Tests that we don't attempt to create remote rooms, and that we don't attempt\n to invite ourselves to rooms we're not in.",
"language": "en",
"n_whitespaces": 28,
"n_words": 22,
"vocab_size": 16
} | 44 | Python | 27 | 652d1669c5a103b1c20478770c4aaf18849c09a3 | test_register.py | 250,388 | 13 | 134 | test_auto_create_auto_join_remote_room | https://github.com/matrix-org/synapse.git | Add missing type hints to tests.handlers. (#14680)
And do not allow untyped defs in tests.handlers. | 135 | 0 | 73,411 | 11 | |
1 | 12 | def logsumexp(x, axis=None, keepdims=False):
return tf.reduce_logsumexp(x, axis, keepdims)
@keras_export("keras.backend.round")
@tf.__internal__.dispatch.add_dispatch_support
@doc_controls.do_not_generate_docs | keras/backend.py | 67 | @keras_export("keras.backend.round")
@tf.__internal__.dispatch.add_dispatch_support
@doc_controls.do_not_generate_docs | keras | {
"docstring": "Computes log(sum(exp(elements across dimensions of a tensor))).\n\n This function is more numerically stable than log(sum(exp(x))).\n It avoids overflows caused by taking the exp of large inputs and\n underflows caused by taking the log of small inputs.\n\n Args:\n x: A tensor or va... | 11 | Python | 11 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | backend.py | 269,469 | 2 | 25 | logsumexp | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 14 | 1 | 80,104 | 7 |
1 | 22 | def test_patch_bot_owner_of_bot_with_can_create_users(self) -> None:
cordelia = self.example_user("cordelia")
self.login("hamlet")
self.create_bot()
bot_realm = get_realm("zulip")
bot_email = "hambot-bot@zulip.testserver"
bot_user = get_user(bot_email, bot_real... | zerver/tests/test_bots.py | 251 | zulip | {
"docstring": "\n can_create_users is granted to organizations upon approval, and thus\n should be thought of as something that only organization owners should\n have control over.\n ",
"language": "en",
"n_whitespaces": 52,
"n_words": 23,
"vocab_size": 22
} | 86 | Python | 65 | af5d0d6f5e5444332f9f8e565d97f4acdceaa72f | test_bots.py | 83,535 | 29 | 134 | test_patch_bot_owner_of_bot_with_can_create_users | https://github.com/zulip/zulip.git | bots: Don't allow admins to change owner of bot with can_create_users.
Ordinary organization administrators shouldn't be allowed to change
ownership of a bot with the can_create_users permission.
This is a special permission that is granted manually by server
administrators to an organization (to a UserProfile of the... | 287 | 0 | 17,679 | 11 | |
2 | 5 | def percentile_fn(data, percentile):
return data[int((len(data) - 1) * percentile)] if len(data) > 0 else None
| src/sentry/api/endpoints/project_dynamic_sampling.py | 54 | sentry | {
"docstring": "\n Returns the nth percentile from a sorted list\n\n :param percentile: A value between 0 and 1\n :param data: Sorted list of values\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 22,
"vocab_size": 20
} | 15 | Python | 15 | 923658b395545abc1b7f7a39cf64d198c9feea74 | project_dynamic_sampling.py | 92,239 | 2 | 34 | percentile_fn | https://github.com/getsentry/sentry.git | feat(dynamic-sampling): Adds endpoint that returns onboarding flow trace info [TET-176] (#36113)
This PR adds an endpoint for the dynamic sampling onboarding flow that:
- Does a query to the transactions table to fetch a random sampleSize over the last passed statsPeriod date range.
- If distrubutedTracing mode is... | 21 | 0 | 18,892 | 14 | |
7 | 12 | def equals(self, other):
if not isinstance(other, PermutationGroup):
return False
set_self_gens = set(self.generators)
set_other_gens = set(other.generators)
# before reaching the general case there are also certain
# optimisation and obvious cases requirin... | sympy/combinatorics/perm_groups.py | 127 | sympy | {
"docstring": "Return ``True`` if PermutationGroup generated by elements in the\n group are same i.e they represent the same PermutationGroup.\n\n Examples\n ========\n\n >>> from sympy.combinatorics import Permutation, PermutationGroup\n >>> p = Permutation(0, 1, 2, 3, 4, 5)\n ... | 86 | Python | 59 | 3e167a67bde4b4817666de48bf98d247bed86e2d | perm_groups.py | 196,343 | 14 | 76 | equals | https://github.com/sympy/sympy.git | Update sympy/combinatorics/perm_groups.py | 251 | 0 | 47,843 | 10 | |
1 | 1 | def set_vars():
return {}
| lib/gui/display_page.py | 17 | faceswap | {
"docstring": " Override to return a dict of page specific variables ",
"language": "en",
"n_whitespaces": 10,
"n_words": 9,
"vocab_size": 9
} | 4 | Python | 4 | c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf | display_page.py | 100,334 | 2 | 8 | set_vars | https://github.com/deepfakes/faceswap.git | Update code to support Tensorflow versions up to 2.8 (#1213)
* Update maximum tf version in setup + requirements
* - bump max version of tf version in launcher
- standardise tf version check
* update keras get_custom_objects for tf>2.6
* bugfix: force black text in GUI file dialogs (linux)
* dssim loss -... | 18 | 0 | 19,830 | 6 | |
4 | 24 | async def get_tasks(self) -> dict:
replies = await asyncio.gather(
*[
self._client.get_task_info(node_id, timeout=DEFAULT_RPC_TIMEOUT)
for node_id in self._client.get_all_registered_raylet_ids()
]
)
result = defaultdict(dict)
... | dashboard/state_aggregator.py | 157 | ray | {
"docstring": "List all task information from the cluster.\n\n Returns:\n {task_id -> task_data_in_dict}\n task_data_in_dict's schema is in TaskState\n ",
"language": "en",
"n_whitespaces": 52,
"n_words": 16,
"vocab_size": 16
} | 47 | Python | 34 | 30ab5458a7e4ba2351d5e1beef8c8797b5946493 | state_aggregator.py | 138,400 | 24 | 98 | get_tasks | https://github.com/ray-project/ray.git | [State Observability] Tasks and Objects API (#23912)
This PR implements ray list tasks and ray list objects APIs.
NOTE: You can ignore the merge conflict for now. It is because the first PR was reverted. There's a fix PR open now. | 261 | 0 | 31,408 | 15 | |
1 | 2 | def measure(self):
return self["measure"]
| packages/python/plotly/plotly/graph_objs/_waterfall.py | 22 | plotly.py | {
"docstring": "\n An array containing types of values. By default the values are\n considered as 'relative'. However; it is possible to use\n 'total' to compute the sums. Also 'absolute' could be applied\n to reset the computed total or to declare an initial value\n where needed.\n... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _waterfall.py | 228,605 | 2 | 11 | measure | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 60,278 | 7 | |
1 | 3 | def disabled_train(self, mode=True):
return self
| ldm/models/diffusion/ddpm.py | 21 | stablediffusion | {
"docstring": "Overwrite model.train with this function to make sure train/eval mode\n does not change anymore.",
"language": "en",
"n_whitespaces": 16,
"n_words": 14,
"vocab_size": 14
} | 5 | Python | 5 | ca86da3a30c4e080d4db8c25fca73de843663cb4 | ddpm.py | 157,333 | 2 | 12 | disabled_train | https://github.com/Stability-AI/stablediffusion.git | release more models | 11 | 0 | 36,899 | 6 | |
1 | 11 | def test_no_auth(self) -> None:
channel = self.make_request("GET", self.url, b"{}")
self.assertEqual(
401,
channel.code,
msg=channel.json_body,
)
self.assertEqual(Codes.MISSING_TOKEN, channel.json_body["errcode"])
| tests/rest/admin/test_device.py | 88 | synapse | {
"docstring": "\n Try to list devices of an user without authentication.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | 16 | Python | 16 | 1595052b2681fb86c1c1b9a6028c1bc0d38a2e4b | test_device.py | 249,234 | 11 | 55 | test_no_auth | https://github.com/matrix-org/synapse.git | Use literals in place of `HTTPStatus` constants in tests (#13479)
Replace
- `HTTPStatus.NOT_FOUND`
- `HTTPStatus.FORBIDDEN`
- `HTTPStatus.UNAUTHORIZED`
- `HTTPStatus.CONFLICT`
- `HTTPStatus.CREATED`
Signed-off-by: Dirk Klimpel <dirk@klimpel.org> | 84 | 0 | 72,738 | 9 | |
1 | 19 | def test_image_crafter_index(encoder_doc_array, tmpdir):
create_test_img(path=str(tmpdir), file_name='1.jpg')
with Flow().add(uses=ImageCrafter) as f:
res = f.index(inputs=encoder_doc_array)
assert len(res) == 1
doc = res[0]
assert doc.mime_type == 'image/jpeg'
assert doc.tensor is ... | tests/unit/helloworld/multimodal/test_executors.py | 120 | jina | {
"docstring": "In this test, we input one ``DocumentArray`` with one ``Document``,\n and the `craft` method in the ``ImageCrafter`` returns chunks.\n In the ``ImageCrafter``, we filtered out all the modalities and only kept `image/jpeg`.\n So the 2 chunks should left only 1 chunk.\n And the tensor value ... | 28 | Python | 24 | 217a11bb8dc613ed1136b8b541a68e6d53ca4fc1 | test_executors.py | 11,747 | 8 | 71 | test_image_crafter_index | https://github.com/jina-ai/jina.git | test: fix tests failing after new docarray patch (#4449)
* test: fix tests failing after new docarray patch
* test: fix failing tests | 56 | 0 | 2,104 | 12 | |
1 | 9 | def orthographic_projection(X, camera):
camera = camera.reshape((-1, 1, 3))
X_trans = X[:, :, :2] + camera[:, :, 1:]
shape = paddle.shape(X_trans)
X_2d = (camera[:, :, 0] * X_trans.reshape((shape[0], -1))).reshape(shape)
return X_2d
@register | ppdet/modeling/architectures/pose3d_metro.py | 137 | @register | PaddleDetection | {
"docstring": "Perform orthographic projection of 3D points X using the camera parameters\n Args:\n X: size = [B, N, 3]\n camera: size = [B, 3]\n Returns:\n Projected 2D points -- size = [B, N, 2]\n ",
"language": "en",
"n_whitespaces": 63,
"n_words": 33,
"vocab_size": 24
} | 31 | Python | 25 | d4e34fe165c09db65fd00113708be1b711ac957c | pose3d_metro.py | 211,415 | 6 | 86 | orthographic_projection | https://github.com/PaddlePaddle/PaddleDetection.git | pose3d metro modeling (#6612)
* pose3d metro modeling
* delete extra comments | 48 | 1 | 53,089 | 14 |
7 | 26 | def to_euler(self, seq):
extrinsic = _check_sequence(seq)
i, j, k = seq.lower()
i = _elementary_axis_index(i)
j = _elementary_axis_index(j)
k = _elementary_axis_index(k)
if not extrinsic:
i, k = k, i
# check if sequence is symmetric
... | sympy/algebras/quaternion.py | 404 | sympy | {
"docstring": "Returns Euler angles representing same in the sequence given by\n `seq`.\n\n Parameters\n ==========\n\n seq : string of length 3\n Represents the sequence of rotations.\n For intrinsic rotations, seq but be all lowercase and its elements\n ... | 197 | Python | 104 | 1d8576449e7ab757f13f49a1d33faed602aa88fb | quaternion.py | 200,596 | 33 | 258 | to_euler | https://github.com/sympy/sympy.git | implemented to_euler and from_euler | 521 | 0 | 49,725 | 13 | |
1 | 16 | def test_jupyter_file_output(tmp_path):
scene_name = "SimpleScene"
current_renderer = config.renderer
with tempconfig({"scene_names": [scene_name], "renderer": "opengl"}):
file_name = _generate_file_name()
actual_path = tmp_path.with_name(file_name)
with actual_path.open("w") as... | tests/opengl/test_ipython_magic_opengl.py | 144 | manim | {
"docstring": "Check the jupyter file naming is valid and can be created",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 41 | Python | 33 | 206db54af53a87985c0d243d75304ea620dad520 | test_ipython_magic_opengl.py | 190,005 | 11 | 76 | test_jupyter_file_output | https://github.com/ManimCommunity/manim.git | Migrate more `os.path` to `pathlib` in tests (#2991)
* Migrate more `os.path` to `pathlib` in tests
* Convert test fixtures to pathlib
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix mypy errors in tests
* migrate another pathlib instance
C... | 113 | 0 | 46,287 | 13 | |
17 | 5 | async def test_statistic_during_period_hole(recorder_mock, hass, hass_ws_client):
id = 1
| tests/components/recorder/test_websocket_api.py | 23 | core | {
"docstring": "Test statistic_during_period when there are holes in the data.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 8 | Python | 8 | 9b8f94363c0b4ecd1434ac1ac3bb82febd3889d0 | test_websocket_api.py | 290,687 | 137 | 900 | test_statistic_during_period_hole | https://github.com/home-assistant/core.git | Fix statistic_during_period for data with holes (#81847) | 14 | 0 | 89,801 | 6 | |
1 | 32 | async def test_valve_set_state(hass, hk_driver, events):
entity_id = "switch.valve_test"
hass.states.async_set(entity_id, None)
await hass.async_block_till_done()
acc = Valve(hass, hk_driver, "Valve", entity_id, 2, {CONF_TYPE: TYPE_FAUCET})
await acc.run()
await hass.async_block_till_done... | tests/components/homekit/test_type_switches.py | 685 | core | {
"docstring": "Test if Valve accessory and HA are updated accordingly.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 207 | Python | 70 | 3b33e0d832b238b40360383099391e2093ea05cb | test_type_switches.py | 289,146 | 51 | 431 | test_valve_set_state | https://github.com/home-assistant/core.git | Add support for restoring HomeKit IIDs (#79913) | 371 | 0 | 88,293 | 10 | |
7 | 30 | def deal_bb(result_token):
# find out <thead></thead> parts.
thead_pattern = '<thead>(.*?)</thead>'
if re.search(thead_pattern, result_token) is None:
return result_token
thead_part = re.search(thead_pattern, result_token).group()
origin_thead_part = copy.deepcopy(thead_part)
# che... | ppstructure/table/table_master_match.py | 484 | PaddleOCR | {
"docstring": "\n In our opinion, <b></b> always occurs in <thead></thead> text's context.\n This function will find out all tokens in <thead></thead> and insert <b></b> by manual.\n :param result_token:\n :return:\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 27,
"vocab_size": 24
} | 324 | Python | 170 | ddaa2c2552e19635cd6cdf38619f1f176c358f89 | table_master_match.py | 24,488 | 35 | 264 | deal_bb | https://github.com/PaddlePaddle/PaddleOCR.git | add SLANet | 720 | 0 | 4,740 | 17 | |
6 | 11 | def _convert_other(other, raiseit=False, allow_float=False):
if isinstance(other, Decimal):
return other
if isinstance(other, int):
return Decimal(other)
if allow_float and isinstance(other, float):
return Decimal.from_float(other)
if raiseit:
raise TypeError("Unabl... | python3.10.4/Lib/_pydecimal.py | 105 | XX-Net | {
"docstring": "Convert other to Decimal.\n\n Verifies that it's ok to use in an implicit construction.\n If allow_float is true, allow conversion from float; this\n is used in the comparison methods (__eq__ and friends).\n\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 32,
"vocab_size": ... | 34 | Python | 25 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | _pydecimal.py | 219,627 | 10 | 66 | _convert_other | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 80 | 0 | 55,662 | 11 | |
4 | 14 | def _process_hidden_imports(self):
# For each hidden import required by the module being hooked...
for import_module_name in self.hiddenimports:
try:
# Graph node for this module. Do not implicitly create namespace packages for non-existent packages.
... | PyInstaller/depend/imphook.py | 121 | pyinstaller | {
"docstring": "\n Add all imports listed in this hook script's `hiddenimports` attribute to the module graph as if directly\n imported by this hooked module.\n\n These imports are typically _not_ implicitly detectable by PyInstaller and hence must be explicitly defined\n by hook scripts.\... | 234 | Python | 146 | 35451d0df77dd4e2c3ad613ee35cb28d99a9421e | imphook.py | 263,832 | 8 | 57 | _process_hidden_imports | https://github.com/pyinstaller/pyinstaller.git | depend: allow hooks to opt out of missing hidden import warnings
Implement new standard hook variable, called
`warn_on_missing_hiddenimports`. This optional boolean flag
allows a hook to opt out from warnings generated by missing
hidden imports originating from that hook. | 615 | 0 | 77,456 | 15 | |
3 | 3 | def check_install_build_global(options, check_options=None):
# type: (Values, Optional[Values]) -> None
if check_options is None:
check_options = options
| .venv/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py | 32 | transferlearning | {
"docstring": "Disable wheels if per-setup.py call options are set.\n\n :param options: The OptionParser options to update.\n :param check_options: The options to check, if not supplied defaults to\n options.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 27,
"vocab_size": 20
} | 16 | Python | 15 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | cmdoptions.py | 60,504 | 13 | 62 | check_install_build_global | https://github.com/jindongwang/transferlearning.git | upd; format | 32 | 0 | 12,188 | 8 | |
1 | 3 | def user_documents_path() -> Path:
return PlatformDirs().user_documents_path
| pipenv/patched/notpip/_vendor/platformdirs/__init__.py | 25 | pipenv | {
"docstring": "\n :returns: documents path tied to the user\n ",
"language": "en",
"n_whitespaces": 14,
"n_words": 7,
"vocab_size": 7
} | 6 | Python | 6 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | __init__.py | 20,185 | 5 | 13 | user_documents_path | https://github.com/pypa/pipenv.git | check point progress on only bringing in pip==22.0.4 (#4966)
* vendor in pip==22.0.4
* updating vendor packaging version
* update pipdeptree to fix pipenv graph with new version of pip.
* Vendoring of pip-shims 0.7.0
* Vendoring of requirementslib 1.6.3
* Update pip index safety restrictions patch for p... | 12 | 0 | 3,239 | 8 | |
1 | 8 | def _config_changeable_items(self) -> dict:
return Config(self._config_section, configfile=self._configfile).changeable_items
| plugins/train/model/_base/model.py | 38 | faceswap | {
"docstring": " dict: The configuration options that can be updated after the model has already been\n created. ",
"language": "en",
"n_whitespaces": 27,
"n_words": 15,
"vocab_size": 15
} | 7 | Python | 7 | ff6b0209dd5ad57b81b0aca570df7f39a7119bfb | model.py | 100,823 | 4 | 23 | _config_changeable_items | https://github.com/deepfakes/faceswap.git | Refactoring and TravisCI to Github Actions (#1239)
* refactor training
* travis to actions | 21 | 0 | 20,274 | 10 | |
1 | 5 | def _import_module(name):
__import__(name)
return sys.modules[name]
| .venv/lib/python3.8/site-packages/pip/_vendor/six.py | 30 | transferlearning | {
"docstring": "Import module, returning the module after the last dot.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 8
} | 5 | Python | 5 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | six.py | 63,730 | 3 | 17 | _import_module | https://github.com/jindongwang/transferlearning.git | upd; format | 14 | 0 | 13,488 | 7 | |
2 | 31 | def keras_model_summary(name, data, step=None):
summary_metadata = tf.compat.v1.SummaryMetadata()
# Hard coding a plugin name. Please refer to go/tb-plugin-name-hardcode for
# the rationale.
summary_metadata.plugin_data.plugin_name = "graph_keras_model"
# version number = 1
summary_metadata... | keras/callbacks.py | 240 | @keras_export("keras.callbacks.TensorBoard", v1=[]) | keras | {
"docstring": "Writes a Keras model as JSON to as a Summary.\n\n Writing the Keras model configuration allows the TensorBoard graph plugin to\n render a conceptual graph, as opposed to graph of ops. In case the model fails\n to serialize as JSON, it ignores and returns False.\n\n Args:\n name: A nam... | 90 | Python | 73 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | callbacks.py | 269,927 | 19 | 133 | keras_model_summary | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 219 | 1 | 80,336 | 14 |
4 | 20 | def test_operator_extra_link_multiple_operators(dag_run, task_2, task_3, viewer_client):
response = viewer_client.get(
f"{ENDPOINT}?dag_id={task_2.dag_id}&task_id={task_2.task_id}"
f"&execution_date={DEFAULT_DATE}&link_name=airflow",
follow_redirects=True,
)
assert response.sta... | tests/www/views/test_views_extra_links.py | 386 | airflow | {
"docstring": "\n This tests checks if Operator Link (AirflowLink2) defined in\n Airflow Plugin (AirflowLink2) is attached to all the list of\n operators defined in the AirflowLink2().operators property\n\n AirflowLink2 returns 'https://airflow.apache.org/1.10.5/' link\n GoogleLink returns 'https://ww... | 99 | Python | 43 | 08575ddd8a72f96a3439f73e973ee9958188eb83 | test_views_extra_links.py | 45,549 | 31 | 195 | test_operator_extra_link_multiple_operators | https://github.com/apache/airflow.git | Change BaseOperatorLink interface to take a ti_key, not a datetime (#21798) | 243 | 0 | 8,641 | 12 | |
5 | 23 | def to_json(self) -> dict:
return {
"id": self.id,
"query": self.query,
"opCode": self.op_code.name,
"authoritativeAnswer": self.authoritative_answer,
"truncation": self.truncation,
"recursionDesired": self.recursion_desired,
... | mitmproxy/dns.py | 271 | mitmproxy | {
"docstring": "\n Converts the message into json for the mitmweb.\n Sync with web/src/flow.ts.\n ",
"language": "en",
"n_whitespaces": 33,
"n_words": 11,
"vocab_size": 10
} | 60 | Python | 49 | f2f918a17e8d06c638b1bb5b06b3150a786d77a0 | dns.py | 250,896 | 26 | 166 | to_json | https://github.com/mitmproxy/mitmproxy.git | [dns] build and improve web UI | 302 | 0 | 73,565 | 12 | |
1 | 4 | def no_verify_ssl(self) -> bool:
return self.namespace.no_verify_ssl
| certbot/certbot/configuration.py | 25 | certbot | {
"docstring": "Disable verification of the ACME server's certificate.\n\n The root certificates trusted by Certbot can be overriden by setting the\n REQUESTS_CA_BUNDLE environment variable.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 22,
"vocab_size": 20
} | 6 | Python | 6 | ae7967c8aed28a8416a329e5eeac117c1672c878 | configuration.py | 186,795 | 7 | 14 | no_verify_ssl | https://github.com/certbot/certbot.git | docs: how to override the trusted CA certificates (#9357)
* docs: how to override the trusted CA certificates
* Update certbot/docs/using.rst
Co-authored-by: ohemorange <ebportnoy@gmail.com>
Co-authored-by: ohemorange <ebportnoy@gmail.com> | 20 | 0 | 45,626 | 7 | |
2 | 7 | def _dictionary(self):
# type: () -> Dict[str, Any]
# NOTE: Dictionaries are not populated if not loaded. So, conditionals
# are not needed here.
retval = {}
for variant in OVERRIDE_ORDER:
retval.update(self._config[variant])
return retval
| .venv/lib/python3.8/site-packages/pip/_internal/configuration.py | 50 | transferlearning | {
"docstring": "A dictionary representing the loaded configuration.\n ",
"language": "en",
"n_whitespaces": 13,
"n_words": 6,
"vocab_size": 6
} | 34 | Python | 28 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | configuration.py | 60,671 | 5 | 28 | _dictionary | https://github.com/jindongwang/transferlearning.git | upd; format | 100 | 0 | 12,237 | 11 | |
1 | 14 | def test_api_set_storage_path_not_provided(self):
response = self.client.post(
"/api/documents/bulk_edit/",
json.dumps(
{
"documents": [self.doc1.id],
"method": "set_storage_path",
"parameters": {},
... | src/documents/tests/test_api.py | 113 | paperless-ngx | {
"docstring": "\n GIVEN:\n - API data to set the storage path of a document\n - API data is missing storage path ID\n WHEN:\n - API is called\n THEN:\n - set_storage_path is called with correct document IDs and storage_path ID\n ",
"language":... | 21 | Python | 21 | 53baed03895f28f24113d376b089e3ef281b34ed | test_api.py | 319,780 | 14 | 66 | test_api_set_storage_path_not_provided | https://github.com/paperless-ngx/paperless-ngx.git | Increases test coverage of storage paths | 187 | 0 | 116,993 | 15 | |
4 | 13 | def encrypt_file(self, file, key=0):
# precondition
assert isinstance(file, str) and isinstance(key, int)
try:
with open(file, "r") as fin:
with open("encrypt.out", "w+") as fout:
# actual encrypt-process
for line in ... | XORcipher/XOR_cipher.py | 125 | Python | {
"docstring": "\n input: filename (str) and a key (int)\n output: returns true if encrypt process was\n successful otherwise false\n if key not passed the method uses the key by the constructor.\n otherwise key = 1\n ",
"language": "en",
"n_whitespaces": 76,
"n_words":... | 37 | Python | 32 | f0af0c43340763724f139fa68aa1e5a9ffe458b4 | XOR_cipher.py | 22,543 | 10 | 72 | encrypt_file | https://github.com/geekcomputers/Python.git | refactor: clean code
Signed-off-by: slowy07 <slowy.arfy@gmail.com> | 177 | 0 | 4,359 | 17 | |
1 | 3 | def test_finished_signal(qtbot):
signal_triggered = False
| tests/unit/misc/test_msgbox.py | 18 | qutebrowser | {
"docstring": "Make sure we can pass a slot to be called when the dialog finished.",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 14
} | 5 | Python | 5 | 0877fb0d78635692e481c8bde224fac5ad0dd430 | test_msgbox.py | 321,418 | 9 | 64 | test_finished_signal | https://github.com/qutebrowser/qutebrowser.git | Run scripts/dev/rewrite_enums.py | 11 | 0 | 117,705 | 6 | |
7 | 26 | def _install_setup_packages(self) -> None:
setup_packages = [(pkg.unsafe_name, pkg.specs)
for pkg in parse_requirements(_INSTALLER_REQUIREMENTS)]
for pkg in setup_packages:
if pkg not in self._env.missing_packages:
continue
self... | setup.py | 269 | faceswap | {
"docstring": " Install any packages that are required for the setup.py installer to work. This\n includes the pexpect package if it is not already installed.\n\n Subprocess is used as we do not currently have pexpect\n ",
"language": "en",
"n_whitespaces": 55,
"n_words": 33,
"vocab_size... | 63 | Python | 48 | 03f6cb4e7e106bc227ad781a515338097fba26f9 | setup.py | 101,106 | 24 | 160 | _install_setup_packages | https://github.com/deepfakes/faceswap.git | setup.py: implement logging | 306 | 0 | 20,537 | 15 | |
1 | 7 | def attrs_dict(self):
return OrderedDict(
[
("src", self.url),
("width", self.width),
("height", self.height),
("alt", self.alt),
]
)
| wagtail/images/models.py | 71 | wagtail | {
"docstring": "\n A dict of the src, width, height, and alt attributes for an <img> tag.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 14,
"vocab_size": 14
} | 15 | Python | 15 | d10f15e55806c6944827d801cd9c2d53f5da4186 | models.py | 75,098 | 9 | 44 | attrs_dict | https://github.com/wagtail/wagtail.git | Reformat with black | 118 | 0 | 16,354 | 10 | |
2 | 17 | def _call_ntimes(self, fun, times):
gc.collect(generation=1)
mem1 = self._get_mem()
for x in range(times):
ret = self.call(fun)
del x, ret
gc.collect(generation=1)
mem2 = self._get_mem()
self.assertEqual(gc.garbage, [])
diff = mem2... | psutil/tests/__init__.py | 127 | psutil | {
"docstring": "Get 2 distinct memory samples, before and after having\n called fun repeatedly, and return the memory difference.\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 17,
"vocab_size": 15
} | 36 | Python | 27 | 04e7aa604155736cce0abcc15c9b7b63d941b0e9 | __init__.py | 189,048 | 11 | 78 | _call_ntimes | https://github.com/giampaolo/psutil.git | docs: fix simple typo, repeadetly -> repeatedly (#2123) | 122 | 0 | 45,981 | 10 | |
4 | 9 | def get_filesystem_type(filepath):
# We import it locally so that click autocomplete works
import psutil
root_type = "unknown"
for part in psutil.disk_partitions():
if part.mountpoint == '/':
root_type = part.fstype
continue
if filepath.startswith(part.mount... | dev/breeze/src/airflow_breeze/utils/run_utils.py | 87 | airflow | {
"docstring": "\n Determine the type of filesystem used - we might want to use different parameters if tmpfs is used.\n :param filepath: path to check\n :return: type of filesystem\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 27,
"vocab_size": 23
} | 35 | Python | 28 | 4ffd4f09532fceb67675fce4c1f5cd383eff992e | run_utils.py | 46,791 | 10 | 49 | get_filesystem_type | https://github.com/apache/airflow.git | Prepare Breeze2 for prime time :) (#22713)
This is a review and clean-up for all the parameters and
commands for Breeze2 in order to prepare it for being
used by the contribugors.
There are various small fixes here and there, removal
of duplicated code, refactoring and moving code around
as well as cleanup and ... | 100 | 0 | 8,995 | 11 | |
3 | 8 | def input_mask(self):
inputs = self.input
if isinstance(inputs, list):
return [getattr(x, "_keras_mask", None) for x in inputs]
else:
return getattr(inputs, "_keras_mask", None)
| keras/engine/base_layer.py | 73 | keras | {
"docstring": "Retrieves the input mask tensor(s) of a layer.\n\n Only applicable if the layer has exactly one inbound node,\n i.e. if it is connected to one incoming layer.\n\n Returns:\n Input mask tensor (potentially None) or list of input\n mask tensors.\n\n Rais... | 21 | Python | 18 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | base_layer.py | 270,737 | 6 | 45 | input_mask | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 71 | 0 | 80,552 | 11 | |
1 | 6 | def get_item_details(item_code):
return frappe.db.sql(
,
item_code,
as_dict=True,
)[0]
| erpnext/stock/doctype/serial_no/serial_no.py | 37 | erpnext | {
"docstring": "select name, has_batch_no, docstatus,\n\t\tis_stock_item, has_serial_no, serial_no_series\n\t\tfrom tabItem where name=%s",
"language": "en",
"n_whitespaces": 8,
"n_words": 11,
"vocab_size": 11
} | 8 | Python | 8 | 494bd9ef78313436f0424b918f200dab8fc7c20b | serial_no.py | 67,737 | 8 | 24 | get_item_details | https://github.com/frappe/erpnext.git | style: format code with black | 2 | 0 | 14,611 | 9 | |
6 | 20 | def collect_qtqml_files(self):
# No-op if requested Qt-based package is not available.
if self.version is None:
return [], []
# Not all PyQt5/PySide2 installs have QML files. In this case, location['Qml2ImportsPath'] is empty.
# Furthermore, even if location path i... | PyInstaller/utils/hooks/qt/__init__.py | 243 | pyinstaller | {
"docstring": "\n Collect additional binaries and data for QtQml module.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 8
} | 146 | Python | 99 | d789a7daa7712716c89259b987349917a89aece7 | __init__.py | 264,031 | 19 | 144 | collect_qtqml_files | https://github.com/pyinstaller/pyinstaller.git | hookutils: reorganize the Qt hook utilities
Reorganize the Qt module information to provide information necessary
to deal with variations between different python Qt bindings (PySide2,
PyQt5, PySide6, and PyQt6). Replace the existing table-like dictionary
with list of entries, which is easier to format and document. F... | 397 | 0 | 77,570 | 15 | |
3 | 8 | def pytest_collection_modifyitems(items):
for item in items:
if inspect.iscoroutinefunction(item.obj):
item.add_marker("asyncio")
assert not inspect.isasyncgenfunction(item.obj)
| IPython/conftest.py | 64 | ipython | {
"docstring": "This function is automatically run by pytest passing all collected test\n functions.\n\n We use it to add asyncio marker to all async tests and assert we don't use\n test functions that are async generators which wouldn't make sense.\n ",
"language": "en",
"n_whitespaces": 50,
"n_wor... | 12 | Python | 12 | 82d1a374575d9785708f144976cf139c76c7acb7 | conftest.py | 208,416 | 5 | 37 | pytest_collection_modifyitems | https://github.com/ipython/ipython.git | make sure to run async tests
there are some `async def` tests, but they are skipped without `mark("asyncio")` | 43 | 0 | 52,319 | 12 | |
1 | 6 | def filter(self, *args, **kwargs):
self._not_support_combined_queries("filter")
return self._filter_or_exclude(False, args, kwargs)
| django/db/models/query.py | 48 | django | {
"docstring": "\n Return a new QuerySet instance with the args ANDed to the existing\n set.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 13,
"vocab_size": 12
} | 9 | Python | 9 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | query.py | 205,772 | 3 | 29 | filter | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 30 | 0 | 51,206 | 8 | |
2 | 25 | def _output_non_grouped(self) -> None:
output_dir = self._args.output_dir
os.makedirs(output_dir, exist_ok=True)
description = f"{'Copying' if self._args.keep_original else 'Moving'} and renaming"
for idx, source in enumerate(tqdm(self._sorter.sorted_filelist,
... | tools/sort/sort.py | 165 | faceswap | {
"docstring": " Output non-grouped files.\n\n These are files which are sorted but not binned, so just the filename gets updated\n ",
"language": "en",
"n_whitespaces": 33,
"n_words": 18,
"vocab_size": 17
} | 32 | Python | 30 | 98d01760e469fd2108eed8d0b0a1ba6297c3177c | sort.py | 101,607 | 14 | 81 | _output_non_grouped | 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 | 212 | 0 | 21,015 | 15 | |
3 | 4 | def insert(self, index, ins_string):
| pipenv/patched/notpip/_vendor/pyparsing/results.py | 19 | """
Inserts new element at location index in the list of parsed tokens.
Similar to ``list.insert()``.
Example::
numlist = Word(nums)[...]
print(numlist.parse_string("0 123 321")) | pipenv | {
"docstring": "\n Inserts new element at location index in the list of parsed tokens.\n\n Similar to ``list.insert()``.\n\n Example::\n\n numlist = Word(nums)[...]\n print(numlist.parse_string(\"0 123 321\")) # -> ['0', '123', '321']\n\n # use a parse action to i... | 4 | Python | 4 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | results.py | 20,623 | 7 | 64 | insert | https://github.com/pypa/pipenv.git | check point progress on only bringing in pip==22.0.4 (#4966)
* vendor in pip==22.0.4
* updating vendor packaging version
* update pipdeptree to fix pipenv graph with new version of pip.
* Vendoring of pip-shims 0.7.0
* Vendoring of requirementslib 1.6.3
* Update pip index safety restrictions patch for p... | 11 | 1 | 3,460 | 4 |
1 | 5 | def mark_scope_as_experimental():
with configure_scope() as scope:
scope.set_tag(EXPERIMENT_TAG, True)
| src/sentry/utils/sdk.py | 39 | sentry | {
"docstring": "\n Set the experimental tag on the SDK scope for outgoing crashes and transactions.\n\n Marking the scope will cause these crashes and transaction to be sent to a separate experimental dsn.\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 30,
"vocab_size": 23
} | 8 | Python | 8 | 9288539aeeac52990705aa6dd0abaebe0d12da21 | sdk.py | 92,157 | 3 | 20 | mark_scope_as_experimental | https://github.com/getsentry/sentry.git | poc(sdk): Add experimental dsn for upcoming perf work (#36000)
This adds an experimental dsn to the MultiplexingTransport to intentionally send specific flagged events solely to a separate dsn, which will help us avoid troubles with ingesting random errors into our main Sentry project. | 21 | 0 | 18,879 | 10 | |
1 | 10 | async def test_handle_mqtt_on_callback(hass, caplog, mqtt_mock, mqtt_client_mock):
# Simulate an ACK for mid == 1, this will call mqtt_mock._mqtt_handle_mid(mid)
mqtt_client_mock.on_publish(mqtt_client_mock, None, 1)
await hass.async_block_till_done()
# Make sure the ACK has been received
await... | tests/components/mqtt/test_init.py | 117 | core | {
"docstring": "Test receiving an ACK callback before waiting for it.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 85 | Python | 64 | 845bf80e725af8c921915906b0f796c7a8164d11 | test_init.py | 292,654 | 11 | 66 | test_handle_mqtt_on_callback | https://github.com/home-assistant/core.git | Mqtt improve test coverage (#66279)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> | 138 | 0 | 91,728 | 9 | |
2 | 8 | def enhanced_hue_supported(self) -> bool:
return (
self.color_capabilities is not None
and lighting.Color.ColorCapabilities.Enhanced_hue in self.color_capabilities
)
| homeassistant/components/zha/core/channels/lighting.py | 47 | core | {
"docstring": "Return True if the channel supports enhanced hue and saturation.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 15 | Python | 14 | df67a8cd4f8df91a153778009a74be1e3876ca53 | lighting.py | 303,468 | 6 | 29 | enhanced_hue_supported | https://github.com/home-assistant/core.git | Fix ZHA light color temp support (#76305) | 58 | 0 | 102,288 | 11 | |
1 | 3 | def set_pipeline(self, pipeline):
self.pipeline = pipeline
| src/sentry/pipeline/provider.py | 23 | sentry | {
"docstring": "\n Used by the pipeline to give the provider access to the executing pipeline.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 10
} | 6 | Python | 6 | d246d2b6d3e014270941209e54f2f12e09ad9a81 | provider.py | 97,870 | 2 | 13 | set_pipeline | https://github.com/getsentry/sentry.git | ref(py): Split up large file (#32862)
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> | 20 | 0 | 19,496 | 7 | |
2 | 25 | def _setup_dynamic(self) -> None:
display.info('Provisioning %s cloud environment.' % self.platform, verbosity=1)
config = self._read_config_template()
aci = self._create_ansible_core_ci()
response = aci.start()
if not self.args.explain:
credentials = res... | test/lib/ansible_test/_internal/commands/integration/cloud/aws.py | 217 | ansible | {
"docstring": "Request AWS credentials through the Ansible Core CI service.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 41 | Python | 35 | 3eb0485dd92c88cc92152d3656d94492db44b183 | aws.py | 267,843 | 18 | 128 | _setup_dynamic | https://github.com/ansible/ansible.git | ansible-test - Use more native type hints. (#78435)
* ansible-test - Use more native type hints.
Simple search and replace to switch from comments to native type hints for return types of functions with no arguments.
* ansible-test - Use more native type hints.
Conversion of simple single-line function annota... | 216 | 0 | 79,123 | 13 | |
1 | 7 | def managed(self): # type: () -> bool
return t.cast(bool, self._get_cloud_config(self._MANAGED))
| test/lib/ansible_test/_internal/commands/integration/cloud/__init__.py | 38 | ansible | {
"docstring": "True if resources are managed by ansible-test, otherwise False.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 10 | Python | 10 | a06fa496d3f837cca3c437ab6e9858525633d147 | __init__.py | 266,742 | 2 | 22 | managed | https://github.com/ansible/ansible.git | 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... | 25 | 0 | 78,553 | 10 | |
3 | 22 | def test_simple_imputer_constant_keep_empty_features(array_type, keep_empty_features):
X = np.array([[np.nan, 2], [np.nan, 3], [np.nan, 6]])
X = _convert_container(X, array_type)
fill_value = 10
imputer = SimpleImputer(
strategy="constant",
fill_value=fill_value,
keep_empty_... | sklearn/impute/tests/test_impute.py | 273 | @pytest.mark.parametrize("array_type", ["array", "sparse"])
@pytest.mark.parametrize("strategy", ["mean", "median", "most_frequent"])
@pytest.mark.parametrize("keep_empty_features", [True, False]) | scikit-learn | {
"docstring": "Check the behaviour of `keep_empty_features` with `strategy='constant'.\n For backward compatibility, a column full of missing values will always be\n fill and never dropped.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 23,
"vocab_size": 22
} | 63 | Python | 53 | d8fa96c29828e3ca79ddd5d7466521ac4d95213c | test_impute.py | 261,585 | 16 | 125 | test_simple_imputer_constant_keep_empty_features | https://github.com/scikit-learn/scikit-learn.git | 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.... | 148 | 1 | 76,879 | 13 |
1 | 15 | def test_copy_with_credential(self):
expression = "col1, col2"
op = DatabricksCopyIntoOperator(
file_location=COPY_FILE_LOCATION,
file_format='CSV',
table_name='test',
task_id=TASK_ID,
expression_list=expression,
credential={'AZURE_... | tests/providers/databricks/operators/test_databricks_sql.py | 102 | airflow | {
"docstring": "COPY INTO test\nFROM (SELECT {expression} FROM '{COPY_FILE_LOCATION}' WITH (CREDENTIAL (AZURE_SAS_TOKEN = 'abc') ))\nFILEFORMAT = CSV\n",
"language": "en",
"n_whitespaces": 14,
"n_words": 17,
"vocab_size": 15
} | 23 | Python | 21 | 401419432082d222b823e4f2a66f21e5cc3ab28d | test_databricks_sql.py | 45,916 | 17 | 56 | test_copy_with_credential | https://github.com/apache/airflow.git | Add new options to DatabricksCopyIntoOperator (#22076)
This includes:
* `encryption` - to specify encryption options for a given location
* `credential` - to specify authentication options for a given location
* `validate` - to control validation of schema & data | 145 | 0 | 8,743 | 12 | |
1 | 11 | def _earlystop_notify_tuner(self, data):
_logger.debug('Early stop notify tuner data: [%s]', data)
data['type'] = MetricType.FINAL
data['value'] = dump(data['value'])
self.enqueue_command(CommandType.ReportMetricData, data)
| nni/runtime/msg_dispatcher.py | 80 | nni | {
"docstring": "Send last intermediate result as final result to tuner in case the\n trial is early stopped.\n ",
"language": "en",
"n_whitespaces": 30,
"n_words": 16,
"vocab_size": 15
} | 18 | Python | 16 | 98c1a77f61900d486f46d284c49fb65675dbee6a | msg_dispatcher.py | 112,868 | 5 | 46 | _earlystop_notify_tuner | https://github.com/microsoft/nni.git | Support multiple HPO experiments in one process (#4855) | 53 | 0 | 24,779 | 10 | |
8 | 36 | def gradient(scalar_field, doit=True):
coord_sys = _get_coord_systems(scalar_field)
if len(coord_sys) == 0:
return Vector.zero
elif len(coord_sys) == 1:
coord_sys = next(iter(coord_sys))
h1, h2, h3 = coord_sys.lame_coefficients()
i, j, k = coord_sys.base_vectors()
... | sympy/vector/operators.py | 329 | sympy | {
"docstring": "\n Returns the vector gradient of a scalar field computed wrt the\n base scalars of the given coordinate system.\n\n Parameters\n ==========\n\n scalar_field : SymPy Expr\n The scalar field to compute the gradient of\n\n doit : bool\n If True, the result is returned aft... | 108 | Python | 60 | 975df9b627556d176039ba3a0f3a2e3a3df9686c | operators.py | 196,453 | 22 | 212 | gradient | https://github.com/sympy/sympy.git | Fixed removals not fully performed earlier | 258 | 0 | 47,935 | 16 | |
3 | 13 | def add_store(source, store, retcode=False, saltenv="base"):
source = __salt__["cp.cache_file"](source, saltenv)
# Since we're allowing a path, let's make sure it exists
if not os.path.exists(source):
msg = "cert_file not found: ".format(source)
raise CommandExecutionError(msg)
cm... | salt/modules/win_certutil.py | 144 | salt | {
"docstring": "\n Add the given cert into the given Certificate Store\n\n source (str):\n The source certificate file. This is either the path to a local file or\n a file from the file server in the form of ``salt://path/to/file``\n\n store (str):\n The certificate store to add the cert... | 45 | Python | 40 | 53b3ebc92648c2081c58865713b50a2859ae8310 | win_certutil.py | 215,877 | 10 | 82 | add_store | https://github.com/saltstack/salt.git | Fix win_certutil module to handle paths with spaces | 94 | 0 | 54,222 | 11 | |
1 | 4 | def base_dir(self) -> str:
return self._base_dir
| python/ray/data/datasource/partitioning.py | 22 | ray | {
"docstring": "Gets the original base directory supplied during object construction.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 6 | Python | 6 | 9f4cb9b3c9c27ae21bf7807595973231b6814648 | partitioning.py | 138,432 | 3 | 12 | base_dir | https://github.com/ray-project/ray.git | [Datasets] Add Path Partitioning Support for All Content Types (#23624)
Adds a content-type-agnostic partition parser with support for filtering files. Also adds some corner-case bug fixes and usability improvements for supporting more robust input path types. | 20 | 0 | 31,421 | 6 | |
1 | 13 | def test_stylesheet_apply_takes_final_rule_in_specificity_clash():
css = ".a {background: red; color: lime;} .b {background: blue;}"
stylesheet = _make_stylesheet(css)
node = DOMNode(classes="a b", id="c")
stylesheet.apply(node)
assert node.styles.color == Color(0, 255, 0) # color: lime
a... | tests/css/test_stylesheet.py | 105 | textual | {
"docstring": ".a and .b both contain background and have same specificity, so .b wins\n since it was declared last - the background should be blue.",
"language": "en",
"n_whitespaces": 26,
"n_words": 24,
"vocab_size": 21
} | 39 | Python | 31 | 4dd0d9fae43583638f34257f97d5749ca4f2c00c | test_stylesheet.py | 183,837 | 7 | 62 | test_stylesheet_apply_takes_final_rule_in_specificity_clash | https://github.com/Textualize/textual.git | Add various additional tests around CSS specificity | 62 | 0 | 44,359 | 10 | |
1 | 14 | async def test_check_loop_async_integration(caplog):
with pytest.raises(RuntimeError), patch(
"homeassistant.util.async_.extract_stack",
return_value=[
Mock(
filename="/home/paulus/homeassistant/core.py",
lineno="23",
line="do_somethin... | tests/util/test_async.py | 158 | core | {
"docstring": "Test check_loop detects and raises when called from event loop from integration context.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 12
} | 58 | Python | 51 | dc58bc375ae203e3d394225f9c3a5a14d43cb2f3 | test_async.py | 309,258 | 28 | 88 | test_check_loop_async_integration | https://github.com/home-assistant/core.git | Warn on`time.sleep` in event loop (#63766)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> | 330 | 0 | 107,965 | 15 | |
1 | 56 | def test_callback(self):
# ensure that we are correctly testing the fallback when "get_extra_attributes"
# is not implemented.
mapping_provider = self.provider._user_mapping_provider
with self.assertRaises(AttributeError):
_ = mapping_provider.get_extra_attributes
... | tests/handlers/test_oidc.py | 1,151 | synapse | {
"docstring": "Code callback works and display errors if something went wrong.\n\n A lot of scenarios are tested here:\n - when the callback works, with userinfo from ID token\n - when the user mapping fails\n - when ID token verification fails\n - when the callback works, with... | 247 | Python | 131 | a121507cfec0ffce45a89f5a1019034eda5b0c70 | test_oidc.py | 246,326 | 111 | 684 | test_callback | https://github.com/matrix-org/synapse.git | Adds misc missing type hints (#11953) | 1,236 | 0 | 71,155 | 15 | |
1 | 6 | def bicubic_degradation(x, sf=3):
x = util.imresize_np(x, scale=1 / sf)
return x
| ldm/modules/image_degradation/bsrgan.py | 42 | stablediffusion | {
"docstring": "\n Args:\n x: HxWxC image, [0, 1]\n sf: down-scale factor\n Return:\n bicubicly downsampled LR image\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 14,
"vocab_size": 14
} | 11 | Python | 10 | ca86da3a30c4e080d4db8c25fca73de843663cb4 | bsrgan.py | 157,491 | 3 | 26 | bicubic_degradation | https://github.com/Stability-AI/stablediffusion.git | release more models | 20 | 0 | 36,943 | 10 | |
2 | 46 | def plot(self, ax, box_kws, flier_kws, line_kws):
self.draw_letter_value_plot(ax, box_kws, flier_kws, line_kws)
self.annotate_axes(ax)
if self.orient == "h":
ax.invert_yaxis()
_categorical_docs = dict(
# Shared narrative docs
categorical_narrative=dedent(),
n... | seaborn/categorical.py | 537 | seaborn | {
"docstring": "Make the plot.\\\n .. note::\n This function always treats one of the variables as categorical and\n draws data at ordinal positions (0, 1, ... n) on the relevant axis,\n even when the data has a numeric or date type.\n\n See the :ref:`tutorial <categorical_tutorial>` for mo... | 65 | Python | 59 | b1db0f72627e9fae8fda261514392d53906384cf | categorical.py | 42,167 | 5 | 44 | plot | https://github.com/mwaskom/seaborn.git | Cleanup and merge #2909 (#2955)
* Sorting boxenplot
* Boxenplot separate kws
Removed `kwargs` which were used to draw the median lines and scatter plot of outliers previously.
Added separate kwargs - `box_kws`, `line_kws` (drawing the median lines) and `flier_kws` (for the scatter of outliers).
Updated the... | 206 | 0 | 7,489 | 10 | |
1 | 9 | def get_all_transfers(date, shareholder):
condition = " "
# if company:
# condition = 'AND company = %(company)s '
return frappe.db.sql(
.format(
condition=condition
),
{"date": date, "shareholder": shareholder},
as_dict=1,
)
| erpnext/accounts/report/share_ledger/share_ledger.py | 70 | erpnext | {
"docstring": "SELECT * FROM `tabShare Transfer`\n\t\tWHERE (DATE(date) <= %(date)s AND from_shareholder = %(shareholder)s {condition})\n\t\tOR (DATE(date) <= %(date)s AND to_shareholder = %(shareholder)s {condition})\n\t\tORDER BY date",
"language": "en",
"n_whitespaces": 22,
"n_words": 26,
"vocab_size": 19... | 29 | Python | 24 | 494bd9ef78313436f0424b918f200dab8fc7c20b | share_ledger.py | 65,350 | 12 | 41 | get_all_transfers | https://github.com/frappe/erpnext.git | style: format code with black | 18 | 0 | 13,868 | 10 | |
3 | 11 | def sqeuclidean_row_norms(X, num_threads):
if X.dtype == np.float64:
return np.asarray(_sqeuclidean_row_norms64(X, num_threads))
if X.dtype == np.float32:
return np.asarray(_sqeuclidean_row_norms32(X, num_threads))
raise ValueError(
"Only float64 or float32 datasets are support... | sklearn/metrics/_pairwise_distances_reduction/_dispatcher.py | 100 | scikit-learn | {
"docstring": "Compute the squared euclidean norm of the rows of X in parallel.\n\n Parameters\n ----------\n X : ndarray or CSR matrix of shape (n_samples, n_features)\n Input data. Must be c-contiguous.\n\n num_threads : int\n The number of OpenMP threads to use.\n\n Returns\n -----... | 33 | Python | 28 | 239e16319116ab7445c0557bb08783ab2d60673d | _dispatcher.py | 261,541 | 9 | 57 | sqeuclidean_row_norms | https://github.com/scikit-learn/scikit-learn.git | MAINT Introduce `MiddleTermComputer`, an abstraction generalizing `GEMMTermComputer` (#24807)
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> | 76 | 0 | 76,852 | 11 | |
1 | 3 | def test_groupby_extension_agg(self):
super().test_groupby_extension_agg()
| pandas/tests/extension/json/test_json.py | 26 | pandas | {
"docstring": "\n This fails when we get to tm.assert_series_equal when left.index\n contains dictionaries, which are not hashable.\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 14
} | 3 | Python | 3 | 24652cf178c12562585639cba39c46d62b95f107 | test_json.py | 165,739 | 2 | 13 | test_groupby_extension_agg | https://github.com/pandas-dev/pandas.git | TST: Convert skip -> xfail (#46427) | 17 | 0 | 39,701 | 9 | |
1 | 20 | def test_login_deactivate_user_error(self) -> None:
user_profile = self.example_user("hamlet")
realm = user_profile.realm
self.assertTrue(email_auth_enabled(realm))
url = f"{realm.uri}/login/?" + urlencode({"is_deactivated": user_profile.delivery_email})
result = self.c... | zerver/tests/test_signup.py | 222 | zulip | {
"docstring": "\n This is meant to test whether the error message signaled by the\n is_deactivated is shown independently of whether the Email\n backend is enabled.\n ",
"language": "en",
"n_whitespaces": 52,
"n_words": 23,
"vocab_size": 18
} | 54 | Python | 34 | 61de767967bb6af077165075260eda3293f95970 | test_signup.py | 84,965 | 23 | 122 | test_login_deactivate_user_error | https://github.com/zulip/zulip.git | login page: Show form-independent errors even if email auth disabled.
These used to only be shown conditional on the
{% if password_auth_enabled %} in the template. Meaning that if you had
an org with email auth disabled and a deactivated user tried to log in,
they wouldn't see the error shown and get confused.
This ... | 188 | 0 | 17,898 | 12 | |
1 | 4 | def location_name(self) -> str | None:
return self._location_name
| homeassistant/components/mqtt/device_tracker/schema_discovery.py | 25 | core | {
"docstring": "Return a location name for the current location of the device.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 9
} | 8 | Python | 8 | bcae6d604e2967c7475f0caa4b1b5e4e76ab88bf | schema_discovery.py | 289,964 | 3 | 14 | location_name | https://github.com/home-assistant/core.git | Improve MQTT type hints part 8 (#81034)
* Improve typing device_tracker discovery
* Improve typing device_tracker yaml
* Add test source_type attribute
* Follow up comment
* Initialize at `__init__` not at class level.
* Use full name for return variable
* Correct import, remove assert
* Use Async... | 22 | 0 | 89,090 | 6 | |
1 | 3 | def __await__(self):
return self.__run().__await__()
| gradio/utils.py | 30 | gradio | {
"docstring": "\n Wrap Request's __await__ magic function to create request calls which are executed in one line.\n ",
"language": "en",
"n_whitespaces": 30,
"n_words": 15,
"vocab_size": 15
} | 4 | Python | 4 | 51c8c34486bfddca5948e46e498de44e21ab6496 | utils.py | 180,422 | 2 | 16 | __await__ | https://github.com/gradio-app/gradio.git | Async Request Class (#1595)
* Implement Request class and its tests.
* Add new requirements
* Reformat codebase.
* Fix formatting.
* Add library level requirements.
* Convert validated_data property to get_validated_data function.
* Fix the client fixture.
* Update test/test_utils.py
* Update t... | 18 | 0 | 43,164 | 9 | |
1 | 10 | async def enter_async_context(self, cm):
_cm_type = type(cm)
_exit = _cm_type.__aexit__
result = await _cm_type.__aenter__(cm)
self._push_async_cm_exit(cm, _exit)
return result
| python3.10.4/Lib/contextlib.py | 64 | XX-Net | {
"docstring": "Enters the supplied async context manager.\n\n If successful, also pushes its __aexit__ method as a callback and\n returns the result of the __aenter__ method.\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 24,
"vocab_size": 22
} | 18 | Python | 15 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | contextlib.py | 221,717 | 6 | 38 | enter_async_context | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 60 | 0 | 56,485 | 9 | |
1 | 5 | def strip_to_restore(self, text):
text, puncs = self._strip_to_restore(text)
return text, puncs
| TTS/tts/utils/text/punctuation.py | 37 | TTS | {
"docstring": "Remove punctuations from text to restore them later.\n\n Args:\n text (str): The text to be processed.\n\n Examples ::\n\n \"This is. example !\" -> [[\"This is\", \"example\"], [\".\", \"!\"]]\n\n ",
"language": "en",
"n_whitespaces": 71,
"n_words": 28... | 10 | Python | 8 | 8d85af84cd5f1748f979fddcbc4aab1449f61ecb | punctuation.py | 261,975 | 3 | 22 | strip_to_restore | https://github.com/coqui-ai/TTS.git | Implement Punctuation class | 31 | 0 | 77,090 | 8 | |
8 | 30 | def batch_encode_candidates(self, text, **kwargs):
r
# Always using a fixed sequence length to encode in order to stack candidates into a batch.
kwargs["padding"] = PaddingStrategy.MAX_LENGTH
batch_text = text
batch_text_pair = kwargs.pop("text_pair", None)
return_tenso... | src/transformers/models/realm/tokenization_realm.py | 351 | transformers | {
"docstring": "\n Encode a batch of text or text pair. This method is similar to regular __call__ method but has the following\n differences:\n\n 1. Handle additional num_candidate axis. (batch_size, num_candidates, text)\n 2. Always pad the sequences to *max_length*.\n ... | 112 | Python | 74 | 22454ae492eca4bb749fa6d770dffc91d17dab87 | tokenization_realm.py | 34,115 | 62 | 213 | batch_encode_candidates | https://github.com/huggingface/transformers.git | Add REALM (#13292)
* REALM initial commit
* Retriever OK (Update new_gelu).
* Encoder prediction score OK
* Encoder pretrained model OK
* Update retriever comments
* Update docs, tests, and imports
* Prune unused models
* Make embedder as a module `RealmEmbedder`
* Add RealmRetrieverOutput
*... | 395 | 0 | 6,202 | 13 | |
5 | 12 | def weight_intercept(self, coef):
if not self.base_loss.is_multiclass:
if self.fit_intercept:
intercept = coef[-1]
weights = coef[:-1]
else:
intercept = 0.0
weights = coef
else:
# reshape to (n_c... | sklearn/linear_model/_linear_loss.py | 185 | scikit-learn | {
"docstring": "Helper function to get coefficients and intercept.\n\n Parameters\n ----------\n coef : ndarray of shape (n_dof,), (n_classes, n_dof) or (n_classes * n_dof,)\n Coefficients of a linear model.\n If shape (n_classes * n_dof,), the classes of one feature are con... | 57 | Python | 31 | ff9344f3d8d11d38fa3a2497199113e5bac9537c | _linear_loss.py | 261,401 | 19 | 116 | weight_intercept | 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 ... | 297 | 0 | 76,808 | 16 | |
3 | 27 | def _run_executable(self, prog, args, run_from_path, runtime):
# Run the test in a clean environment to make sure they're really self-contained.
prog_env = copy.deepcopy(os.environ)
prog_env['PATH'] = ''
del prog_env['PATH']
# For Windows we need to keep minimal PATH for... | PyInstaller/utils/conftest.py | 275 | pyinstaller | {
"docstring": "\n Run executable created by PyInstaller.\n\n :param args: CLI options to pass to the created executable.\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 13
} | 169 | Python | 115 | be94db4587c16f3f6498d64d563c7ce740e11863 | conftest.py | 263,985 | 16 | 165 | _run_executable | https://github.com/pyinstaller/pyinstaller.git | tests: do not attempt to re-run executable after a failed run
Remove the re-runs of a failed executable. This functionality
was originally intended for executables whose execution timed
out (when running in "regular" mode, where we expect the
program to exit). However, it ended up subtly broken ever
since cf9dfec8018c... | 390 | 0 | 77,541 | 14 | |
7 | 14 | def unscale_gradients(self, optimizer=None):
if self.state.use_fp16 and self.native_amp:
if optimizer is None:
# TODO: this unscales all optimizers where we should only unscale the one where parameters are.
optimizer = self._optimizers
elif not is... | src/accelerate/accelerator.py | 119 | accelerate | {
"docstring": "\n Unscale the gradients in mixed precision training with AMP. This is a noop in all other settings.\n\n Args:\n optimizer (`torch.optim.Optimizer` or `List[torch.optim.Optimizer]`, *optional*):\n The optimizer(s) for which to unscale gradients. If not set, will... | 49 | Python | 42 | fb5ed62c102c0323486b89805e1888495de3db15 | accelerator.py | 337,281 | 10 | 75 | unscale_gradients | https://github.com/huggingface/accelerate.git | Convert documentation to the new front (#271)
* Main conversion
* Doc styling
* Style
* New front deploy
* Fixes
* Fixes
* Fix new docstrings
* Style | 190 | 0 | 120,995 | 13 | |
1 | 32 | def test_coin_api_load_df_for_ta(get_bitcoin, mocker):
mock_load = mocker.patch(
base
+ "due_diligence.pycoingecko_model.CoinGeckoAPI.get_coin_market_chart_by_id"
)
_, symbol = get_bitcoin
coin_map_df = prepare_all_coins_df().set_index("Symbol").loc[symbol.upper()].iloc[0]
with... | tests/openbb_terminal/cryptocurrency/test_cryptocurrency_helpers.py | 205 | @pytest.mark.record_stdout
@pytest.mark.vcr | OpenBBTerminal | {
"docstring": "\n Mock load function through get_coin_market_chart_by_id.\n Mock returns a dict saved as .json\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 12,
"vocab_size": 11
} | 50 | Python | 39 | 9068ad01249c1e1adaca3ef9a704d70da7e3a17b | test_cryptocurrency_helpers.py | 284,452 | 21 | 110 | test_coin_api_load_df_for_ta | https://github.com/OpenBB-finance/OpenBBTerminal.git | Refactored Crypto Tests (#1743)
* Refactored tests
* Removed unused command
* Added tests
* Tests : remove cassettes files + add fixture
* Black
* Tests : skip tests
Co-authored-by: didierlopes.eth <dro.lopes@campus.fct.unl.pt>
Co-authored-by: minhhoang1023 <40023817+minhhoang1023@users.noreply.gith... | 147 | 1 | 84,723 | 14 |
1 | 7 | def choose_parent_view(self, request):
kwargs = {"model_admin": self}
view_class = self.choose_parent_view_class
return view_class.as_view(**kwargs)(request)
| wagtail/contrib/modeladmin/options.py | 54 | wagtail | {
"docstring": "\n Instantiates a class-based view to allows a parent page to be chosen\n for a new object, where the assigned model extends Wagtail's Page\n model, and there is more than one potential parent for new instances.\n The view class used can be overridden by changing the\n ... | 12 | Python | 11 | d10f15e55806c6944827d801cd9c2d53f5da4186 | options.py | 73,176 | 4 | 31 | choose_parent_view | https://github.com/wagtail/wagtail.git | Reformat with black | 40 | 0 | 15,972 | 9 | |
1 | 10 | def is_within_directory(directory, target):
# type: (str, str) -> bool
abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)
prefix = os.path.commonprefix([abs_directory, abs_target])
return prefix == abs_directory
| .venv/lib/python3.8/site-packages/pip/_internal/utils/unpacking.py | 75 | transferlearning | {
"docstring": "\n Return true if the absolute path of target is within the directory\n ",
"language": "en",
"n_whitespaces": 19,
"n_words": 12,
"vocab_size": 11
} | 23 | Python | 19 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | unpacking.py | 61,321 | 5 | 46 | is_within_directory | https://github.com/jindongwang/transferlearning.git | upd; format | 41 | 0 | 12,507 | 9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.