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 | 2 | def itemdoubleclick(self):
return self["itemdoubleclick"]
| packages/python/plotly/plotly/graph_objs/layout/_legend.py | 22 | plotly.py | {
"docstring": "\n Determines the behavior on legend item double-click. \"toggle\"\n toggles the visibility of the item clicked on the graph.\n \"toggleothers\" makes the clicked item the sole visible item on\n the graph. False disables legend item double-click\n interactions.\n\n ... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _legend.py | 231,584 | 2 | 11 | itemdoubleclick | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 63,028 | 7 | |
1 | 24 | def _generate_legacy_events_context_id_query() -> Select:
# This can be removed once we no longer have event_ids in the states table
return (
select(
*EVENT_COLUMNS,
literal(value=None, type_=sqlalchemy.String).label("shared_data"),
States.state,
Stat... | homeassistant/components/logbook/__init__.py | 151 | core | {
"docstring": "Generate a legacy events context id query that also joins states.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 45 | Python | 41 | 26177bd080b4eb6d11cfd9fbdd158be36f4983d4 | __init__.py | 300,319 | 18 | 98 | _generate_legacy_events_context_id_query | https://github.com/home-assistant/core.git | Convert logbook to use lambda_stmt (#71624) | 183 | 0 | 99,183 | 22 | |
14 | 20 | def get_mailbox_list(value):
mailbox_list = MailboxList()
while value and value[0] != ';':
try:
token, value = get_mailbox(value)
mailbox_list.append(token)
except errors.HeaderParseError:
leader = None
if value[0] in CFWS_LEADER:
... | python3.10.4/Lib/email/_header_value_parser.py | 482 | XX-Net | {
"docstring": " mailbox-list = (mailbox *(\",\" mailbox)) / obs-mbox-list\n obs-mbox-list = *([CFWS] \",\") mailbox *(\",\" [mailbox / CFWS])\n\n For this routine we go outside the formal grammar in order to improve error\n handling. We recognize the end of the mailbox list only at the end of the\n ... | 147 | Python | 69 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | _header_value_parser.py | 223,548 | 42 | 283 | get_mailbox_list | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 727 | 0 | 56,965 | 20 | |
1 | 13 | def _clone_config(self, config):
old_path = os.path.abspath(get_testdata(config))
new_path = os.path.join(self._temp_directory, config)
shutil.copy2(old_path,
new_path)
return new_path
| tests/functional/eks/test_kubeconfig.py | 72 | aws-cli | {
"docstring": "\n Copies the testdata named config into the temp directory,\n Returns the new path\n\n :param config: The name of the testdata to copy\n :type config: str\n ",
"language": "en",
"n_whitespaces": 61,
"n_words": 25,
"vocab_size": 20
} | 14 | Python | 12 | 1a6b498657ec5dd29ddf4f6b240c6fc0c5d88f7a | test_kubeconfig.py | 189,164 | 6 | 45 | _clone_config | https://github.com/aws/aws-cli.git | Deprecate Kubernetes client API version v1alpha1
Kubernetes has deprecated v1alpha1, v1beta1 has been available since Kubernetes
v1.11 (kubernetes/kubernetes#64482), and EKS currently supports Kubernetes
versions v1.16 through v1.21. This is a breaking change for clients running
versions v1.10 and older, which haven't... | 69 | 0 | 46,004 | 10 | |
2 | 44 | def test_clear_task_instances_dr_state(self, state, last_scheduling, dag_maker):
with dag_maker(
'test_clear_task_instances',
start_date=DEFAULT_DATE,
end_date=DEFAULT_DATE + datetime.timedelta(days=10),
) as dag:
EmptyOperator(task_id='0')
... | tests/models/test_cleartasks.py | 326 | airflow | {
"docstring": "Test that DR state is set to None after clear.\n And that DR.last_scheduling_decision is handled OK.\n start_date is also set to None\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 22,
"vocab_size": 16
} | 124 | Python | 95 | 49e336ae0302b386a2f47269a6d13988382d975f | test_cleartasks.py | 47,548 | 25 | 204 | test_clear_task_instances_dr_state | https://github.com/apache/airflow.git | Replace usage of `DummyOperator` with `EmptyOperator` (#22974)
* Replace usage of `DummyOperator` with `EmptyOperator` | 355 | 0 | 9,154 | 15 | |
3 | 14 | def downgrade():
conn = op.get_bind()
if conn.dialect.name == "sqlite":
# in sqlite TEXT and STRING column types are the same
return
if conn.dialect.name == "mysql":
op.alter_column(
'connection',
'description',
existing_type=sa.Text(5000),
... | airflow/migrations/versions/64a7d6477aae_fix_description_field_in_connection_to_.py | 165 | airflow | {
"docstring": "Unapply Fix description field in ``connection`` to be ``text``",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 50 | Python | 40 | 69f6f9e01b6df76c3c8fa266d460324163957887 | 64a7d6477aae_fix_description_field_in_connection_to_.py | 45,466 | 20 | 98 | downgrade | https://github.com/apache/airflow.git | Autogenerate migration reference doc (#21601)
* document airflow version in each alembic migration module and use this to autogen the doc
* update each migration module to have the same description used in migration ref (so it can be used in autogen) | 224 | 0 | 8,593 | 14 | |
3 | 8 | def _canonicalize_dtype(x64_enabled, dtype):
try:
dtype = np.dtype(dtype)
except TypeError as e:
raise TypeError(f'dtype {dtype!r} not understood') from e
if x64_enabled:
return dtype
else:
return _dtype_to_32bit_dtype.get(dtype, dtype)
| jax/_src/dtypes.py | 83 | jax | {
"docstring": "Convert from a dtype to a canonical dtype based on config.x64_enabled.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 9
} | 26 | Python | 24 | 329de7c9cc1b77f9caacf2163a77a9d8496c379b | dtypes.py | 119,122 | 9 | 47 | _canonicalize_dtype | https://github.com/google/jax.git | Only use config.x64_enabled as the memo cache key for canonicalize_dtype, not any other fields.
This saves the time to repeatedly build a tuple as a cache key. Reduces the time for CustomLinearSolveTest.test_custom_linear_solve_pytree on my workstation from 110s to 85s.
PiperOrigin-RevId: 422632700 | 43 | 0 | 26,545 | 12 | |
4 | 7 | def copyDataFiles():
for included_datafile in getIncludedDataFiles():
# TODO: directories should be resolved to files.
if (
not isinstance(included_datafile, (IncludedDataFile))
or included_datafile.needsCopy()
):
_handleDataFile(
inc... | nuitka/freezer/IncludedDataFiles.py | 62 | Nuitka | {
"docstring": "Copy the data files needed for standalone distribution.\n\n Notes:\n This is for data files only, not DLLs or even extension modules,\n those must be registered as entry points, and would not go through\n necessary handling if provided like this.\n ",
"language": "en",
"... | 25 | Python | 25 | abfb99b0a05dd76d2ecc6ebc20732a271857c6c8 | IncludedDataFiles.py | 178,914 | 9 | 36 | copyDataFiles | https://github.com/Nuitka/Nuitka.git | Plugins: Massive cleanup of data file handling
* Move data file handling out of standalone only, allowing support
for other modes as well.
* Attach logger and tags to data file objects. | 111 | 0 | 42,859 | 13 | |
7 | 19 | def _check_pyarrow_version():
global _VERSION_VALIDATED
if not _VERSION_VALIDATED:
if os.environ.get(RAY_DISABLE_PYARROW_VERSION_CHECK, "0") == "1":
_VERSION_VALIDATED = True
return
try:
import pyarrow
except ModuleNotFoundError:
# p... | python/ray/data/_internal/util.py | 266 | ray | {
"docstring": "Check that pyarrow's version is within the supported bounds.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 149 | Python | 93 | ee0fbf9d43dfa05fdf90ad0515b2671cac16a92b | util.py | 134,777 | 37 | 134 | _check_pyarrow_version | https://github.com/ray-project/ray.git | [Datasets] Add upper bound to pyarrow version check. (#29674)
We previously weren't checking that the 7.0.0 pyarrow upper bound was being respected. This PR adds this upper bound check. | 603 | 0 | 30,413 | 17 | |
1 | 12 | def cogview_attention(self, attention_scores, alpha=32):
scaled_attention_scores = attention_scores / alpha
max_value = scaled_attention_scores.amax(dim=(-1)).unsqueeze(-1)
new_attention_scores = (scaled_attention_scores - max_value) * alpha
return nn.Softmax(dim=-1)(new_attenti... | src/transformers/models/layoutlmv3/modeling_layoutlmv3.py | 94 | transformers | {
"docstring": "\n https://arxiv.org/abs/2105.13290 Section 2.4 Stabilization of training: Precision Bottleneck Relaxation\n (PB-Relax). A replacement of the original nn.Softmax(dim=-1)(attention_scores). Seems the new attention_probs\n will result in a slower speed and a little bias. Can use tor... | 21 | Python | 18 | 31ee80d55673f32c0f5d50936f371e661b74b21a | modeling_layoutlmv3.py | 38,773 | 5 | 58 | cogview_attention | https://github.com/huggingface/transformers.git | Add LayoutLMv3 (#17060)
* Make forward pass work
* More improvements
* Remove unused imports
* Remove timm dependency
* Improve loss calculation of token classifier
* Fix most tests
* Add docs
* Add model integration test
* Make all tests pass
* Add LayoutLMv3FeatureExtractor
* Improve in... | 56 | 0 | 7,030 | 13 | |
3 | 8 | def check_planarity(G, counterexample=False):
planarity_state = LRPlanarity(G)
embedding = planarity_state.lr_planarity()
if embedding is None:
# graph is not planar
if counterexample:
return False, get_counterexample(G)
else:
return False, None
else... | networkx/algorithms/planarity.py | 86 | networkx | {
"docstring": "Check if a graph is planar and return a counterexample or an embedding.\n\n A graph is planar iff it can be drawn in a plane without\n any edge intersections.\n\n Parameters\n ----------\n G : NetworkX graph\n counterexample : bool\n A Kuratowski subgraph (to proof non planari... | 35 | Python | 22 | 1af7d49d70869081e5cb64d17165652f1b26c57b | planarity.py | 176,544 | 10 | 50 | check_planarity | https://github.com/networkx/networkx.git | Improve documentation of PlanarEmbedding class (#5523)
* Improve documentation of PlanarEmbedding
* Fix type
* Make suggested changes
* rst formatting nits.
* Update networkx/algorithms/planarity.py
Co-authored-by: Dan Schult <dschult@colgate.edu>
* Run black for formatting
Co-authored-by: Ross Ba... | 107 | 0 | 41,953 | 12 | |
11 | 9 | def draw(self, renderer):
if not self.get_visible():
return
self._recompute_transform()
width = self.convert_xunits(self.width)
height = self.convert_yunits(self.height)
# If the width and height of ellipse are not equal, take into account
# stretc... | lib/matplotlib/patches.py | 74 | matplotlib | {
"docstring": "\n Draw the arc to the given *renderer*.\n\n Notes\n -----\n Ellipses are normally drawn using an approximation that uses\n eight cubic Bezier splines. The error of this approximation\n is 1.89818e-6, according to this unverified source:\n\n Lancaste... | 36 | Python | 31 | cf995d1304bfa7f660e7158b5121a46e54f869f2 | patches.py | 108,776 | 50 | 404 | draw | https://github.com/matplotlib/matplotlib.git | Remove ineffective exclusion of Arcs without parent Axes.
The `if not hasattr(self, 'axes'): raise RuntimeError(...)` check was
ineffectual, as artists now always have an Axes attribute, which can
just be None for some artists. In fact, small Arcs are drawn just fine
without a parent Axes; e.g.
```
from pylab import ... | 96 | 0 | 23,337 | 9 | |
2 | 10 | def _async_setup_scanner_watchdog(self) -> None:
self._start_time = self._last_detection = MONOTONIC_TIME()
if not self._cancel_watchdog:
self._cancel_watchdog = async_track_time_interval(
self.hass, self._async_scanner_watchdog, SCANNER_WATCHDOG_INTERVAL
... | homeassistant/components/bluetooth/base_scanner.py | 67 | core | {
"docstring": "If something has restarted or updated, we need to restart the scanner.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | 19 | Python | 17 | 0e2ebfe5c45716250280186234123f170e3bd08c | base_scanner.py | 297,460 | 7 | 41 | _async_setup_scanner_watchdog | https://github.com/home-assistant/core.git | Move bluetooth watchdog into the scanner base class (#83888) | 77 | 0 | 96,429 | 11 | |
1 | 3 | def test_image_crafter_index(encoder_doc_array, tmpdir):
| tests/unit/helloworld/multimodal/test_executors.py | 15 | 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 blob value of... | 3 | Python | 3 | 933415bfa1f9eb89f935037014dfed816eb9815d | test_executors.py | 10,208 | 5 | 49 | test_image_crafter_index | https://github.com/jina-ai/jina.git | feat: star routing (#3900)
* feat(proto): adjust proto for star routing (#3844)
* feat(proto): adjust proto for star routing
* feat(proto): generate proto files
* feat(grpc): refactor grpclet interface (#3846)
* feat: refactor connection pool for star routing (#3872)
* feat(k8s): add more labels to k8s ... | 6 | 0 | 1,818 | 6 | |
2 | 2 | def get_rename_function(mapper):
| pandas/core/common.py | 13 | pandas | {
"docstring": "\n Returns a function that will map names/labels, dependent if mapper\n is a dict, Series or just a function.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 18,
"vocab_size": 16
} | 2 | Python | 2 | 830130a543619fe945365fdea5e6e5877fe81c6f | common.py | 167,165 | 3 | 25 | get_rename_function | https://github.com/pandas-dev/pandas.git | TYP: Series.quantile (#47304)
* TYP: Series.quantile
* common.py | 5 | 0 | 39,944 | 6 | |
3 | 24 | def _call_boxer(self, candc_out, verbose=False):
f = None
try:
fd, temp_filename = tempfile.mkstemp(
prefix="boxer-", suffix=".in", text=True
)
f = os.fdopen(fd, "w")
f.write(candc_out.decode("utf-8"))
finally:
... | nltk/sem/boxer.py | 242 | nltk | {
"docstring": "\n Call the ``boxer`` binary with the given input.\n\n :param candc_out: str output from C&C parser\n :return: stdout\n ",
"language": "en",
"n_whitespaces": 46,
"n_words": 17,
"vocab_size": 16
} | 60 | Python | 53 | c6d9e0529eecce2c0742ca47135b28e5316611e0 | boxer.py | 42,474 | 30 | 142 | _call_boxer | https://github.com/nltk/nltk.git | Update boxer.py
Used to have this py2 to py3 error
TypeError: write() argument must be str, not bytes | 373 | 0 | 7,559 | 12 | |
1 | 7 | def unique_id() -> str:
return binascii.hexlify(os.urandom(16)).decode("utf-8")
| certbot-apache/certbot_apache/_internal/apache_util.py | 44 | certbot | {
"docstring": " Returns an unique id to be used as a VirtualHost identifier",
"language": "en",
"n_whitespaces": 11,
"n_words": 11,
"vocab_size": 11
} | 6 | Python | 6 | 7d9e9a49005de7961e84d2a7c608db57dbab3046 | apache_util.py | 186,613 | 3 | 24 | unique_id | https://github.com/certbot/certbot.git | Add typing to certbot.apache (#9071)
* Add typing to certbot.apache
Co-authored-by: Adrien Ferrand <ferrand.ad@gmail.com> | 12 | 0 | 45,525 | 11 | |
3 | 9 | def add_auto_adjustable_area(self, use_axes, pad=0.1, adjust_dirs=None):
if adjust_dirs is None:
adjust_dirs = ["left", "right", "bottom", "top"]
for d in adjust_dirs:
self.append_size(d, Size._AxesDecorationsSize(use_axes, d) + pad)
| lib/mpl_toolkits/axes_grid1/axes_divider.py | 87 | matplotlib | {
"docstring": "\n Add auto-adjustable padding around *use_axes* to take their decorations\n (title, labels, ticks, ticklabels) into account during layout.\n\n Parameters\n ----------\n use_axes : `~.axes.Axes` or list of `~.axes.Axes`\n The Axes whose decorations are tak... | 24 | Python | 23 | eb12b029ffe2f110540a4338684d1a729d1ddfc5 | axes_divider.py | 107,683 | 5 | 56 | add_auto_adjustable_area | https://github.com/matplotlib/matplotlib.git | Document, test, and simplify impl. of auto_adjustable_area.
Document behavior of auto_adjustable_area, and slightly modernize the
example.
Simplify its implementation: `Padded` is just size addition and
`GetExtentHelper` and `SizeFromFunc` can reasonably be fused into a
single class; none of them are used anywhere el... | 67 | 0 | 22,866 | 12 | |
1 | 12 | def test_failure_subschema(self, obj):
with pytest.raises(validate.ValidationError) as cm:
validate.validate(validate.attr({"foo": str}), obj)
assert_validationerror(cm.value, )
| tests/test_api_validate.py | 75 | streamlink | {
"docstring": "\n ValidationError(AttrSchema):\n Could not validate attribute 'foo'\n Context(type):\n Type of 1 should be str, but is int\n ",
"language": "en",
"n_whitespaces": 76,
"n_words": 16,
"vocab_size": 16
} | 12 | Python | 12 | d09112ab1f6db6aa605650fe1ff6a3028344f90d | test_api_validate.py | 187,182 | 9 | 44 | test_failure_subschema | https://github.com/streamlink/streamlink.git | plugin.api.validate: rewrite tests
Completely rewrite tests using pytest, with full coverage | 36 | 0 | 45,728 | 14 | |
1 | 3 | def clear_checkbox_id(self, name):
return name + "_id"
| django/forms/widgets.py | 23 | django | {
"docstring": "\n Given the name of the clear checkbox input, return the HTML id for it.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 14,
"vocab_size": 12
} | 7 | Python | 7 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | widgets.py | 206,026 | 2 | 12 | clear_checkbox_id | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 21 | 0 | 51,329 | 7 | |
1 | 7 | def done(self):
with self._condition:
return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]
| python3.10.4/Lib/concurrent/futures/_base.py | 39 | XX-Net | {
"docstring": "Return True of the future was cancelled or finished executing.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 10 | Python | 10 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | _base.py | 221,588 | 3 | 23 | done | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 35 | 0 | 56,443 | 9 | |
7 | 26 | def get_data(filters):
data = []
conditions = get_conditions(filters)
salary_slips = frappe.db.sql(
% (conditions),
as_dict=1,
)
component_type_dict = frappe._dict(
frappe.db.sql(
)
)
if not len(component_type_dict):
return []
entry = frappe.db.sql(
% (conditions, ", ".join(["%s"] * l... | erpnext/regional/report/provident_fund_deductions/provident_fund_deductions.py | 586 | @frappe.whitelist() | erpnext | {
"docstring": " select sal.name from `tabSalary Slip` sal\n\t\twhere docstatus = 1 %s\n\t\t select name, component_type from `tabSalary Component`\n\t\twhere component_type in ('Provident Fund', 'Additional Provident Fund', 'Provident Fund Loan') select sal.name, sal.employee, sal.employee_name, ded.salary_component... | 107 | Python | 60 | 494bd9ef78313436f0424b918f200dab8fc7c20b | provident_fund_deductions.py | 67,253 | 52 | 337 | get_data | https://github.com/frappe/erpnext.git | style: format code with black | 67 | 1 | 14,456 | 17 |
2 | 18 | def dag_list_import_errors(args):
dagbag = DagBag(process_subdir(args.subdir))
data = []
for filename, errors in dagbag.import_errors.items():
data.append({"filepath": filename, "error": errors})
AirflowConsole().print_as(
data=data,
output=args.output,
)
@cli_utils.ac... | airflow/cli/commands/dag_command.py | 119 | @cli_utils.action_cli
@suppress_logs_and_warning | airflow | {
"docstring": "Displays dags with import errors on the command line",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 23 | Python | 21 | e1134590973355549272b1f3a213dbfa29698df7 | dag_command.py | 45,966 | 9 | 65 | dag_list_import_errors | https://github.com/apache/airflow.git | Add `list-import-errors` to `airflow dags` command (#22084)
This will help users to see the dags with import error and enable scripts
process the output | 60 | 1 | 8,751 | 12 |
2 | 7 | def mktime_tz(data):
if data[9] is None:
# No zone info, so localtime is better assumption than GMT
return time.mktime(data[:8] + (-1,))
else:
t = calendar.timegm(data)
return t - data[9]
| python3.10.4/Lib/email/_parseaddr.py | 79 | XX-Net | {
"docstring": "Turn a 10-tuple as returned by parsedate_tz() into a POSIX timestamp.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 10
} | 29 | Python | 25 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | _parseaddr.py | 223,623 | 6 | 48 | mktime_tz | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 66 | 0 | 57,013 | 12 | |
3 | 9 | def identbodychars(cls):
return "".join(
sorted(
set(
cls.identchars
+ "0123456789"
+ "".join(
[c for c in cls._chars_for_ranges if ("_" + c).isidentifier()]
)
... | pipenv/patched/notpip/_vendor/pyparsing/unicode.py | 86 | pipenv | {
"docstring": "\n all characters in this range that are valid identifier body characters,\n plus the digits 0-9\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 15
} | 24 | Python | 18 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | unicode.py | 20,660 | 12 | 48 | identbodychars | 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... | 196 | 0 | 3,469 | 21 | |
1 | 5 | def require_tf(test_case):
return unittest.skipUnless(is_tf_available(), "test requires TensorFlow")(test_case)
| src/transformers/testing_utils.py | 37 | transformers | {
"docstring": "\n Decorator marking a test that requires TensorFlow. These tests are skipped when TensorFlow isn't installed.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 15,
"vocab_size": 15
} | 7 | Python | 7 | 57e6464ac9a31156f1c93e59107323e6ec01309e | testing_utils.py | 37,498 | 2 | 20 | require_tf | https://github.com/huggingface/transformers.git | Update all require decorators to use skipUnless when possible (#16999) | 13 | 0 | 6,803 | 10 | |
2 | 18 | def test_constrained_layout23():
for i in range(2):
fig = plt.figure(layout="constrained", clear=True, num="123")
gs = fig.add_gridspec(1, 2)
sub = gs[0].subgridspec(2, 2)
fig.suptitle("Suptitle{}".format(i))
@image_comparison(['test_colorbar_location.png'],
... | lib/matplotlib/tests/test_constrainedlayout.py | 134 | @image_comparison(['test_colorbar_location.png'],
remove_text=True, style='mpl20') | matplotlib | {
"docstring": "\n Comment in #11035: suptitle used to cause an exception when\n reusing a figure w/ CL with ``clear=True``.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 17,
"vocab_size": 17
} | 23 | Python | 20 | ec4dfbc3c83866f487ff0bc9c87b0d43a1c02b22 | test_constrainedlayout.py | 107,180 | 6 | 65 | test_constrained_layout23 | https://github.com/matplotlib/matplotlib.git | ENH: implement and use base layout_engine for more flexible layout. | 73 | 1 | 22,632 | 12 |
1 | 4 | def test_positive_integer_or_none_3():
assert_raises(Exception, positive_integer_or_none, 'foobar')
| tests/driver_tests.py | 25 | tpot | {
"docstring": "Assert that the TPOT CLI interface's positive_integer_or_none parsing throws an exception when n is not an integer and not None.",
"language": "en",
"n_whitespaces": 19,
"n_words": 20,
"vocab_size": 18
} | 5 | Python | 5 | 388616b6247ca4ea8de4e2f340d6206aee523541 | driver_tests.py | 181,603 | 2 | 13 | test_positive_integer_or_none_3 | https://github.com/EpistasisLab/tpot.git | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 11 | 0 | 43,392 | 8 | |
2 | 5 | def get_list_display_add_buttons(self, request):
return self.list_display_add_buttons or self.get_list_display(request)[0]
| wagtail/contrib/modeladmin/options.py | 36 | wagtail | {
"docstring": "\n Return the name of the field/method from list_display where action\n buttons should be added. Defaults to the first item from\n get_list_display()\n ",
"language": "en",
"n_whitespaces": 50,
"n_words": 21,
"vocab_size": 18
} | 7 | Python | 7 | d10f15e55806c6944827d801cd9c2d53f5da4186 | options.py | 73,182 | 2 | 22 | get_list_display_add_buttons | https://github.com/wagtail/wagtail.git | Reformat with black | 21 | 0 | 15,977 | 9 | |
1 | 12 | def _update_size_variant(self) -> None:
width, height = self.size
position_data = {
"width": width,
"height": height,
}
self.update(Panel(Align.center(Pretty(position_data)), title="Placeholder"))
| src/textual/widgets/_placeholder.py | 83 | textual | {
"docstring": "Update the placeholder with the \"size\" variant.\n\n This variant shows the the size of the widget.\n ",
"language": "en",
"n_whitespaces": 30,
"n_words": 16,
"vocab_size": 12
} | 18 | Python | 16 | 67947d5806bb3181eba349f0da3fd35e0542d1be | _placeholder.py | 185,867 | 11 | 48 | _update_size_variant | https://github.com/Textualize/textual.git | Fix documentation about the variant 'size'. | 75 | 0 | 45,216 | 13 | |
1 | 3 | def mass_matrix_full_implicit(self):
return self._mass_matrix_full(False)
| sympy/physics/mechanics/kane.py | 24 | sympy | {
"docstring": "The mass matrix of the system, augmented by the kinematic\n differential equations in implicit form.",
"language": "en",
"n_whitespaces": 21,
"n_words": 15,
"vocab_size": 14
} | 4 | Python | 4 | 1e522ee112f19216f367b457b6804fd58b94f28b | kane.py | 200,100 | 2 | 13 | mass_matrix_full_implicit | https://github.com/sympy/sympy.git | redo of #22626 based on feedback | 18 | 0 | 49,526 | 7 | |
1 | 9 | def test_import_error(self):
self.write_settings_with_import_error("settings.py")
args = ["check", "admin_scripts"]
out, err = self.run_manage(args)
self.assertNoOutput(out)
self.assertOutput(err, "No module named")
self.assertOutput(err, "foo42bar")
| tests/admin_scripts/tests.py | 93 | django | {
"docstring": "\n import error: manage.py builtin commands shows useful diagnostic info\n when settings with import errors is provided (#14130).\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 17,
"vocab_size": 16
} | 18 | Python | 16 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 207,402 | 7 | 51 | test_import_error | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 67 | 0 | 51,952 | 8 | |
1 | 12 | def test_displacy_parse_spans_with_kb_id_options(en_vocab):
doc = Doc(en_vocab, words=["Welcome", "to", "the", "Bank", "of", "China"])
doc.spans["sc"] = [
Span(doc, 3, 6, "ORG", kb_id="Q790068"),
Span(doc, 5, 6, "GPE", kb_id="Q148"),
]
spans = displacy.parse_spans(
doc, {"k... | spacy/tests/test_displacy.py | 294 | spaCy | {
"docstring": "Test that spans with kb_id on a Doc are converted into displaCy's format",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 13
} | 82 | Python | 57 | a79cd3542b3dd667d8a97293462e22ed26a04ee5 | test_displacy.py | 111,253 | 31 | 165 | test_displacy_parse_spans_with_kb_id_options | https://github.com/explosion/spaCy.git | Add displacy support for overlapping Spans (#10332)
* Fix docstring for EntityRenderer
* Add warning in displacy if doc.spans are empty
* Implement parse_spans converter
One notable change here is that the default spans_key is sc, and
it's set by the user through the options.
* Implement SpanRenderer
H... | 315 | 0 | 24,366 | 11 | |
3 | 7 | def __getitem__(self, key):
if key is None:
key = self._key()
value = self._get_recursive(key)
if value is None:
value = self[key] = self.default_factory()
return value
| keras/backend.py | 78 | keras | {
"docstring": "Gets the value at key (or current context), or sets default value.\n\n Args:\n key: May be `None` or `Graph`object. When `None`, the key is set to\n the current context.\n\n Returns:\n Either the cached or default value.\n ",
"language": "en",
"n_w... | 24 | Python | 14 | 3613c3defc39c236fb1592c4f7ba1a9cc887343a | backend.py | 278,622 | 7 | 47 | __getitem__ | https://github.com/keras-team/keras.git | Remove pylint comments.
PiperOrigin-RevId: 452353044 | 81 | 0 | 82,635 | 11 | |
6 | 19 | def resume_end(self) -> None:
assert self.trainer.state.fn is not None
if self.resume_checkpoint_path:
if self.trainer.state.fn == TrainerFn.FITTING:
rank_zero_info(f"Restored all states from the checkpoint file at {self.resume_checkpoint_path}")
elif sel... | pytorch_lightning/trainer/connectors/checkpoint_connector.py | 219 | lightning | {
"docstring": "Signal the connector that all states have resumed and memory for the checkpoint object can be\n released.",
"language": "en",
"n_whitespaces": 23,
"n_words": 17,
"vocab_size": 16
} | 76 | Python | 55 | 5693a94c320297cf007f3bfd13ce4d7deeb1954a | checkpoint_connector.py | 241,668 | 18 | 126 | resume_end | https://github.com/Lightning-AI/lightning.git | Extend the deprecation of `Trainer(resume_from_checkpoint)` (#11334) | 245 | 0 | 69,643 | 15 | |
1 | 3 | def unfrack_path(pathsep=False, follow=True):
| lib/ansible/cli/arguments/option_helpers.py | 21 | ansible | {
"docstring": "Turn an Option's data into a single path in Ansible locations",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 3 | Python | 3 | b1ff0f4ebc7e964f8f67ffc344815a0d23577f45 | option_helpers.py | 268,472 | 3 | 16 | unfrack_path | https://github.com/ansible/ansible.git | vault secrets file, keep context when symlink (#78734)
* vault secrets file, keep context when symlink
fixes #18319
Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> | 6 | 0 | 79,515 | 6 | |
12 | 20 | def get_freq(self) -> str | None:
if not self.is_monotonic or not self.index._is_unique:
return None
delta = self.deltas[0]
ppd = periods_per_day(self._reso)
if delta and _is_multiple(delta, ppd):
return self._infer_daily_rule()
# Business hourl... | pandas/tseries/frequencies.py | 367 | pandas | {
"docstring": "\n Find the appropriate frequency string to describe the inferred\n frequency of self.i8values\n\n Returns\n -------\n str or None\n ",
"language": "en",
"n_whitespaces": 60,
"n_words": 17,
"vocab_size": 15
} | 162 | Python | 94 | e9350a4affbb424aaecad279f638a0dd1584df68 | frequencies.py | 166,591 | 35 | 210 | get_freq | https://github.com/pandas-dev/pandas.git | infer_freq handle non-nano (#47126)
* infer_freq handle non-nano
* remove unused import | 487 | 0 | 39,834 | 13 | |
2 | 5 | def require_tensorflow(test_case):
if not is_tensorflow_available():
return unittest.skip("test requires TensorFlow")(test_case)
else:
return test_case
| src/accelerate/test_utils/testing.py | 49 | accelerate | {
"docstring": "\n Decorator marking a test that requires TensorFlow installed. These tests are skipped when TensorFlow isn't\n installed\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 16,
"vocab_size": 15
} | 12 | Python | 11 | 5668270de74a09e5bff15891054f73ddbb1176ac | testing.py | 337,338 | 5 | 26 | require_tensorflow | https://github.com/huggingface/accelerate.git | Add logging capabilities (#293)
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
- Added experiment tracking API, and support for Weights and Biases, TensorBoard, and CometML + Tests
- Added `tensorflow` to a new dependency list to be used during tests
- Added three new functions in `Acc... | 35 | 0 | 121,034 | 11 | |
4 | 12 | def _errt(self):
# Count (UI, OI) pairs for truncation points until we find the segment where (ui, oi) crosses the truncation line
self.coords = self._get_truncation_coordinates()
if (0.0, 0.0) in self.coords:
# Truncation line goes through origo, so ERRT cannot be counted
... | nltk/metrics/paice.py | 230 | nltk | {
"docstring": "Count Error-Rate Relative to Truncation (ERRT).\n\n :return: ERRT, length of the line from origo to (UI, OI) divided by\n the length of the line from origo to the point defined by the same\n line when extended until the truncation line.\n :rtype: float\n ",
"langua... | 175 | Python | 100 | 0fac0c0f8e4618c2bdd3d2137d5fb8a80f581246 | paice.py | 42,464 | 15 | 157 | _errt | https://github.com/nltk/nltk.git | Update black to 22.3.0
The most recent release of Click (8.1.0) was breaking Black. See psf/black#2964 | 383 | 0 | 7,553 | 13 | |
2 | 8 | def get_tf_version():
global _TF_VERS # pylint:disable=global-statement
if _TF_VERS is None:
import tensorflow as tf # pylint:disable=import-outside-toplevel
_TF_VERS = float(".".join(tf.__version__.split(".")[:2])) # pylint:disable=no-member
return _TF_VERS
| lib/utils.py | 75 | faceswap | {
"docstring": " Obtain the major.minor version of currently installed Tensorflow.\n\n Returns\n -------\n float\n The currently installed tensorflow version\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 16,
"vocab_size": 13
} | 23 | Python | 18 | c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf | utils.py | 100,370 | 6 | 40 | get_tf_version | 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 -... | 52 | 0 | 19,859 | 16 | |
2 | 15 | def _compile_output(self) -> Union[List[str], List[Tuple[str, int]]]:
action = self._job.replace("-", "_")
processor = getattr(self, f"_get_{action}")
logger.debug("Processor: %s", processor)
return [item for item in processor()] # pylint:disable=unnecessary-comprehension
| tools/alignments/jobs.py | 106 | faceswap | {
"docstring": " Compile list of frames that meet criteria\n\n Returns\n -------\n list\n List of filenames or filenames and face indices for the selected criteria\n ",
"language": "en",
"n_whitespaces": 62,
"n_words": 22,
"vocab_size": 18
} | 25 | Python | 24 | e2a77e7c6e84e81f642cb22f528e25e3f2d2dbc1 | jobs.py | 101,714 | 12 | 63 | _compile_output | https://github.com/deepfakes/faceswap.git | Alignments Tool - Typing, Documentation + Re-org | 61 | 0 | 21,118 | 10 | |
6 | 12 | def find_submodule_and_param_name(model, long_key, start_prefix):
if len(start_prefix) > 0 and long_key.startswith(start_prefix):
long_key = ".".join(long_key.split(".")[1:])
split_key = long_key.split(".")
submodule = model
while len(split_key) > 1:
if hasattr(submodule, split_ke... | src/transformers/modeling_utils.py | 178 | transformers | {
"docstring": "\n A helper util to find the last sub-module and the param/buffer name. If `start_prefix` is supplied it'll be removed\n from the start of the key\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 25,
"vocab_size": 22
} | 47 | Python | 33 | 5da33f872913255d64717efe745a053975bbc28e | modeling_utils.py | 37,157 | 15 | 109 | find_submodule_and_param_name | https://github.com/huggingface/transformers.git | [modeling utils] revamp `from_pretrained(..., low_cpu_mem_usage=True)` + tests (#16657)
* add low_cpu_mem_usage tests
* wip: revamping
* wip
* install /usr/bin/time
* wip
* cleanup
* cleanup
* cleanup
* cleanup
* cleanup
* fix assert
* put the wrapper back
* cleanup; switch to bert-... | 140 | 0 | 6,748 | 14 | |
1 | 4 | def test_task_group_context_mix():
from airflow.decorators import task
| tests/utils/test_task_group.py | 21 | airflow | {
"docstring": "Test cases to check nested TaskGroup context manager with taskgroup decorator",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 6 | Python | 6 | 49e336ae0302b386a2f47269a6d13988382d975f | test_task_group.py | 47,694 | 50 | 269 | test_task_group_context_mix | https://github.com/apache/airflow.git | Replace usage of `DummyOperator` with `EmptyOperator` (#22974)
* Replace usage of `DummyOperator` with `EmptyOperator` | 12 | 0 | 9,216 | 6 | |
2 | 20 | def add_noise_to_input(self, sample, sigma, generator=None):
if self.s_min <= sigma <= self.s_max:
gamma = min(self.s_churn / self.num_inference_steps, 2**0.5 - 1)
else:
gamma = 0
# sample eps ~ N(0, S_noise^2 * I)
eps = self.s_noise * torch.randn(sample... | src/diffusers/schedulers/scheduling_karras_ve.py | 159 | diffusers | {
"docstring": "\n Explicit Langevin-like \"churn\" step of adding noise to the sample according to\n a factor gamma_i ≥ 0 to reach a higher noise level sigma_hat = sigma_i + gamma_i*sigma_i.\n ",
"language": "en",
"n_whitespaces": 50,
"n_words": 28,
"vocab_size": 24
} | 58 | Python | 41 | dd10da76a78e9566d12ddf1eb5aac90021b7e51d | scheduling_karras_ve.py | 336,293 | 9 | 107 | add_noise_to_input | https://github.com/huggingface/diffusers.git | Add an alternative Karras et al. stochastic scheduler for VE models (#160)
* karras + VE, not flexible yet
* Fix inputs incompatibility with the original unet
* Roll back sigma scaling
* Apply suggestions from code review
* Old comment
* Fix doc | 136 | 0 | 120,864 | 13 | |
5 | 19 | def _getPythonForSconsExePath():
python_exe = Options.getPythonPathForScons()
if python_exe is not None:
return python_exe
scons_supported_pythons = ("3.5", "3.6", "3.7", "3.8", "3.9", "3.10")
if not Utils.isWin32Windows():
scons_supported_pythons += ("2.7", "2.6")
# Our inli... | nuitka/build/SconsInterface.py | 192 | @contextlib.contextmanager | Nuitka | {
"docstring": "Find a way to call any Python that works for Scons.\n\n Scons needs it as it doesn't support all Python versions.\n \\\nError, while Nuitka works with older Python, Scons does not, and therefore\nNuitka needs to find a %s executable, so please install\nit.\n\nYou may provide it using option \"--... | 79 | Python | 56 | c4ce69f97f7fefbcf637e9e59b6df056ad03eb16 | SconsInterface.py | 178,460 | 28 | 102 | _getPythonForSconsExePath | https://github.com/Nuitka/Nuitka.git | Scons: Refactor Python scan for major cleanup
* This is in preparation of making it reusable for onefile
compression which also has a simular need. | 202 | 1 | 42,705 | 12 |
1 | 7 | def test_func(self, qapp):
pytest.importorskip("qutebrowser.qt.opengl")
version.opengl_info()
| tests/unit/utils/test_version.py | 36 | qutebrowser | {
"docstring": "Simply call version.opengl_info() and see if it doesn't crash.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 5 | Python | 5 | d387b1a1084b9649009e5cffb9d71facc80bb41f | test_version.py | 321,555 | 3 | 19 | test_func | https://github.com/qutebrowser/qutebrowser.git | tests: Adjust most imports | 26 | 0 | 117,800 | 8 | |
1 | 11 | def classifiers(self):
url = self.repository+'?:action=list_classifiers'
response = urllib.request.urlopen(url)
log.info(self._read_pypi_response(response))
| python3.10.4/Lib/distutils/command/register.py | 60 | XX-Net | {
"docstring": " Fetch the list of classifiers from the server.\n ",
"language": "en",
"n_whitespaces": 16,
"n_words": 8,
"vocab_size": 7
} | 9 | Python | 8 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | register.py | 222,796 | 4 | 34 | classifiers | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 37 | 0 | 56,745 | 9 | |
1 | 2 | def yanchor(self):
return self["yanchor"]
| packages/python/plotly/plotly/graph_objs/bar/marker/_colorbar.py | 22 | plotly.py | {
"docstring": "\n Sets this color bar's vertical position anchor This anchor\n binds the `y` position to the \"top\", \"middle\" or \"bottom\" of\n the color bar. Defaults to \"middle\" when `orientation` is \"v\"\n and \"bottom\" when `orientation` is \"h\".\n\n The 'yanchor' prop... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _colorbar.py | 228,764 | 2 | 11 | yanchor | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 60,437 | 7 | |
4 | 5 | def _debugger_window_is_open():
if _Debugger.debugger is None:
return False
debugger = _Debugger.debugger
if debugger.popout_window or debugger.watcher_window:
return True
return False
| PySimpleGUI.py | 54 | PySimpleGUI | {
"docstring": "\n Determines if one of the debugger window is currently open\n :return: returns True if the popout window or the main debug window is open\n :rtype: (bool)\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 26,
"vocab_size": 19
} | 19 | Python | 14 | 37c3afc8ca0dc0057a23ab512ee8b879074dd119 | PySimpleGUI.py | 212,794 | 7 | 32 | _debugger_window_is_open | https://github.com/PySimpleGUI/PySimpleGUI.git | ButtonMenu.Click aliased added. Debugger - automatically adds a timeout to read calls if a debug window is open. Still need to handle user-level multi-window support. | 48 | 0 | 53,407 | 7 | |
1 | 4 | def detected_faces(self) -> List["DetectedFace"]:
return self._detected_faces
| plugins/extract/pipeline.py | 28 | faceswap | {
"docstring": "list: A list of :class:`~lib.align.DetectedFace` objects in the :attr:`image`. ",
"language": "en",
"n_whitespaces": 9,
"n_words": 9,
"vocab_size": 9
} | 6 | Python | 6 | 1022651eb8a7741014f5d2ec7cbfe882120dfa5f | pipeline.py | 101,353 | 3 | 15 | detected_faces | https://github.com/deepfakes/faceswap.git | Bugfix: convert - Gif Writer
- Fix non-launch error on Gif Writer
- convert plugins - linting
- convert/fs_media/preview/queue_manager - typing
- Change convert items from dict to Dataclass | 20 | 0 | 20,768 | 6 | |
4 | 18 | def _check_input_folder(self) -> bool:
if not os.path.exists(self._args.input_dir):
logger.error("Input location %s not found.", self._args.input_dir)
sys.exit(1)
if (os.path.isfile(self._args.input_dir) and
os.path.splitext(self._args.input_dir)[1].lower... | scripts/fsmedia.py | 186 | faceswap | {
"docstring": " Check whether the input is a folder or video.\n\n Returns\n -------\n bool\n ``True`` if the input is a video otherwise ``False``\n ",
"language": "en",
"n_whitespaces": 61,
"n_words": 21,
"vocab_size": 17
} | 37 | Python | 28 | 1022651eb8a7741014f5d2ec7cbfe882120dfa5f | fsmedia.py | 101,393 | 19 | 113 | _check_input_folder | https://github.com/deepfakes/faceswap.git | Bugfix: convert - Gif Writer
- Fix non-launch error on Gif Writer
- convert plugins - linting
- convert/fs_media/preview/queue_manager - typing
- Change convert items from dict to Dataclass | 153 | 0 | 20,808 | 15 | |
3 | 58 | def _background_extract(self, output_folder, progress_queue):
_io = dict(saver=ImagesSaver(get_folder(output_folder), as_bytes=True),
loader=ImagesLoader(self._input_location, count=self._alignments.frames_count))
for frame_idx, (filename, image) in enumerate(_io["loader"].l... | tools/manual/detected_faces.py | 366 | faceswap | {
"docstring": " Perform the background extraction in a thread so GUI doesn't become unresponsive.\n\n Parameters\n ----------\n output_folder: str\n The location to save the output faces to\n progress_queue: :class:`queue.Queue`\n The queue to place incremental count... | 65 | Python | 56 | 5e73437be47f2410439a3c6716de96354e6a0c94 | detected_faces.py | 101,259 | 24 | 232 | _background_extract | https://github.com/deepfakes/faceswap.git | lib.align updates:
- alignments.py
- Add typed dicts for imported alignments
- Explicitly check for presence of thumb value in alignments dict
- linting
- detected_face.py
- Typing
- Linting
- Legacy support for pre-aligned face
- Update dependencies to new property names | 575 | 0 | 20,679 | 18 | |
1 | 1 | def test_default_kwargs():
| tests/unit/test_isolation.py | 12 | pyinstaller | {
"docstring": "\n Verify that default keyword-only arguments are properly passed to the isolated function call.\n ",
"language": "en",
"n_whitespaces": 20,
"n_words": 13,
"vocab_size": 13
} | 2 | Python | 2 | 3ba0aaf983f5223000a713c9275ea66e21f78b11 | test_isolation.py | 262,759 | 8 | 67 | test_default_kwargs | https://github.com/pyinstaller/pyinstaller.git | tests: add a test for calling isolated function with default (kw)args
Add tests that show that current implementation does not transfer
default arguments (function.__defaults__) nor default keyword-only
arguments (function.__kwdefaults__) to the child process, resulting
in a missing-positional-argument error unless al... | 5 | 0 | 77,348 | 6 | |
3 | 12 | def _tune_legacy_checkpoint_score_attr(self) -> Optional[str]:
if self.checkpoint_score_attribute is None:
return self.checkpoint_score_attribute
prefix = ""
if self.checkpoint_score_order == MIN:
prefix = "min-"
return f"{prefix}{self.checkpoint_score_at... | python/ray/util/ml_utils/checkpoint_manager.py | 111 | @Deprecated(message=deprecation_message)
@dataclass | ray | {
"docstring": "Same as ``checkpoint_score_attr`` in ``tune.run``.\n\n Only used for Legacy API compatibility.\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 11,
"vocab_size": 11
} | 49 | Python | 41 | dc7ed086a5038775e378b32cb31fb4a79f418dd9 | checkpoint_manager.py | 123,916 | 11 | 38 | _tune_legacy_checkpoint_score_attr | https://github.com/ray-project/ray.git | [AIR] More checkpoint configurability, `Result` extension (#25943)
This PR:
* Allows the user to set `keep_checkpoints_num` and `checkpoint_score_attr` in `RunConfig` using the `CheckpointStrategy` dataclass
* Adds two new fields to the `Result` object - `best_checkpoints` - a list of saved best checkpoints as deter... | 110 | 1 | 27,474 | 9 |
1 | 13 | def test_receive_data_before_server_connected(tctx):
assert (
Playbook(tcp.TCPLayer(tctx), hooks=False)
<< OpenConnection(tctx.server)
>> DataReceived(tctx.client, b"hello!")
>> reply(None, to=-2)
<< SendData(tctx.server, b"hello!")
)
| test/mitmproxy/proxy/layers/test_tcp.py | 93 | mitmproxy | {
"docstring": "\n assert that data received before a server connection is established\n will still be forwarded.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 14,
"vocab_size": 14
} | 18 | Python | 15 | b3587b52b25077f68116b9852b041d33e7fc6601 | test_tcp.py | 251,916 | 8 | 63 | test_receive_data_before_server_connected | https://github.com/mitmproxy/mitmproxy.git | make it black! | 62 | 0 | 73,888 | 14 | |
2 | 25 | def demo_tp(rank, args):
print(f"Running basic Megatron style TP example on rank {rank}.")
setup(rank, args.world_size)
# create a sharding plan based on the given world_size.
module_sharding_plan = _get_toy_module_sharding_plan(
args.world_size
)
# create model and move it to GPU ... | distributed/sharded_tensor/tensor_parallel.py | 176 | examples | {
"docstring": "\n Main body of the demo of a basic version of tensor parallel by using\n PyTorch native sharded tensor APIs.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 19,
"vocab_size": 16
} | 94 | Python | 67 | 9ba53df5a19131e6926027b2e73aaa77cec17272 | tensor_parallel.py | 82,841 | 15 | 103 | demo_tp | https://github.com/pytorch/examples.git | Gh/fduwjj/2/base (#1007)
* test ghstack
[ghstack-poisoned]
* Update base for Update on "[PT-D] Add an example for Megatron-LM style example"
[ghstack-poisoned]
* Update base for Update on "[PT-D] Add an example for Megatron-LM style example"
[ghstack-poisoned]
* Update base for Update on ... | 177 | 0 | 17,550 | 12 | |
6 | 21 | def makelink(self, tarinfo, targetpath):
try:
# For systems that support symbolic and hard links.
if tarinfo.issym():
os.symlink(tarinfo.linkname, targetpath)
else:
# See extract().
if os.path.exists(tarinfo._link_targe... | pipenv/patched/notpip/_vendor/distlib/_backport/tarfile.py | 219 | pipenv | {
"docstring": "Make a (symbolic) link called targetpath. If it cannot be created\n (platform limitation), we try to make a copy of the referenced file\n instead of a link.\n ",
"language": "en",
"n_whitespaces": 52,
"n_words": 27,
"vocab_size": 24
} | 54 | Python | 39 | c69d55f7c82d5ae2cce542bcfb98d043ca4836a0 | tarfile.py | 21,391 | 22 | 133 | makelink | https://github.com/pypa/pipenv.git | Vendor in pip 22.1.2 | 432 | 0 | 3,804 | 17 | |
1 | 3 | def get_rules(self) -> RulesMap:
| src/textual/css/styles.py | 16 | textual | {
"docstring": "Get the rules in a mapping.\n\n Returns:\n RulesMap: A TypedDict of the rules.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 13,
"vocab_size": 12
} | 4 | Python | 4 | 116f3735b68e8dd293dba4b3a183f98afbd0b167 | styles.py | 182,279 | 6 | 8 | get_rules | https://github.com/Textualize/textual.git | docstrings | 11 | 0 | 43,780 | 6 | |
1 | 8 | def test_fillna_frame(self):
super().test_fillna_frame()
unhashable = pytest.mark.xfail(reason="Unhashable")
| pandas/tests/extension/json/test_json.py | 47 | pandas | {
"docstring": "We treat dictionaries as a mapping in fillna, not a scalar.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 10
} | 6 | Python | 6 | 24652cf178c12562585639cba39c46d62b95f107 | test_json.py | 165,750 | 2 | 13 | test_fillna_frame | https://github.com/pandas-dev/pandas.git | TST: Convert skip -> xfail (#46427) | 19 | 0 | 39,706 | 9 | |
2 | 10 | def push(self, exit):
# We use an unbound method rather than a bound method to follow
# the standard lookup behaviour for special methods.
_cb_type = type(exit)
try:
exit_method = _cb_type.__exit__
except AttributeError:
# Not a context manager, ... | python3.10.4/Lib/contextlib.py | 75 | XX-Net | {
"docstring": "Registers a callback with the standard __exit__ method signature.\n\n Can suppress exceptions the same way __exit__ method can.\n Also accepts any object with an __exit__ method (registering a call\n to the method instead of the object itself).\n ",
"language": "en",
"n... | 55 | Python | 46 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | contextlib.py | 221,712 | 9 | 42 | push | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 156 | 0 | 56,482 | 10 | |
1 | 17 | async def test_filter_non_existent_column(state_api_manager):
data_source_client = state_api_manager.data_source_client
id = b"1234"
data_source_client.get_all_worker_info.return_value = GetAllWorkerInfoReply(
worker_table_data=[
generate_worker_data(id, pid=1),
generate... | python/ray/tests/test_state_api.py | 138 | ray | {
"docstring": "Test when the non existent column is given, it handles that properly.\n\n Related: https://github.com/ray-project/ray/issues/26811\n ",
"language": "en",
"n_whitespaces": 20,
"n_words": 14,
"vocab_size": 14
} | 32 | Python | 28 | 37f4692aa805eba230e2879c098320111788a64c | test_state_api.py | 125,623 | 14 | 85 | test_filter_non_existent_column | https://github.com/ray-project/ray.git | [State Observability] Fix "No result for get crashing the formatting" and "Filtering not handled properly when key missing in the datum" #26881
Fix two issues
No result for get crashing the formatting
Filtering not handled properly when key missing in the datum | 106 | 0 | 27,927 | 16 | |
11 | 24 | def _url(self, hashed_name_func, name, force=False, hashed_files=None):
if settings.DEBUG and not force:
hashed_name, fragment = name, ""
else:
clean_name, fragment = urldefrag(name)
if urlsplit(clean_name).path.endswith("/"): # don't hash paths
... | django/contrib/staticfiles/storage.py | 261 | django | {
"docstring": "\n Return the non-hashed URL in DEBUG mode.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | 94 | Python | 60 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | storage.py | 204,364 | 22 | 156 | _url | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 356 | 0 | 50,711 | 15 | |
1 | 6 | def set_raw_scale(self, in_, scale):
self.__check_input(in_)
self.raw_scale[in_] = scale
| code/deep/BJMMD/caffe/python/caffe/io.py | 39 | transferlearning | {
"docstring": "\n Set the scale of raw features s.t. the input blob = input * scale.\n While Python represents images in [0, 1], certain Caffe models\n like CaffeNet and AlexNet represent images in [0, 255] so the raw_scale\n of these models must be 255.\n\n Parameters\n ---... | 8 | Python | 8 | cc4d0564756ca067516f71718a3d135996525909 | io.py | 60,255 | 3 | 24 | set_raw_scale | https://github.com/jindongwang/transferlearning.git | Balanced joint maximum mean discrepancy for deep transfer learning | 29 | 0 | 12,047 | 8 | |
4 | 12 | def list_distinfo_files(self):
base = os.path.dirname(self.path)
for path, checksum, size in self._get_records():
# XXX add separator or use real relpath algo
if not os.path.isabs(path):
path = os.path.join(base, path)
if path.startswith(self.... | .venv/lib/python3.8/site-packages/pip/_vendor/distlib/database.py | 108 | transferlearning | {
"docstring": "\n Iterates over the ``RECORD`` entries and returns paths for each line if\n the path is pointing to a file located in the ``.dist-info`` directory\n or one of its subdirectories.\n\n :returns: iterator of paths\n ",
"language": "en",
"n_whitespaces": 69,
"n_wo... | 31 | Python | 28 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | database.py | 61,929 | 7 | 66 | list_distinfo_files | https://github.com/jindongwang/transferlearning.git | upd; format | 115 | 0 | 12,754 | 13 | |
2 | 8 | def validate(self):
if not self._check_schedule_interval_matches_timetable():
raise AirflowDagInconsistent(
f"inconsistent schedule: timetable {self.timetable.summary!r} "
f"does not match schedule_interval {self.schedule_interval!r}",
)
s... | airflow/models/dag.py | 85 | airflow | {
"docstring": "Validate the DAG has a coherent setup.\n\n This is called by the DAG bag before bagging the DAG.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 18,
"vocab_size": 15
} | 20 | Python | 19 | a1a9a8f9a3adc63e783cf3fd699066f35e488d4f | dag.py | 43,013 | 8 | 37 | validate | https://github.com/apache/airflow.git | Check bag DAG schedule_interval match tiemtable (#23113)
This guards against the DAG's timetable or schedule_interval from being
changed after it's created. Validation is done by creating a timetable
and check its summary matches schedule_interval. The logic is not
bullet-proof, especially if a custom timetable doe... | 100 | 0 | 7,791 | 14 | |
1 | 6 | def get_tokenizer(*args, **kwargs):
return AlbertTokenizer.from_pretrained(pretrained_model_name_or_path='albert-base-v1', *args, **kwargs)
| modules/text/language_model/albert-base-v1/module.py | 43 | PaddleHub | {
"docstring": "\n Gets the tokenizer that is customized for this module.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | 7 | Python | 7 | 26e56d098d7cebdc910e84ce1d0d1a909c1988c3 | module.py | 48,752 | 2 | 25 | get_tokenizer | https://github.com/PaddlePaddle/PaddleHub.git | add albert-base-v1 | 21 | 0 | 9,591 | 9 | |
1 | 10 | def exit_with_error(message, code=1, **kwargs):
kwargs.setdefault("style", "red")
app.console.print(message, **kwargs)
raise typer.Exit(code)
| src/prefect/cli/base.py | 66 | prefect | {
"docstring": "\n Utility to print a stylized error message and exit with a non-zero code\n ",
"language": "en",
"n_whitespaces": 20,
"n_words": 13,
"vocab_size": 12
} | 10 | Python | 10 | c0cb1fee460c1bded9e3eb741ad7979402844bf8 | base.py | 55,137 | 4 | 39 | exit_with_error | https://github.com/PrefectHQ/prefect.git | Update `set` command; allow CLI `console` object to be patched | 22 | 0 | 11,226 | 8 | |
12 | 67 | async def contracts_command(ctx, ticker="", past_transaction_days="", raw=""):
try:
# Debug user input
if cfg.DEBUG:
logger.debug(
"!stocks.gov.contracts %s %s %s", ticker, past_transaction_days, raw
)
if past_transaction_days == "":
... | discordbot/stocks/government/contracts.py | 766 | OpenBBTerminal | {
"docstring": "Displays contracts associated with tickers [quiverquant.com]",
"language": "en",
"n_whitespaces": 5,
"n_words": 6,
"vocab_size": 6
} | 200 | Python | 131 | f40ba0d256a78ab2b8461f0df3a9a52ca7dc5704 | contracts.py | 281,178 | 66 | 444 | contracts_command | https://github.com/OpenBB-finance/OpenBBTerminal.git | Bot logging fix (#1105)
* Write bot logs to stdout instead of a file
Heroku's logging uses the stdout and has problems with files
* Send "you snooze you lose" only if debug flag is enabled
* Replace print statements with logger entries in the economy menu
* Add logging to bot menu command calls
* Silence ... | 799 | 0 | 83,584 | 16 | |
1 | 14 | async def test_storage_is_updated_on_add(hass, hass_storage, utcnow):
await setup_test_component(hass, create_lightbulb_service)
entity_map: EntityMapStorage = hass.data[ENTITY_MAP]
hkid = "00:00:00:00:00:00"
# Is in memory store updated?
assert hkid in entity_map.storage_data
# Is saved... | tests/components/homekit_controller/test_storage.py | 96 | core | {
"docstring": "Test entity map storage is cleaned up on adding an accessory.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 37 | Python | 28 | b9c8d65940ec47a82332b8b1a67301da018ccadf | test_storage.py | 317,256 | 7 | 56 | test_storage_is_updated_on_add | https://github.com/home-assistant/core.git | Restore accessory state into pairing using new HKC methods (#75276) | 64 | 0 | 115,831 | 9 | |
1 | 2 | def disable_run_logger():
with disable_logger("prefect.flow_run"), disable_logger("prefect.task_run"):
yield
| src/prefect/logging/loggers.py | 39 | prefect | {
"docstring": "\n Gets both `prefect.flow_run` and `prefect.task_run` and disables them\n within the context manager. Upon exiting the context manager, both loggers\n are returned to its original state.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 25,
"vocab_size": 21
} | 6 | Python | 6 | 895a5203623c205ede2ee0c31f99be72822d5351 | loggers.py | 59,074 | 3 | 17 | disable_run_logger | https://github.com/PrefectHQ/prefect.git | Add docstring | 19 | 0 | 11,863 | 10 | |
1 | 10 | def add_to_apply_calls(self, func, *args, length=None, width=None, **kwargs):
return PandasOnDaskDataframePartition(
self._data,
call_queue=self.call_queue + [[func, args, kwargs]],
length=length,
width=width,
)
| modin/core/execution/dask/implementations/pandas_on_dask/partitioning/partition.py | 76 | modin | {
"docstring": "\n Add a function to the call queue.\n\n Parameters\n ----------\n func : callable\n Function to be added to the call queue.\n *args : iterable\n Additional positional arguments to be passed in `func`.\n length : distributed.Future or int... | 18 | Python | 18 | 39b36eb2a2e3bf3d612933e1c78545a8bb28cde4 | partition.py | 154,339 | 7 | 54 | add_to_apply_calls | https://github.com/modin-project/modin.git | PERF-#4794: Compute caches in `_propagate_index_objs` (#4888)
Co-authored-by: Mahesh Vashishtha <mvashishtha@users.noreply.github.com>
Signed-off-by: Myachev <anatoly.myachev@intel.com> | 83 | 0 | 35,932 | 11 | |
1 | 10 | def use_numexpr_cb(key) -> None:
from pandas.core.computation import expressions
expressions.set_use_numexpr(cf.get_option(key))
use_numba_doc =
| pandas/core/config_init.py | 48 | pandas | {
"docstring": "\n: bool\n Use the numba engine option for select operations if it is installed,\n the default is False\n Valid values: False,True\n",
"language": "en",
"n_whitespaces": 29,
"n_words": 21,
"vocab_size": 19
} | 11 | Python | 11 | 9612375ca28ade056f15d4338f1bfde5d045c9fc | config_init.py | 167,699 | 3 | 26 | use_numexpr_cb | https://github.com/pandas-dev/pandas.git | TYP: return values in core/*.py (#47587)
* TYP: return values in core/*.py
* fix test
* to_html
* to_html part 2
* DataFrame.query
* more overloads
* fix query?
* increase stacklevel by one
* fix rename_axis
* and an overload for DataFrame.eval
* address comments
* fix typevar | 16 | 0 | 40,082 | 9 | |
1 | 11 | def test_unavailable_models(self):
state = migrations.state.ProjectState()
# Unavailable contenttypes.ContentType
with self.assertNumQueries(0):
create_permissions(self.app_config, verbosity=0, apps=state.apps)
# Unavailable auth.Permission
state = migrations... | tests/auth_tests/test_management.py | 130 | django | {
"docstring": "\n #24075 - Permissions shouldn't be created or deleted if the ContentType\n or Permission models aren't available.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 16,
"vocab_size": 15
} | 24 | Python | 15 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | test_management.py | 201,336 | 7 | 77 | test_unavailable_models | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 95 | 0 | 49,920 | 11 | |
1 | 3 | def info(self):
return self.headers
| python3.10.4/Lib/http/client.py | 19 | XX-Net | {
"docstring": "Returns an instance of the class mimetools.Message containing\n meta-information associated with the URL.\n\n When the method is HTTP, these headers are those returned by\n the server at the head of the retrieved HTML page (including\n Content-Length and Content-Type).\n\n ... | 4 | Python | 4 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | client.py | 217,717 | 2 | 10 | info | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 18 | 0 | 54,898 | 6 | |
3 | 23 | def get_timestamped_export_dir(export_dir_base):
attempts = 0
while attempts < MAX_DIRECTORY_CREATION_ATTEMPTS:
timestamp = int(time.time())
result_dir = tf.io.gfile.join(
tf.compat.as_bytes(export_dir_base),
tf.compat.as_bytes(str(timestamp)),
)
if ... | keras/saving/utils_v1/export_utils.py | 191 | keras | {
"docstring": "Builds a path to a new subdirectory within the base directory.\n\n Each export is written into a new subdirectory named using the\n current time. This guarantees monotonically increasing version\n numbers even across multiple runs of the pipeline.\n The timestamp used is the number of sec... | 83 | Python | 69 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | export_utils.py | 276,300 | 23 | 112 | get_timestamped_export_dir | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 301 | 0 | 81,622 | 14 | |
1 | 7 | def compare(self, a, b):
a = _convert_other(a, raiseit=True)
return a.compare(b, context=self)
| python3.10.4/Lib/_pydecimal.py | 48 | XX-Net | {
"docstring": "Compares values numerically.\n\n If the signs of the operands differ, a value representing each operand\n ('-1' if the operand is less than zero, '0' if the operand is zero or\n negative zero, or '1' if the operand is greater than zero) is used in\n place of that operand fo... | 11 | Python | 11 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | _pydecimal.py | 219,736 | 3 | 31 | compare | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 32 | 0 | 55,755 | 9 | |
1 | 5 | async def count_daily_user_type(self) -> Dict[str, int]:
| synapse/storage/databases/main/registration.py | 23 | synapse | {
"docstring": "\n Counts 1) native non guest users\n 2) native guests users\n 3) bridged users\n who registered on the homeserver in the past 24 hours\n ",
"language": "en",
"n_whitespaces": 73,
"n_words": 23,
"vocab_size": 19
} | 6 | Python | 6 | 1783156dbcf4164692e66275d1c29857c434995b | registration.py | 248,015 | 11 | 27 | count_daily_user_type | https://github.com/matrix-org/synapse.git | Add some type hints to datastore (#12423)
* Add some type hints to datastore
* newsfile
* change `Collection` to `List`
* refactor return type of `select_users_txn`
* correct type hint in `stream.py`
* Remove `Optional` in `select_users_txn`
* remove not needed return type in `__init__`
* Revert c... | 13 | 0 | 72,046 | 6 | |
3 | 23 | def __iter__(self) -> Iterator[tuple[Hashable, NDFrameT]]:
keys = self.keys
if isinstance(keys, list) and len(keys) == 1:
warnings.warn(
(
"In a future version of pandas, a length 1 "
"tuple will be returned when iterating over... | pandas/core/groupby/groupby.py | 140 | pandas | {
"docstring": "\n Groupby iterator.\n\n Returns\n -------\n Generator yielding sequence of (name, subsetted object)\n for each group\n ",
"language": "en",
"n_whitespaces": 57,
"n_words": 14,
"vocab_size": 14
} | 82 | Python | 68 | 14de3fd9ca4178bfce5dd681fa5d0925e057c04d | groupby.py | 168,124 | 23 | 74 | __iter__ | https://github.com/pandas-dev/pandas.git | DEPR: returning tuple when grouping by a list containing single element (#47761)
* DOC #45443 edited the documentation of where/mask functions
* DOC #45443 edited the documentation of where/mask functions
* Update generic.py
* ENH: add suffixes argument to DataFrame.compare #44354
* Edited the tests
* s... | 285 | 0 | 40,213 | 12 | |
1 | 17 | def _transform_url(url, transform_netloc):
# type: (str, Callable[[str], Tuple[Any, ...]]) -> Tuple[str, NetlocTuple]
purl = urllib.parse.urlsplit(url)
netloc_tuple = transform_netloc(purl.netloc)
# stripped url
url_pieces = (purl.scheme, netloc_tuple[0], purl.path, purl.query, purl.fragment)
... | .venv/lib/python3.8/site-packages/pip/_internal/utils/misc.py | 109 | transferlearning | {
"docstring": "Transform and replace netloc in a url.\n\n transform_netloc is a function taking the netloc and returning a\n tuple. The first element of this tuple is the new netloc. The\n entire tuple is returned.\n\n Returns a tuple containing the transformed url as item 0 and the\n original tuple r... | 35 | Python | 31 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | misc.py | 61,234 | 6 | 69 | _transform_url | https://github.com/jindongwang/transferlearning.git | upd; format | 59 | 0 | 12,455 | 9 | |
1 | 31 | def test_update_notice_user_name_when_changed(self) -> None:
server_notice_request_content = {
"user_id": self.other_user,
"content": {"msgtype": "m.text", "body": "test msg one"},
}
self.make_request(
"POST",
self.url,
access... | tests/rest/admin/test_server_notice.py | 282 | synapse | {
"docstring": "\n Tests that existing server notices user name in room is updated after\n server notice config changes.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 16,
"vocab_size": 15
} | 74 | Python | 57 | 2e2d8cc2f9b9af5f8b48d75e22c474e08feca236 | test_server_notice.py | 247,957 | 38 | 175 | test_update_notice_user_name_when_changed | https://github.com/matrix-org/synapse.git | Update the server notices user profile in room if changed. (#12115) | 383 | 0 | 72,024 | 11 | |
13 | 39 | def assign_wrt_overlaps(self, overlaps, gt_labels=None):
num_gts, num_bboxes = overlaps.size(0), overlaps.size(1)
# 1. assign -1 by default
assigned_gt_inds = overlaps.new_full((num_bboxes, ),
-1,
... | mmdet/core/bbox/assigners/max_iou_assigner.py | 593 | mmdetection | {
"docstring": "Assign w.r.t. the overlaps of bboxes with gts.\n\n Args:\n overlaps (Tensor): Overlaps between k gt_bboxes and n bboxes,\n shape(k, n).\n gt_labels (Tensor, optional): Labels of k gt_bboxes, shape (k, ).\n\n Returns:\n :obj:`AssignResult`: ... | 342 | Python | 168 | 9bf37f509ddf6aea1be3a4ad19036f96b9fc3902 | max_iou_assigner.py | 243,941 | 50 | 379 | assign_wrt_overlaps | https://github.com/open-mmlab/mmdetection.git | fix typos in comment (#7124)
bbox A's assigned_gt_inds will be overwritten to be bbox 2 instead of bbox B (In the previous content, bbox B was not mentioned). | 1,286 | 0 | 70,154 | 17 | |
7 | 7 | def _rewrite_warnings(cls, record):
if record.levelno == 30 and record.funcName == "warn" and record.module == "ag_logging":
# TF 2.3 in Conda is imported with the wrong gast(0.4 when 0.3.3 should be used). This
# causes warnings in autograph. They don't appear to impact perform... | lib/logger.py | 134 | faceswap | {
"docstring": " Change certain warning messages from WARNING to DEBUG to avoid passing non-important\n information to output.\n\n Parameters\n ----------\n record: :class:`logging.LogRecord`\n The log record to check for rewriting\n\n Returns\n -------\n :c... | 79 | Python | 55 | afec52309326304f4323029039e49bfcf928ef43 | logger.py | 100,733 | 9 | 74 | _rewrite_warnings | https://github.com/deepfakes/faceswap.git | Bugfixes:
- Stats graph - Handle NaNs in data
- logger - de-elevate matplotlib font messages | 231 | 0 | 20,188 | 11 | |
12 | 21 | def _find_alignments(self) -> str:
fname = self._args.alignments_file
frames = self._args.frames_dir
if fname and os.path.isfile(fname) and os.path.splitext(fname)[-1].lower() == ".fsa":
return fname
if fname:
logger.error("Not a valid alignments file: '%... | tools/alignments/alignments.py | 360 | faceswap | {
"docstring": " If an alignments folder is required and hasn't been provided, scan for a file based on\n the video folder.\n\n Exits if an alignments file cannot be located\n\n Returns\n -------\n str\n The full path to an alignments file\n ",
"language": "en",
... | 95 | Python | 50 | 2d312a9db228c025d0bd2ea7a4f747a2c644b5d8 | alignments.py | 101,635 | 32 | 204 | _find_alignments | https://github.com/deepfakes/faceswap.git | Minor updates and fixups
- Mask Tool - Typing + BiSeNet mask update fix
- Alignments Tool - Auto search for alignments file | 289 | 0 | 21,043 | 13 | |
21 | 46 | def build(self, input_shape):
if self._is_graph_network:
super().build(input_shape)
return
if input_shape is None:
raise ValueError(
"Input shape must be defined when calling `build()` on "
"a `Model` subclass."
)
... | keras/engine/training.py | 609 | keras | {
"docstring": "Builds the model based on input shapes received.\n\n This is to be used for subclassed models, which do not know at instantiation\n time what their inputs look like.\n\n This method only exists for users who want to call `model.build()` in a\n standalone way (as a substitut... | 414 | Python | 227 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | training.py | 271,605 | 82 | 345 | build | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 2,068 | 0 | 80,825 | 20 | |
1 | 7 | def check(self) -> bool:
modified = self._get_modified()
changed = modified != self._modified
self._modified = modified
return changed
| src/textual/file_monitor.py | 50 | textual | {
"docstring": "Check the monitored file. Return True if it was changed.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 17 | Python | 11 | 7df1c123e9fbc8641052a30ba74282f9d9ec1870 | file_monitor.py | 184,610 | 6 | 29 | check | https://github.com/Textualize/textual.git | docstrings | 52 | 0 | 44,712 | 8 | |
1 | 3 | def _new_training(self):
self.should_training_stop = False
| paddlenlp/trainer/trainer_callback.py | 21 | PaddleNLP | {
"docstring": "Internal method that resets the variable for a new training.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 5 | Python | 5 | 44a290e94d1becd1f09fddc3d873f9e19c9d6919 | trainer_callback.py | 323,160 | 2 | 11 | _new_training | https://github.com/PaddlePaddle/PaddleNLP.git | [Trainer] Add init version of paddlenlp trainer and apply finetune for ernie-1.0 pretraining. (#1761)
* add some datasets for finetune.
* support fine tune for all tastks.
* add trainer prototype.
* init verison for paddlenlp trainer.
* refine trainer.
* update for some details.
* support multi-card... | 19 | 0 | 118,391 | 7 | |
1 | 4 | def set_state(self, state):
raise NotImplementedError()
| mitmproxy/coretypes/serializable.py | 22 | mitmproxy | {
"docstring": "\n Set object state to the given state. Consumes the passed state.\n May return a `dataclasses.FrozenInstanceError` if the object is immutable.\n ",
"language": "en",
"n_whitespaces": 42,
"n_words": 20,
"vocab_size": 16
} | 5 | Python | 5 | 07a40208a32cb2d48a1f2a24d2569894b5a378a0 | serializable.py | 253,285 | 2 | 12 | set_state | https://github.com/mitmproxy/mitmproxy.git | `rm -rf stateobject` | 19 | 0 | 74,053 | 7 | |
1 | 5 | def get_next_event_id(self, event, snuba_filter):
raise NotImplementedError
| src/sentry/eventstore/base.py | 20 | sentry | {
"docstring": "\n Gets the next event given a current event and some conditions/filters.\n Returns a tuple of (project_id, event_id)\n\n Arguments:\n event (Event): Event object\n snuba_filter (Filter): Filter\n ",
"language": "en",
"n_whitespaces": 68,
"n_words": 25,
... | 6 | Python | 6 | 94c896a4a3663abbd31775957f1aa5448fde5491 | base.py | 98,544 | 2 | 12 | get_next_event_id | https://github.com/getsentry/sentry.git | ref: clean up sentry flake8 plugin (#33847)
* fix: Remove unused `# noqa` lint disable comments
* ref: clean up sentry flake8 plugin
- remove S005: pyupgrade handles this for us
- remove `pycodestyle` handling: flake8 does this natively
- clean up the ignore list and use extend-ignore | 20 | 0 | 19,582 | 6 | |
7 | 26 | def center(self, frequency=1000):
equal_energy_fr = self.__class__(name='equal_energy', frequency=self.frequency.copy(), raw=self.raw.copy())
equal_energy_fr.interpolate()
interpolator = InterpolatedUnivariateSpline(np.log10(equal_energy_fr.frequency), equal_energy_fr.raw, k=1)
... | research/neo_peq/legacy_frequency_response.py | 353 | AutoEq | {
"docstring": "Removed bias from frequency response.\n\n Args:\n frequency: Frequency which is set to 0 dB. If this is a list with two values then an average between the two\n frequencies is set to 0 dB.\n\n Returns:\n Gain shifted\n ",
"language": "... | 125 | Python | 87 | 9120cdffe618c6c2ff16fe6a311b6a1367efdbc8 | legacy_frequency_response.py | 162,744 | 22 | 225 | center | https://github.com/jaakkopasanen/AutoEq.git | Added PEQ configs to CLI and function interfaces. Improved default value handling for PEQ parameters and added more predefined configs. Removed legacy PEQ optimization. Fixed readme write. Improved shelf filter initialization. Added plot method to PEQ. Notebook for comparing old and new optimizers. Bug fixes. | 375 | 0 | 39,282 | 15 | |
3 | 6 | def additional_resources_per_worker(self):
return {
k: v
for k, v in self._resources_per_worker_not_none.items()
if k not in ["CPU", "GPU"]
}
| python/ray/air/config.py | 56 | ray | {
"docstring": "Resources per worker, not including CPU or GPU resources.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 18 | Python | 16 | b3878e26d765e28dd7c69abadbd856181037db97 | config.py | 124,636 | 6 | 33 | additional_resources_per_worker | https://github.com/ray-project/ray.git | [AIR] Fix `ResourceChangingScheduler` not working with AIR (#26307)
This PR ensures that the new trial resources set by `ResourceChangingScheduler` are respected by the train loop logic by modifying the scaling config to match. Previously, even though trials had their resources updated, the scaling config was not modi... | 72 | 0 | 27,641 | 10 | |
3 | 12 | def match(self, image):
if self.lut is None:
msg = "No operator loaded"
raise Exception(msg)
if image.mode != "L":
msg = "Image mode must be L"
raise ValueError(msg)
return _imagingmorph.match(bytes(self.lut), image.im.id)
| src/PIL/ImageMorph.py | 96 | Pillow | {
"docstring": "Get a list of coordinates matching the morphological operation on\n an image.\n\n Returns a list of tuples of (x,y) coordinates\n of all matching pixels. See :ref:`coordinate-system`.",
"language": "en",
"n_whitespaces": 46,
"n_words": 26,
"vocab_size": 19
} | 30 | Python | 26 | 2ae55ccbdad9c842929fb238ea1eb81d1f999024 | ImageMorph.py | 243,769 | 8 | 56 | match | https://github.com/python-pillow/Pillow.git | Improve exception traceback readability | 102 | 0 | 70,119 | 10 | |
4 | 10 | def get_files(d, pattern, sort=True):
files = glob(osp.join(d, pattern))
files = [f for f in files if osp.isfile(f)]
if sort:
| ludwig/utils/checkpoint_utils.py | 69 | ludwig | {
"docstring": "Return a list of files in a given directory.\n\n Args:\n d (str): The path to the directory.\n pattern (str): The wildcard to filter files with.\n sort (bool): Whether to sort the returned list. Assumes filenames contain a number value to sort by (tmp-001).\n ",
"language": "en"... | 19 | Python | 15 | cbff12a584ac253b6953551fecd8a66afc320de7 | checkpoint_utils.py | 6,465 | 7 | 80 | get_files | https://github.com/ludwig-ai/ludwig.git | Fixes FileExistsError thrown after training on windows completes (#1845)
* Catch exception when os.rename throws when renaming checkpoint.
* Filter out -tmp prefix (or any other) when sorting files in get_files.
* Use os.replace instead of os.rename, this works on windows
* [pre-commit.ci] auto fixes from pre... | 31 | 0 | 1,000 | 10 | |
1 | 4 | def free_symbols(self, reference_frame):
return self.to_matrix(reference_frame).free_symbols
| sympy/physics/vector/vector.py | 29 | sympy | {
"docstring": "Returns the free symbols in the measure numbers of the vector\n expressed in the given reference frame.\n\n Parameters\n ==========\n reference_frame : ReferenceFrame\n The frame with respect to which the free symbols of the given\n vector is to be det... | 5 | Python | 5 | c03c0eb2136e693b8431c19dd3294d832b4a394c | vector.py | 197,247 | 2 | 17 | free_symbols | https://github.com/sympy/sympy.git | Add .free_dynamicsymbols to physics vectors. | 19 | 0 | 48,408 | 8 | |
10 | 15 | def should_strip_auth(self, old_url, new_url):
old_parsed = urlparse(old_url)
new_parsed = urlparse(new_url)
if old_parsed.hostname != new_parsed.hostname:
return True
# Special case: allow http -> https redirect when using the standard
# ports. This isn't sp... | pipenv/patched/pip/_vendor/requests/sessions.py | 206 | pipenv | {
"docstring": "Decide whether Authorization header should be removed when redirecting",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 130 | Python | 87 | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | sessions.py | 22,123 | 22 | 128 | should_strip_auth | https://github.com/pypa/pipenv.git | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | 366 | 0 | 4,199 | 11 | |
2 | 8 | def units(self):
max_position = self.u_height + decimal.Decimal(0.5)
if self.desc_units:
drange(0.5, max_position, 0.5)
return drange(max_position, 0.5, -0.5)
| netbox/dcim/models/racks.py | 65 | netbox | {
"docstring": "\n Return a list of unit numbers, top to bottom.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | 16 | Python | 16 | 84f056171286d18c1c14a2fc9d28155a7dcf169a | racks.py | 265,088 | 5 | 51 | units | https://github.com/netbox-community/netbox.git | Initial work on half-height RUs | 55 | 0 | 77,978 | 9 | |
2 | 41 | def test_visualization_compare_classifiers_from_pred_csv_output_saved(csv_filename):
input_features = [category_feature(vocab_size=10)]
output_features = [category_feature(vocab_size=2, reduce_input="sum")]
# Generate test data
rel_path = generate_data(input_features, output_features, csv_filename... | tests/integration_tests/test_visualization.py | 385 | ludwig | {
"docstring": "Ensure pdf and png figures from the experiments can be saved.\n\n Predictions are loaded from csv file.\n :param csv_filename: csv fixture from tests.fixtures.filenames.csv_filename\n :return: None\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 25,
"vocab_size": 22
} | 115 | Python | 86 | 4fb8f63181f5153b4f6778c6ef8dad61022c4f3f | test_visualization.py | 5,869 | 44 | 234 | test_visualization_compare_classifiers_from_pred_csv_output_saved | https://github.com/ludwig-ai/ludwig.git | Use tempfile to automatically garbage collect data and modeling artifacts in ludwig integration tests. (#1642)
* Use tmpdir to automatically garbage collect data and modeling artifacts in ludwig integration tests. | 350 | 0 | 864 | 11 | |
6 | 36 | def real_root(arg, n=None, evaluate=None):
r
from sympy.functions.elementary.complexes import Abs, im, sign
from sympy.functions.elementary.piecewise import Piecewise
if n is not None:
return Piecewise(
(root(arg, n, evaluate=evaluate), Or(Eq(n, S.One), Eq(n, S.NegativeOne))),
... | sympy/functions/elementary/miscellaneous.py | 322 | sympy | {
"docstring": "Return the real *n*'th-root of *arg* if possible.\n\n Parameters\n ==========\n\n n : int or None, optional\n If *n* is ``None``, then all instances of\n $(-n)^{1/\\text{odd}}$ will be changed to $-n^{1/\\text{odd}}$.\n This will only create a real root of a principal roo... | 75 | Python | 58 | cda8dfe6f45dc5ed394c2f5cda706cd6c729f713 | miscellaneous.py | 195,861 | 61 | 221 | real_root | https://github.com/sympy/sympy.git | Improved documentation formatting | 248 | 0 | 47,448 | 16 | |
2 | 12 | def get_dashboard_url():
if ray_constants.RAY_OVERRIDE_DASHBOARD_URL in os.environ:
return _remove_protocol_from_url(
os.environ.get(ray_constants.RAY_OVERRIDE_DASHBOARD_URL)
)
else:
worker = global_worker
worker.check_connected()
return _global_node.webu... | python/ray/_private/worker.py | 72 | ray | {
"docstring": "Get the URL to access the Ray dashboard.\n\n Note that the URL does not specify which node the dashboard is on.\n\n Returns:\n The URL of the dashboard as a string.\n ",
"language": "en",
"n_whitespaces": 46,
"n_words": 30,
"vocab_size": 23
} | 17 | Python | 16 | 4692e8d8023e789120d3f22b41ffb136b50f70ea | worker.py | 127,153 | 9 | 42 | get_dashboard_url | https://github.com/ray-project/ray.git | [core] Don't override external dashboard URL in internal KV store (#27901)
Fix 2.0.0 release blocker bug where Ray State API and Jobs not accessible if the override URL doesn't support adding additional subpaths. This PR keeps the localhost dashboard URL in the internal KV store and only overrides in values printed or... | 72 | 0 | 28,373 | 12 | |
1 | 26 | def test_install_non_rpm_using_dnf_gen_error():
info_fake_error =
dnf_call = MagicMock(
return_value={"retcode": 1, "stdout": "", "stderr": info_fake_error}
)
list_pkgs_mock = MagicMock(side_effect=[{"info": "6.6-2"}, {"info": "6.6-2"}])
with patch("pathlib.Path.is_file", return_value=... | tests/pytests/unit/modules/test_aixpkg.py | 303 | salt | {
"docstring": "\n Test install of non rpm using dnf which should generate an error\n Last metadata expiration check: 1 day, 23:40:22 ago on Mon Dec 6 19:26:36 EST 2021.\nNo match for argument: info_fake\nError: Unable to find a match: info_fake\n",
"language": "en",
"n_whitespaces": 44,
"n_words": 39,
... | 70 | Python | 60 | f1c37893caf90738288e789c3233ab934630254f | test_aixpkg.py | 215,096 | 29 | 172 | test_install_non_rpm_using_dnf_gen_error | https://github.com/saltstack/salt.git | Working tests for install | 326 | 0 | 53,813 | 16 | |
3 | 13 | def get_install_candidate(self, link_evaluator, link):
# type: (LinkEvaluator, Link) -> Optional[InstallationCandidate]
is_candidate, result = link_evaluator.evaluate_link(link)
if not is_candidate:
if result:
self._log_skipped_link(link, reason=result)
... | .venv/lib/python3.8/site-packages/pip/_internal/index/package_finder.py | 89 | transferlearning | {
"docstring": "\n If the link is a candidate for install, convert it to an\n InstallationCandidate and return it. Otherwise, return None.\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 19,
"vocab_size": 18
} | 29 | Python | 27 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | package_finder.py | 60,741 | 11 | 57 | get_install_candidate | https://github.com/jindongwang/transferlearning.git | upd; format | 141 | 0 | 12,270 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.