complexity int64 1 139 | fun_name stringlengths 1 80 | code stringlengths 101 62.2k | commit_id stringlengths 40 40 | ast_errors stringlengths 0 3.11k | ast_levels int64 6 36 | file_name stringlengths 5 79 | n_ast_nodes int64 17 19.2k | commit_message stringlengths 3 15.3k | d_id int64 12 121k | n_ast_errors int64 0 9 | n_whitespaces int64 4 10.8k | token_counts int64 5 3.06k | vocab_size int64 4 1.11k | id int64 20 338k | n_words int64 4 4.82k | repo stringlengths 3 22 | n_identifiers int64 2 176 | path stringlengths 7 134 | language stringclasses 1
value | nloc int64 1 413 | documentation dict | url stringlengths 31 59 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | preprocess_input | def preprocess_input(x, data_format=None):
return x
@keras_export("keras.applications.efficientnet_v2.decode_predictions") | 3613c3defc39c236fb1592c4f7ba1a9cc887343a | @keras_export("keras.applications.efficientnet_v2.decode_predictions") | 7 | efficientnet_v2.py | 32 | Remove pylint comments.
PiperOrigin-RevId: 452353044 | 82,629 | 1 | 11 | 12 | 6 | 278,616 | 6 | keras | 4 | keras/applications/efficientnet_v2.py | Python | 2 | {
"docstring": "A placeholder method for backward compatibility.\n\n The preprocessing logic has been included in the EfficientNetV2 model\n implementation. Users are no longer required to call this method to\n normalize the input data. This method does nothing and only kept as a\n placeholder to align th... | https://github.com/keras-team/keras.git |
2 | make_increasing_ohlc | def make_increasing_ohlc(open, high, low, close, dates, **kwargs):
(flat_increase_x, flat_increase_y, text_increase) = _OHLC(
open, high, low, close, dates
).get_increase()
if "name" in kwargs:
showlegend = True
else:
kwargs.setdefault("name", "Increasing")
showlege... | 43e3a4011080911901176aab919c0ecf5046ddd3 | 11 | _ohlc.py | 183 | switch to black .22 | 57,818 | 0 | 148 | 117 | 39 | 226,144 | 48 | plotly.py | 23 | packages/python/plotly/plotly/figure_factory/_ohlc.py | Python | 20 | {
"docstring": "\n Makes increasing ohlc sticks\n\n _make_increasing_ohlc() and _make_decreasing_ohlc separate the\n increasing trace from the decreasing trace so kwargs (such as\n color) can be passed separately to increasing or decreasing traces\n when direction is set to 'increasing' or 'decreasing'... | https://github.com/plotly/plotly.py.git | |
1 | test_tags_help_text_no_spaces_allowed | def test_tags_help_text_no_spaces_allowed(self):
widget = widgets.AdminTagWidget()
help_text = widget.get_context(None, None, {})["widget"]["help_text"]
html = widget.render("tags", None, {})
help_text_html_element = self.get_help_text_html_element(html)
self.assertEqu... | 1822d7eee23cf5fceff8b1f58f3ca2f0a32c6e34 | 11 | test_widgets.py | 122 | display help text message for tag field
- resolves #1874
- ensure message is dynamic based on the setting TAG_SPACES_ALLOWED
- Update wagtail/admin/templates/wagtailadmin/widgets/tag_widget.html | 16,621 | 0 | 134 | 72 | 31 | 77,079 | 37 | wagtail | 13 | wagtail/admin/tests/test_widgets.py | Python | 12 | {
"docstring": "Checks that the tags help text html element content is correct when TAG_SPACES_ALLOWED is False<p class=\"help\">%s</p>",
"language": "en",
"n_whitespaces": 15,
"n_words": 16,
"vocab_size": 15
} | https://github.com/wagtail/wagtail.git | |
3 | handle_template_exception | def handle_template_exception(ex, field):
if ex.args and ex.args[0].startswith("UndefinedError: 'None' has no attribute"):
# Common during HA startup - so just a warning
_LOGGER.warning(ex)
return
_LOGGER.error("Error parsing template for field %s", field, ex... | 73a368c24246b081cdb98923ca3180937d436c3b | 10 | helpers.py | 75 | Refactor history_stats to minimize database access (part 2) (#70255) | 95,827 | 0 | 85 | 44 | 31 | 296,853 | 31 | core | 9 | homeassistant/components/history_stats/helpers.py | Python | 5 | {
"docstring": "Log an error nicely if the template cannot be interpreted.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/home-assistant/core.git | |
3 | find_profile_dir_by_name | def find_profile_dir_by_name(cls, ipython_dir, name=u'default', config=None):
dirname = u'profile_' + name
paths = [ipython_dir]
for p in paths:
profile_dir = os.path.join(p, dirname)
if os.path.isdir(profile_dir):
return cls(location=profile_dir,... | 1ec91ebf328bdf3450130de4b4604c79dc1e19d9 | 12 | profiledir.py | 119 | FIX CVE-2022-21699
See https://github.com/ipython/ipython/security/advisories/GHSA-pq7m-3gw7-gq5x | 52,335 | 0 | 120 | 75 | 32 | 208,471 | 37 | ipython | 15 | IPython/core/profiledir.py | Python | 9 | {
"docstring": "Find an existing profile dir by profile name, return its ProfileDir.\n\n This searches through a sequence of paths for a profile dir. If it\n is not found, a :class:`ProfileDirError` exception will be raised.\n\n The search path algorithm is:\n 1. ``os.getcwd()`` # removed... | https://github.com/ipython/ipython.git | |
11 | add_dep_paths | def add_dep_paths():
paths = []
if old_deps is not None:
for importer, modname, ispkg in pkgutil.iter_modules(
old_deps.__path__):
if not ispkg:
continue
try:
mod = importer.find_module(modname).load_module(modname)
... | e6c144b5423dada62fd13034c2d40bf48a2bc423 | 16 | __init__.py | 293 | Replace deprecated logging.warn with logging.warning (#7906) | 47,008 | 0 | 332 | 171 | 38 | 194,585 | 77 | kivy | 22 | kivy/tools/packaging/pyinstaller_hooks/__init__.py | Python | 29 | {
"docstring": "Should be called by the hook. It adds the paths with the binary\n dependencies to the system path so that pyinstaller can find the binaries\n during its crawling stage.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 29,
"vocab_size": 25
} | https://github.com/kivy/kivy.git | |
4 | _ln_exp_bound | def _ln_exp_bound(self):
# for 0.1 <= x <= 10 we use the inequalities 1-1/x <= ln(x) <= x-1
adj = self._exp + len(self._int) - 1
if adj >= 1:
# argument >= 10; we use 23/10 = 2.3 as a lower bound for ln(10)
return len(str(adj*23//10)) - 1
if adj <= -2:
... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 17 | _pydecimal.py | 225 | add python 3.10.4 for windows | 55,682 | 0 | 267 | 126 | 59 | 219,652 | 109 | XX-Net | 15 | python3.10.4/Lib/_pydecimal.py | Python | 13 | {
"docstring": "Compute a lower bound for the adjusted exponent of self.ln().\n In other words, compute r such that self.ln() >= 10**r. Assumes\n that self is finite and positive and that self != 1.\n ",
"language": "en",
"n_whitespaces": 54,
"n_words": 32,
"vocab_size": 28
} | https://github.com/XX-net/XX-Net.git | |
1 | test_orderline_query | def test_orderline_query(staff_api_client, permission_manage_orders, fulfilled_order):
order = fulfilled_order
query =
line = order.lines.first()
metadata_key = "md key"
metadata_value = "md value"
line.store_value_in_private_metadata({metadata_key: metadata_value})
line.store_value_in_me... | a68553e1a55e3a1bd32826cdce294d27f74175e9 | 15 | test_order.py | 595 | Metadata added to checkout and order lines (#10040)
* Metadata added to checkout and order lines
* CHANGELOG.md update
* Missing tests added | 5,130 | 0 | 330 | 349 | 78 | 27,800 | 129 | saleor | 45 | saleor/graphql/order/tests/test_order.py | Python | 93 | {
"docstring": "\n query OrdersQuery {\n orders(first: 1) {\n edges {\n node {\n lines {\n thumbnail(size: 540) {\n url\n }\n varia... | https://github.com/saleor/saleor.git | |
1 | test_login_view | def test_login_view(self):
# Get login page
response = self.client.get(reverse("wagtailadmin_login"))
# Check that the user received a login page
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/login.html")
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 11 | test_account_management.py | 67 | Reformat with black | 15,736 | 0 | 64 | 37 | 19 | 71,769 | 22 | wagtail | 9 | wagtail/admin/tests/test_account_management.py | Python | 4 | {
"docstring": "\n This tests that the login view responds with a login page\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 11,
"vocab_size": 10
} | https://github.com/wagtail/wagtail.git | |
8 | construct_change_message | def construct_change_message(form, formsets, add):
# Evaluating `form.changed_data` prior to disabling translations is required
# to avoid fields affected by localization from being included incorrectly,
# e.g. where date formats differ such as MM/DD/YYYY vs DD/MM/YYYY.
changed_data = form.changed_... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 23 | utils.py | 352 | Refs #33476 -- Reformatted code with Black. | 50,436 | 0 | 979 | 206 | 101 | 203,539 | 144 | django | 22 | django/contrib/admin/utils.py | Python | 43 | {
"docstring": "\n Construct a JSON structure describing changes from a changed object.\n Translations are deactivated so that strings are stored untranslated.\n Translation happens later on LogEntry access.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 25,
"vocab_size": 23
} | https://github.com/django/django.git | |
9 | split_header_words | def split_header_words(header_values):
r
assert not isinstance(header_values, str)
result = []
for text in header_values:
orig_text = text
pairs = []
while text:
m = HEADER_TOKEN_RE.search(text)
if m:
text = unmatched(m)
nam... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 19 | cookiejar.py | 392 | add python 3.10.4 for windows | 54,932 | 0 | 700 | 227 | 78 | 217,784 | 136 | XX-Net | 29 | python3.10.4/Lib/http/cookiejar.py | Python | 81 | {
"docstring": "Parse header values into a list of lists containing key,value pairs.\n\n The function knows how to deal with \",\", \";\" and \"=\" as well as quoted\n values after \"=\". A list of space separated tokens are parsed as if they\n were separated by \";\".\n\n If the header_values passed as ... | https://github.com/XX-net/XX-Net.git | |
2 | reparse | def reparse(self) -> None:
# Do this in a fresh Stylesheet so if there are errors we don't break self.
stylesheet = Stylesheet(variables=self.variables)
for css, path in self.source:
stylesheet.parse(css, path=path)
self._clone(stylesheet)
| e8636d0d86e596690647564b84a68d5e6d107dd0 | 10 | stylesheet.py | 71 | css reparse | 43,963 | 0 | 77 | 43 | 30 | 182,783 | 31 | textual | 10 | src/textual/css/stylesheet.py | Python | 12 | {
"docstring": "Re-parse source, applying new variables.\n\n Raises:\n StylesheetError: If the CSS could not be read.\n StylesheetParseError: If the CSS is invalid.\n\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 20,
"vocab_size": 17
} | https://github.com/Textualize/textual.git | |
3 | _get_feature_encoder_or_decoder | def _get_feature_encoder_or_decoder(feature):
if DECODER in feature:
return feature[DECODER]
elif ENCODER in feature:
return feature[ENCODER]
else:
feature[ENCODER] = {}
return feature[ENCODER]
| 60197fe851aadfa51d18c16dd42b49f728ed7eaa | 10 | dataset_synthesizer.py | 65 | Adds registry to organize backward compatibility updates around versions and config sections (#2335)
* First pass implementation of VersionTransformation
* Remove test main.
* Refactors backward_compatibility.py to use version registration system
* Changed sort order to process outer first.
* Moves test_de... | 1,274 | 0 | 60 | 40 | 14 | 7,812 | 20 | ludwig | 4 | ludwig/data/dataset_synthesizer.py | Python | 8 | {
"docstring": "Returns the nested decoder or encoder dictionary for a feature.\n\n If neither encoder nor decoder is present, creates an empty encoder dict and returns it.\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 25,
"vocab_size": 22
} | https://github.com/ludwig-ai/ludwig.git | |
1 | test_ContinuousSelector_4 | def test_ContinuousSelector_4():
cs = ContinuousSelector()
assert_raises(ValueError, cs.transform, iris_data[0:10,:])
| 388616b6247ca4ea8de4e2f340d6206aee523541 | 9 | feature_transformers_tests.py | 45 | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 43,430 | 0 | 17 | 27 | 8 | 181,642 | 8 | tpot | 7 | tests/feature_transformers_tests.py | Python | 3 | {
"docstring": "Assert that ContinuousSelector rasies ValueError without categorical features.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/EpistasisLab/tpot.git | |
6 | dpm_solver_first_update | def dpm_solver_first_update(self, x, s, t, model_s=None, return_intermediate=False):
ns = self.noise_schedule
dims = x.dim()
lambda_s, lambda_t = ns.marginal_lambda(s), ns.marginal_lambda(t)
h = lambda_t - lambda_s
log_alpha_s, log_alpha_t = ns.marginal_log_mean_coeff(s)... | ca86da3a30c4e080d4db8c25fca73de843663cb4 | 17 | dpm_solver.py | 371 | release more models | 36,909 | 0 | 481 | 235 | 57 | 157,369 | 113 | stablediffusion | 30 | ldm/models/diffusion/dpm_solver/dpm_solver.py | Python | 32 | {
"docstring": "\n DPM-Solver-1 (equivalent to DDIM) from time `s` to time `t`.\n Args:\n x: A pytorch tensor. The initial value at time `s`.\n s: A pytorch tensor. The starting time, with the shape (x.shape[0],).\n t: A pytorch tensor. The ending time, with the shape (x... | https://github.com/Stability-AI/stablediffusion.git | |
3 | _asarray_with_order | def _asarray_with_order(array, dtype=None, order=None, copy=None, xp=None):
if xp is None:
xp, _ = get_namespace(array)
if xp.__name__ in {"numpy", "numpy.array_api"}:
# Use NumPy API to support order
array = numpy.asarray(array, order=order, dtype=dtype)
return xp.asarray(a... | 2710a9e7eefd2088ce35fd2fb6651d5f97e5ef8b | 11 | _array_api.py | 139 | ENH Adds Array API support to LinearDiscriminantAnalysis (#22554)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz> | 76,628 | 0 | 86 | 90 | 34 | 261,023 | 39 | scikit-learn | 11 | sklearn/utils/_array_api.py | Python | 8 | {
"docstring": "Helper to support the order kwarg only for NumPy-backed arrays\n\n Memory layout parameter `order` is not exposed in the Array API standard,\n however some input validation code in scikit-learn needs to work both\n for classes and functions that will leverage Array API only operations\n an... | https://github.com/scikit-learn/scikit-learn.git | |
1 | test_bound_blocks_are_available_on_template | def test_bound_blocks_are_available_on_template(self):
block = SectionBlock()
value = block.to_python({"title": "Hello", "body": "<i>italic</i> world"})
result = block.render(value)
self.assertEqual(result, )
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 11 | test_blocks.py | 81 | Reformat with black | 16,226 | 0 | 52 | 43 | 15 | 74,164 | 17 | wagtail | 9 | wagtail/core/tests/test_blocks.py | Python | 5 | {
"docstring": "\n Test that we are able to use value.bound_blocks within templates\n to access a child block's own HTML rendering\n <h1>Hello</h1><i>italic</i> world",
"language": "en",
"n_whitespaces": 41,
"n_words": 20,
"vocab_size": 19
} | https://github.com/wagtail/wagtail.git | |
2 | _genName | def _genName(cls, name):
if not name:
name = "frame_" + str(uuid.uuid4()).replace("-", "")
# TODO: reword name in case of caller's mistake
return name
| 1c0935c1bc0856d43f69c1e32498636ee24ebc85 | 15 | base_worker.py | 62 | FEAT-#4913: Enabling pyhdk (#4900)
Co-authored-by: ienkovich <ilya.enkovich@intel.com>
Signed-off-by: izamyati <igor.zamyatin@intel.com> | 35,956 | 0 | 62 | 33 | 21 | 154,395 | 23 | modin | 7 | modin/experimental/core/execution/native/implementations/omnisci_on_native/base_worker.py | Python | 4 | {
"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": "... | https://github.com/modin-project/modin.git | |
11 | sort_graph_by_row_values | def sort_graph_by_row_values(graph, copy=False, warn_when_not_sorted=True):
if not issparse(graph):
raise TypeError(f"Input graph must be a sparse matrix, got {graph!r} instead.")
if graph.format == "csr" and _is_sorted_by_data(graph):
return graph
if warn_when_not_sorted:
war... | b94bc5ea6821607d1e9826ce2d084c76379820ba | 15 | _base.py | 503 | ENH add new function sort_graph_by_row_values (#23139)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> | 75,959 | 0 | 501 | 297 | 125 | 259,865 | 190 | scikit-learn | 33 | sklearn/neighbors/_base.py | Python | 41 | {
"docstring": "Sort a sparse graph such that each row is stored with increasing values.\n\n .. versionadded:: 1.2\n\n Parameters\n ----------\n graph : sparse matrix of shape (n_samples, n_samples)\n Distance matrix to other samples, where only non-zero elements are\n considered neighbors. ... | https://github.com/scikit-learn/scikit-learn.git | |
1 | add_and_show_greeks | def add_and_show_greeks(price, implied_volatility, strike, days, side):
# Add in hedge option
delta, gamma, vega = hedge_model.add_hedge_option(
price, implied_volatility, strike, days, side
)
# Show the added delta, gamma and vega positions. Next to that, also show the inputted
# impl... | 54a1b6f545a0016c576e9e00eef5c003d229dacf | 11 | hedge_view.py | 154 | Feature/hedge (#1768)
* [Bug] Incorrect log for reddit keys. #1733 fix
* Create new feature-hedge
* Significantly improve code of hedge menu
* More robust
* Robustness
* Fix tests
* Fix can't multiply sequence by non-int of type 'numpy.float64' error
* Temporary fix of singular matrix error. Retur... | 84,766 | 0 | 135 | 101 | 53 | 284,500 | 71 | OpenBBTerminal | 22 | openbb_terminal/stocks/options/hedge/hedge_view.py | Python | 12 | {
"docstring": "Determine the delta, gamma and vega value of the portfolio and/or options and show them.\n\n Parameters\n ----------\n price: int\n The price.\n implied_volatility: float\n The implied volatility.\n strike: float\n The strike price.\n days: float\n The amo... | https://github.com/OpenBB-finance/OpenBBTerminal.git | |
1 | test_acknowledged_new | def test_acknowledged_new(self) -> None:
expected_topic = "Test policy name (1234)"
expected_message = .strip()
self.check_webhook(
"incident_acknowledged_new",
expected_topic,
expected_message,
content_type="application/json",
)
| bfd9fc86223c2446e8b38d2cdd5876caed50bfda | 9 | tests.py | 57 | integration: Fix integration with newrelic.
Newrelic updated the payload that's sent via the webhook incoming call
causing a bug in the newrelic webhook endpoint.
This fixes the bug by updating the endpoint to respect the new format
of the payload as well as the old format. This should be updated once
the old format i... | 17,831 | 0 | 90 | 32 | 18 | 84,412 | 19 | zulip | 7 | zerver/webhooks/newrelic/tests.py | Python | 11 | {
"docstring": "\n[Incident](https://alerts.newrelic.com/accounts/2941966/incidents/1234) **acknowledged** by **Alice** for condition: **Server Down**\n",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/zulip/zulip.git | |
2 | _get_vhost_block | def _get_vhost_block(self, vhost):
try:
span_val = self.parser.aug.span(vhost.path)
except ValueError:
logger.critical("Error while reading the VirtualHost %s from "
"file %s", vhost.name, vhost.filep, exc_info=True)
raise errors.... | eeca208c8f57304590ac1af80b496e61021aaa45 | 13 | configurator.py | 187 | Various clean-ups in certbot-apache. Use f-strings. (#9132)
* Various clean-ups in certbot-apache. Use f-strings.
* Smaller tweaks | 45,465 | 0 | 195 | 110 | 43 | 186,369 | 50 | certbot | 26 | certbot-apache/certbot_apache/_internal/configurator.py | Python | 15 | {
"docstring": " Helper method to get VirtualHost contents from the original file.\n This is done with help of augeas span, which returns the span start and\n end positions\n\n :returns: `list` of VirtualHost block content lines without closing tag\n ",
"language": "en",
"n_whitespaces... | https://github.com/certbot/certbot.git | |
3 | __call__ | def __call__(self, string):
texts = []
floats = []
for i, part in enumerate(self._FLOAT_RE.split(string)):
if i % 2 == 0:
texts.append(part)
else:
floats.append(float(part))
return texts, np.array(floats)
| 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 14 | keras_doctest_lib.py | 109 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81,626 | 0 | 113 | 66 | 24 | 276,313 | 26 | keras | 14 | keras/testing_infra/keras_doctest_lib.py | Python | 9 | {
"docstring": "Extracts floats from a string.\n\n >>> text_parts, floats = _FloatExtractor()(\"Text 1.0 Text\")\n >>> text_parts\n ['Text ', ' Text']\n >>> floats\n array([1.])\n\n Args:\n string: the string to extract floats from.\n\n Returns:\n A (... | https://github.com/keras-team/keras.git | |
7 | parse_boundary_stream | def parse_boundary_stream(stream, max_header_size):
# Stream at beginning of header, look for end of header
# and parse it if found. The header must fit within one
# chunk.
chunk = stream.read(max_header_size)
# 'find' returns the top of these four bytes, so we'll
# need to munch them late... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 9 | multipartparser.py | 53 | Refs #33476 -- Reformatted code with Black. | 51,350 | 0 | 86 | 149 | 47 | 206,065 | 59 | django | 7 | django/http/multipartparser.py | Python | 24 | {
"docstring": "\n Parse one and exactly one stream that encapsulates a boundary.\n ",
"language": "en",
"n_whitespaces": 17,
"n_words": 10,
"vocab_size": 9
} | https://github.com/django/django.git | |
12 | slice_with_int_dask_array | def slice_with_int_dask_array(x, index):
from dask.array.core import Array
assert len(index) == x.ndim
fancy_indexes = [
isinstance(idx, (tuple, list))
or (isinstance(idx, (np.ndarray, Array)) and idx.ndim > 0)
for idx in index
]
if sum(fancy_indexes) > 1:
raise... | cccb9d8d8e33a891396b1275c2448c352ef40c27 | 19 | slicing.py | 344 | absolufy-imports - No relative - PEP8 (#8796)
Conversation in https://github.com/dask/distributed/issues/5889 | 36,524 | 0 | 408 | 219 | 89 | 156,059 | 127 | dask | 31 | dask/array/slicing.py | Python | 31 | {
"docstring": "Slice x with at most one 1D dask arrays of ints.\n\n This is a helper function of :meth:`Array.__getitem__`.\n\n Parameters\n ----------\n x: Array\n index: tuple with as many elements as x.ndim, among which there are\n one or more Array's with dtype=int\n\n Returns\n --... | https://github.com/dask/dask.git | |
1 | get_edit_upload_response_data | def get_edit_upload_response_data(self):
return {
"success": True,
self.context_upload_id_name: self.upload_object.id,
"form": render_to_string(
self.edit_form_template_name,
self.get_edit_upload_form_context_data(),
re... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 11 | multiple_upload.py | 72 | Reformat with black | 15,889 | 0 | 125 | 45 | 15 | 72,418 | 15 | wagtail | 9 | wagtail/admin/views/generic/multiple_upload.py | Python | 10 | {
"docstring": "\n Return the JSON response data for an object that has been uploaded to an\n upload object and now needs extra metadata to become a final object\n ",
"language": "en",
"n_whitespaces": 48,
"n_words": 26,
"vocab_size": 22
} | https://github.com/wagtail/wagtail.git | |
1 | peek | def peek(self, n=0):
self._check_can_read()
# Relies on the undocumented fact that BufferedReader.peek()
# always returns at least one byte (except at EOF), independent
# of the value of n
return self._buffer.peek(n)
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 8 | bz2.py | 44 | add python 3.10.4 for windows | 56,263 | 0 | 73 | 24 | 26 | 221,193 | 31 | XX-Net | 5 | python3.10.4/Lib/bz2.py | Python | 3 | {
"docstring": "Return buffered data without advancing the file position.\n\n Always returns at least one byte of data, unless at EOF.\n The exact number of bytes returned is unspecified.\n ",
"language": "en",
"n_whitespaces": 48,
"n_words": 27,
"vocab_size": 25
} | https://github.com/XX-net/XX-Net.git | |
3 | _get_boot_time_aix | def _get_boot_time_aix():
res = __salt__["cmd.run_all"]("ps -o etime= -p 1")
if res["retcode"] > 0:
raise CommandExecutionError("Unable to find boot_time for pid 1.")
bt_time = res["stdout"]
match = re.match(r"\s*(?:(\d+)-)?(?:(\d\d):)?(\d\d):(\d\d)\s*", bt_time)
if not match:
r... | 7fabb22f3e361bfff3fdbca01c12659591d15109 | 14 | status.py | 182 | Fix uptime on AIX systems when less than 24 hours | 54,364 | 0 | 129 | 106 | 46 | 216,058 | 57 | salt | 11 | salt/modules/status.py | Python | 16 | {
"docstring": "\n Return the number of seconds since boot time on AIX\n\n t=$(LC_ALL=POSIX ps -o etime= -p 1)\n d=0 h=0\n case $t in *-*) d=${t%%-*}; t=${t#*-};; esac\n case $t in *:*:*) h=${t%%:*}; t=${t#*:};; esac\n s=$((d*86400 + h*3600 + ${t%%:*}*60 + ${t#*:}))\n ",
"language": "en",
"n_... | https://github.com/saltstack/salt.git | |
3 | _matches_get_other_nodes | def _matches_get_other_nodes(dictionary, nodes, node_ind):
ind_node = nodes[node_ind]
return [ind for ind in dictionary if nodes[ind] == ind_node]
| 9d58006fc0a23afcba38f641c9472917c436428a | 9 | mul.py | 47 | Code cleanup | 48,956 | 0 | 38 | 31 | 17 | 198,477 | 17 | sympy | 6 | sympy/core/mul.py | Python | 3 | {
"docstring": "Find other wildcards that may have already been matched.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/sympy/sympy.git | |
1 | test_uncancellable_disconnect | def test_uncancellable_disconnect(self) -> None:
channel = make_request(
self.reactor, self.site, "POST", "/sleep", await_result=False
)
self._test_disconnect(
self.reactor,
channel,
expect_cancellation=False,
expected_body={"r... | dffecade7df8a88caced2a7707c51e2de3407c0d | 11 | test_server.py | 81 | Respect the `@cancellable` flag for `DirectServe{Html,Json}Resource`s (#12698)
`DirectServeHtmlResource` and `DirectServeJsonResource` both inherit
from `_AsyncResource`. These classes expect to be subclassed with
`_async_render_*` methods.
This commit has no effect on `JsonResource`, despite inheriting from
`_A... | 72,162 | 0 | 110 | 51 | 18 | 248,229 | 20 | synapse | 10 | tests/test_server.py | Python | 11 | {
"docstring": "Test that handlers without the `@cancellable` flag cannot be cancelled.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/matrix-org/synapse.git | |
1 | test_del_store_not_found | def test_del_store_not_found(certutil, cert_file):
with pytest.raises(salt.exceptions.CommandExecutionError) as exc:
certutil.del_store(
source=str(cert_file.parent / "absent.cer"),
store="TrustedPublisher",
)
assert "cert_file not found" in exc.value.message
| a8d2d1e1397cdc79b2c5f1ad7f6e3b729dcf8857 | 14 | test_win_certutil.py | 88 | Add tests, fix state module | 54,234 | 0 | 64 | 50 | 19 | 215,899 | 19 | salt | 16 | tests/pytests/functional/modules/test_win_certutil.py | Python | 7 | {
"docstring": "\n Test del_store with a missing certificate\n ",
"language": "en",
"n_whitespaces": 13,
"n_words": 6,
"vocab_size": 6
} | https://github.com/saltstack/salt.git | |
2 | __next__ | def __next__(self):
line = self.readline()
if line:
return line
raise StopIteration
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 8 | codecs.py | 36 | add python 3.10.4 for windows | 56,375 | 0 | 50 | 20 | 10 | 221,360 | 11 | XX-Net | 5 | python3.10.4/Lib/codecs.py | Python | 5 | {
"docstring": " Return the next decoded line from the input stream.",
"language": "en",
"n_whitespaces": 9,
"n_words": 9,
"vocab_size": 8
} | https://github.com/XX-net/XX-Net.git | |
1 | datetime_cast_date_sql | def datetime_cast_date_sql(self, field_name, tzname):
raise NotImplementedError(
"subclasses of BaseDatabaseOperations may require a "
"datetime_cast_date_sql() method."
)
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 9 | operations.py | 31 | Refs #33476 -- Reformatted code with Black. | 50,949 | 0 | 59 | 16 | 16 | 204,876 | 16 | django | 5 | django/db/backends/base/operations.py | Python | 5 | {
"docstring": "\n Return the SQL to cast a datetime value to date value.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 11,
"vocab_size": 10
} | https://github.com/django/django.git | |
1 | test_empty | def test_empty(self) -> None:
id_gen = self._create_id_generator()
# The table is empty so we expect an empty map for positions
self.assertEqual(id_gen.get_positions(), {})
| 9d21ecf7ceab55bc19c4457b8b07401b0b1623a7 | 9 | test_id_generators.py | 50 | Add type hints to tests files. (#12256) | 71,933 | 0 | 50 | 28 | 21 | 247,800 | 22 | synapse | 6 | tests/storage/test_id_generators.py | Python | 6 | {
"docstring": "Test an ID generator against an empty database gives sensible\n current positions.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 12,
"vocab_size": 11
} | https://github.com/matrix-org/synapse.git | |
3 | nodata_value | def nodata_value(self, value):
if value is None:
capi.delete_band_nodata_value(self._ptr)
elif not isinstance(value, (int, float)):
raise ValueError("Nodata value must be numeric or None.")
else:
capi.set_band_nodata_value(self._ptr, value)
se... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | band.py | 93 | Refs #33476 -- Reformatted code with Black. | 50,605 | 0 | 93 | 56 | 24 | 204,001 | 25 | django | 12 | django/contrib/gis/gdal/raster/band.py | Python | 8 | {
"docstring": "\n Set the nodata value for this band.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | https://github.com/django/django.git | |
1 | test_has_module_permission | def test_has_module_permission(self):
self.client.force_login(self.superuser)
response = self.client.get(self.index_url)
self.assertContains(response, "admin_views")
self.assertContains(response, "Articles")
self.client.logout()
self.client.force_login(self.view... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 9 | tests.py | 376 | Refs #33476 -- Reformatted code with Black. | 52,077 | 0 | 221 | 224 | 14 | 207,737 | 46 | django | 14 | tests/admin_views/tests.py | Python | 25 | {
"docstring": "\n has_module_permission() returns True for all users who\n have any permission for that module (add, change, or delete), so that\n the module is displayed on the admin index page.\n ",
"language": "en",
"n_whitespaces": 57,
"n_words": 28,
"vocab_size": 24
} | https://github.com/django/django.git | |
2 | _supports_universal_builds | def _supports_universal_builds():
# As an approximation, we assume that if we are running on 10.4 or above,
# then we are running with an Xcode environment that supports universal
# builds, in particular -isysroot and -arch arguments to the compiler. This
# is in support of allowing 10.4 universal ... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 10 | _osx_support.py | 46 | add python 3.10.4 for windows | 55,636 | 0 | 88 | 25 | 51 | 219,598 | 67 | XX-Net | 4 | python3.10.4/Lib/_osx_support.py | Python | 3 | {
"docstring": "Returns True if universal builds are supported on this system",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/XX-net/XX-Net.git | |
1 | mock_smile_adam_2 | def mock_smile_adam_2() -> Generator[None, MagicMock, None]:
chosen_env = "m_adam_heating"
with patch(
"homeassistant.components.plugwise.gateway.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "da224107914542988a88561b4452b0f6"
... | 2667f0b792b1f936aeb5958cc40d5dee26350bf6 | @pytest.fixture | 11 | conftest.py | 180 | Bump plugwise to v0.21.3, add related new features (#76610)
Co-authored-by: Franck Nijhof <frenck@frenck.nl> | 87,135 | 1 | 146 | 95 | 39 | 287,952 | 51 | core | 21 | tests/components/plugwise/conftest.py | Python | 17 | {
"docstring": "Create a 2nd Mock Adam environment for testing exceptions.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/home-assistant/core.git |
1 | get_tables | def get_tables(self) -> StatusResponse:
query =
result = self.native_query(query)
df = result.data_frame
df = df[['TABLE_NAME' 'TABLE_TYPE']]
result.data_frame = df.rename(columns={'TABLE_NAME': 'table_name', 'TABLE_TYPE': 'table_type'})
return result
| 9a0e918bba3439959112a7fd8e5210276b5ac255 | 12 | druid_handler.py | 103 | implemented the get_tables() and get_columns() methods | 25,698 | 0 | 74 | 55 | 17 | 116,214 | 24 | mindsdb | 10 | mindsdb/integrations/handlers/druid_handler/druid_handler.py | Python | 15 | {
"docstring": "\n Return list of entities that will be accessible as tables.\n Returns:\n HandlerResponse\n \n SELECT *\n FROM INFORMATION_SCHEMA.TABLES\n ",
"language": "en",
"n_whitespaces": 79,
"n_words": 16,
"vocab_size": 16
} | https://github.com/mindsdb/mindsdb.git | |
4 | _add_unique_metric_name | def _add_unique_metric_name(self, metric_name, metric_fn, output_index):
# For multi-output models, prepend the output names to the metric name.
if len(self.output_names) > 1:
# If we're loading from an already-serialized model, we've already
# prepended the output name,... | fa6d9107a498f7c2403ff28c7b389a1a0c5cc083 | 14 | training_v1.py | 128 | reduct too long lines | 82,051 | 0 | 345 | 75 | 80 | 277,470 | 118 | keras | 11 | keras/engine/training_v1.py | Python | 13 | {
"docstring": "Makes the metric name unique.\n\n If there are multiple outputs for which the metrics are calculated,\n the metric names have to be made unique by appending an integer.\n\n Args:\n metric_name: Metric name that corresponds to the metric specified by\n the u... | https://github.com/keras-team/keras.git | |
1 | test_statistics_duplicated | def test_statistics_duplicated(hass_recorder, caplog):
hass = hass_recorder()
recorder = hass.data[DATA_INSTANCE]
setup_component(hass, "sensor", {})
zero, four, states = record_states(hass)
hist = history.get_significant_states(hass, zero, four)
assert dict(states) == dict(hist)
wait_... | 3737b58e85d834728fe27fefa05e8a0526e66d12 | 14 | test_statistics.py | 304 | Avoid fetching metadata multiple times during stat compile (#70397) | 97,291 | 0 | 236 | 181 | 44 | 298,347 | 88 | core | 28 | tests/components/recorder/test_statistics.py | Python | 28 | {
"docstring": "Test statistics with same start time is not compiled.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/home-assistant/core.git | |
2 | test_push | def test_push(self):
filename = "/saltines/test.file"
if salt.utils.platform.is_windows():
filename = "C:\\saltines\\test.file"
with patch(
"salt.modules.cp.os.path",
MagicMock(isfile=Mock(return_value=True), wraps=cp.os.path),
), patch(
... | 68ab9eeae6899b7ff14fb3489b012862d62653c6 | 16 | test_cp.py | 403 | Fix more tests | 54,034 | 0 | 514 | 241 | 63 | 215,571 | 88 | salt | 43 | tests/unit/modules/test_cp.py | Python | 36 | {
"docstring": "\n Test if push works with good posix path.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 8
} | https://github.com/saltstack/salt.git | |
23 | in1d | def in1d(ar1, ar2, assume_unique=False, invert=False, kind=None):
# Ravel both arrays, behavior for the first array could be different
ar1 = np.asarray(ar1).ravel()
ar2 = np.asarray(ar2).ravel()
# Ensure that iteration through object arrays yields size-1 arrays
if ar2.dtype == object:
... | cde60cee195660f2dafb2993e609d66559525fe8 | 17 | arraysetops.py | 955 | MAINT: Switch parameter name to 'kind' over 'method' | 38,719 | 0 | 1,384 | 585 | 258 | 160,766 | 496 | numpy | 57 | numpy/lib/arraysetops.py | Python | 77 | {
"docstring": "\n Test whether each element of a 1-D array is also present in a second array.\n\n Returns a boolean array the same length as `ar1` that is True\n where an element of `ar1` is in `ar2` and False otherwise.\n\n We recommend using :func:`isin` instead of `in1d` for new code.\n\n Parameter... | https://github.com/numpy/numpy.git | |
1 | center_of_mass | def center_of_mass(mask, esp=1e-6):
h, w = mask.shape
grid_h = torch.arange(h, device=mask.device)[:, None]
grid_w = torch.arange(w, device=mask.device)
normalizer = mask.sum().float().clamp(min=esp)
center_h = (mask * grid_h).sum() / normalizer
center_w = (mask * grid_w).sum() / normalizer... | fa77be290460e84ce7da975831cb7e687a419177 | 12 | misc.py | 156 | Refactor package | 70,747 | 0 | 60 | 100 | 25 | 245,290 | 36 | mmdetection | 18 | mmdet/models/utils/misc.py | Python | 8 | {
"docstring": "Calculate the centroid coordinates of the mask.\n\n Args:\n mask (Tensor): The mask to be calculated, shape (h, w).\n esp (float): Avoid dividing by zero. Default: 1e-6.\n\n Returns:\n tuple[Tensor]: the coordinates of the center point of the mask.\n\n - center_h ... | https://github.com/open-mmlab/mmdetection.git | |
23 | streams | def streams(self, stream_types=None, sorting_excludes=None):
try:
ostreams = self._get_streams()
if isinstance(ostreams, dict):
ostreams = ostreams.items()
# Flatten the iterator to a list so we can reuse it.
if ostreams:
... | b72f23fd699de9730e9009ac319b84da68f15a73 | 21 | plugin.py | 506 | docs: update API page, add type annotations | 45,676 | 0 | 907 | 482 | 135 | 187,036 | 215 | streamlink | 44 | src/streamlink/plugin/plugin.py | Python | 68 | {
"docstring": "\n Attempts to extract available streams.\n\n Returns a :class:`dict` containing the streams, where the key is\n the name of the stream (most commonly the quality name), with the value\n being a :class:`Stream` instance.\n\n The result can contain the synonyms **best... | https://github.com/streamlink/streamlink.git | |
18 | insert_predictor_answer | def insert_predictor_answer(self, insert):
model_interface = self.session.model_interface
data_store = self.session.data_store
select_data_query = insert.get('select_data_query')
if isinstance(select_data_query, str) is False or len(select_data_query) == 0:
self.pac... | 551205a18ac2ac19626f4e4ffb2ed88fcad705b9 | 16 | mysql_proxy.py | 713 | fix | 25,051 | 0 | 833 | 445 | 109 | 113,876 | 181 | mindsdb | 42 | mindsdb/api/mysql/mysql_proxy/mysql_proxy.py | Python | 63 | {
"docstring": " Start learn new predictor.\n Parameters:\n - insert - dict with keys as columns of mindsb.predictors table.\n ",
"language": "en",
"n_whitespaces": 47,
"n_words": 16,
"vocab_size": 15
} | https://github.com/mindsdb/mindsdb.git | |
3 | _remove_long_seq | def _remove_long_seq(maxlen, seq, label):
new_seq, new_label = [], []
for x, y in zip(seq, label):
if len(x) < maxlen:
new_seq.append(x)
new_label.append(y)
return new_seq, new_label
@keras_export('keras.preprocessing.sequence.TimeseriesGenerator') | f1aa8b7d2a0c89591c5c42eca5b6f013114a7bbd | @keras_export('keras.preprocessing.sequence.TimeseriesGenerator') | 11 | sequence.py | 99 | Copy sequence utils from keras_preprocessing directly into core keras
PiperOrigin-RevId: 424915569 | 79,741 | 1 | 41 | 55 | 22 | 268,873 | 25 | keras | 12 | keras/preprocessing/sequence.py | Python | 7 | {
"docstring": "Removes sequences that exceed the maximum length.\n\n Args:\n maxlen: Int, maximum length of the output sequences.\n seq: List of lists, where each sublist is a sequence.\n label: List where each element is an integer.\n\n Returns:\n new_seq, new_label: shortened lists for `seq` ... | https://github.com/keras-team/keras.git |
7 | remove_xml_tags | def remove_xml_tags(buf):
filtered = bytearray()
in_tag = False
prev = 0
buf = memoryview(buf).cast("c")
for curr, buf_char in enumerate(buf):
# Check if we're coming out of or entering an XML tag
if buf_char == b">":
prev = curr ... | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | 16 | charsetprober.py | 180 | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | 4,089 | 0 | 384 | 103 | 62 | 21,893 | 100 | pipenv | 12 | pipenv/patched/pip/_vendor/chardet/charsetprober.py | Python | 17 | {
"docstring": "\n Returns a copy of ``buf`` that retains only the sequences of English\n alphabet and high byte characters that are not between <> characters.\n This filter can be applied to all scripts which contain both English\n characters and extended ASCII characters, but is currentl... | https://github.com/pypa/pipenv.git | |
1 | test_rich_text_is_safe | def test_rich_text_is_safe(self):
stream_block = blocks.StreamBlock(
[
(
"paragraph",
blocks.RichTextBlock(template="tests/jinja2/rich_text.html"),
)
]
)
stream_value = stream_block.to_python... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 14 | test_jinja2.py | 125 | Reformat with black | 16,234 | 0 | 344 | 70 | 27 | 74,208 | 42 | wagtail | 12 | wagtail/core/tests/test_jinja2.py | Python | 26 | {
"docstring": "\n Ensure that RichText values are marked safe\n so that they don't get double-escaped when inserted into a parent template (#2542)\n ",
"language": "en",
"n_whitespaces": 42,
"n_words": 20,
"vocab_size": 19
} | https://github.com/wagtail/wagtail.git | |
6 | getWindowsDLLVersion | def getWindowsDLLVersion(filename):
# Get size needed for buffer (0 if no info)
import ctypes.wintypes
if type(filename) is unicode:
GetFileVersionInfoSizeW = ctypes.windll.version.GetFileVersionInfoSizeW
GetFileVersionInfoSizeW.argtypes = [
ctypes.wintypes.LPCWSTR,
... | 982929807fdc5838554cf302a2013a28e7707514 | 13 | SharedLibraries.py | 537 | macOS: Avoid references to original install paths as library ids | 42,769 | 0 | 480 | 351 | 118 | 178,629 | 194 | Nuitka | 43 | nuitka/utils/SharedLibraries.py | Python | 46 | {
"docstring": "Return DLL version information from a file.\n\n If not present, it will be (0, 0, 0, 0), otherwise it will be\n a tuple of 4 numbers.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 26,
"vocab_size": 21
} | https://github.com/Nuitka/Nuitka.git | |
1 | test_rollback_cursor_consistency | def test_rollback_cursor_consistency(self):
con = sqlite.connect(":memory:")
cur = con.cursor()
cur.execute("create table test(x)")
cur.execute("insert into test(x) values (5)")
cur.execute("select 1 union select 2 union select 3")
con.rollback()
self.as... | 9d6a239a34a66e16188d76c23a3a770515ca44ca | 9 | test_transactions.py | 123 | bpo-44092: Don't reset statements/cursors before rollback (GH-26026)
In SQLite versions pre 3.7.11, pending statements would block a rollback. This is no longer the case, so remove the workaround. | 41,562 | 0 | 85 | 71 | 26 | 175,168 | 29 | cpython | 11 | Lib/test/test_sqlite3/test_transactions.py | Python | 8 | {
"docstring": "Check that cursors behave correctly after rollback.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/python/cpython.git | |
1 | is_package | def is_package(cls, fullname):
return False
load_module = classmethod(_load_module_shim)
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 6 | _bootstrap.py | 28 | add python 3.10.4 for windows | 55,099 | 0 | 25 | 10 | 8 | 218,049 | 8 | XX-Net | 6 | python3.10.4/Lib/importlib/_bootstrap.py | Python | 2 | {
"docstring": "Return False as built-in modules are never packages.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/XX-net/XX-Net.git | |
2 | get_ind_under_point | def get_ind_under_point(self, event):
xy = self.pathpatch.get_path().vertices
xyt = self.pathpatch.get_transform().transform(xy) # to display coords
xt, yt = xyt[:, 0], xyt[:, 1]
d = np.sqrt((xt - event.x)**2 + (yt - event.y)**2)
ind = d.argmin()
return ind if d... | 1068a6faa19767724437461bcfb88c6852ec435c | 13 | path_editor.py | 152 | Remove unnecessary np.{,as}array / astype calls.
Quite often numpy will call asarray for us, saving us the need to call
asarray explicitly.
When we do call asarray (or array) ourselves, a dtype can directly be
passed in, rather than immediately calling astype immediately after.
Passing the dtype makes it unnecessary ... | 23,885 | 0 | 90 | 96 | 33 | 110,014 | 40 | matplotlib | 20 | examples/event_handling/path_editor.py | Python | 7 | {
"docstring": "\n Return the index of the point closest to the event position or *None*\n if no point is within ``self.epsilon`` to the event position.\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 23,
"vocab_size": 17
} | https://github.com/matplotlib/matplotlib.git | |
3 | round_filters | def round_filters(filters, global_params):
multiplier = global_params.width_coefficient
if not multiplier:
return filters
divisor = global_params.depth_divisor
filters *= multiplier
new_filters = int(filters + divisor / 2) // divisor * divisor
if new_... | 6e607a0fa1cefbf0388dac86c84debf4781cec48 | 12 | rec_efficientb3_pren.py | 92 | [Feature] Add PREN Scene Text Recognition Model(Accepted in CVPR2021) (#5563)
* [Feature] add PREN scene text recognition model
* [Patch] Optimize yml File
* [Patch] Save Label/Pred Preprocess Time Cost
* [BugFix] Modify Shape Conversion to Fit for Inference Model Exportion
* [Patch] ?
* [Patch] ?
* ... | 4,587 | 0 | 117 | 56 | 26 | 23,387 | 39 | PaddleOCR | 9 | ppocr/modeling/backbones/rec_efficientb3_pren.py | Python | 10 | {
"docstring": "Calculate and round number of filters based on depth multiplier.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/PaddlePaddle/PaddleOCR.git | |
6 | assert_lca_dicts_same | def assert_lca_dicts_same(self, d1, d2, G=None):
if G is None:
G = self.DG
root_distance = self.root_distance
else:
roots = [n for n, deg in G.in_degree if deg == 0]
assert len(roots) == 1
root_distance = nx.shortest_path_length(G, sou... | b2f91c34a23058dd70b41784af0d87890216026a | 13 | test_lowest_common_ancestors.py | 183 | Naive lowest common ancestor implementation (#5736)
* Add naive lca methods
* Naive algorithm implementation for LCA
* Modify naive lca functions
* Correct parameters of nx.ancestors
* Update lowest_common_ancestors.py
* Parametrize tests
* Apply suggestions from code review
Co-authored-by: Dan Sc... | 42,227 | 0 | 177 | 124 | 40 | 177,015 | 57 | networkx | 22 | networkx/algorithms/tests/test_lowest_common_ancestors.py | Python | 12 | {
"docstring": "Checks if d1 and d2 contain the same pairs and\n have a node at the same distance from root for each.\n If G is None use self.DG.",
"language": "en",
"n_whitespaces": 40,
"n_words": 27,
"vocab_size": 24
} | https://github.com/networkx/networkx.git | |
6 | _prepare_socket_file | def _prepare_socket_file(self, socket_path, default_prefix):
result = socket_path
is_mac = sys.platform.startswith("darwin")
if sys.platform == "win32":
if socket_path is None:
result = f"tcp://{self._localhost}" f":{self._get_unused_port()}"
else:
... | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | 17 | node.py | 234 | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 29,375 | 0 | 333 | 127 | 56 | 130,803 | 77 | ray | 25 | python/ray/node.py | Python | 20 | {
"docstring": "Prepare the socket file for raylet and plasma.\n\n This method helps to prepare a socket file.\n 1. Make the directory if the directory does not exist.\n 2. If the socket file exists, do nothing (this just means we aren't the\n first worker on the node).\n\n Args:... | https://github.com/ray-project/ray.git | |
1 | test_user_message_already_unlinked | def test_user_message_already_unlinked(self):
IdentityProvider.objects.create(type="slack", external_id="TXXXXXXX1", config={})
responses.add(responses.POST, "https://slack.com/api/chat.postMessage", json={"ok": True})
resp = self.post_webhook(event_data=json.loads(MESSAGE_IM_EVENT_UNL... | b7d894b56953153cf33008ae7d33e1e41b175eb7 | 11 | test_message_im.py | 174 | ref(tests): Split up large files (#31828) | 19,302 | 0 | 103 | 104 | 35 | 96,313 | 40 | sentry | 25 | tests/sentry/integrations/slack/endpoints/events/test_message_im.py | Python | 9 | {
"docstring": "\n Test that when a user without an Identity types in \"unlink\" to the DM we\n reply with the correct response.\n ",
"language": "en",
"n_whitespaces": 42,
"n_words": 20,
"vocab_size": 19
} | https://github.com/getsentry/sentry.git | |
1 | test_subscribe_to_stream_post_policy_moderators_stream | def test_subscribe_to_stream_post_policy_moderators_stream(self) -> None:
member = self.example_user("AARON")
stream = self.make_stream("stream1")
# Make sure that we are testing this with full member which is just below the moderator
# in the role hierarchy.
self.assert... | c30458e1740c7878e436037f61431884e54b349d | 11 | test_subs.py | 172 | streams: Add notifications for posting policy changes.
An explanatory note on the changes in zulip.yaml and
curl_param_value_generators is warranted here. In our automated
tests for our curl examples, the test for the API endpoint that
changes the posting permissions of a stream comes before our
existing curl test for... | 17,579 | 0 | 153 | 100 | 45 | 83,023 | 51 | zulip | 18 | zerver/tests/test_subs.py | Python | 15 | {
"docstring": "\n Members can subscribe to streams where only admins and moderators can post\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 11
} | https://github.com/zulip/zulip.git | |
1 | test_overwrite_storage_path | def test_overwrite_storage_path(self):
call_command("document_retagger", "--storage_path", "--overwrite")
d_first, d_second, d_unrelated, d_auto = self.get_updated_docs()
self.assertEqual(d_first.storage_path, self.sp2)
self.assertEqual(d_auto.storage_path, self.sp1)
se... | c8e838e3a0828e82efac1fd93ebb9aba6a000ff8 | 8 | test_management_retagger.py | 116 | Adds the storage paths to the re-tagger command | 117,022 | 0 | 67 | 71 | 17 | 319,934 | 18 | paperless-ngx | 13 | src/documents/tests/test_management_retagger.py | Python | 7 | {
"docstring": "\n GIVEN:\n - 2 storage paths with documents which match them\n - 1 document which matches but has a storage path\n WHEN:\n - document retagger is called with overwrite\n THEN:\n - Matching document's storage paths updated\n -... | https://github.com/paperless-ngx/paperless-ngx.git | |
1 | hashkey | def hashkey(cls, *args, **kwargs):
return cachetools.keys.hashkey(f"<{cls.__name__}>", *args, **kwargs)
| 21972c91dd2b52cd206bf71ea038ab0e1f478b32 | 10 | settings.py | 52 | add lock to cachetools usage
* We observed daphne giving tracebacks when accessing logging settings.
Originally, configure tower in tower settings was no a suspect because
daphne is not multi-process. We've had issues with configure tower in
tower settings and multi-process before. We later learned that Daphne
... | 17,168 | 0 | 22 | 28 | 7 | 81,176 | 8 | awx | 7 | awx/conf/settings.py | Python | 2 | {
"docstring": "\n Usage of @cachetools.cached has changed to @cachetools.cachedmethod\n The previous cachetools decorator called the hash function and passed in (self, key).\n The new cachtools decorator calls the hash function with just (key).\n Ideally, we would continue to pass self, h... | https://github.com/ansible/awx.git | |
2 | link_entity | def link_entity(props):
id_ = props.get("id")
link_props = {}
if id_ is not None:
link_props["linktype"] = "page"
link_props["id"] = id_
else:
link_props["href"] = check_url(props.get("url"))
return DOM.create_element("a", link_props, props["children"])
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 14 | contentstate.py | 121 | Reformat with black | 15,641 | 0 | 66 | 66 | 21 | 71,201 | 27 | wagtail | 8 | wagtail/admin/rich_text/converters/contentstate.py | Python | 9 | {
"docstring": "\n <a linktype=\"page\" id=\"1\">internal page link</a>\n ",
"language": "en",
"n_whitespaces": 12,
"n_words": 5,
"vocab_size": 5
} | https://github.com/wagtail/wagtail.git | |
14 | _suggest_semantic_version | def _suggest_semantic_version(s):
result = s.strip().lower()
for pat, repl in _REPLACEMENTS:
result = pat.sub(repl, result)
if not result:
result = '0.0.0'
# Now look for numeric prefix, and separate it out from
# the rest.
#import pdb; pdb.set_trace()
m = _NUMERIC_PREF... | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 19 | version.py | 411 | upd; format | 12,903 | 0 | 370 | 242 | 67 | 62,242 | 144 | transferlearning | 26 | .venv/lib/python3.8/site-packages/pip/_vendor/distlib/version.py | Python | 33 | {
"docstring": "\n Try to suggest a semantic form for a version for which\n _suggest_normalized_version couldn't come up with anything.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 17,
"vocab_size": 15
} | https://github.com/jindongwang/transferlearning.git | |
1 | test_previewing_subprocess_deployment | def test_previewing_subprocess_deployment():
result = invoke_and_assert(
[
"deployment",
"preview",
"./tests/deployment_test_files/single_deployment.py",
],
expected_output_contains="prefect.engine",
)
assert result.stdout.endswith("\n")
... | 5afded9fe6724d9e336f59792ee1d60656a2d94d | 10 | test_deployment_preview.py | 110 | Add a CLI command to preview how a FlowRun will appear in any FlowRunner's execution environment (PrefectHQ/orion#1971)
Co-authored-by: Terrence Dorsey <terrence@prefect.io>
Co-authored-by: Michael Adkins <madkinszane@gmail.com> | 11,495 | 0 | 120 | 56 | 31 | 56,284 | 39 | prefect | 8 | tests/cli/test_deployment_preview.py | Python | 14 | {
"docstring": "`prefect deployment preview my-flow-file.py` should render the\n shell command that will be run for the subprocess",
"language": "en",
"n_whitespaces": 18,
"n_words": 16,
"vocab_size": 15
} | https://github.com/PrefectHQ/prefect.git | |
4 | completion_item_yank | def completion_item_yank(self, sel=False):
text = self._cmd.selectedText()
if not text:
index = self.currentIndex()
if not index.isValid():
raise cmdutils.CommandError("No item selected!")
text = self._model().data(index)
if not utils... | a20bb67a878b2e68abf8268c1b0a27f018d01352 | 12 | completionwidget.py | 133 | mypy: Upgrade to PyQt5-stubs 5.15.6.0
For some unknown reason, those new stubs cause a *lot* of things now to be
checked by mypy which formerly probably got skipped due to Any being implied
somewhere.
The stubs themselves mainly improved, with a couple of regressions too.
In total, there were some 337 (!) new mypy e... | 117,342 | 0 | 124 | 78 | 22 | 320,775 | 30 | qutebrowser | 17 | qutebrowser/completion/completionwidget.py | Python | 10 | {
"docstring": "Yank the current completion item into the clipboard.\n\n Args:\n sel: Use the primary selection instead of the clipboard.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 18,
"vocab_size": 14
} | https://github.com/qutebrowser/qutebrowser.git | |
1 | get_index_and_columns | def _get_index_and_columns(df):
return len(df.index), len(df.columns)
@ray.remote(num_returns=4) | e7cb2e82f8b9c7a68f82abdd3b6011d661230b7e | @ray.remote(num_returns=4) | 9 | partition.py | 50 | REFACTOR-#4251: define public interfaces in `modin.core.execution.ray` module (#3868)
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com> | 35,381 | 1 | 11 | 20 | 6 | 153,345 | 6 | modin | 8 | modin/core/execution/ray/implementations/pandas_on_ray/partitioning/partition.py | Python | 2 | {
"docstring": "\n Get the number of rows and columns of a pandas DataFrame.\n\n Parameters\n ----------\n df : pandas.DataFrame\n A pandas DataFrame which dimensions are needed.\n\n Returns\n -------\n int\n The number of rows.\n int\n The number of columns.\n ",
"la... | https://github.com/modin-project/modin.git |
2 | test_extra_tags | def test_extra_tags(self):
for extra_tags in ['', None, 'some tags']:
with self.subTest(extra_tags=extra_tags):
self.assertEqual(
self.encode_decode('message', extra_tags=extra_tags).extra_tags,
extra_tags,
)
| efb4478e484ae61c5fc23563d4e9df1f8f49df49 | 15 | test_cookie.py | 80 | Fixed #33458 -- Fixed encoding of messages with empty string as extra_tags. | 50,236 | 0 | 109 | 47 | 16 | 203,144 | 16 | django | 6 | tests/messages_tests/test_cookie.py | Python | 7 | {
"docstring": "\n A message's extra_tags attribute is correctly preserved when retrieved\n from the message storage.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 13,
"vocab_size": 13
} | https://github.com/django/django.git | |
2 | compile_helper | def compile_helper():
import os
import subprocess
path = os.path.abspath(os.path.dirname(__file__))
ret = subprocess.run(['make', '-C', path])
if ret.returncode != 0:
print("Making C++ dataset helpers module failed, exiting.")
import sys
sys.exit(1)
| 1d930169e118c325c03343b6acd7d9c05eab1f85 | 11 | dataset_utils.py | 105 | [Pre-training] Optional for nsp task, support multi-datasets in ERNIE-1.0 pre-training (#1621)
* add no nsp training.
* support for multi-dataset
* fix test sample nums. | 118,235 | 0 | 67 | 59 | 25 | 322,771 | 28 | PaddleNLP | 13 | examples/language_model/data_tools/dataset_utils.py | Python | 9 | {
"docstring": "Compile helper function ar runtime. Make sure this\n is invoked on a single process.",
"language": "en",
"n_whitespaces": 16,
"n_words": 14,
"vocab_size": 14
} | https://github.com/PaddlePaddle/PaddleNLP.git | |
5 | variable | def variable(value, dtype=None, name=None, constraint=None):
if dtype is None:
dtype = floatx()
if hasattr(value, "tocoo"):
sparse_coo = value.tocoo()
indices = np.concatenate(
(
np.expand_dims(sparse_coo.row, 1),
np.expand_dims(sparse_coo... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 14 | backend.py | 265 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,150 | 0 | 264 | 173 | 44 | 269,521 | 64 | keras | 29 | keras/backend.py | Python | 28 | {
"docstring": "Instantiates a variable and returns it.\n\n Args:\n value: Numpy array, initial value of the tensor.\n dtype: Tensor type.\n name: Optional name string for the tensor.\n constraint: Optional projection function to be\n applied to the variable after an optimize... | https://github.com/keras-team/keras.git | |
1 | test_conversation_chain_errors_bad_variable | def test_conversation_chain_errors_bad_variable() -> None:
llm = FakeLLM()
prompt = PromptTemplate(input_variables=["foo"], template="{foo}")
memory = ConversationBufferMemory(dynamic_key="foo")
with pytest.raises(ValueError):
ConversationChain(llm=llm, prompt=prompt, memory=memory, input_k... | a408ed3ea39dfa47e8b522a9e153b259f25df54e | @pytest.mark.parametrize(
"memory",
[
ConversationBufferMemory(dynamic_key="baz"),
ConversationSummaryMemory(llm=FakeLLM(), dynamic_key="baz"),
],
) | 12 | test_conversation.py | 161 | Samantha/add conversation chain (#166)
Add MemoryChain and ConversationChain as chains that take a docstore in
addition to the prompt, and use the docstore to stuff context into the
prompt. This can be used to have an ongoing conversation with a chatbot.
Probably needs a bit of refactoring for code quality
Co-... | 46,692 | 1 | 71 | 60 | 26 | 191,569 | 28 | langchain | 18 | tests/unit_tests/chains/test_conversation.py | Python | 7 | {
"docstring": "Test that conversation chain works in basic setting.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/hwchase17/langchain.git |
8 | register | async def register(cls):
for field in cls.__fields__.values():
if Block.is_block_class(field.type_):
await field.type_.register()
if get_origin(field.type_) is Union:
for type in get_args(field.type_):
if Block.is_block_class(t... | 1c74cd08aaa8eb7759490fc156abb18f916b0764 | 16 | core.py | 116 | Renames method from install to register | 11,452 | 0 | 131 | 178 | 18 | 56,177 | 23 | prefect | 12 | src/prefect/blocks/core.py | Python | 27 | {
"docstring": "\n Makes block available for configuration with current Orion server.\n Recursively registers all nested blocks. Registration is idempotent.\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 17,
"vocab_size": 17
} | https://github.com/PrefectHQ/prefect.git | |
14 | get_input | def get_input(self, field_name, **kwargs):
if self.credential_type.kind != 'external' and field_name in self.dynamic_input_fields:
return self._get_dynamic_input(field_name)
if field_name in self.credential_type.secret_fields:
try:
return decrypt_field(se... | 871175f97fb177ad3c6d6f150e2b685dc11893ce | 16 | __init__.py | 279 | Sending field_name in AttributeError | 17,314 | 0 | 327 | 166 | 35 | 82,077 | 76 | awx | 14 | awx/main/models/credential/__init__.py | Python | 21 | {
"docstring": "\n Get an injectable and decrypted value for an input field.\n\n Retrieves the value for a given credential input field name. Return\n values for secret input fields are decrypted. If the credential doesn't\n have an input value defined for the given field name, an Attribut... | https://github.com/ansible/awx.git | |
1 | synchronized_update_sequences | def synchronized_update_sequences(self) -> tuple[str, str]:
return (
self._synchronized_update_start_sequence(),
self._synchronized_update_end_sequence(),
)
| d14659c1a3760eade2dd3479b66eb8b2e7711db0 | 8 | _terminal_features.py | 45 | [terminal buffering] Add support for the "mode 2026"
That task is definitely way more complicated that it seemed to be 😅 | 44,251 | 0 | 53 | 28 | 10 | 183,562 | 10 | textual | 6 | src/textual/_terminal_features.py | Python | 14 | {
"docstring": "\n Returns the ANSI sequence that we should send to the terminal to tell it that\n it should buffer the content we're about to send, as well as the ANIS sequence to end the buffering.\n If the terminal doesn't seem to support synchronised updates both strings will be empty.\n\n ... | https://github.com/Textualize/textual.git | |
8 | do_for | def do_for(parser, token):
bits = token.split_contents()
if len(bits) < 4:
raise TemplateSyntaxError(
"'for' statements should have at least four words: %s" % token.contents
)
is_reversed = bits[-1] == 'reversed'
in_index = -3 if is_reversed else -2
if bits[in_index... | c5cd8783825b5f6384417dac5f3889b4210b7d08 | 13 | defaulttags.py | 343 | Refs #33476 -- Refactored problematic code before reformatting by Black.
In these cases Black produces unexpected results, e.g.
def make_random_password(
self,
length=10,
allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789',
):
or
cursor.execute("""
SELECT ...
""",
... | 50,268 | 0 | 296 | 203 | 89 | 203,240 | 121 | django | 27 | django/template/defaulttags.py | Python | 27 | {
"docstring": "\n Loop over each item in an array.\n\n For example, to display a list of athletes given ``athlete_list``::\n\n <ul>\n {% for athlete in athlete_list %}\n <li>{{ athlete.name }}</li>\n {% endfor %}\n </ul>\n\n You can loop over a list in reverse by using... | https://github.com/django/django.git | |
2 | set_global_relative_scale_factor | def set_global_relative_scale_factor(self, scale_factor, reference_quantity):
from sympy.physics.units import UnitSystem
scale_factor = sympify(scale_factor)
if isinstance(scale_factor, Prefix):
self._is_prefixed = True
# replace all prefixes by their ratio to canoni... | 40a89803dbe877edc8ab6672819715f959273e60 | 11 | quantities.py | 133 | feat(physics.units): add `is_prefixed` property to `Quantity` | 48,646 | 0 | 151 | 86 | 38 | 197,624 | 48 | sympy | 16 | sympy/physics/units/quantities.py | Python | 12 | {
"docstring": "\n Setting a scale factor that is valid across all unit system.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 11,
"vocab_size": 11
} | https://github.com/sympy/sympy.git | |
14 | validate_expense_against_budget | def validate_expense_against_budget(args):
args = frappe._dict(args)
if args.get("company") and not args.fiscal_year:
args.fiscal_year = get_fiscal_year(args.get("posting_date"), company=args.get("company"))[0]
frappe.flags.exception_approver_role = frappe.get_cached_value(
"Company", args.get("company"), "ex... | 494bd9ef78313436f0424b918f200dab8fc7c20b | 19 | budget.py | 538 | style: format code with black | 13,727 | 0 | 83 | 324 | 82 | 64,811 | 123 | erpnext | 33 | erpnext/accounts/doctype/budget/budget.py | Python | 59 | {
"docstring": "and exists(select name from `tab%s`\n\t\t\t\t\twhere lft<=%s and rgt>=%s and name=b.%s)\n\t\t\t\tselect\n\t\t\t\t\tb.{budget_against_field} as budget_against, ba.budget_amount, b.monthly_distribution,\n\t\t\t\t\tifnull(b.applicable_on_material_request, 0) as for_material_request,\n\t\t\t\t\tifnull(app... | https://github.com/frappe/erpnext.git | |
5 | load_macros | def load_macros(self, version):
vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version
self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir")
self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir")
net = r"Software\Microsoft\.NETFramework"
self.set_m... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 13 | msvccompiler.py | 255 | add python 3.10.4 for windows | 56,835 | 0 | 296 | 151 | 58 | 222,984 | 75 | XX-Net | 20 | python3.10.4/Lib/distutils/msvccompiler.py | Python | 26 | {
"docstring": "Python was built with Visual Studio 2003;\nextensions must be built with a compiler than can generate compatible binaries.\nVisual Studio 2003 was not found on this system. If you have Cygwin installed,\nyou can try compiling with MingW32, by passing \"-c mingw32\" to setup.py.",
"language": "en",
... | https://github.com/XX-net/XX-Net.git | |
2 | samestat | def samestat(s1, s2):
return (s1.st_ino == s2.st_ino and
s1.st_dev == s2.st_dev)
# Are two filenames really pointing to the same file? | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 9 | genericpath.py | 43 | add python 3.10.4 for windows | 54,829 | 0 | 37 | 26 | 20 | 217,516 | 21 | XX-Net | 5 | python3.10.4/Lib/genericpath.py | Python | 3 | {
"docstring": "Test whether two stat buffers reference the same file",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/XX-net/XX-Net.git | |
11 | batch | def batch(_func=None, max_batch_size=10, batch_wait_timeout_s=0.0):
# `_func` will be None in the case when the decorator is parametrized.
# See the comment at the end of this function for a detailed explanation.
if _func is not None:
if not callable(_func):
raise TypeError(
... | e5a8b1dd55817305ac85237cd99d8b6ed23df294 | 13 | batching.py | 206 | [Serve] Add API Annotations And Move to _private (#27058) | 28,055 | 0 | 264 | 136 | 78 | 126,078 | 121 | ray | 12 | python/ray/serve/batching.py | Python | 21 | {
"docstring": "Converts a function to asynchronously handle batches.\n\n The function can be a standalone function or a class method. In both\n cases, the function must be `async def` and take a list of objects as\n its sole argument and return a list of the same length as a result.\n\n When invoked, the... | https://github.com/ray-project/ray.git | |
3 | convert_example | def convert_example(example, tokenizer, max_seq_length=512, is_test=False):
text_a = example['text_a']
text_b = example.get('text_b', None)
text_a = _tokenize_special_chars(_normalize(text_a))
if text_b is not None:
text_b = _tokenize_special_chars(_normalize(text_b))
encoded_inputs =... | 15f0aa8f4515ae6cf2ee3ef71f90d533bc9e61b2 | 12 | utils.py | 205 | [ehealth] add sequence classification example | 118,112 | 0 | 132 | 128 | 37 | 322,284 | 54 | PaddleNLP | 22 | examples/biomedical/cblue/sequence_classification/utils.py | Python | 18 | {
"docstring": "\n Builds model inputs from a sequence or a pair of sequences for sequence\n classification tasks by concatenating and adding special tokens. And\n creates a mask from the two sequences for sequence-pair classification\n tasks.\n\n The convention in Electra/EHealth is:\n\n - single s... | https://github.com/PaddlePaddle/PaddleNLP.git | |
4 | accepted_pairs | def accepted_pairs(self) -> List[Dict[str, Any]]:
final = []
for pair, info in self._cached_pairs.items():
if (info.expectancy > float(self.edge_config.get('minimum_expectancy', 0.2)) and
info.winrate > float(self.edge_config.get('minimum_winrate', 0.60))):
... | 6024fa482e1b09bae8e85b3afc9fc58e483c1512 | 15 | edge_positioning.py | 168 | Use brackets to break IF lines | 34,375 | 0 | 199 | 107 | 32 | 149,135 | 35 | freqtrade | 18 | freqtrade/edge/edge_positioning.py | Python | 15 | {
"docstring": "\n return a list of accepted pairs along with their winrate, expectancy and stoploss\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 13
} | https://github.com/freqtrade/freqtrade.git | |
1 | get_remote_url | def get_remote_url(cls, location):
# type: (str) -> str
raise NotImplementedError
| f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 6 | versioncontrol.py | 19 | upd; format | 12,560 | 0 | 31 | 10 | 10 | 61,416 | 10 | transferlearning | 4 | .venv/lib/python3.8/site-packages/pip/_internal/vcs/versioncontrol.py | Python | 2 | {
"docstring": "\n Return the url used at location\n\n Raises RemoteNotFoundError if the repository does not have a remote\n url configured.\n ",
"language": "en",
"n_whitespaces": 47,
"n_words": 18,
"vocab_size": 16
} | https://github.com/jindongwang/transferlearning.git | |
12 | answer_drop_tables | def answer_drop_tables(self, statement):
if statement.if_exists is False:
for table in statement.tables:
if len(table.parts) > 1:
db_name = table.parts[0]
else:
db_name = self.session.database
if db_name... | 01b47406a29d17781356badb20f49f2fdc24d00e | 16 | mysql_proxy.py | 366 | 'drop table' query | 25,199 | 0 | 491 | 217 | 46 | 114,473 | 107 | mindsdb | 22 | mindsdb/api/mysql/mysql_proxy/mysql_proxy.py | Python | 28 | {
"docstring": " answer on 'drop table [if exists] {name}'\n Args:\n statement: ast\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 10,
"vocab_size": 10
} | https://github.com/mindsdb/mindsdb.git | |
2 | validate | def validate(self, num_steps=None, profile=False, reduce_results=True, info=None):
worker_stats = self.worker_group.validate(
num_steps=num_steps, profile=profile, info=info
)
if reduce_results:
return self._process_stats(worker_stats)
else:
... | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | 9 | torch_trainer.py | 85 | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 29,985 | 0 | 88 | 56 | 18 | 133,353 | 20 | ray | 9 | python/ray/util/sgd/torch/torch_trainer.py | Python | 8 | {
"docstring": "Evaluates the model on the validation data set.\n\n Args:\n num_steps (int): Number of batches to compute update steps on\n per worker. This corresponds also to the number of times\n ``TrainingOperator.validate_batch`` is called per worker.\n ... | https://github.com/ray-project/ray.git | |
2 | _Net_set_input_arrays | def _Net_set_input_arrays(self, data, labels):
if labels.ndim == 1:
labels = np.ascontiguousarray(labels[:, np.newaxis, np.newaxis,
np.newaxis])
return self._set_input_arrays(data, labels)
| cc4d0564756ca067516f71718a3d135996525909 | 12 | pycaffe.py | 74 | Balanced joint maximum mean discrepancy for deep transfer learning | 12,064 | 0 | 77 | 49 | 16 | 60,284 | 17 | transferlearning | 9 | code/deep/BJMMD/caffe/python/caffe/pycaffe.py | Python | 5 | {
"docstring": "\n Set input arrays of the in-memory MemoryDataLayer.\n (Note: this is only for networks declared with the memory data layer.)\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 19,
"vocab_size": 18
} | https://github.com/jindongwang/transferlearning.git | |
1 | test_multi_trial_reuse | def test_multi_trial_reuse(ray_start_4_cpus_extra):
os.environ["TUNE_MAX_PENDING_TRIALS_PG"] = "2"
register_trainable("foo2", MyResettableClass)
# We sleep here for one second so that the third actor
# does not finish training before the fourth can be scheduled.
# This helps ensure that both ... | 1510fb2cd631b2776092fb45ee4082e5e65f16f8 | 16 | test_actor_reuse.py | 175 | [air/tune] Internal resource management 2 - Ray Tune to use new Ray AIR resource manager (#30016)
Includes/depends on #30777
TLDR: This PR refactors Ray Tune's resource management to use a central AIR resource management package instead of the tightly coupled PlacementGroupManager.
Ray Tune's resource management... | 31,311 | 0 | 176 | 100 | 65 | 138,087 | 75 | ray | 18 | python/ray/tune/tests/test_actor_reuse.py | Python | 15 | {
"docstring": "Test that actors from multiple trials running in parallel will be reused.\n\n - 2 trials can run at the same time\n - Trial 3 will be scheduled after trial 1 succeeded, so will reuse actor\n - Trial 4 will be scheduled after trial 2 succeeded, so will reuse actor\n ",
"language": "en",
... | https://github.com/ray-project/ray.git | |
1 | test_get_dynamic_sampling_default_biases | def test_get_dynamic_sampling_default_biases(self):
with Feature(
{
self.new_ds_flag: True,
}
):
response = self.get_success_response(
self.organization.slug, self.project.slug, method="get"
)
assert res... | 6fc6106b6a57149a5bae3c0f4677349cfbae1155 | 12 | test_project_details.py | 84 | fix(dyn-sampling): Backend code clean up (#42001)
We are consolidating server-side-sampling and dynamic-sampling flags
into only dynamic-sampling. The flag is being controlled by plan | 18,532 | 0 | 126 | 50 | 20 | 89,350 | 20 | sentry | 12 | tests/sentry/api/endpoints/test_project_details.py | Python | 10 | {
"docstring": "\n Tests the case when organization on AM2 plan, but haven't manipulated the bias toggles\n yet, so they get the default biases.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 21,
"vocab_size": 19
} | https://github.com/getsentry/sentry.git | |
6 | remove_widget | def remove_widget(self, widget):
if widget not in self.children:
return
self.children.remove(widget)
if widget.canvas in self.canvas.children:
self.canvas.remove(widget.canvas)
elif widget.canvas in self.canvas.after.children:
self.canvas.afte... | 1830123ba3edf7290b7c6cb1c6f406ccf1d0e5d4 | 12 | widget.py | 213 | Feature: EventManagerBase (#7658)
* Added EventManagerBase class and event_managers attribute to WindowBase class.
* Added on_motion event to Widget class.
* Updated post_dispatch_input in EventLoopBase to skip non-touch events.
* Using type ids in MouseMotionEventProvider.
* Added on_motion method to Widget subcl... | 46,984 | 0 | 162 | 134 | 29 | 194,460 | 37 | kivy | 16 | kivy/uix/widget.py | Python | 15 | {
"docstring": "Remove a widget from the children of this widget.\n\n :Parameters:\n `widget`: :class:`Widget`\n Widget to remove from our children list.\n\n .. code-block:: python\n\n >>> from kivy.uix.button import Button\n >>> root = Widget()\n >>> button = ... | https://github.com/kivy/kivy.git | |
3 | mixin_base_ppr_parser | def mixin_base_ppr_parser(parser):
mixin_essential_parser(parser)
gp = add_arg_group(parser, title='Base Deployment')
gp.add_argument(
'--extra-search-paths',
type=str,
default=[],
nargs='*',
help='Extra search paths to be used when loading modules and finding... | a3b71c7208b3cd48aa7bc978c3343a074947e3d9 | 13 | base.py | 202 | fix(parsers): clearify flow args (#4701) | 2,215 | 0 | 253 | 123 | 64 | 12,207 | 80 | jina | 21 | jina/parsers/orchestrate/base.py | Python | 41 | {
"docstring": "Mixing in arguments required by pod/deployment/runtime module into the given parser.\n :param parser: the parser instance to which we add arguments\n \n The polling strategy of the Deployment and its endpoints (when `shards>1`).\n Can be defined for all endpoints of a Deployment or by endp... | https://github.com/jina-ai/jina.git | |
7 | calc | def calc(term):
# This part is for reading and converting arithmetic terms.
term = term.replace(" ", "")
term = term.replace("^", "**")
term = term.replace("=", "")
term = term.replace("?", "")
term = term.replace("%", "/100.00")
term = term.replace("rad", "radians")
term = term.re... | f0af0c43340763724f139fa68aa1e5a9ffe458b4 | 12 | calculator.py | 345 | refactor: clean code
Signed-off-by: slowy07 <slowy.arfy@gmail.com> | 4,373 | 0 | 359 | 182 | 93 | 22,594 | 143 | Python | 13 | calculator.py | Python | 38 | {
"docstring": "\n input: term of type str\n output: returns the result of the computed term.\n purpose: This function is the actual calculator and the heart of the application\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 26,
"vocab_size": 20
} | https://github.com/geekcomputers/Python.git | |
1 | test_song_from_dict | def test_song_from_dict():
song = Song.from_dict(
{
"name": "Ropes",
"artists": ["Dirty Palm", "Chandler Jewels"],
"album_name": "Ropes",
"album_artist": "Dirty Palm",
"genres": ["gaming edm", "melbourne bounce international"],
"d... | fa2ad657482aca9dc628e6d7062b8badf2706bb6 | 12 | test_song.py | 384 | v4 init | 5,349 | 0 | 445 | 206 | 81 | 30,148 | 129 | spotify-downloader | 19 | tests/types/test_song.py | Python | 44 | {
"docstring": "\n Tests if Song.from_dict() works correctly.\n ",
"language": "en",
"n_whitespaces": 12,
"n_words": 5,
"vocab_size": 5
} | https://github.com/spotDL/spotify-downloader.git | |
3 | _get_states_count_upstream_ti | def _get_states_count_upstream_ti(ti, finished_tis):
counter = Counter(task.state for task in finished_tis if task.task_id in ti.task.upstream_task_ids)
return (
counter.get(State.SUCCESS, 0),
counter.get(State.SKIPPED, 0),
counter.get(State.FAILED, 0),
... | 99f86ccfa59df6aa1aa33afce5e0b66dd5df9a3d | 12 | trigger_rule_dep.py | 127 | Some refactoring work on scheduling code (#21414) | 8,298 | 0 | 109 | 86 | 22 | 44,559 | 26 | airflow | 17 | airflow/ti_deps/deps/trigger_rule_dep.py | Python | 9 | {
"docstring": "\n This function returns the states of the upstream tis for a specific ti in order to determine\n whether this ti can run in this iteration\n\n :param ti: the ti that we want to calculate deps for\n :param finished_tis: all the finished tasks of the dag_run\n ",
"l... | https://github.com/apache/airflow.git | |
2 | fit | def fit(self, X, y=None):
# Validating the scalar parameters.
check_scalar(
self.threshold,
"threshold",
target_type=numbers.Real,
min_val=0.0,
include_boundaries="neither",
)
check_scalar(
self.branching_f... | ee5a1b69d1dfa99635a10f0a5b54ec263cedf866 | 11 | _birch.py | 171 | DOC, MNT Typos found by codespell (#22906) | 75,706 | 0 | 309 | 113 | 39 | 259,315 | 47 | scikit-learn | 20 | sklearn/cluster/_birch.py | Python | 24 | {
"docstring": "\n Build a CF Tree for the input data.\n\n Parameters\n ----------\n X : {array-like, sparse matrix} of shape (n_samples, n_features)\n Input data.\n\n y : Ignored\n Not used, present here for API consistency by convention.\n\n Returns\n ... | https://github.com/scikit-learn/scikit-learn.git | |
3 | load | def load(self):
for key in sorted(self._alignments.data):
this_frame_faces = []
for item in self._alignments.data[key]["faces"]:
face = DetectedFace()
face.from_alignment(item, with_thumb=True)
face.load_aligned(None)
... | 23d92c1f0d83ce1cdcc51480cfe37af074a981b3 | 12 | detected_faces.py | 149 | Bugfixes
- Sort - Fix rare help-text parsing bug
- Manual - Fix issue where frame count is incorrect when een > 1 used on extract | 19,790 | 0 | 161 | 91 | 26 | 100,289 | 31 | faceswap | 19 | tools/manual/detected_faces.py | Python | 11 | {
"docstring": " Load the faces from the alignments file, convert to\n :class:`~lib.align.DetectedFace`. objects and add to :attr:`_frame_faces`. ",
"language": "en",
"n_whitespaces": 23,
"n_words": 15,
"vocab_size": 13
} | https://github.com/deepfakes/faceswap.git | |
1 | get_assessment_criteria | def get_assessment_criteria(course):
return frappe.get_all(
"Course Assessment Criteria",
fields=["assessment_criteria", "weightage"],
filters={"parent": course},
order_by="idx",
)
@frappe.whitelist() | 494bd9ef78313436f0424b918f200dab8fc7c20b | @frappe.whitelist() | 11 | api.py | 72 | style: format code with black | 14,035 | 1 | 6 | 34 | 14 | 65,846 | 14 | erpnext | 8 | erpnext/education/api.py | Python | 7 | {
"docstring": "Returns Assessmemt Criteria and their Weightage from Course Master.\n\n\t:param Course: Course\n\t",
"language": "en",
"n_whitespaces": 10,
"n_words": 12,
"vocab_size": 11
} | https://github.com/frappe/erpnext.git |
7 | new_compiler | def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
if plat is None:
plat = os.name
try:
if compiler is None:
compiler = get_default_compiler(plat)
(module_name, class_name, long_description) = compiler_class[compiler]
except KeyError:
... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 14 | ccompiler.py | 242 | add python 3.10.4 for windows | 56,657 | 0 | 329 | 148 | 83 | 222,589 | 136 | XX-Net | 24 | python3.10.4/Lib/distutils/ccompiler.py | Python | 26 | {
"docstring": "Generate an instance of some CCompiler subclass for the supplied\n platform/compiler combination. 'plat' defaults to 'os.name'\n (eg. 'posix', 'nt'), and 'compiler' defaults to the default compiler\n for that platform. Currently only 'posix' and 'nt' are supported, and\n the default comp... | https://github.com/XX-net/XX-Net.git | |
1 | register | def register(config_class, feature_extractor_class):
FEATURE_EXTRACTOR_MAPPING.register(config_class, feature_extractor_class)
| 2e11a043374a6229ec129a4765ee4ba7517832b9 | 7 | feature_extraction_auto.py | 27 | Register feature extractor (#15634)
* Rework AutoFeatureExtractor.from_pretrained internal
* Custom feature extractor
* Add more tests
* Add support for custom feature extractor code
* Clean up
* Add register API to AutoFeatureExtractor | 6,418 | 0 | 19 | 16 | 5 | 35,173 | 5 | transformers | 4 | src/transformers/models/auto/feature_extraction_auto.py | Python | 2 | {
"docstring": "\n Register a new feature extractor for this class.\n\n Args:\n config_class ([`PretrainedConfig`]):\n The configuration corresponding to the model to register.\n feature_extractor_class ([`FeatureExtractorMixin`]): The feature extractor to register.\... | https://github.com/huggingface/transformers.git | |
8 | execute | def execute():
if not frappe.get_all("Pricing Rule", limit=1):
return
frappe.reload_doc("accounts", "doctype", "pricing_rule_detail")
doctypes = {
"Supplier Quotation": "buying",
"Purchase Order": "buying",
"Purchase Invoice": "accounts",
"Purchase Receipt": "stock",
"Quotation": "selling",
"Sales Or... | 494bd9ef78313436f0424b918f200dab8fc7c20b | 19 | update_pricing_rule_fields.py | 756 | style: format code with black | 14,303 | 0 | 99 | 450 | 106 | 66,703 | 188 | erpnext | 40 | erpnext/patches/v12_0/update_pricing_rule_fields.py | Python | 100 | {
"docstring": " UPDATE `tab{child_doctype}` SET pricing_rules = pricing_rule\n\t\t\tWHERE docstatus < 2 and pricing_rule is not null and pricing_rule != ''\n\t\t SELECT pricing_rule, name, parent,\n\t\t\t\tparenttype, creation, modified, docstatus, modified_by, owner, name\n\t\t\tFROM `tab{child_doc}` where docstatu... | https://github.com/frappe/erpnext.git | |
2 | test_state_aggregate_option_behavior | def test_state_aggregate_option_behavior(master_opts):
minion_opts = salt.config.DEFAULT_MINION_OPTS.copy()
possible = [None, True, False, ["pkg"]]
expected_result = [
True,
False,
["pkg"],
True,
True,
["pkg"],
False,
True,
["pkg"]... | 8168b25fe5906883a07de5bfdfefabc6d1f57784 | 12 | test_state_options.py | 209 | fixes saltstack/salt#61478 state_aggregate minion option not respected | 54,314 | 0 | 187 | 132 | 32 | 215,998 | 50 | salt | 21 | tests/pytests/unit/state/test_state_options.py | Python | 23 | {
"docstring": "\n Ensure state_aggregate can be overridden on the minion\n ",
"language": "en",
"n_whitespaces": 15,
"n_words": 8,
"vocab_size": 8
} | https://github.com/saltstack/salt.git | |
2 | register | def register(cls, map_function, reduce_function=None, **kwargs):
if reduce_function is None:
reduce_function = map_function
return cls.call(map_function, reduce_function, **kwargs)
| 58bbcc37477866d19c8b092a0e1974a4f0baa586 | 8 | tree_reduce.py | 54 | REFACTOR-#2656: Update modin to fit algebra (code only) (#3717)
Co-authored-by: Yaroslav Igoshev <Poolliver868@mail.ru>
Co-authored-by: Vasily Litvinov <vasilij.n.litvinov@intel.com>
Co-authored-by: Alexey Prutskov <alexey.prutskov@intel.com>
Co-authored-by: Devin Petersohn <devin-petersohn@users.noreply.github.com... | 35,228 | 0 | 48 | 35 | 15 | 153,044 | 16 | modin | 6 | modin/core/dataframe/algebra/tree_reduce.py | Python | 4 | {
"docstring": "\n Build TreeReduce function.\n\n Parameters\n ----------\n map_function : callable(pandas.DataFrame) -> [pandas.DataFrame, pandas.Series]\n Source map function.\n reduce_function : callable(pandas.DataFrame) -> pandas.Series, optional\n Source ... | https://github.com/modin-project/modin.git | |
3 | trustworthiness | def trustworthiness(X, X_embedded, *, n_neighbors=5, metric="euclidean"):
r
n_samples = X.shape[0]
if n_neighbors >= n_samples / 2:
raise ValueError(
f"n_neighbors ({n_neighbors}) should be less than n_samples / 2"
f" ({n_samples / 2})"
)
dist_X = pairwise_distanc... | ade90145c9c660a1a7baf2315185995899b0f356 | 16 | _t_sne.py | 352 | FIX Raise error when n_neighbors >= n_samples / 2 in manifold.trustworthiness (#23033)
Co-authored-by: Shao Yang Hong <hongsy2006@gmail.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> | 75,842 | 0 | 322 | 228 | 115 | 259,640 | 173 | scikit-learn | 32 | sklearn/manifold/_t_sne.py | Python | 84 | {
"docstring": "Expresses to what extent the local structure is retained.\n\n The trustworthiness is within [0, 1]. It is defined as\n\n .. math::\n\n T(k) = 1 - \\frac{2}{nk (2n - 3k - 1)} \\sum^n_{i=1}\n \\sum_{j \\in \\mathcal{N}_{i}^{k}} \\max(0, (r(i, j) - k))\n\n where for each sample... | https://github.com/scikit-learn/scikit-learn.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.