complexity int64 1 56 | n_identifiers int64 1 114 | code stringlengths 19 12.7k | path stringlengths 8 134 | n_ast_nodes int64 12 2.35k | ast_errors stringlengths 0 4.01k | repo stringlengths 3 28 | documentation dict | n_words int64 2 866 | language stringclasses 1
value | vocab_size int64 2 323 | commit_id stringlengths 40 40 | file_name stringlengths 5 79 | id int64 243 338k | nloc int64 1 228 | token_counts int64 5 1.4k | fun_name stringlengths 1 77 | url stringlengths 31 60 | commit_message stringlengths 3 15.3k | n_whitespaces int64 1 3.23k | n_ast_errors int64 0 20 | d_id int64 74 121k | ast_levels int64 4 29 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 9 | def writelines(self, lines):
self._checkClosed()
for line in lines:
self.write(line)
io.IOBase.register(IOBase)
| python3.10.4/Lib/_pyio.py | 54 | XX-Net | {
"docstring": "Write a list of lines to the stream.\n\n Line separators are not added, so it is usual for each of the lines\n provided to have a line separator at the end.\n ",
"language": "en",
"n_whitespaces": 52,
"n_words": 31,
"vocab_size": 25
} | 10 | Python | 10 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | _pyio.py | 219,909 | 4 | 24 | writelines | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 41 | 0 | 55,895 | 9 | |
1 | 5 | def _on_slider_update(self, value) -> None:
self.scale_var.set(f"{value}%")
| lib/training/preview_tk.py | 37 | faceswap | {
"docstring": " Callback for when the scale slider is adjusted. Adjusts the combo box display to the\n current slider value.\n\n Parameters\n ----------\n value: int\n The value that the slider has been set to\n ",
"language": "en",
"n_whitespaces": 79,
"n_words":... | 6 | Python | 6 | 7da2cc3dd266aabebf41a31384cc2e0e7e5af6e5 | preview_tk.py | 101,558 | 10 | 19 | _on_slider_update | https://github.com/deepfakes/faceswap.git | Training - Use custom preview pop-out | 20 | 0 | 20,968 | 9 | |
1 | 10 | def unrank_binary(self, rank, superset):
bits = bin(rank)[2:].rjust(len(superset), '0')
return Subset.subset_from_bitlist(superset, bits)
| sympy/combinatorics/subsets.py | 63 | sympy | {
"docstring": "\n Gets the binary ordered subset of the specified rank.\n\n Examples\n ========\n\n >>> from sympy.combinatorics import Subset\n >>> Subset.unrank_binary(4, ['a', 'b', 'c', 'd']).subset\n ['b']\n\n See Also\n ========\n\n iterate_binary, ... | 11 | Python | 11 | 498015021131af4dbb07eb110e5badaba8250c7b | subsets.py | 196,204 | 3 | 39 | unrank_binary | https://github.com/sympy/sympy.git | Updated import locations | 32 | 0 | 47,704 | 11 | |
16 | 5 | def lcm_list(seq, *gens, **args):
seq = sympify(seq)
| sympy/polys/polytools.py | 31 | sympy | {
"docstring": "\n Compute LCM of a list of polynomials.\n\n Examples\n ========\n\n >>> from sympy import lcm_list\n >>> from sympy.abc import x\n\n >>> lcm_list([x**3 - 1, x**2 - 1, x**2 - 3*x + 2])\n x**5 - x**4 - 2*x**3 - x**2 + x + 2\n\n ",
"language": "en",
"n_whitespaces": 67,
"n_... | 7 | Python | 7 | 29e153dd0a70a3fe97c2a9a5f752334e937023c5 | polytools.py | 197,244 | 35 | 254 | lcm_list | https://github.com/sympy/sympy.git | update some type hints | 13 | 0 | 48,406 | 8 | |
2 | 8 | def _calculate_mean_and_var(self, x, axes, keep_dims):
if self.synchronized:
return self._sync_calculate_mean_and_var(x, axes, keep_dims)
else:
return super()._calculate_mean_and_var(x, axes, keep_dims)
| keras/layers/normalization/batch_normalization.py | 65 | keras | {
"docstring": "Override mean and var calculation when used with `synchronized`.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 16 | Python | 12 | 8c401c032b3021f89609eac79bd1c881b9bbc84f | batch_normalization.py | 280,181 | 5 | 43 | _calculate_mean_and_var | https://github.com/keras-team/keras.git | Merge `SyncBatchNormalization` into `BatchNormalization` with parameter `use_sync`
PiperOrigin-RevId: 482921013 | 59 | 0 | 83,281 | 12 | |
3 | 14 | def format_block(self) -> str:
if self.summary:
block = self.summary
else:
block = '\n'.join(m.format() for m in self.messages)
message = block.strip()
# Hack to remove ANSI color reset code from SubprocessError messages.
message = message.repla... | test/lib/ansible_test/_internal/test.py | 103 | ansible | {
"docstring": "Format the test summary or messages as a block of text and return the result.",
"language": "en",
"n_whitespaces": 14,
"n_words": 15,
"vocab_size": 14
} | 37 | Python | 31 | 3eb0485dd92c88cc92152d3656d94492db44b183 | test.py | 268,054 | 9 | 59 | format_block | https://github.com/ansible/ansible.git | ansible-test - Use more native type hints. (#78435)
* ansible-test - Use more native type hints.
Simple search and replace to switch from comments to native type hints for return types of functions with no arguments.
* ansible-test - Use more native type hints.
Conversion of simple single-line function annota... | 108 | 0 | 79,328 | 13 | |
1 | 2 | def row(self):
return self["row"]
| packages/python/plotly/plotly/graph_objs/funnelarea/_domain.py | 22 | plotly.py | {
"docstring": "\n If there is a layout grid, use the domain for this row in the\n grid for this funnelarea trace .\n\n The 'row' property is a integer and may be specified as:\n - An int (or float that will be cast to an int)\n in the interval [0, 9223372036854775807]\n\n ... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _domain.py | 229,865 | 2 | 11 | row | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 61,538 | 7 | |
1 | 7 | def active(self) -> Optional[Scope]:
ctx = current_context()
return ctx.scope
| synapse/logging/scopecontextmanager.py | 35 | synapse | {
"docstring": "\n Returns the currently active Scope which can be used to access the\n currently active Scope.span.\n If there is a non-null Scope, its wrapped Span\n becomes an implicit parent of any newly-created Span at\n Tracer.start_active_span() time.\n\n Return:\n ... | 9 | Python | 9 | 6ad012ef89c966cbb3616c1be63d964db48d49ca | scopecontextmanager.py | 248,680 | 13 | 20 | active | https://github.com/matrix-org/synapse.git | More type hints for `synapse.logging` (#13103)
Completes type hints for synapse.logging.scopecontextmanager and (partially)
for synapse.logging.opentracing. | 30 | 0 | 72,415 | 8 | |
1 | 9 | def to_sql(cls, qc, **kwargs):
# we first insert an empty DF in order to create the full table in the database
# This also helps to validate the input against pandas
# we would like to_sql() to complete only when all rows have been inserted into the database
# since the mapping ... | modin/core/execution/ray/implementations/pandas_on_ray/io/io.py | 89 | modin | {
"docstring": "\n Write records stored in the `qc` to a SQL database.\n\n Parameters\n ----------\n qc : BaseQueryCompiler\n The query compiler of the Modin dataframe that we want to run ``to_sql`` on.\n **kwargs : dict\n Parameters for ``pandas.to_sql(**kwarg... | 95 | Python | 65 | 0faf4675140415e17d4112f9d0d37cfe87770b9e | io.py | 152,977 | 8 | 77 | to_sql | https://github.com/modin-project/modin.git | REFACTOR-#3871: move related to pandas functionality into 'PandasOnRayIO' class (#3872)
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com> | 172 | 0 | 35,219 | 13 | |
11 | 21 | def align_xlabels(self, axs=None):
if axs is None:
axs = self.axes
axs = [ax for ax in np.ravel(axs) if ax.get_subplotspec() is not None]
for ax in axs:
_log.debug(' Working on: %s', ax.get_xlabel())
rowspan = ax.get_subplotspec().rowspan
... | lib/matplotlib/figure.py | 240 | matplotlib | {
"docstring": "\n Align the xlabels of subplots in the same subplot column if label\n alignment is being done automatically (i.e. the label position is\n not manually set).\n\n Alignment persists for draw events after this is called.\n\n If a label is on the bottom, it is aligned w... | 121 | Python | 82 | c73f4c455514cf5422d27bf38c93250de8316b21 | figure.py | 109,453 | 14 | 143 | align_xlabels | https://github.com/matplotlib/matplotlib.git | Merge SubplotBase into AxesBase. | 386 | 0 | 23,596 | 17 | |
3 | 17 | def _pad_spatial_dims(x, x_shape, padding, is_conv1d):
# Add empty padding for batch and feature dimensions.
no_pad = ((0, 0),)
padding = tuple(padding)
if is_conv1d:
padding = no_pad + padding + no_pad
# Add empty padding for dummy dimension, too.
padding = no_pad + padding + no_pad + no_pad
e... | jax/experimental/jax2tf/impl_no_xla.py | 178 | jax | {
"docstring": "Pads `x` using `padding`, which specifies padding for the spatial dimensions.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 82 | Python | 47 | b22121c0c1579dd5108825becac42d5db1b29276 | impl_no_xla.py | 121,203 | 13 | 115 | _pad_spatial_dims | https://github.com/google/jax.git | [jax2tf] Fixes for handling of convolutions with shape_polymorphism and enable_xla=False
Issue: #11402
Due to a typo we were running no tests for convolutions with shape
polymorphism and enable_xla=False.
Added a few more tests from #11402 (Thanks @sdenton4).
The main issue was that in presence of shape polymorphis... | 105 | 0 | 27,040 | 11 | |
31 | 9 | def _intervals(self, sym):
from sympy.solvers.inequalities import _solve_inequality
assert isinstance(self, Piecewise)
| sympy/functions/elementary/piecewise.py | 36 | sympy | {
"docstring": "Return a list of unique tuples, (a, b, e, i), where a and b\n are the lower and upper bounds in which the expression e of\n argument i in self is defined and $a < b$ (when involving\n numbers) or $a \\le b$ when involving symbols.\n\n If there are any relationals not involv... | 10 | Python | 10 | 498015021131af4dbb07eb110e5badaba8250c7b | piecewise.py | 196,246 | 82 | 577 | _intervals | https://github.com/sympy/sympy.git | Updated import locations | 31 | 0 | 47,746 | 7 | |
4 | 10 | def subword_index(self, word, w):
low = -1
high = -1
for i in range(len(word)-len(w)+1):
if word.subword(i, i+len(w)) == w:
low = i
high = i+len(w)
break
if low == high == -1:
return -1, -1
return lo... | sympy/combinatorics/pc_groups.py | 133 | sympy | {
"docstring": "\n Returns the start and ending index of a given\n subword in a word.\n\n Parameters\n ==========\n\n word : FreeGroupElement\n word defined on free group elements for a\n polycyclic group.\n w : FreeGroupElement\n subword of a... | 38 | Python | 23 | 498015021131af4dbb07eb110e5badaba8250c7b | pc_groups.py | 196,113 | 11 | 83 | subword_index | https://github.com/sympy/sympy.git | Updated import locations | 147 | 0 | 47,613 | 13 | |
4 | 11 | 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,... | keras/engine/training_v1.py | 127 | keras | {
"docstring": "Makes the metric name unique.\n\n If there are multiple outputs for which the metrics are calculated, the\n 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 the\n ... | 117 | Python | 80 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | training_v1.py | 271,980 | 13 | 75 | _add_unique_metric_name | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 333 | 0 | 80,920 | 14 | |
1 | 2 | def close(self) -> None:
return
| plugins/convert/writer/opencv.py | 18 | faceswap | {
"docstring": " Does nothing as OpenCV writer does not need a close method ",
"language": "en",
"n_whitespaces": 12,
"n_words": 11,
"vocab_size": 11
} | 5 | Python | 5 | 049314429f71a21e6595e9d27e9e36f6a3479c42 | opencv.py | 101,067 | 3 | 9 | close | https://github.com/deepfakes/faceswap.git | Convert: Add option to output mask separately for draw-transparent | 19 | 0 | 20,504 | 6 | |
1 | 14 | def get_tables(self) -> Response:
return self.native_query(
str(text(f).bindparams(
bindparam('database', value=self.database, type_=String)
).compile(compile_kwargs={"literal_binds": True}))
)
| mindsdb/integrations/handlers/teradata_handler/teradata_handler.py | 86 | mindsdb | {
"docstring": "\n List all tables in Teradata in the current database\n \n SELECT DataBaseName,\n TableName,\n TableKind\n FROM DBC.TablesV\n WHERE DatabaseName = :database\n AND (TableKind = 'T'\n OR TableKi... | 13 | Python | 13 | 47c5e0ac2d89807f8ff7239d423a3d346bd39a1e | teradata_handler.py | 116,755 | 18 | 51 | get_tables | https://github.com/mindsdb/mindsdb.git | feat: add teradata integration | 71 | 0 | 25,827 | 17 | |
5 | 28 | def get_project_name(doctype, txt, searchfield, start, page_len, filters):
cond = ""
if filters and filters.get("customer"):
cond = % (
frappe.db.escape(filters.get("customer"))
)
fields = get_fields("Project", ["name", "project_name"])
searchfields = frappe.get_meta("Project").get_search_fields()
searchf... | erpnext/controllers/queries.py | 296 | @frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs | erpnext | {
"docstring": "(`tabProject`.customer = %s or\n\t\t\tifnull(`tabProject`.customer,\"\")=\"\") andselect {fields} from `tabProject`\n\t\twhere\n\t\t\t`tabProject`.status not in (\"Completed\", \"Cancelled\")\n\t\t\tand {cond} {scond} {match_cond}\n\t\torder by\n\t\t\tif(locate(%(_txt)s, name), locate(%(_txt)s, name),... | 64 | Python | 54 | 494bd9ef78313436f0424b918f200dab8fc7c20b | queries.py | 65,644 | 29 | 166 | get_project_name | https://github.com/frappe/erpnext.git | style: format code with black | 43 | 1 | 13,966 | 16 |
1 | 16 | async def test_visit_collection_with_private_pydantic(self):
input = PrivatePydantic(x=1)
input._y = 2
input._z = 4
result = await visit_collection(
input, visit_fn=visit_even_numbers, return_data=False
)
assert result is None
assert EVEN == ... | tests/utilities/test_collections.py | 150 | prefect | {
"docstring": "Check that we successfully capture private pydantic fields",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 54 | Python | 33 | c33f87fc7e0b6fb4714a88b492e7545f4dbd821f | test_collections.py | 56,293 | 17 | 95 | test_visit_collection_with_private_pydantic | https://github.com/PrefectHQ/prefect.git | get private attrs working | 181 | 0 | 11,499 | 10 | |
12 | 64 | def load_data(self, ds, basedir, variable_manager=None, loader=None):
# import here to avoid a dependency loop
from ansible.playbook import Playbook
from ansible.playbook.play import Play
# first, we use the original parent method to correctly load the object
# via the... | lib/ansible/playbook/playbook_include.py | 620 | ansible | {
"docstring": "\n Overrides the base load_data(), as we're actually going to return a new\n Playbook() object rather than a PlaybookInclude object\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 19,
"vocab_size": 17
} | 285 | Python | 164 | 43153c58310d02223f2cb0964f4255ba1ac4ed53 | playbook_include.py | 267,584 | 40 | 384 | load_data | https://github.com/ansible/ansible.git | `FieldAttribute`s as descriptors (#73908) | 829 | 0 | 78,964 | 18 | |
1 | 2 | def arraydtick(self):
return self["arraydtick"]
| packages/python/plotly/plotly/graph_objs/carpet/_aaxis.py | 22 | plotly.py | {
"docstring": "\n The stride between grid lines along the axis\n\n The 'arraydtick' property is a integer and may be specified as:\n - An int (or float that will be cast to an int)\n in the interval [1, 9223372036854775807]\n\n Returns\n -------\n int\n "... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _aaxis.py | 229,084 | 2 | 11 | arraydtick | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 60,757 | 7 | |
6 | 17 | def to_dict(self) -> Dict[str, any]:
input_features = [feat for feat in self.input_features.to_list() if feat["active"]]
output_features = [feat for feat in self.output_features.to_list() if feat["active"]]
config_dict = {
"model_type": self.model_type,
"input_f... | ludwig/schema/model_config.py | 219 | ludwig | {
"docstring": "This method converts the current config object into an equivalent dictionary representation for the\n parts of the codebase that use the dictionary representation of the config.\n\n Returns:\n Config Dictionary\n ",
"language": "en",
"n_whitespaces": 61,
"n_words"... | 51 | Python | 41 | e2dbab9adf85a018bc6279c9538d995a2227f619 | model_config.py | 8,745 | 21 | 132 | to_dict | https://github.com/ludwig-ai/ludwig.git | fix: Restrict allowed top-level config keys (#2826)
* fix
* add ludwig_version
* prints
* remove extra | 188 | 0 | 1,495 | 11 | |
2 | 18 | def local_rank() -> int:
| python/ray/train/train_loop_utils.py | 57 | """Get the local rank of thisrank of the worker on its..block:: | ray | {
"docstring": "Get the local rank of this worker (rank of the worker on its node).\n\n .. code-block:: python\n\n import time\n from ray import train\n",
"language": "en",
"n_whitespaces": 39,
"n_words": 23,
"vocab_size": 19
} | 4 | Python | 4 | 0e8eb8aedb3e158da8c3e7378e818ce87ca7813e | train_loop_utils.py | 128,345 | 28 | 47 | local_rank | https://github.com/ray-project/ray.git | [AIR] More Train and Tune session deprecations (#28856)
Signed-off-by: Amog Kamsetty amogkamsetty@yahoo.com
Finish marking train. and tune. session APIs as deprecated | 7 | 4 | 28,679 | 10 |
13 | 46 | def _build_test_case(self, task_data, host_data):
name = '[%s] %s: %s' % (host_data.name, task_data.play, task_data.name)
duration = host_data.finish - task_data.start
if self._task_relative_path and task_data.path:
junit_classname = os.path.relpath(task_data.path, self._t... | lib/ansible/plugins/callback/junit.py | 589 | ansible | {
"docstring": " build a TestCase from the given TaskData and HostData ",
"language": "en",
"n_whitespaces": 10,
"n_words": 9,
"vocab_size": 9
} | 138 | Python | 81 | fbb5d56bd274c44b193cb95f0230b9352f62aab2 | junit.py | 266,525 | 37 | 360 | _build_test_case | https://github.com/ansible/ansible.git | ansible-test - Use relative paths in junit output. (#76871)
* ansible-test - Use relative paths in junit output.
Also fix a traceback in the junit callback during automatic fact gathering.
* ansible-test - Handle out-of-tree JUnit paths. | 509 | 0 | 78,457 | 17 | |
23 | 114 | def model_fn(features, labels, mode, params, config):
del config
hparams = params
length = features.length
spec = features.spec
is_training = mode == tf_estimator.ModeKeys.TRAIN
if is_training:
onset_labels = labels.onsets
offset_labels = labels.offsets
velocity_labels = labels.velocities
... | magenta/models/onsets_frames_transcription/model.py | 1,442 | magenta | {
"docstring": "Builds the acoustic model.Convert frame predictions into a sequence (TF).",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 385 | Python | 217 | f73ff0c91f0159a925fb6547612199bb7c915248 | model.py | 173,538 | 228 | 1,401 | model_fn | https://github.com/magenta/magenta.git | Explicitly import estimator from tensorflow as a separate import instead of accessing it via tf.estimator and depend on the tensorflow estimator target.
PiperOrigin-RevId: 436568278 | 1,488 | 0 | 40,851 | 18 | |
1 | 12 | async def test_reload_entry_with_new_config(hass, tmp_path):
config_old = [{"name": "test_old1", "command_topic": "test-topic_old"}]
config_yaml_new = {
"mqtt": {
"light": [{"name": "test_new_modern", "command_topic": "test-topic_new"}]
},
# Test deprecated YAML configur... | tests/components/mqtt/test_init.py | 254 | @patch("homeassistant.components.mqtt.PLATFORMS", [Platform.LIGHT]) | core | {
"docstring": "Test reloading the config entry with a new yaml config.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 80 | Python | 58 | b3a48389789549b3cb1aabd042310137baccc9b9 | test_init.py | 287,034 | 20 | 127 | test_reload_entry_with_new_config | https://github.com/home-assistant/core.git | Refactor MQTT tests to use modern platform schema part 1 (#77387)
* Tests alarm_control_panel
* Tests binary_sensor
* Tests button
* Tests camera
* Tests Climate + corrections default config
* Tests cover
* Tests device_tracker
* Tests fan
* Tests humidifier
* Fix test_supported_features tes... | 229 | 1 | 86,227 | 14 |
2 | 7 | def suspend(self):
if POSIX:
self._send_signal(signal.SIGSTOP)
else: # pragma: no cover
self._proc.suspend()
| psutil/__init__.py | 48 | psutil | {
"docstring": "Suspend process execution with SIGSTOP pre-emptively checking\n whether PID has been reused.\n On Windows this has the effect of suspending all process threads.\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 23,
"vocab_size": 21
} | 11 | Python | 11 | 471b19d2aa799cd73bded23379e864dd35bec2b6 | __init__.py | 188,993 | 5 | 26 | suspend | https://github.com/giampaolo/psutil.git | Fix typos | 55 | 0 | 45,957 | 11 | |
2 | 17 | def _simulate_installation_of(to_install, package_set):
# type: (List[InstallRequirement], PackageSet) -> Set[NormalizedName]
# Keep track of packages that were installed
installed = set()
# Modify it as installing requirement_set would (assuming no errors)
for inst_req in to_install:
... | .venv/lib/python3.8/site-packages/pip/_internal/operations/check.py | 115 | transferlearning | {
"docstring": "Computes the version of packages after installing to_install.\n ",
"language": "en",
"n_whitespaces": 11,
"n_words": 8,
"vocab_size": 8
} | 55 | Python | 46 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | check.py | 60,923 | 10 | 69 | _simulate_installation_of | https://github.com/jindongwang/transferlearning.git | upd; format | 118 | 0 | 12,346 | 12 | |
1 | 27 | def test_title_column(self):
root_page = Page.objects.filter(depth=2).first()
blog = Site.objects.create(
hostname="blog.example.com", site_name="My blog", root_page=root_page
)
gallery = Site.objects.create(
hostname="gallery.example.com", site_name="My gallery",... | wagtail/admin/tests/ui/test_tables.py | 223 | wagtail | {
"docstring": "\n <table class=\"listing\">\n <thead>\n <tr><th>Hostname</th><th>Site name</th></tr>\n </thead>\n <tbody>\n <tr>\n <td class=\"title\">\n <div class=\"title-... | 51 | Python | 40 | 5994cc43dfc5cc1ed891ab78eff3a3bcf56f6830 | test_tables.py | 77,580 | 51 | 136 | test_title_column | https://github.com/wagtail/wagtail.git | Allow passing arbitrary link attributes to TitleColumn | 337 | 0 | 16,677 | 15 | |
1 | 2 | def silence_transformers_logs(from_pretrained_func):
| haystack/modeling/model/language_model.py | 13 | haystack | {
"docstring": "\n Wrapper that raises the log level of Transformers to\n ERROR to hide some unnecessary warnings\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 15,
"vocab_size": 14
} | 2 | Python | 2 | a59bca366174d9c692fa19750c24d65f47660ef7 | language_model.py | 256,238 | 4 | 15 | silence_transformers_logs | https://github.com/deepset-ai/haystack.git | Apply black formatting (#2115)
* Testing black on ui/
* Applying black on docstores
* Add latest docstring and tutorial changes
* Create a single GH action for Black and docs to reduce commit noise to the minimum, slightly refactor the OpenAPI action too
* Remove comments
* Relax constraints on pydoc-ma... | 5 | 0 | 74,819 | 6 | |
1 | 3 | def num_columns(self):
return self.table.num_columns
| src/datasets/table.py | 22 | datasets | {
"docstring": "\n Number of columns in this table.\n\n Returns:\n int:\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 8,
"vocab_size": 8
} | 4 | Python | 4 | e35be138148333078284b942ccc9ed7b1d826f97 | table.py | 104,392 | 2 | 12 | num_columns | https://github.com/huggingface/datasets.git | Update docs to new frontend/UI (#3690)
* WIP: update docs to new UI
* make style
* Rm unused
* inject_arrow_table_documentation __annotations__
* hasattr(arrow_table_method, "__annotations__")
* Update task_template.rst
* Codeblock PT-TF-SPLIT
* Convert loading scripts
* Convert docs to mdx
... | 18 | 0 | 21,829 | 7 | |
2 | 15 | def compute(self) -> Tensor:
# self.total maps to the number of observations in preds/target computed during update()
if self.total <= 1:
logger.warning(
)
return torch.tensor(float("nan"))
return _r2_score_compute(
self... | ludwig/modules/metric_modules.py | 94 | ludwig | {
"docstring": "Computes r2 score over the metric states.R-squared (r2) is not defined for one sample. It needs at least two samples. Returning NaN.",
"language": "en",
"n_whitespaces": 21,
"n_words": 22,
"vocab_size": 22
} | 34 | Python | 31 | dfdc98caa35f38665dbe045ccff431715e976841 | metric_modules.py | 7,263 | 10 | 58 | compute | https://github.com/ludwig-ai/ludwig.git | Update R2 score to handle single sample computation (#2235)
* Update R2 scores to handle single sample computation | 129 | 0 | 1,171 | 12 | |
4 | 23 | def convert_to_legacy_optimizer(optimizer):
if not isinstance(optimizer, base_optimizer.Optimizer):
raise ValueError(
"`convert_to_legacy_optimizer` should only be called "
"on instances of `tf.keras.optimizers.Optimizer`, but "
f"received {optimizer} of type {type(o... | keras/optimizers/__init__.py | 220 | @keras_export("keras.optimizers.get") | keras | {
"docstring": "Convert experimental optimizer to legacy optimizer.\n\n This function takes in a `tf.keras.optimizers.experimental.Optimizer`\n instance and converts it to the corresponding\n `tf.keras.optimizers.legacy.Optimizer` instance.\n For example, `tf.keras.optimizers.experimental.Adam(...)` to\n ... | 98 | Python | 82 | 5a105aadbdc6fde2c2529280c4789864adbb81c7 | __init__.py | 280,501 | 28 | 113 | convert_to_legacy_optimizer | https://github.com/keras-team/keras.git | Move new optimizer out of optimizer_experimental/ directory.
PiperOrigin-RevId: 488998585 | 266 | 1 | 83,358 | 14 |
1 | 13 | def test_non_existing_file_download(self) -> None:
hamlet = self.example_user("hamlet")
self.login_user(hamlet)
response = self.client_get(
f"http://{hamlet.realm.host}/user_uploads/{hamlet.realm_id}/ff/gg/abc.py"
)
self.assertEqual(response.status_code, 404)... | zerver/tests/test_upload.py | 102 | zulip | {
"docstring": "\n Trying to download a file that was never uploaded will return a json_error\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 12
} | 19 | Python | 18 | 5ff4754090259dea52c0554d82eeaf601490f383 | test_upload.py | 84,031 | 11 | 49 | test_non_existing_file_download | https://github.com/zulip/zulip.git | test_upload: Fix some URLs to uploaded files.
Using http://localhost:9991 is incorrect - e.g. messages sent with file
urls constructed trigger do_claim_attachments to be called with empty
list in potential_path_ids.
realm.host should be used in all these places, like in the other tests
in the file. | 79 | 0 | 17,766 | 12 | |
1 | 2 | def readable(self):
# type: () -> bool
return True
| .venv/lib/python3.8/site-packages/pip/_internal/network/lazy_wheel.py | 17 | transferlearning | {
"docstring": "Return whether the file is readable, which is True.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 8
} | 9 | Python | 9 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | lazy_wheel.py | 60,897 | 2 | 8 | readable | https://github.com/jindongwang/transferlearning.git | upd; format | 30 | 0 | 12,329 | 6 | |
3 | 28 | def _generate_pynsist_config(repo_path, build_path):
print('Generate pynsist configuration')
installer_cfg_path = os.path.join(build_path, 'installer.cfg')
certbot_pkg_path = os.path.join(repo_path, 'certbot')
certbot_version = subprocess.check_output([sys.executable, '-c', 'import certbot; print(cert... | windows-installer/windows_installer/construct.py | 202 | certbot | {
"docstring": "\\\n[Application]\nname=Certbot\nversion={certbot_version}\nicon=certbot.ico\npublisher=Electronic Frontier Foundation\ntarget=$INSTDIR\\\\run.bat\n\n[Build]\ndirectory=nsis\nnsi_template=template.nsi\ninstaller_name=certbot-beta-installer-{installer_suffix}.exe\n\n[Python]\nversion={python_version}\n... | 61 | Python | 56 | f251a13f322e10c530897be31aa07a1199061f10 | construct.py | 186,741 | 38 | 118 | _generate_pynsist_config | https://github.com/certbot/certbot.git | Remove Windows 2016 environment, generate 64 bit installer (#9202)
* Remove Windows 2016 environment, generate 64 bit installer
* Add note to changelog
* Use win_amd64 as installer suffix
* Bump PYTHON_BITNESS to 64
* Require 64 bit Windows for the installer_build job
* Update certbot install path
* update windo... | 170 | 0 | 45,615 | 16 | |
5 | 9 | def get_worker_host(pod_args, pod_is_container, head_is_container):
# Check if the current pod and head are both containerized on the same host
# If so __docker_host__ needs to be advertised as the worker's address to the head
worker_host = (
__docker_host__
if (... | jina/orchestrate/deployments/__init__.py | 65 | jina | {
"docstring": "\n Check if the current pod and head are both containerized on the same host\n If so __docker_host__ needs to be advertised as the worker's address to the head\n\n :param pod_args: arguments of the worker pod\n :param pod_is_container: boolean specifying if pod is to be run... | 51 | Python | 40 | ef662b529b2a2eecea7bb99759a9f7b9d86d3062 | __init__.py | 12,497 | 8 | 40 | get_worker_host | https://github.com/jina-ai/jina.git | feat: add grpc health checking (#4779) | 137 | 0 | 2,318 | 15 | |
6 | 36 | def step(self, action_dict):
self.resetted = False
self.steps += 1
logger.debug(
"====> [SUMOTestMultiAgentEnv:step] Episode: %d - Step: %d <====",
self.episodes,
self.steps,
)
dones = {}
dones["__all__"] = False
shuff... | rllib/examples/simulators/sumo/marlenvironment.py | 549 | ray | {
"docstring": "\n Returns observations from ready agents.\n\n The returns are dicts mapping from agent_id strings to values. The\n number of agents in the env can vary over time.\n\n Returns\n -------\n obs: New observations for each ready agent.\n rewards: Re... | 217 | Python | 136 | 8e680c483ce326cefc62e44f68ab1a6948b1c3d2 | marlenvironment.py | 137,963 | 43 | 329 | step | https://github.com/ray-project/ray.git | [RLlib] gymnasium support (new `Env.reset()/step()/seed()/render()` APIs). (#28369) | 743 | 0 | 31,259 | 15 | |
8 | 20 | def _peeloff_pi(arg):
r
pi_coeff = S.Zero
rest_terms = []
for a in Add.make_args(arg):
K = a.coeff(S.Pi)
if K and K.is_rational:
pi_coeff += K
else:
rest_terms.append(a)
if pi_coeff is S.Zero:
return arg, S.Zero
m1 = (pi_coeff % S.Half)
... | sympy/functions/elementary/trigonometric.py | 197 | sympy | {
"docstring": "\n Split ARG into two parts, a \"rest\" and a multiple of $\\pi$.\n This assumes ARG to be an Add.\n The multiple of $\\pi$ returned in the second position is always a Rational.\n\n Examples\n ========\n\n >>> from sympy.functions.elementary.trigonometric import _peeloff_pi as peel\n... | 58 | Python | 38 | cda8dfe6f45dc5ed394c2f5cda706cd6c729f713 | trigonometric.py | 195,866 | 33 | 124 | _peeloff_pi | https://github.com/sympy/sympy.git | Improved documentation formatting | 141 | 0 | 47,453 | 15 | |
4 | 9 | def _randint(seed=None):
if seed is None:
return randint
elif isinstance(seed, int):
rng.seed(seed)
return randint
elif is_sequence(seed):
seed = list(seed) # make a copy
seed.reverse()
| sympy/core/random.py | 82 | sympy | {
"docstring": "Return a randint generator.\n\n ``seed`` can be\n\n * None - return randomly seeded generator\n * int - return a generator seeded with the int\n * list - the values to be returned will be taken from the list\n in the order given; the provided list is not modified.\n\n Examples\n ... | 24 | Python | 20 | 092c0c6ea1e6f435a2cddb6e6fe723088b73bd81 | random.py | 197,150 | 13 | 59 | _randint | https://github.com/sympy/sympy.git | Add sympy.core.random to Sphinx | 72 | 0 | 48,353 | 11 | |
8 | 30 | def _get_curr_status(self) -> Tuple[DeploymentStatusInfo, bool]:
# TODO(edoakes): we could make this more efficient in steady-state by
# having a "healthy" flag that gets flipped if an update or replica
# failure happens.
target_version = self._target_version
target_rep... | python/ray/serve/deployment_state.py | 356 | ray | {
"docstring": "Get the current deployment status.\n\n Checks the difference between the target vs. running replica count for\n the target version.\n\n TODO(edoakes): we should report the status as FAILED if replicas are\n repeatedly failing health checks. Need a reasonable heuristic here.... | 248 | Python | 151 | 48adb6f7bb335b28fb0fb0d1190bd6c5dfc8ddfa | deployment_state.py | 144,666 | 66 | 216 | _get_curr_status | https://github.com/ray-project/ray.git | [serve] Introduce DeploymentStatus, poll for statuses instead of using async goals (#22121) | 1,143 | 0 | 33,279 | 18 | |
5 | 13 | def _batch_format_to_use(cls) -> BatchFormat:
has_pandas_implemented = cls._predict_pandas != Predictor._predict_pandas
has_numpy_implemented = cls._predict_numpy != Predictor._predict_numpy
if has_pandas_implemented and has_numpy_implemented:
return cls.preferred_batch_form... | python/ray/train/predictor.py | 109 | ray | {
"docstring": "Determine the batch format to use for the predictor.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 8
} | 44 | Python | 36 | 326d84f1149319809191e7887155df7f04f6f46a | predictor.py | 136,394 | 15 | 60 | _batch_format_to_use | https://github.com/ray-project/ray.git | [AIR][Predictor] Enable numpy based predictor (#28917)
Co-authored-by: Clark Zinzow <clarkzinzow@gmail.com>
Co-authored-by: Amog Kamsetty <amogkam@users.noreply.github.com> | 178 | 0 | 30,905 | 14 | |
3 | 9 | async def read(self) -> discord.Message:
msg = await self.queue.get()
if msg is None and self.expired:
raise ChannelExpiredException()
return msg
| bot/channel_handlers.py | 61 | Open-Assistant | {
"docstring": "Call this method to read the next message from the user in the handler method.",
"language": "en",
"n_whitespaces": 14,
"n_words": 15,
"vocab_size": 13
} | 19 | Python | 17 | 3205491166e190512608bf01754815cadae47a92 | channel_handlers.py | 216,680 | 6 | 35 | read | https://github.com/LAION-AI/Open-Assistant.git | add channel handler async msg routing | 58 | 0 | 54,675 | 10 | |
2 | 11 | def yamlcheck(python):
result = json.loads(raw_command([python.path, os.path.join(ANSIBLE_TEST_TARGET_TOOLS_ROOT, 'yamlcheck.py')], capture=True)[0])
if not result['yaml']:
return None
return result['cloader']
| test/lib/ansible_test/_internal/util_common.py | 88 | ansible | {
"docstring": "Return True if PyYAML has libyaml support, False if it does not and None if it was not found.",
"language": "en",
"n_whitespaces": 18,
"n_words": 19,
"vocab_size": 15
} | 15 | Python | 14 | d19b506ce8c5ee43865b1cead2246fc07cc8902b | util_common.py | 266,508 | 5 | 53 | yamlcheck | https://github.com/ansible/ansible.git | ansible-test - Clean up future boilerplate. (#76874)
* ansible-test - Clarify need for empty __init__.py
* ansible-test - Update code-smell boilerplate.
* Update code-smell boilerplate for core.
* Update future boilerplate test for ansible-test.
All ansible-test code (except for targets) and core-specific sanity... | 34 | 0 | 78,447 | 15 | |
1 | 2 | def imag(self):
return self["imag"]
| packages/python/plotly/plotly/graph_objs/_scattersmith.py | 22 | plotly.py | {
"docstring": "\n Sets the imaginary component of the data, in units of\n normalized impedance such that real=1, imag=0 is the center of\n the chart.\n\n The 'imag' property is an array that may be specified as a tuple,\n list, numpy array, or pandas Series\n\n Returns\n ... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _scattersmith.py | 228,102 | 2 | 11 | imag | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 59,775 | 7 | |
1 | 13 | def test_get_conn_uri_non_existent_key(self):
conn_id = "test_mysql"
secret_id = 'airflow/connections/test_postgres'
create_param = {
'Name': secret_id,
}
param = {
'SecretId': secret_id,
'SecretString': 'postgresql://airflow:airflow... | tests/providers/amazon/aws/secrets/test_secrets_manager.py | 137 | airflow | {
"docstring": "\n Test that if the key with connection ID is not present,\n SecretsManagerBackend.get_connection should return None\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 15
} | 35 | Python | 25 | 79a2f79ff85a740d6b3680215dc2c9a143ddafbb | test_secrets_manager.py | 48,448 | 15 | 77 | test_get_conn_uri_non_existent_key | https://github.com/apache/airflow.git | cleanup usage of `get_connections()`` from test suite (#23757)
The function is deprecated and raises warnings https://github.com/apache/airflow/pull/10192
Replacing the usage with `get_connection()` | 152 | 0 | 9,496 | 9 | |
1 | 11 | def _create_trial_info(self, expr_dir):
meta = self._build_trial_meta(expr_dir)
self.logger.debug("Create trial for %s" % meta)
trial_record = TrialRecord.from_json(meta)
trial_record.save()
| python/ray/tune/automlboard/backend/collector.py | 68 | ray | {
"docstring": "Create information for given trial.\n\n Meta file will be loaded if exists, and the trial information\n will be saved in db backend.\n\n Args:\n expr_dir: Directory path of the experiment.\n ",
"language": "en",
"n_whitespaces": 68,
"n_words": 29,
"vocab_... | 16 | Python | 15 | d2f0c3b2f64b41f6541f6521e98cf3a37577c016 | collector.py | 140,346 | 5 | 39 | _create_trial_info | https://github.com/ray-project/ray.git | Clean up docstyle in data, ml, and tune packages (#25188) | 51 | 0 | 31,930 | 9 | |
1 | 8 | def image_svg(viz, env):
svgstr =
viz.svg(
svgstr=svgstr,
opts=dict(title='Example of SVG Rendering')
)
| example/components/image.py | 46 | visdom | {
"docstring": "\n <svg height=\"300\" width=\"300\">\n <ellipse cx=\"80\" cy=\"80\" rx=\"50\" ry=\"30\"\n style=\"fill:red;stroke:purple;stroke-width:2\" />\n Sorry, your browser does not support inline SVG.\n </svg>\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 19,
"vocab_s... | 12 | Python | 12 | b4115c0337b1bacc876bef1ece97e8fa8b3e2834 | image.py | 106,603 | 12 | 27 | image_svg | https://github.com/fossasia/visdom.git | test: split demo.py into seperate files and functions | 35 | 0 | 22,423 | 12 | |
1 | 3 | def escape_eid(eid):
return eid.replace('/', '_')
| py/visdom/utils/server_utils.py | 30 | visdom | {
"docstring": "Replace slashes with underscores, to avoid recognizing them\n as directories.\n ",
"language": "en",
"n_whitespaces": 16,
"n_words": 10,
"vocab_size": 10
} | 5 | Python | 5 | 60c90e313e106c0af62339d29eeda0e62823c648 | server_utils.py | 106,776 | 2 | 15 | escape_eid | https://github.com/fossasia/visdom.git | Refactoring server.py into more intentional files | 11 | 0 | 22,436 | 8 | |
1 | 7 | def size(self) -> int | np.signedinteger:
return np.prod(self.shape)
| dask/array/core.py | 36 | dask | {
"docstring": "\n The total number of blocks in the array.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 8
} | 8 | Python | 8 | 1a760229fc18c0c7df41669a13a329a287215819 | core.py | 156,682 | 5 | 21 | size | https://github.com/dask/dask.git | Only import IPython if type checking (#9230) | 22 | 0 | 36,713 | 8 | |
1 | 2 | def icicle(self):
return self["icicle"]
| packages/python/plotly/plotly/graph_objs/layout/template/_data.py | 22 | plotly.py | {
"docstring": "\n The 'icicle' property is a tuple of instances of\n Icicle that may be specified as:\n - A list or tuple of instances of plotly.graph_objs.layout.template.data.Icicle\n - A list or tuple of dicts of string/value properties that\n will be passed to the Icicl... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _data.py | 232,553 | 2 | 11 | icicle | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 63,997 | 7 | |
4 | 17 | def _async_update_rssi(self) -> None:
for (
unique_id,
ibeacon_advertisement,
) in self._last_ibeacon_advertisement_by_unique_id.items():
address = unique_id.split("_")[-1]
if (
service_info := bluetooth.async_last_service_info(
... | homeassistant/components/ibeacon/coordinator.py | 134 | core | {
"docstring": "Check to see if the rssi has changed and update any devices.\n\n We don't callback on RSSI changes so we need to check them\n here and send them over the dispatcher periodically to\n ensure the distance calculation is update.\n ",
"language": "en",
"n_whitespaces": 67,
... | 34 | Python | 28 | 02731efc4cb3f7ee94b0c08aecc10e3a5209dbf4 | coordinator.py | 287,742 | 23 | 86 | _async_update_rssi | https://github.com/home-assistant/core.git | Handle iBeacons that broadcast multiple different uuids (#79011)
* Handle iBeacons that broadcast multiple different uuids
* fix flip-flopping between uuids
* naming | 261 | 0 | 86,930 | 13 | |
1 | 2 | def session():
return Session()
| .venv/lib/python3.8/site-packages/pip/_vendor/requests/sessions.py | 19 | transferlearning | {
"docstring": "\n Returns a :class:`Session` for context-management.\n\n .. deprecated:: 1.0.0\n\n This method has been deprecated since version 1.0.0 and is only kept for\n backwards compatibility. New code should use :class:`~requests.sessions.Session`\n to create a session. This may be ... | 4 | Python | 4 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | sessions.py | 63,591 | 2 | 9 | session | https://github.com/jindongwang/transferlearning.git | upd; format | 10 | 0 | 13,405 | 7 | |
6 | 38 | async def async_update(self, log_errors=True):
if not self._async_client:
self._async_client = get_async_client(
self._hass, verify_ssl=self._verify_ssl
)
rendered_headers = template.render_complex(self._headers, parse_result=False)
rendered_para... | homeassistant/components/rest/data.py | 317 | core | {
"docstring": "Get the latest data from REST service with provided method.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 91 | Python | 56 | 599d61a4da096227ce4d5ba1dc0eaabceea56f49 | data.py | 289,315 | 35 | 202 | async_update | https://github.com/home-assistant/core.git | Fix payload in rest (#80544) | 500 | 0 | 88,457 | 13 | |
1 | 12 | async def test_auth(hass, aioclient_mock):
expiration_time = time.time() + 86400
create_config_entry(expiration_time).add_to_hass(hass)
# Prepare to capture credentials in API request. Empty payloads just mean
# no devices or structures are loaded.
aioclient_mock.get(f"{API_URL}/enterprises/... | tests/components/nest/test_api.py | 108 | core | {
"docstring": "Exercise authentication library creates valid credentials.",
"language": "en",
"n_whitespaces": 5,
"n_words": 6,
"vocab_size": 6
} | 43 | Python | 35 | c576a68d336bc91fd82c299d9b3e5dfdc1c14960 | test_api.py | 291,721 | 30 | 208 | test_auth | https://github.com/home-assistant/core.git | Upgrade pytest-aiohttp (#82475)
* Upgrade pytest-aiohttp
* Make sure executors, tasks and timers are closed
Some test will trigger warnings on garbage collect, these warnings
spills over into next test.
Some test trigger tasks that raise errors on shutdown, these spill
over into next test.
This is to mim... | 71 | 0 | 90,825 | 9 | |
7 | 24 | def authenticate(request=None, **credentials):
username = credentials.get('username')
for backend, backend_path in _get_backends(return_tuples=True):
# 预先检查,不浪费认证时间
if not backend.username_can_authenticate(username):
continue
# 原生
backend_signature = inspect.si... | apps/authentication/mixins.py | 220 | jumpserver | {
"docstring": "\n If the given credentials are valid, return a User object.\n 之所以 hack 这个 auticate\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 14,
"vocab_size": 14
} | 112 | Python | 78 | edfca5eb2486c2f006257723ffeda6f56b170170 | mixins.py | 188,426 | 21 | 125 | authenticate | https://github.com/jumpserver/jumpserver.git | Fix rbac (#7699)
* perf: 优化 suggesstion
* perf: 修改 migrations
* feat: 添加OIDC认证逻辑
* perf: 修改 backend
* perf: 优化认证backends
* perf: 优化认证backends
* perf: 优化CAS认证, 用户多域名进行访问时回调到各自域名
Co-authored-by: ibuler <ibuler@qq.com> | 323 | 0 | 45,914 | 13 | |
2 | 11 | def config_test(self) -> None:
try:
util.run_script([self.conf('ctl'), "-c", self.nginx_conf, "-t"])
except errors.SubprocessError as err:
raise errors.MisconfigurationError(str(err))
| certbot-nginx/certbot_nginx/_internal/configurator.py | 84 | certbot | {
"docstring": "Check the configuration of Nginx for errors.\n\n :raises .errors.MisconfigurationError: If config_test fails\n\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 12,
"vocab_size": 12
} | 15 | Python | 15 | 16aad35d31a887dab157f9d4f5e0fe9218d06064 | configurator.py | 186,582 | 10 | 48 | config_test | https://github.com/certbot/certbot.git | Fully type certbot-nginx module (#9124)
* Work in progress
* Fix type
* Work in progress
* Work in progress
* Work in progress
* Work in progress
* Work in progress
* Oups.
* Fix typing in UnspacedList
* Fix logic
* Finish typing
* List certbot-nginx as fully typed in tox
* Fix lint... | 58 | 0 | 45,498 | 13 | |
1 | 6 | def print_stack(self, *, limit=None, file=None):
return base_tasks._task_print_stack(self, limit, file)
| python3.10.4/Lib/asyncio/tasks.py | 41 | XX-Net | {
"docstring": "Print the stack or traceback for this task's coroutine.\n\n This produces output similar to that of the traceback module,\n for the frames retrieved by get_stack(). The limit argument\n is passed to get_stack(). The file argument is an I/O stream\n to which the output is ... | 9 | Python | 9 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | tasks.py | 220,797 | 2 | 27 | print_stack | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 23 | 0 | 56,120 | 7 | |
2 | 11 | def _rename_tmp_file(self) -> None:
os.rename(self._video_tmp_file, self._output_filename)
logger.debug("Removing temp file")
if os.path.isfile(self._video_tmp_file):
os.remove(self._video_tmp_file)
| plugins/convert/writer/ffmpeg.py | 78 | faceswap | {
"docstring": " Rename the temporary video file if not muxing audio. ",
"language": "en",
"n_whitespaces": 10,
"n_words": 9,
"vocab_size": 9
} | 12 | Python | 12 | 60291d49c4da1cd260fbc0b04aa6a312eedfefbb | ffmpeg.py | 100,615 | 6 | 46 | _rename_tmp_file | https://github.com/deepfakes/faceswap.git | ffmpeg writer: Create new filename if output pre-exists | 51 | 0 | 20,077 | 10 | |
4 | 14 | def get_tightbbox(self, renderer=None):
bbox = self.get_window_extent(renderer)
if self.get_clip_on():
clip_box = self.get_clip_box()
if clip_box is not None:
bbox = Bbox.intersection(bbox, clip_box)
clip_path = self.get_clip_path()
... | lib/matplotlib/artist.py | 137 | matplotlib | {
"docstring": "\n Like `.Artist.get_window_extent`, but includes any clipping.\n\n Parameters\n ----------\n renderer : `.RendererBase` subclass\n renderer that will be used to draw the figures (i.e.\n ``fig.canvas.get_renderer()``)\n\n Returns\n ------... | 37 | Python | 20 | 24b16804731d3a724e4ec0984da140b1a6b05c66 | artist.py | 108,560 | 11 | 84 | get_tightbbox | https://github.com/matplotlib/matplotlib.git | MNT: make renderer always optional | 154 | 0 | 23,258 | 14 | |
1 | 17 | async def logout():
confirm_logged_in()
profiles = prefect.settings.load_profiles()
profiles.update_active_profile()
update_profile(PREFECT_API_URL=None, PREFECT_API_KEY=None)
profile = prefect.context.get_settings_context()
exit_with_success(f"Successfully logged out in profile {profil... | src/prefect/cli/cloud.py | 101 | @workspace_app.command() | prefect | {
"docstring": "\n Log out of Prefect Cloud.\n Removes PREFECT_API_URL and PREFECT_API_KEY from profile.\n ",
"language": "en",
"n_whitespaces": 21,
"n_words": 11,
"vocab_size": 11
} | 20 | Python | 18 | b0af6cf8b1eaea33ee6809efc770fc041908b7ca | cloud.py | 55,096 | 7 | 46 | logout | https://github.com/PrefectHQ/prefect.git | Refactor settings context | 40 | 1 | 11,209 | 10 |
1 | 18 | def test_post_save_change_redirect(self):
Person.objects.create(name="John Doe")
self.assertEqual(Person.objects.count(), 1)
person = Person.objects.all()[0]
post_url = reverse(
"admin_custom_urls:admin_custom_urls_person_change", args=[person.pk]
)
r... | tests/admin_custom_urls/tests.py | 154 | django | {
"docstring": "\n ModelAdmin.response_post_save_change() controls the redirection after\n the 'Save' button has been pressed when editing an existing object.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 16,
"vocab_size": 15
} | 28 | Python | 23 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 207,062 | 14 | 92 | test_post_save_change_redirect | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 150 | 0 | 51,854 | 12 | |
1 | 2 | def prefixsrc(self):
return self["prefixsrc"]
| packages/python/plotly/plotly/graph_objs/table/_cells.py | 22 | plotly.py | {
"docstring": "\n Sets the source reference on Chart Studio Cloud for `prefix`.\n\n The 'prefixsrc' property must be specified as a string or\n as a plotly.grid_objs.Column object\n\n Returns\n -------\n str\n ",
"language": "en",
"n_whitespaces": 77,
"n_words":... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _cells.py | 235,481 | 2 | 11 | prefixsrc | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 66,925 | 7 | |
6 | 16 | def get_conditions(filters):
filters = frappe._dict(filters) if filters else frappe._dict({})
conditions = frappe._dict({})
conditions.company = filters.company or frappe.defaults.get_user_default("company")
conditions.end_date = filters.period_end_date or frappe.utils.today()
conditions.start_date = filters.pe... | erpnext/selling/report/payment_terms_status_for_sales_order/payment_terms_status_for_sales_order.py | 158 | erpnext | {
"docstring": "\n\tConvert filter options to conditions used in query\n\t",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 37 | Python | 26 | 1bac7930834d6f688950e836c45305a62e7ecb3f | payment_terms_status_for_sales_order.py | 63,938 | 10 | 97 | get_conditions | https://github.com/frappe/erpnext.git | feat: Payment Terms Status report
- calculate status at runtime for payment terms based on invoices
- invoices are used in FIFO method | 27 | 0 | 13,537 | 10 | |
22 | 19 | def call(self, src_files, dest_files):
# :var src_done: True if there are no more files from the source left.
src_done = False
# :var dest_done: True if there are no more files form the dest left.
dest_done = False
# :var src_take: Take the next source file from the gene... | awscli/customizations/s3/comparator.py | 402 | aws-cli | {
"docstring": "\n This function preforms the actual comparisons. The parameters it takes\n are the generated files for both the source and the destination. The\n key concept in this function is that no matter the type of where the\n files are coming from, they are listed in the same ord... | 210 | Python | 68 | 8a16d7d8ce5e3f97fb100af7a960224f7f80137d | comparator.py | 189,212 | 52 | 239 | call | https://github.com/aws/aws-cli.git | Delete extra whitespace
A correction that does not affect the operation. | 1,052 | 0 | 46,019 | 16 | |
4 | 13 | def _bool_arith_fallback(op_str, a, b):
if _has_bool_dtype(a) and _has_bool_dtype(b):
if op_str in _BOOL_OP_UNSUPPORTED:
warnings.warn(
f"evaluating in Python space because the {repr(op_str)} "
"operator is not supported by numexpr for the bool dtype, "
... | pandas/core/computation/expressions.py | 108 | pandas | {
"docstring": "\n Check if we should fallback to the python `_evaluate_standard` in case\n of an unsupported operation by numexpr, which is the case for some\n boolean ops.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 25,
"vocab_size": 23
} | 41 | Python | 36 | e94faa23e24c0abf9db74d79cfebe06676577867 | expressions.py | 168,434 | 11 | 52 | _bool_arith_fallback | https://github.com/pandas-dev/pandas.git | WARN,TST check stacklevel for all warnings (#47998)
* use find_stack_level everywhere
* fixup
* pyx fixups
* fixup test_optional_dependency
* fixup api
* set check_stacklevel=False for some tests
* use lru_cache for currentframe
* fixup import in __init__
* add missing imports to pyx files
* add missing impo... | 150 | 0 | 40,296 | 17 | |
2 | 5 | def get_file_breaks(self, filename):
filename = self.canonic(filename)
if filename in self.breaks:
return self.breaks[filename]
else:
return []
| python3.10.4/Lib/bdb.py | 58 | XX-Net | {
"docstring": "Return all lines with breakpoints for filename.\n\n If no breakpoints are set, return an empty list.\n ",
"language": "en",
"n_whitespaces": 30,
"n_words": 16,
"vocab_size": 15
} | 15 | Python | 13 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | bdb.py | 221,103 | 6 | 35 | get_file_breaks | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 65 | 0 | 56,206 | 9 | |
5 | 11 | def radius(G, e=None, usebounds=False, weight=None):
if usebounds is True and e is None and not G.is_directed():
return _extrema_bounding(G, compute="radius", weight=weight)
if e is None:
e = eccentricity(G, weight=weight)
return min(e.values())
| networkx/algorithms/distance_measures.py | 112 | networkx | {
"docstring": "Returns the radius of the graph G.\n\n The radius is the minimum eccentricity.\n\n Parameters\n ----------\n G : NetworkX graph\n A graph\n\n e : eccentricity dictionary, optional\n A precomputed dictionary of eccentricities.\n\n weight : string, function, or None\n ... | 30 | Python | 22 | 28f78cfa9a386620ee1179582fda1db5ffc59f84 | distance_measures.py | 177,078 | 6 | 71 | radius | https://github.com/networkx/networkx.git | Add weight distance metrics (#5305)
Adds the weight keyword argument to allow users to compute weighted distance metrics
e.g. diameter, eccentricity, periphery, etc. The kwarg works in the same fashion as the
weight param for shortest paths - i.e. if a string, look up with edge attr by key, if callable,
compute the... | 56 | 0 | 42,265 | 11 | |
8 | 24 | def write(self, args, path): # type: (CommonConfig, str) -> None
# NOTE: Switching the inventory generation to write JSON would be nice, but is currently not possible due to the use of hard-coded inventory filenames.
# The name `inventory` works for the POSIX integration tests, but `inv... | test/lib/ansible_test/_internal/host_profiles.py | 268 | ansible | {
"docstring": "Write the given inventory to the specified path on disk.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | 159 | Python | 109 | fe349a1ccd658d86cfcf10eecdce9d48ece6176c | host_profiles.py | 267,273 | 17 | 133 | write | https://github.com/ansible/ansible.git | ansible-test - Enhance the shell command. (#77734)
* ansible-test - Add shell --export option.
* ansible-test - Support cmd args for shell command.
Also allow shell to be used without a valid layout if no delegation is required.
* ansible-test - Improve stderr/stdout consistency.
By default all output goes... | 377 | 0 | 78,828 | 15 | |
1 | 4 | def ambient_dimension(self):
return len(self.args[0])
| sympy/geometry/curve.py | 28 | sympy | {
"docstring": "The dimension of the curve.\n\n Returns\n =======\n\n int :\n the dimension of curve.\n\n Examples\n ========\n\n >>> from sympy.abc import t\n >>> from sympy import Curve\n >>> C = Curve((t, t**2), (t, 0, 2))\n >>> C.ambient_di... | 4 | Python | 4 | 498015021131af4dbb07eb110e5badaba8250c7b | curve.py | 196,266 | 2 | 16 | ambient_dimension | https://github.com/sympy/sympy.git | Updated import locations | 18 | 0 | 47,766 | 9 | |
1 | 6 | def from_pandas(cls, *args, **kwargs):
return cls(pa.Table.from_pandas(*args, **kwargs))
| src/datasets/table.py | 46 | datasets | {
"docstring": "\n Convert pandas.DataFrame to an Arrow Table.\n\n The column types in the resulting Arrow Table are inferred from the\n dtypes of the pandas.Series in the DataFrame. In the case of non-object\n Series, the NumPy dtype is translated to its Arrow equivalent. In the\n ... | 7 | Python | 7 | e35be138148333078284b942ccc9ed7b1d826f97 | table.py | 104,411 | 2 | 28 | from_pandas | https://github.com/huggingface/datasets.git | Update docs to new frontend/UI (#3690)
* WIP: update docs to new UI
* make style
* Rm unused
* inject_arrow_table_documentation __annotations__
* hasattr(arrow_table_method, "__annotations__")
* Update task_template.rst
* Codeblock PT-TF-SPLIT
* Convert loading scripts
* Convert docs to mdx
... | 21 | 0 | 21,847 | 10 | |
1 | 6 | def divides(p, n):
sympy_deprecation_warning(
,
deprecated_since_version="1.11",
active_deprecations_target='deprecated-carmichael-static-methods',
)
return n % p == 0
| sympy/functions/combinatorial/numbers.py | 44 | sympy | {
"docstring": "\n divides can be replaced by directly testing n % p == 0.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 12
} | 14 | Python | 14 | b27e2b44626d138bd6ea235fbf114644baa5b144 | numbers.py | 197,219 | 9 | 26 | divides | https://github.com/sympy/sympy.git | Deprecate redundant static methods | 55 | 0 | 48,392 | 9 | |
1 | 8 | def is_decompressed(self) -> bool:
return type(self._pb_body) in [
jina_pb2.DataRequestProto,
jina_pb2.DataRequestProtoWoData,
]
| jina/types/request/data.py | 42 | jina | {
"docstring": "\n Checks if the underlying proto object was already deserialized into a :class:`jina.proto.jina_pb2.DataRequestProto` or\n :class:`jina.proto.jina_pb2.DataRequestProtoWoData`. This does not necessarily mean that the data (docs) inside the request is also decompressed.\n :retur... | 11 | Python | 11 | c3849c6fee4a65a77a82b2cfda9670d727ff0f53 | data.py | 12,701 | 10 | 26 | is_decompressed | https://github.com/jina-ai/jina.git | feat: allow to access parameters of data request wo loading data (#4991) | 54 | 0 | 2,387 | 9 | |
1 | 4 | def model_file_path_key(self):
return f"{self.tag_to_agent()[self.value]}_response_model_path"
| projects/bb3/agents/module.py | 36 | ParlAI | {
"docstring": "\n Opt key for model file path for this agent.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 8
} | 4 | Python | 4 | b1acb681207559da56a787ba96e16f0e23697d92 | module.py | 195,191 | 2 | 9 | model_file_path_key | https://github.com/facebookresearch/ParlAI.git | Patch 8322 (#4709)
* add dafetymix teacher
* safety_mix teacher
* safety_mix teacher pos and neg teachers
* add tests for teacher
* add license info
* improvement
* add task list
* add task list and lint
* add init.py
* adding some patch to director
* seeker changes
* th
* 3
* ji... | 18 | 0 | 47,220 | 10 | |
1 | 9 | def swish(x):
return tf.nn.silu(x)
@keras_export("keras.activations.relu")
@tf.__internal__.dispatch.add_dispatch_support | keras/activations.py | 50 | @keras_export("keras.activations.relu")
@tf.__internal__.dispatch.add_dispatch_support | keras | {
"docstring": "Swish activation function, `swish(x) = x * sigmoid(x)`.\n\n Swish activation function which returns `x*sigmoid(x)`.\n It is a smooth, non-monotonic function that consistently matches\n or outperforms ReLU on deep networks, it is unbounded above and\n bounded below.\n\n\n Example Usage:\... | 6 | Python | 6 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | activations.py | 269,309 | 2 | 15 | swish | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 10 | 1 | 80,023 | 8 |
2 | 15 | def item_details(doctype, txt, searchfield, start, page_len, filters):
from erpnext.controllers.queries import get_match_cond
return frappe.db.sql(
% ("%s", searchfield, "%s", get_match_cond(doctype), "%s", "%s"),
((filters or {}).get("delivery_note"), "%%%s%%" % txt, page_len, start),
)
| erpnext/stock/doctype/packing_slip/packing_slip.py | 110 | erpnext | {
"docstring": "select name, item_name, description from `tabItem`\n\t\t\t\twhere name in ( select item_code FROM `tabDelivery Note Item`\n\t \t\t\t\t\t\twhere parent= %s)\n\t \t\t\tand %s like \"%s\" %s\n\t \t\t\tlimit %s offset %s ",
"language": "en",
"n_whitespaces": 28,
"n_words": 28,
"vocab_size": 23
} | 29 | Python | 24 | 00ef499739959630cd7cf97419fbb6ca59be05f2 | packing_slip.py | 68,812 | 11 | 72 | item_details | https://github.com/frappe/erpnext.git | refactor: use db independent offset syntax (#31345)
* chore: use db independent offset syntax
* fix: typo
* style: reformat code to black spec
Co-authored-by: Ankush Menat <ankush@frappe.io> | 23 | 0 | 14,893 | 13 | |
3 | 14 | def export_probs(self) -> dict[str, Any]:
result = {}
for module in self.nas_modules:
try:
result.update(module.export_probs(memo=result))
except NotImplementedError:
warnings.warn(
'Some super-modules you have used did... | nni/nas/oneshot/pytorch/base_lightning.py | 86 | nni | {
"docstring": "\n Export the probability of every choice in the search space got chosen.\n\n .. note:: If such method of some modules is not implemented, they will be simply ignored.\n\n Returns\n -------\n dict\n In most cases, keys are names of ``nas_modules`` suffixed... | 37 | Python | 36 | f77db747d07d5c90a3a9f70bb17f71d4573f329e | base_lightning.py | 113,318 | 22 | 52 | export_probs | https://github.com/microsoft/nni.git | Enhancement of one-shot NAS (v2.9) (#5049) | 170 | 0 | 24,885 | 14 | |
4 | 7 | def clear(self):
self._block_partition_refs = [None for _ in self._block_partition_refs]
self._block_partition_meta_refs = [
None for _ in self._block_partition_meta_refs
]
self._cached_metadata = [None for _ in self._cached_metadata]
self._stats_actor = None... | python/ray/data/_internal/lazy_block_list.py | 78 | ray | {
"docstring": "Clears all object references (block partitions and base block partitions)\n from this lazy block list.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 15,
"vocab_size": 14
} | 28 | Python | 16 | b1cad0a1121c06cae55aaed32f2b901b2b725521 | lazy_block_list.py | 127,026 | 7 | 50 | clear | https://github.com/ray-project/ray.git | [Datasets] Use detached lifetime for stats actor (#25271)
The actor handle held at Ray client will become dangling if the Ray cluster is shutdown, and in such case if the user tries to get the actor again it will result in crash. This happened in a real user and blocked them from making progress.
This change makes ... | 81 | 0 | 28,336 | 9 | |
4 | 13 | def _read_all_pages(self, endpoint):
internal_data = []
while True:
resp = self._session.get(endpoint)
if resp.status_code == 200:
internal_data += resp.json()
if "next" in resp.links:
endpoint = resp.links["next"]["ur... | .github/scripts/github.py | 149 | paperless-ngx | {
"docstring": "\n Helper function to read all pages of an endpoint, utilizing the\n next.url until exhausted. Assumes the endpoint returns a list\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 20,
"vocab_size": 19
} | 40 | Python | 32 | 0b8eff9643c12aa7c766538d8a3e4194934cf44c | github.py | 319,987 | 15 | 78 | _read_all_pages | https://github.com/paperless-ngx/paperless-ngx.git | Extends the cleanup of image versions to the library images and all the registry cache images as well | 233 | 0 | 117,041 | 15 | |
1 | 3 | def lazy(func, *resultclasses):
| django/utils/functional.py | 17 | django | {
"docstring": "\n Turn any callable into a lazy evaluated callable. result classes or types\n is required -- at least one is needed so that the automatic forcing of\n the lazy evaluation code is triggered. Results are not memoized; the\n function is evaluated on every access.\n ",
"language": "en",
... | 3 | Python | 3 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | functional.py | 206,667 | 31 | 68 | lazy | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 6 | 0 | 51,617 | 6 | |
3 | 22 | def chromatic_polynomial(G):
r
import sympy
x = sympy.Symbol("x")
stack = deque()
stack.append(nx.MultiGraph(G, contraction_idx=0))
polynomial = 0
while stack:
G = stack.pop()
edges = list(G.edges)
if not edges:
polynomial += (-1) ** G.graph["contraction... | networkx/algorithms/polynomials.py | 253 | networkx | {
"docstring": "Returns the chromatic polynomial of `G`\n\n This function computes the chromatic polynomial via an iterative version of\n the deletion-contraction algorithm.\n\n The chromatic polynomial `X_G(x)` is a fundamental graph polynomial\n invariant in one variable. Evaluating `X_G(k)` for an natu... | 57 | Python | 45 | a3a383f7a90e478df40bc9d746c925f2c94a5a2b | polynomials.py | 176,832 | 120 | 154 | chromatic_polynomial | https://github.com/networkx/networkx.git | Chromatic polynomial (#5675)
Adds chromatic_polynomial function to the graph polynomials package. | 196 | 0 | 42,128 | 14 | |
4 | 25 | def reidemeister_presentation(fp_grp, H, C=None, homomorphism=False):
if not C:
C = coset_enumeration_r(fp_grp, H)
C.compress(); C.standardize()
define_schreier_generators(C, homomorphism=homomorphism)
reidemeister_relators(C)
gens, rels = C._schreier_generators, C._reidemeister_relator... | sympy/combinatorics/fp_groups.py | 217 | sympy | {
"docstring": "\n Parameters\n ==========\n\n fp_group: A finitely presented group, an instance of FpGroup\n H: A subgroup whose presentation is to be found, given as a list\n of words in generators of `fp_grp`\n homomorphism: When set to True, return a homomorphism from the subgroup\n ... | 54 | Python | 41 | 498015021131af4dbb07eb110e5badaba8250c7b | fp_groups.py | 196,052 | 16 | 136 | reidemeister_presentation | https://github.com/sympy/sympy.git | Updated import locations | 125 | 0 | 47,552 | 14 | |
1 | 8 | def test_preserve_username_case(self):
user = User.objects.create_user("forms_test2", "tesT@EXAMple.com", "test")
self.assertEqual(user.email, "tesT@example.com")
user = User.objects.create_user("forms_test3", "tesT", "test")
self.assertEqual(user.email, "tesT")
| tests/auth_tests/test_forms.py | 99 | django | {
"docstring": "\n Preserve the case of the user name (before the @ in the email address)\n when creating a user (#5605).\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 19,
"vocab_size": 15
} | 16 | Python | 12 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | test_forms.py | 201,228 | 5 | 54 | test_preserve_username_case | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 51 | 0 | 49,906 | 9 | |
1 | 4 | def clean_up_synthetic_data():
shutil.rmtree("audio_files", ignore_errors=True)
shutil.rmtree("image_files", ignore_errors=True)
| ludwig/utils/triton_utils.py | 46 | ludwig | {
"docstring": "Clean up synthetic example generated data for audio and image features.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 6 | Python | 5 | ed8d9cf20843744f18593b22fb6a30eaf5f325eb | triton_utils.py | 7,519 | 3 | 25 | clean_up_synthetic_data | https://github.com/ludwig-ai/ludwig.git | Triton ensemble export (#2251) | 15 | 0 | 1,227 | 8 | |
6 | 24 | def load_weights_only(model, filepath):
temp_dir = None
archive = None
if filepath.endswith(".weights.h5"):
# TODO: download file if h5 filepath is remote
weights_store = H5IOStore(filepath, mode="r")
elif filepath.endswith(".keras"):
archive = zipfile.ZipFile(filepath, "r")... | keras/saving/experimental/saving_lib.py | 212 | keras | {
"docstring": "Load the weights of a model from a filepath (.keras or .weights.h5).\n\n Note: only supports h5 for now.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 18,
"vocab_size": 17
} | 55 | Python | 43 | e6f739a31247c43a86c37c33b0b8b2ba6be6a5f6 | saving_lib.py | 280,201 | 22 | 126 | load_weights_only | https://github.com/keras-team/keras.git | - Add standalone weights file saving/loading functionality.
- Switch to in-memory, single write / single read archive saving for better performance.
- Remove ability to pick between zipping or not zipping a Keras saved artifact: it's always a zip archive now.
PiperOrigin-RevId: 483705728 | 180 | 0 | 83,286 | 13 | |
1 | 11 | def cg(A, b, x0=None, *, tol=1e-5, atol=0.0, maxiter=None, M=None):
return _isolve(_cg_solve,
A=A, b=b, x0=x0, tol=tol, atol=atol,
maxiter=maxiter, M=M, check_symmetric=True)
| jax/_src/scipy/sparse/linalg.py | 91 | jax | {
"docstring": "Use Conjugate Gradient iteration to solve ``Ax = b``.\n\n The numerics of JAX's ``cg`` should exact match SciPy's ``cg`` (up to\n numerical precision), but note that the interface is slightly different: you\n need to supply the linear operator ``A`` as a function instead of a sparse\n matrix or ``... | 19 | Python | 19 | 998d60dd07d2c33438f606307de0276bcf110428 | linalg.py | 119,883 | 4 | 71 | cg | https://github.com/google/jax.git | DOC: clarify parameter types in cg/bicgstab | 53 | 0 | 26,708 | 8 | |
2 | 6 | def _get_database_display_str(self, verbosity, database_name):
return "'%s'%s" % (
self.connection.alias,
(" ('%s')" % database_name) if verbosity >= 2 else "",
)
| django/db/backends/base/creation.py | 55 | django | {
"docstring": "\n Return display string for a database for use in various actions.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 11,
"vocab_size": 10
} | 20 | Python | 19 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | creation.py | 204,841 | 5 | 33 | _get_database_display_str | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 63 | 0 | 50,920 | 11 | |
1 | 11 | def pre_run_hook(self, instance, private_data_dir):
instance.log_lifecycle("pre_run")
# Before task is started, ensure that job_event partitions exist
create_partition(instance.event_class._meta.db_table, start=instance.created)
| awx/main/tasks/jobs.py | 54 | awx | {
"docstring": "\n Hook for any steps to run before the job/task starts\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 10
} | 17 | Python | 17 | e87fabe6bb84691472ab67e5da737c9fe515cf3f | jobs.py | 81,641 | 3 | 32 | pre_run_hook | https://github.com/ansible/awx.git | Submit job to dispatcher as part of transaction (#12573)
Make it so that submitting a task to the dispatcher happens as part of the transaction.
this applies to dispatcher task "publishers" which NOTIFY the pg_notify queue
if the transaction is not successful, it will not be sent, as per postgres docs
This ke... | 45 | 0 | 17,240 | 10 | |
3 | 30 | def make_dataset(X, y, sample_weight, random_state=None):
rng = check_random_state(random_state)
# seed should never be 0 in SequentialDataset64
seed = rng.randint(1, np.iinfo(np.int32).max)
if X.dtype == np.float32:
CSRData = CSRDataset32
ArrayData = ArrayDataset32
else:
... | sklearn/linear_model/_base.py | 197 | scikit-learn | {
"docstring": "Create ``Dataset`` abstraction for sparse and dense inputs.\n\n This also returns the ``intercept_decay`` which is different\n for sparse datasets.\n\n Parameters\n ----------\n X : array-like, shape (n_samples, n_features)\n Training data\n\n y : array-like, shape (n_samples,... | 66 | Python | 43 | b4da3b406379b241bf5e81d0f60bbcddd424625b | _base.py | 259,567 | 17 | 130 | make_dataset | https://github.com/scikit-learn/scikit-learn.git | MNT ensure creation of dataset is deterministic in SGD (#19716)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> | 156 | 0 | 75,821 | 12 | |
2 | 28 | def test_big_ndept() -> None:
# for multiplier in [1, 10, 100, 1000]:
for multiplier in [10]:
ndim = 1_000_000
rows = 1
cols = 7
num_entites = 1000
upper = highest()
lower = lowest()
reference_data = np.random.randint(
lower, upper, ... | packages/syft/tests/syft/core/tensor/tensor_serde_test.py | 185 | PySyft | {
"docstring": "Create big NDEPTs\n failed capnp deserialize capnp/serialize.c++:197:\n failed: expected totalWords <= options.traversalLimitInWords;\n Message is too large. To increase the limit on the receiving end,\n see capnp::ReaderOptions.\n ",
"language": "en",
"n_whitespaces": 42,
"n_wor... | 67 | Python | 53 | b2768484a1b5720be74c78335502cd996e0b1895 | tensor_serde_test.py | 735 | 27 | 118 | test_big_ndept | https://github.com/OpenMined/PySyft.git | WIP: Having issue with 10M NDEPT serde
- options.traversalLimitInWords; Message is too large. | 229 | 0 | 107 | 15 | |
2 | 6 | def popitem(self):
for key in self.sections():
value = self[key]
del self[key]
return key, value
raise KeyError
| python3.10.4/Lib/configparser.py | 52 | XX-Net | {
"docstring": "Remove a section from the parser and return it as\n a (section_name, section_proxy) tuple. If no section is present, raise\n KeyError.\n\n The section DEFAULT is never returned because it cannot be removed.\n ",
"language": "en",
"n_whitespaces": 60,
"n_words": 32,
... | 16 | Python | 14 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | configparser.py | 221,679 | 6 | 32 | popitem | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 70 | 0 | 56,473 | 9 | |
2 | 9 | def cleanup_cache_files(self) -> Dict[str, int]:
self._check_values_type()
return {k: dataset.cleanup_cache_files() for k, dataset in self.items()}
| src/datasets/dataset_dict.py | 62 | datasets | {
"docstring": "Clean up all cache files in the dataset cache directory, excepted the currently used cache file if there is one.\n Be careful when running this command that no other process is currently using other cache files.\n\n Return:\n Dict with the number of removed files for each spli... | 14 | Python | 14 | 1904d0c0a3a96330d9b870cdca3e9a3a137f2977 | dataset_dict.py | 104,788 | 18 | 38 | cleanup_cache_files | https://github.com/huggingface/datasets.git | Add code examples for DatasetDict (#4245)
* 📝 add code examples for DatasetDict
* 🖍 apply quentin review | 35 | 0 | 21,970 | 9 | |
2 | 14 | def test_recursion_to_deep(large_import_chain):
if is_win:
pytest.xfail("Worker is known to crash on Windows.")
path, script = large_import_chain
mg = modulegraph.ModuleGraph(path)
# Increase recursion limit to 5 times of the default. Given the module import chain created above
# this s... | tests/unit/test_recursion_limit.py | 83 | pyinstaller | {
"docstring": "\n modulegraph is recursive and triggers RecursionError if nesting of imported modules is to deep.\n This can be worked around by increasing recursion limit.\n\n With the default recursion limit (1000), the recursion error occurs at about 115 modules, with limit 2000\n (as tested below) at... | 43 | Python | 39 | 080d95d83bb7f60ce2ec25b0c81c207d303ec46c | test_recursion_limit.py | 262,741 | 7 | 45 | test_recursion_to_deep | https://github.com/pyinstaller/pyinstaller.git | Drop Python 3.6 support. | 78 | 0 | 77,340 | 11 | |
4 | 12 | def field_as_sql(self, field, val):
if field is None:
# A field value of None means the value is raw.
sql, params = val, []
elif hasattr(val, "as_sql"):
# This is an expression, let's compile it.
sql, params = self.compile(val)
elif hasatt... | django/db/models/sql/compiler.py | 168 | django | {
"docstring": "\n Take a field and a value intended to be saved on that field, and\n return placeholder SQL and accompanying params. Check for raw values,\n expressions, and fields with get_placeholder() defined in that order.\n\n When field is None, consider the value raw and use it as t... | 136 | Python | 90 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | compiler.py | 205,824 | 11 | 98 | field_as_sql | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 319 | 0 | 51,226 | 13 | |
1 | 16 | def psi_n(n, x, m, omega):
# sympify arguments
n, x, m, omega = map(S, [n, x, m, omega])
nu = m * omega / hbar
# normalization coefficient
C = (nu/pi)**Rational(1, 4) * sqrt(1/(2**n*factorial(n)))
return C * exp(-nu* x**2 /2) * hermite(n, sqrt(nu)*x)
| sympy/physics/qho_1d.py | 146 | sympy | {
"docstring": "\n Returns the wavefunction psi_{n} for the One-dimensional harmonic oscillator.\n\n Parameters\n ==========\n\n n :\n the \"nodal\" quantum number. Corresponds to the number of nodes in the\n wavefunction. ``n >= 0``\n x :\n x coordinate.\n m :\n Mass o... | 43 | Python | 31 | a0989bcfd26470833cf03737941bfd80f511c745 | qho_1d.py | 199,984 | 5 | 97 | psi_n | https://github.com/sympy/sympy.git | applied backtick correction to the remainder of the project | 64 | 0 | 49,473 | 14 | |
2 | 6 | async def async_get_hev_cycle(self) -> None:
if lifx_features(self.device)["hev"]:
await async_execute_lifx(self.device.get_hev_cycle)
| homeassistant/components/lifx/coordinator.py | 51 | core | {
"docstring": "Update the HEV cycle status from a LIFX Clean bulb.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 9 | Python | 9 | dde763418a1c4ee0ecff17de76b6d670670a3bb7 | coordinator.py | 289,881 | 4 | 28 | async_get_hev_cycle | https://github.com/home-assistant/core.git | Add an RSSI sensor to the LIFX integration (#80993) | 34 | 0 | 89,009 | 12 | |
6 | 10 | def subsets(seq, k=None, repetition=False):
r
if k is None:
if not repetition:
return chain.from_iterable((combinations(seq, k)
for k in range(len(seq) + 1)))
else:
return chain.from_iterable((combinations_with_replacement(seq, k)
... | sympy/utilities/iterables.py | 155 | sympy | {
"docstring": "Generates all `k`-subsets (combinations) from an `n`-element set, ``seq``.\n\n A `k`-subset of an `n`-element set is any subset of length exactly `k`. The\n number of `k`-subsets of an `n`-element set is given by ``binomial(n, k)``,\n whereas there are `2^n` subsets all together. If `k` is ``... | 42 | Python | 23 | a25ba231f9c3fd6518f9ae81d1df0323898b9e44 | iterables.py | 197,085 | 52 | 100 | subsets | https://github.com/sympy/sympy.git | Optimization of subsets() to use return rather than yield from
By avoiding the use of yield in the body of iterables.subsets, Python
sees it as just a regular function rather than a generator. Hence it
can call generators and return the resulting generator objects,
avoiding some overhead from a layer of yield from ha... | 200 | 0 | 48,328 | 19 | |
1 | 33 | async def test_doorbell_update_via_pubnub(hass):
doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.json")
pubnub = AugustPubNub()
await _create_august_with_devices(hass, [doorbell_one], pubnub=pubnub)
assert doorbell_one.pubsub_channel == "7c7a6672-59c8-3333-ffff-dcd98705cccc"
... | tests/components/august/test_binary_sensor.py | 819 | core | {
"docstring": "Test creation of a doorbell that can be updated via pubnub.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 211 | Python | 87 | ea5b18c1ef16b64cd7916f2540692ab5de2d2edf | test_binary_sensor.py | 309,149 | 109 | 475 | test_doorbell_update_via_pubnub | https://github.com/home-assistant/core.git | Split august motion and image capture binary sensors (#62154) | 1,162 | 0 | 107,857 | 17 | |
4 | 8 | def get_span_dict(span_list):
strip_prefix = "python.ray.tests."
span_names = {}
for span in span_list:
span_name = span["name"]
if span_name.startswith(strip_prefix):
span_name = span_name[len(strip_prefix) :]
if span_name in span_names:
span_names[span_... | python/ray/tests/test_tracing.py | 107 | ray | {
"docstring": "Given a list of span names, return dictionary of span names.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 9
} | 34 | Python | 23 | 2cdb76789e6d0d59928891a4b520f588b7844edf | test_tracing.py | 124,698 | 12 | 63 | get_span_dict | https://github.com/ray-project/ray.git | Bump pytest from 5.4.3 to 7.0.1 (#26334)
See #23676 for context. This is another attempt at that as I figured out what's going wrong in `bazel test`. Supersedes #24828.
Now that there are Python 3.10 wheels for Ray 1.13 and this is no longer a blocker for supporting Python 3.10, I still want to make `bazel test //p... | 110 | 0 | 27,661 | 14 | |
3 | 23 | async def dry_run(self, empty, context) -> jina_pb2.StatusProto:
from docarray import DocumentArray
from jina.clients.request import request_generator
from jina.enums import DataInputType
from jina.serve.executors import __dry_run_endpoint__
da = DocumentArray()
... | jina/serve/runtimes/gateway/grpc/__init__.py | 100 | async def dry_run(self, empty, context) -> jina_pb2.StatusProto:
"""
Process the the call requested by having a dry run call to every Executor in the graph
:param empty: The service expects an empty protobuf message
:param context: grpc context
:returns: the response request
... | jina | {
"docstring": "\n Process the the call requested by having a dry run call to every Executor in the graph\n\n :param empty: The service expects an empty protobuf message\n :param context: grpc context\n :returns: the response request\n ",
"language": "en",
"n_whitespaces": 70,
... | 34 | Python | 27 | ef662b529b2a2eecea7bb99759a9f7b9d86d3062 | __init__.py | 12,508 | 28 | 121 | dry_run | https://github.com/jina-ai/jina.git | feat: add grpc health checking (#4779) | 150 | 1 | 2,326 | 10 |
1 | 7 | def test_parsing_of_open_actions(self):
from kitty.open_actions import actions_for_url, KeyAction
spec =
| kitty_tests/open_actions.py | 28 | kitty | {
"docstring": "\nprotocol file\nmime text/*\nfragment_matches .\nAcTion launch $EDITOR $FILE_PATH $FRAGMENT\naction\n\nprotocol file\nmime text/*\naction ignored\n\next py,txt\naction one\naction two\n",
"language": "en",
"n_whitespaces": 13,
"n_words": 24,
"vocab_size": 17
} | 9 | Python | 9 | 1454af2d416f0eb738c2268ee3297cacb0215dd0 | open_actions.py | 102,829 | 22 | 68 | test_parsing_of_open_actions | https://github.com/kovidgoyal/kitty.git | macOS: Allow customizing the launch actions | 23 | 0 | 21,573 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.