ast_errors
stringlengths
0
3.2k
d_id
int64
44
121k
id
int64
70
338k
n_whitespaces
int64
3
14k
path
stringlengths
8
134
n_words
int64
4
4.82k
n_identifiers
int64
1
131
random_cut
stringlengths
16
15.8k
commit_message
stringlengths
2
15.3k
fun_name
stringlengths
1
84
commit_id
stringlengths
40
40
repo
stringlengths
3
28
file_name
stringlengths
5
79
ast_levels
int64
6
31
nloc
int64
1
548
url
stringlengths
31
59
complexity
int64
1
66
token_counts
int64
6
2.13k
n_ast_errors
int64
0
28
vocab_size
int64
4
1.11k
n_ast_nodes
int64
15
19.2k
language
stringclasses
1 value
documentation
dict
code
stringlengths
101
62.2k
@sympify_method_args
48,788
198,089
34
sympy/core/expr.py
12
7
def _imaginary_unit_as_coefficient(arg): if getattr(arg, 'is_real', True): return None else: return arg.as_coefficient(
move _imaginary_unit_as_coefficient to sympy.core.expr
_imaginary_unit_as_coefficient
bad8e3c1d614a05a0b1c6a05c21720f8751f0f2b
sympy
expr.py
11
5
https://github.com/sympy/sympy.git
2
29
1
11
54
Python
{ "docstring": " Helper to extract symbolic coefficient for imaginary unit ", "language": "en", "n_whitespaces": 9, "n_words": 8, "vocab_size": 8 }
def _imaginary_unit_as_coefficient(arg): if getattr(arg, 'is_real', True): return None else: return arg.as_coefficient(S.ImaginaryUnit) @sympify_method_args
83,198
279,959
100
keras/optimizers/optimizer_experimental/optimizer.py
19
8
def from_config(cls, config, custom_objects=None): if "learning_rate" in config: if isinstance(config["learning_rate"], dict): config["learning_rate"] = learning_rate_schedule.deserialize( config["learning_rate"], custom_objects=custom_objects
Some changes on the new optimizer: 1. Include `custom_objects` in `from_config` for deserializing custom learning rate. 2. Handle the error of seeing unrecognized variable with a better error message. PiperOrigin-RevId: 476505974
from_config
51a6050b936ec87cd684fc1a052f79785ec9aaec
keras
optimizer.py
14
7
https://github.com/keras-team/keras.git
3
52
0
18
88
Python
{ "docstring": "Creates an optimizer from its config.\n\n This method is the reverse of `get_config`, capable of instantiating the\n same optimizer from the config dictionary.\n\n Args:\n config: A Python dictionary, typically the output of get_config.\n custom_objects: A Py...
def from_config(cls, config, custom_objects=None): if "learning_rate" in config: if isinstance(config["learning_rate"], dict): config["learning_rate"] = learning_rate_schedule.deserialize( config["learning_rate"], custom_objects=custom_objects ...
117,113
320,283
363
src/paperless_mail/tests/test_parsers_live.py
81
32
def test_generate_pdf_from_mail(self): mail = self.parser.get_parsed(os.path.join(self.SAMPLE_FILES, "html.eml")) pdf_path = os.path.join(self.parser.tempdir, "html.eml.pdf") with open(pdf_path, "wb") as file: file.write(self.parser.generate_pdf_from_mail(mail)) c...
add test comments
test_generate_pdf_from_mail
4aa318598fd0dc6c5d4e08dd2a13e7bf614511ec
paperless-ngx
test_parsers_live.py
12
30
https://github.com/paperless-ngx/paperless-ngx.git
1
176
0
70
291
Python
{ "docstring": "\n GIVEN:\n - Fresh start\n WHEN:\n - pdf generation from simple eml file is requested\n THEN:\n - gotenberg is called and the resulting file is returned and look as expected.\n ", "language": "en", "n_whitespaces": 91, "n_words": 29, ...
def test_generate_pdf_from_mail(self): mail = self.parser.get_parsed(os.path.join(self.SAMPLE_FILES, "html.eml")) pdf_path = os.path.join(self.parser.tempdir, "html.eml.pdf") with open(pdf_path, "wb") as file: file.write(self.parser.generate_pdf_from_mail(mail)) c...
53,380
212,750
460
DemoPrograms/Demo_Desktop_Widget_Drive_Usage_Gauges.py
100
33
def new(self, degree=0, color=None): (center_x, center_y, angle, inner_radius, outer_radius, outer_color, pointer_color, origin_color, line_width) = self.all pointer_color = color or pointer_color if self.figure != []: for figure in self.figu...
More demo programs updates 🤦‍♂️ wow.....I thought for sure these were checked in....
new
430d1bc77fcdc0969a66ff370ec5e7e590423c83
PySimpleGUI
Demo_Desktop_Widget_Drive_Usage_Gauges.py
13
19
https://github.com/PySimpleGUI/PySimpleGUI.git
4
238
0
61
354
Python
{ "docstring": "\n Draw new pointer by angle, erase old pointer if exist\n degree defined as clockwise from negative x-axis.\n ", "language": "en", "n_whitespaces": 51, "n_words": 17, "vocab_size": 16 }
def new(self, degree=0, color=None): (center_x, center_y, angle, inner_radius, outer_radius, outer_color, pointer_color, origin_color, line_width) = self.all pointer_color = color or pointer_color if self.figure != []: for figure in self.figu...
10,241
50,918
610
modules/image/object_detection/yolov3_darknet53_vehicles/processor.py
172
48
def postprocess(paths, images, data_out, score_thresh, label_names, output_dir, handle_id, visualization=True): results = data_out.copy_to_cpu() lod = data_out.lod()[0] check_dir(output_dir) if paths: assert type(paths) is list, "type(paths) is not list." if handle_id < len(paths)...
update yolov3_darknet53_vehicles (#1957) * update yolov3_darknet53_vehicles * update gpu config * update * add clean func * update save inference model
postprocess
7a847a39b1da6e6867031f52f713d92391b9729d
PaddleHub
processor.py
19
50
https://github.com/PaddlePaddle/PaddleHub.git
13
380
0
107
611
Python
{ "docstring": "\n postprocess the lod_tensor produced by Executor.run\n\n Args:\n paths (list[str]): The paths of images.\n images (list(numpy.ndarray)): images data, shape of each is [H, W, C]\n data_out (lod_tensor): data output of predictor.\n output_dir (str): The path to store ...
def postprocess(paths, images, data_out, score_thresh, label_names, output_dir, handle_id, visualization=True): results = data_out.copy_to_cpu() lod = data_out.lod()[0] check_dir(output_dir) if paths: assert type(paths) is list, "type(paths) is not list." if handle_id < len(paths)...
@pytest.fixture(params=_index_or_series_objs.keys())
40,068
167,616
102
pandas/conftest.py
59
28
def series_with_multilevel_index() -> Series: arrays = [ ["bar", "bar", "baz", "baz", "qux", "qux", "foo", "foo"], ["one", "two", "one", "two", "one", "two", "one", "two"], ] tuples = zip(*arrays) index = MultiIndex.from_tuples(tuples) da
TYP: misc return type annotations (#47558)
series_with_multilevel_index
f538568afc2c76c2d738d32e3544cf9fe6742960
pandas
conftest.py
10
14
https://github.com/pandas-dev/pandas.git
1
92
1
45
249
Python
{ "docstring": "\n Fixture with a Series with a 2-level MultiIndex.\n ", "language": "en", "n_whitespaces": 15, "n_words": 8, "vocab_size": 6 }
def series_with_multilevel_index() -> Series: arrays = [ ["bar", "bar", "baz", "baz", "qux", "qux", "foo", "foo"], ["one", "two", "one", "two", "one", "two", "one", "two"], ] tuples = zip(*arrays) index = MultiIndex.from_tuples(tuples) data = np.random.randn(8) ser = Series(...
106,436
307,668
46
homeassistant/components/group/__init__.py
10
3
def _async_stop(self) -> None: if self._async_unsub_state_changed: self._async_unsub_state_changed() self._async_unsub_state_ch
Improve type hints in group (#78350)
_async_stop
5cccb248307d138a33c353544c57dc997b4fe917
core
__init__.py
9
8
https://github.com/home-assistant/core.git
2
23
0
10
41
Python
{ "docstring": "Unregister the group from Home Assistant.\n\n This method must be run in the event loop.\n ", "language": "en", "n_whitespaces": 29, "n_words": 15, "vocab_size": 14 }
def _async_stop(self) -> None: if self._async_unsub_state_changed: self._async_unsub_state_changed() self._async_unsub_state_changed = None
@pytest.fixture(scope="session")
11,567
56,814
129
tests/conftest.py
51
12
def test_database_connection_url(generate_test_database_connection_url): url = generate_test_database_connection_url if url is None: yield None else: # TODO: https://github.com/PrefectHQ/orion/issues/2045 # Also temporarily override the environment variable, so that child ...
:facepalm: I got bitten by the async fixture context issue. Fixed and added comments to help future developers.
test_database_connection_url
ef032ee4a8f5d357a6e8dadf4021177ccc71f767
prefect
conftest.py
14
10
https://github.com/PrefectHQ/prefect.git
2
56
1
39
122
Python
{ "docstring": "\n Update the setting for the database connection url to the generated value from\n `generate_test_database_connection_url`\n\n This _must_ be separate from the generation of the test url because async fixtures\n are run in a separate context from the test suite.\n ", "language": "en"...
def test_database_connection_url(generate_test_database_connection_url): url = generate_test_database_connection_url if url is None: yield None else: # TODO: https://github.com/PrefectHQ/orion/issues/2045 # Also temporarily override the environment variable, so that child ...
27,941
125,665
84
python/ray/tune/examples/optuna_define_by_run_example.py
50
9
def define_by_run_func(trial) -> Optional[Dict[str, Any]]: # This param is not used in the objective function. activation = trial.suggest_categorical("activation", ["relu", "tanh"]) trial.suggest_float("width", 0, 20) trial.suggest_float("height", -100, 100) # Define-by-run allows for conditio...
[air/tuner/docs] Update docs for Tuner() API 2a: Tune examples (non-docs) (#26931) Splitting up #26884: This PR includes changes to use Tuner() instead of tune.run() for all examples included in python/ray/tune/examples Signed-off-by: xwjiang2010 <xwjiang2010@gmail.com> Signed-off-by: Kai Fricke <kai@anyscale.com>...
define_by_run_func
8d7b865614f3635def12c42b653f8acd8b4ae56a
ray
optuna_define_by_run_example.py
10
18
https://github.com/ray-project/ray.git
2
72
0
46
127
Python
{ "docstring": "Define-by-run function to create the search space.\n\n Ensure no actual computation takes place here. That should go into\n the trainable passed to ``Tuner`` (in this example, that's\n ``easy_objective``).\n\n For more information, see https://optuna.readthedocs.io/en/stable\\\n/tutorial/1...
def define_by_run_func(trial) -> Optional[Dict[str, Any]]: # This param is not used in the objective function. activation = trial.suggest_categorical("activation", ["relu", "tanh"]) trial.suggest_float("width", 0, 20) trial.suggest_float("height", -100, 100) # Define-by-run allows for conditio...
43,616
181,843
142
tpot/base.py
34
16
def _compile_to_sklearn(self, expr): sklearn_pipeline_str = generate_pipeline_code( expr_to_tree(expr, self._pset), self.operators ) sklearn_pipeline = eval(sklearn_pipeline_str, self.operators_context) sklearn_pipeline.memory = self._memory if self.random_st...
Revert "Deployed 7ccda9a with MkDocs version: 1.3.0" This reverts commit bd9629c40e01241766197119b581a99409b07068.
_compile_to_sklearn
388616b6247ca4ea8de4e2f340d6206aee523541
tpot
base.py
11
11
https://github.com/EpistasisLab/tpot.git
2
61
0
30
97
Python
{ "docstring": "Compile a DEAP pipeline into a sklearn pipeline.\n\n Parameters\n ----------\n expr: DEAP individual\n The DEAP pipeline to be compiled\n\n Returns\n -------\n sklearn_pipeline: sklearn.pipeline.Pipeline\n ", "language": "en", "n_whitespa...
def _compile_to_sklearn(self, expr): sklearn_pipeline_str = generate_pipeline_code( expr_to_tree(expr, self._pset), self.operators ) sklearn_pipeline = eval(sklearn_pipeline_str, self.operators_context) sklearn_pipeline.memory = self._memory if self.random_st...
47,902
196,402
189
sympy/matrices/repmatrix.py
49
13
def equals(self, other, failing_expression=False): if self.shape != getattr(other, 'shape', None): retu
Moved imports to higher level
equals
59d22b6bb7287613d598611027f640d068ca5748
sympy
repmatrix.py
13
12
https://github.com/sympy/sympy.git
7
93
0
32
141
Python
{ "docstring": "Applies ``equals`` to corresponding elements of the matrices,\n trying to prove that the elements are equivalent, returning True\n if they are, False if any pair is not, and None (or the first\n failing expression if failing_expression is True) if it cannot\n be decided if ...
def equals(self, other, failing_expression=False): if self.shape != getattr(other, 'shape', None): return False rv = True for i in range(self.rows): for j in range(self.cols): ans = self[i, j].equals(other[i, j], failing_expression) ...
73,623
251,177
44
mitmproxy/addons/blocklist.py
8
6
def load(self, loader): loader.add_option( "b
use Python 3.9+ typing
load
fdde9ba3b3caaa2654048cec0af07bfcc3a6a3f8
mitmproxy
blocklist.py
8
11
https://github.com/mitmproxy/mitmproxy.git
1
23
0
8
37
Python
{ "docstring": "\n Block matching requests and return an empty response with the specified HTTP status.\n Option syntax is \"/flow-filter/status-code\", where flow-filter describes\n which requests this rule should be applied to and status-code is the HTTP status code to return for\n ...
def load(self, loader): loader.add_option( "block_list", Sequence[str], [], )
1,691
9,778
59
gensim/models/translation_matrix.py
24
15
def train(self, tagged_docs): m1 = [self.source_lang_vec.dv[item.tags].flatten() for item in tagged_docs] m2 = [self.ta
Replace np.multiply with np.square and copyedit in translation_matrix.py (#3374) * Replace np.multiply with np.square and copyedit * Copyedit translation_matrix.py Co-authored-by: Michael Penkov <m@penkov.dev>
train
77c3a7ff5254346146d0e9eedf8e84fb6d577878
gensim
translation_matrix.py
12
5
https://github.com/RaRe-Technologies/gensim.git
3
76
0
17
116
Python
{ "docstring": "Build the translation matrix to map from the source model's vectors to target model's vectors\n\n Parameters\n ----------\n tagged_docs : list of :class:`~gensim.models.doc2vec.TaggedDocument`, Documents\n that will be used for training, both the source language documen...
def train(self, tagged_docs): m1 = [self.source_lang_vec.dv[item.tags].flatten() for item in tagged_docs] m2 = [self.target_lang_vec.dv[item.tags].flatten() for item in tagged_docs] self.translation_matrix = np.linalg.lstsq(m2, m1, -1)[0] return self.translation_matrix
12,993
62,568
35
.venv/lib/python3.8/site-packages/pip/_vendor/html5lib/serializer.py
20
11
def serialize(input, tree="etree", encoding=None, **serializer_opts): # XXX: Should we cache this? walker = treewalkers.getTreeWalker(tree) s = HTMLSerializer(**serializer_opts) return s.render(walker(input), encoding)
upd; format
serialize
f638f5d0e6c8ebed0e69a6584bc7f003ec646580
transferlearning
serializer.py
9
4
https://github.com/jindongwang/transferlearning.git
1
44
0
19
73
Python
{ "docstring": "Serializes the input token stream using the specified treewalker\n\n :arg input: the token stream to serialize\n\n :arg tree: the treewalker to use\n\n :arg encoding: the encoding to use\n\n :arg serializer_opts: any options to pass to the\n :py:class:`html5lib.serializer.HTMLSerial...
def serialize(input, tree="etree", encoding=None, **serializer_opts): # XXX: Should we cache this? walker = treewalkers.getTreeWalker(tree) s = HTMLSerializer(**serializer_opts) return s.render(walker(input), encoding)
1,853
10,563
83
jina/parsers/__init__.py
28
13
def set_client_cli_parser(parser=None): if not parser: from jina.parsers.base import set_base_parser parser = set_base_parser() from jina.parsers.peapods.runtimes.remote import mixin_client_gateway_parser from jina.parsers.client import ( mixin_client_features_parser, ...
refactor: use absolute imports (#4167)
set_client_cli_parser
cea300655ed8be70d74c390ca12e8b09fb741665
jina
__init__.py
10
13
https://github.com/jina-ai/jina.git
2
64
0
23
99
Python
{ "docstring": "Set the parser for the cli client\n\n :param parser: an optional existing parser to build upon\n :return: the parser\n ", "language": "en", "n_whitespaces": 28, "n_words": 19, "vocab_size": 15 }
def set_client_cli_parser(parser=None): if not parser: from jina.parsers.base import set_base_parser parser = set_base_parser() from jina.parsers.peapods.runtimes.remote import mixin_client_gateway_parser from jina.parsers.client import ( mixin_client_features_parser, ...
5,141
27,924
111
saleor/graphql/discount/mutations/sale_create.py
36
17
def send_sale_toggle_notification(info, instance, catalogue): manager = info.context.plugins now = datetime.now(pytz.utc) start_date = instance.start_date end_date = instance.end_date if (start_date and start_date <= now) and (not end_date or not end_date <= now): ...
New event for starting and ending sales (#10110) * Add sale started and sale ended webhooks * Add started_notification_sent and ended_notification_sent flags to Sale model * Add sale_webhook_schedule * Add send_sale_started_and_sale_ended_notifications discount task * Add tests for discount tasks * Move...
send_sale_toggle_notification
67492396aa41d068cac82e8fa328f218b5951d13
saleor
sale_create.py
12
9
https://github.com/saleor/saleor.git
5
79
0
26
128
Python
{ "docstring": "Send a notification about starting or ending sale if it hasn't been sent yet.\n\n Send the notification when the start date is before the current date and the\n sale is not already finished.\n ", "language": "en", "n_whitespaces": 54, "n_words": 33, "vocab_size": 25 }
def send_sale_toggle_notification(info, instance, catalogue): manager = info.context.plugins now = datetime.now(pytz.utc) start_date = instance.start_date end_date = instance.end_date if (start_date and start_date <= now) and (not end_date or not end_date <= now): ...
@bcoo_todense_p.def_impl
26,536
119,028
11
jax/experimental/sparse/bcoo.py
10
9
def bcoo_todense(data, indices, *, spinfo): return bcoo_todense_p.bind(jnp.asarray(data), jnp.asarray(indices), spinfo=spin
[sparse] generalize metadata argument in BCOO primitives
bcoo_todense
2c20d82776fea482aaf52e18ebad4f7fce5c3a81
jax
bcoo.py
9
2
https://github.com/google/jax.git
1
35
1
10
61
Python
{ "docstring": "Convert batched sparse matrix to a dense matrix.\n\n Args:\n data : array of shape ``batch_dims + (nse,) + block_dims``.\n indices : array of shape ``batch_dims + (n_sparse, nse)``\n spinfo : BCOOInfo. In particular, this includes the shape\n of the matrix, which is equal to ``batch_dim...
def bcoo_todense(data, indices, *, spinfo): return bcoo_todense_p.bind(jnp.asarray(data), jnp.asarray(indices), spinfo=spinfo) @bcoo_todense_p.def_impl
30,685
135,648
48
rllib/utils/actor_manager.py
16
10
def ignore_ray_errors(self) -> Iterator[ResultOrError]: return self._Iterator( [r for r in self.result_or_errors if not isinstance(r.ge
Refactor ActorManager to store underlying remote actors in dict. (#29953) Signed-off-by: Jun Gong <jungong@anyscale.com>
ignore_ray_errors
b84dac2609bd587c43ed17bb6fa18fb7241a41de
ray
actor_manager.py
14
10
https://github.com/ray-project/ray.git
3
38
0
16
61
Python
{ "docstring": "Return an iterator over the results, skipping only Ray errors.\n\n Similar to ignore_errors, but only skips Errors raised from the\n Ray framework. This is useful for application that wants to handle\n errors from user code differently.\n ", "language": "en", "n_whitesp...
def ignore_ray_errors(self) -> Iterator[ResultOrError]: return self._Iterator( [r for r in self.result_or_errors if not isinstance(r.get(), RayError)] )
@dataclasses.dataclass
117,906
321,782
70
qutebrowser/utils/usertypes.py
21
7
def certificate_was_accepted(self) -> None: if not self.is_overridable(): return False if self._certificate_accepted is None: raise ValueError("No decision taken yet") return self._certificate_accepted
lint: Fix remaining pylint issues
certificate_was_accepted
ec8eebf99640d5a73072d05e73c6ea9b2ebea556
qutebrowser
usertypes.py
10
7
https://github.com/qutebrowser/qutebrowser.git
3
34
1
17
67
Python
{ "docstring": "Check whether the certificate was accepted by the user.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 8 }
def certificate_was_accepted(self) -> None: if not self.is_overridable(): return False if self._certificate_accepted is None: raise ValueError("No decision taken yet") return self._certificate_accepted @dataclasses.dataclass
35,292
153,191
65
modin/core/execution/ray/implementations/pandas_on_ray/partitioning/virtual_partition.py
11
6
def mask(self, row_indices, col_indices):
FIX-#3675: Expand virtual partitioning utility (#3886) Co-authored-by: mvashishtha <mahesh@ponder.io> Co-authored-by: jeffreykennethli <jkli@ponder.io> Co-authored-by: Anatoly Myachev <anatoly.myachev@intel.com> Co-authored-by: Vasily Litvinov <vasilij.n.litvinov@intel.com> Co-authored-by: Alexey Prutskov <alexey....
mask
8d1004fdbdaa05700613c8e6287641a732acf606
modin
virtual_partition.py
12
6
https://github.com/modin-project/modin.git
1
30
0
11
47
Python
{ "docstring": "\n Create (synchronously) a mask that extracts the indices provided.\n\n Parameters\n ----------\n row_indices : list-like, slice or label\n The row labels for the rows to extract.\n col_indices : list-like, slice or label\n The column labels fo...
def mask(self, row_indices, col_indices): return ( self.force_materialization() .list_of_partitions_to_combine[0] .mask(row_indices, col_indices) )
48,898
198,386
92
sympy/integrals/intpoly.py
46
20
def left_integral3D(facets, index, expr, vertices, hp_param, degree): value = S.Zero facet = facets[index] x0 = vertices[fac
Cleanup loops and ranges
left_integral3D
7d773eb18daaef3c54f34d1ac6cbc5b83a5bb16c
sympy
intpoly.py
14
10
https://github.com/sympy/sympy.git
2
103
0
37
149
Python
{ "docstring": "Computes the left integral of Eq 10 in Chin et al.\n\n Explanation\n ===========\n\n For the 3D case, this is the sum of the integral values over constituting\n line segments of the face (which is accessed by facets[index]) multiplied\n by the distance between the first point of facet a...
def left_integral3D(facets, index, expr, vertices, hp_param, degree): value = S.Zero facet = facets[index] x0 = vertices[facet[0]] facet_len = len(facet) for i, fac in enumerate(facet): side = (vertices[fac], vertices[facet[(i + 1) % facet_len]]) value += distance_to_side(x0, si...
6,017
32,887
111
src/transformers/models/deberta/modeling_tf_deberta.py
32
21
def xdropout(self, inputs): mask = tf.cast( 1 - tf.compat.v1.distributions.Bernoulli(probs=1.0 - self.drop_prob).sample(sample_shape=shape_list(inputs)), tf.bool,
TF: XLA-trainable DeBERTa v2 (#18546) * fix deberta issues * add different code paths for gpu and tpu * shorter gpu take along axis * Stable Dropout without tf cond * variable must be float
xdropout
34aad0dac000508015d09ed7cf7c88adb5a0e308
transformers
modeling_tf_deberta.py
16
11
https://github.com/huggingface/transformers.git
2
105
0
27
143
Python
{ "docstring": "\n Applies dropout to the inputs, as vanilla dropout, but also scales the remaining elements up by 1/drop_prob.\n ", "language": "en", "n_whitespaces": 32, "n_words": 17, "vocab_size": 16 }
def xdropout(self, inputs): mask = tf.cast( 1 - tf.compat.v1.distributions.Bernoulli(probs=1.0 - self.drop_prob).sample(sample_shape=shape_list(inputs)), tf.bool, ) scale = tf.convert_to_tensor(1.0 / (1 - self.drop_prob), dtype=tf.float32) if ...
26,500
118,955
122
lib/tests/streamlit/legacy_add_rows_test.py
35
17
def test_deltas_that_melt_dataframes(self): deltas = self._get_deltas_that_melt_dataframe
Remove legacy "`add_rows` coalescing" from ForwardMsgQueue (#4485) Removes the `add_rows` legacy DataFrame concatenation implementation _from Python_. (To be clear: `add_rows` still works for legacy DataFrames, but the logic is frontend-only now. This is already how Arrow DataFrame concatenation is implemented.) ##...
test_deltas_that_melt_dataframes
0f76064dbb9b9405173effe7f872aa8a8dba69cc
streamlit
legacy_add_rows_test.py
13
8
https://github.com/streamlit/streamlit.git
2
74
0
30
116
Python
{ "docstring": "Some element types require that their dataframes are\n 'melted' (https://pandas.pydata.org/docs/reference/api/pandas.melt.html)\n before being sent to the frontend. Test that the melting occurs.\n ", "language": "en", "n_whitespaces": 43, "n_words": 21, "vocab_size": 19 }
def test_deltas_that_melt_dataframes(self): deltas = self._get_deltas_that_melt_dataframes() for delta in deltas: el = delta(DATAFRAME) el._legacy_add_rows(NEW_ROWS) df_proto = _get_data_frame(self.get_delta_from_queue()) # Test that the add_ro...
45,948
188,973
1,294
psutil/_pslinux.py
326
47
def sensors_temperatures(): ret = collections.defaultdict(list) basenames = glob.glob('/sys/class/hwmon/hwmon*/temp*_*') # CentOS has an intermediate /device directory: # https://github.com/giampaolo/psutil/issues/971 # https://github.com/nicolargo/glances/issues/1060 basenames.extend(glob....
[Linux] cat/bcat utils refactoring (#2053)
sensors_temperatures
46cb6c212a870b36bd0af17c48dd29f53468734b
psutil
_pslinux.py
21
72
https://github.com/giampaolo/psutil.git
21
563
0
150
928
Python
{ "docstring": "Return hardware (CPU and others) temperatures as a dict\n including hardware name, label, current, max and critical\n temperatures.\n\n Implementation notes:\n - /sys/class/hwmon looks like the most recent interface to\n retrieve this info, and this implementation relies on it\n ...
def sensors_temperatures(): ret = collections.defaultdict(list) basenames = glob.glob('/sys/class/hwmon/hwmon*/temp*_*') # CentOS has an intermediate /device directory: # https://github.com/giampaolo/psutil/issues/971 # https://github.com/nicolargo/glances/issues/1060 basenames.extend(glob....
15,901
72,541
223
wagtail/admin/views/pages/workflow.py
68
36
def preview_revision_for_task(request, page_id, task_id):
Reformat with black
preview_revision_for_task
d10f15e55806c6944827d801cd9c2d53f5da4186
wagtail
workflow.py
15
24
https://github.com/wagtail/wagtail.git
3
140
0
57
221
Python
{ "docstring": "Preview the revision linked to the in-progress TaskState of a specified Task. This enables pages in moderation\n to be edited and new TaskStates linked to the new revisions created, with preview links remaining valid", "language": "en", "n_whitespaces": 36, "n_words": 34, "vocab_size": 28 }
def preview_revision_for_task(request, page_id, task_id): page = get_object_or_404(Page, id=page_id) task = get_object_or_404(Task, id=task_id).specific try: task_state = TaskState.objects.get( page_revision__page=page, task=task, status=TaskState.STATUS_IN_PROGRESS ) e...
56,492
221,726
94
python3.10.4/Lib/contextlib.py
44
9
def push_async_callback(self, callback, /, *args, **kwds): _exit_wrapper = self._create_async_cb_wrapper(callback, *args, **kwds) # We changed the signature, so using @wraps is not appropriate, but # setti
add python 3.10.4 for windows
push_async_callback
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
contextlib.py
9
5
https://github.com/XX-net/XX-Net.git
1
45
0
39
73
Python
{ "docstring": "Registers an arbitrary coroutine function and arguments.\n\n Cannot suppress exceptions.\n ", "language": "en", "n_whitespaces": 24, "n_words": 10, "vocab_size": 10 }
def push_async_callback(self, callback, /, *args, **kwds): _exit_wrapper = self._create_async_cb_wrapper(callback, *args, **kwds) # We changed the signature, so using @wraps is not appropriate, but # setting __wrapped__ may still help with introspection. _exit_wrapper.__wrapped...
13,285
63,394
789
.venv/lib/python3.8/site-packages/pip/_vendor/pyparsing.py
135
35
def scanString(self, instring, maxMatches=_MAX_INT, overlap=False): if not self.streamlined: self.streamline() for e in self.ignoreExprs: e.streamline() if not self.keepTabs: instring = _ustr(instring).expandtabs() instrlen = len(instring) ...
upd; format
scanString
f638f5d0e6c8ebed0e69a6584bc7f003ec646580
transferlearning
pyparsing.py
20
41
https://github.com/jindongwang/transferlearning.git
13
217
0
80
354
Python
{ "docstring": "\n Scan the input string for expression matches. Each match will return the\n matching tokens, start location, and end location. May be called with optional\n ``maxMatches`` argument, to clip scanning after 'n' matches are found. If\n ``overlap`` is specified, then overl...
def scanString(self, instring, maxMatches=_MAX_INT, overlap=False): if not self.streamlined: self.streamline() for e in self.ignoreExprs: e.streamline() if not self.keepTabs: instring = _ustr(instring).expandtabs() instrlen = len(instring) ...
35,932
154,339
83
modin/core/execution/dask/implementations/pandas_on_dask/partitioning/partition.py
18
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, )
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>
add_to_apply_calls
39b36eb2a2e3bf3d612933e1c78545a8bb28cde4
modin
partition.py
11
7
https://github.com/modin-project/modin.git
1
54
0
18
76
Python
{ "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...
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, )
6,208
34,178
141
src/transformers/feature_extraction_utils.py
48
18
def to_json_string(self) -> str: dictionary = self.to_dict() for key, value in dictionary.items(): if isinstance(value, np.ndarray): dictionary[key] = value.tolist() # make sure private name "_processor_class" is correctly # saved as "processor_clas...
[ASR pipeline] correct with lm pipeline (#15200) * [ASR pipeline] correct with lm pipeline * improve error
to_json_string
497346d07ec39da3a7f38a7e0a67a4906c141ea3
transformers
feature_extraction_utils.py
12
15
https://github.com/huggingface/transformers.git
4
85
0
40
142
Python
{ "docstring": "\n Serializes this instance to a JSON string.\n\n Returns:\n `str`: String containing all the attributes that make up this feature_extractor instance in JSON format.\n ", "language": "en", "n_whitespaces": 56, "n_words": 23, "vocab_size": 20 }
def to_json_string(self) -> str: dictionary = self.to_dict() for key, value in dictionary.items(): if isinstance(value, np.ndarray): dictionary[key] = value.tolist() # make sure private name "_processor_class" is correctly # saved as "processor_clas...
5,070
26,810
357
saleor/core/permissions/__init__.py
125
28
def one_of_permissions_or_auth_filter_required(context, permissions): if not permissions: return True authorization_filters = [ p for p in permissions if isinstance(p, AuthorizationFilters) ] permissions = [p for p in permissions if not isinstance(p, AuthorizationFilters)] gra...
Include permissions in schema descriptions of protected fields (#9428) * POC Generate permission description for queries * Use PermissionField for app queries * Rename functions checking object ownership * Switch to PermissionsField in more fields * CR fixes * Add missing descriptions
one_of_permissions_or_auth_filter_required
f0a988e798dd86befbbf7a0eda1bc1a8cc94dda2
saleor
__init__.py
16
29
https://github.com/saleor/saleor.git
14
172
0
76
278
Python
{ "docstring": "Determine whether user or app has rights to perform an action.\n\n The `context` parameter is the Context instance associated with the request.\n ", "language": "en", "n_whitespaces": 28, "n_words": 22, "vocab_size": 21 }
def one_of_permissions_or_auth_filter_required(context, permissions): if not permissions: return True authorization_filters = [ p for p in permissions if isinstance(p, AuthorizationFilters) ] permissions = [p for p in permissions if not isinstance(p, AuthorizationFilters)] gra...
33,344
144,928
45
python/ray/_private/runtime_env/_clonevirtualenv.py
19
8
def _dirmatch(path, matchwith): matchlen = len(matchwith) if (path.startswith(matchwith)
[runtime env] Support clone `virtualenv` from an existing `virtualenv` (#22309) Before this PR, we can't run ray in virtualenv, cause `runtime_env` does not support create a new virtualenv from an existing virtualenv. More details:https://github.com/ray-project/ray/pull/21801#discussion_r796848499 Co-authored-b...
_dirmatch
4c73560b313821fbfbb8c943e02c8b298b7c1731
ray
_clonevirtualenv.py
11
6
https://github.com/ray-project/ray.git
3
45
0
18
73
Python
{ "docstring": "Check if path is within matchwith's tree.\n >>> _dirmatch('/home/foo/bar', '/home/foo/bar')\n True\n >>> _dirmatch('/home/foo/bar/', '/home/foo/bar')\n True\n >>> _dirmatch('/home/foo/bar/etc', '/home/foo/bar')\n True\n >>> _dirmatch('/home/foo/bar2', '/home/foo/bar')\n False\n...
def _dirmatch(path, matchwith): matchlen = len(matchwith) if (path.startswith(matchwith) and path[matchlen:matchlen + 1] in [os.sep, '']): return True return False
70,270
244,173
79
mmdet/models/dense_heads/tood_head.py
37
13
def deform_sampling(self, feat, offset): # it is an equivalent implementation of bilinear interpolation b, c, h, w = feat.shape weight = feat.new_ones(c, 1, 1, 1) y = deform_conv2d(feat, offset, weight, 1, 0, 1, c, c) return y
[Fix] Avoid invalid bbox after deform_sampling (#7567) * Avoid invalid bbox after deform_sampling * replace in-place opertion with torch.where, update docstring * Update
deform_sampling
b403751bd409795cf63fcc6aa7ee280326358bac
mmdetection
tood_head.py
8
5
https://github.com/open-mmlab/mmdetection.git
1
57
0
30
79
Python
{ "docstring": "Sampling the feature x according to offset.\n\n Args:\n feat (Tensor): Feature\n offset (Tensor): Spatial offset for feature sampling\n ", "language": "en", "n_whitespaces": 54, "n_words": 18, "vocab_size": 15 }
def deform_sampling(self, feat, offset): # it is an equivalent implementation of bilinear interpolation b, c, h, w = feat.shape weight = feat.new_ones(c, 1, 1, 1) y = deform_conv2d(feat, offset, weight, 1, 0, 1, c, c) return y
17,285
81,965
694
awxkit/awxkit/api/pages/page.py
171
47
def page_identity(self, response, request_json=None): request_path = response.request.path_url if request_path == '/migrations_notran/': raise exc.IsMigrating('You have been redirected to the migration-in-progress page.') request_method = response.request.method.lower() ...
Register pages for the Instance peers and install bundle endpoints This includes exposing a new interface for Page objects, Page.bytes, to return the full bytestring contents of the response.
page_identity
68a44529b6b77d2d43d7099b654560bfd8bbf518
awx
page.py
13
44
https://github.com/ansible/awx.git
15
337
0
104
536
Python
{ "docstring": "Takes a `requests.Response` and\n returns a new __item_class__ instance if the request method is not a get, or returns\n a __class__ instance if the request path is different than the caller's `endpoint`.\n ", "language": "en", "n_whitespaces": 56, "n_words": 32, "vocab...
def page_identity(self, response, request_json=None): request_path = response.request.path_url if request_path == '/migrations_notran/': raise exc.IsMigrating('You have been redirected to the migration-in-progress page.') request_method = response.request.method.lower() ...
21,442
102,077
108
lib/sysinfo.py
33
16
def _installed_conda(self): if not self._is_conda: return None with Popen("conda list", shell=True, stdout=PIPE, stderr=PIPE) as conda: stdout, stderr = conda.communicate() if stderr: return "Could not get package list" installed = stdout.deco...
Allow decoding errors
_installed_conda
48c886b3dce3d3117ad16edaf35c8abd28dc51f5
faceswap
sysinfo.py
12
9
https://github.com/deepfakes/faceswap.git
3
73
0
28
128
Python
{ "docstring": " str: The list of installed Conda packages within Faceswap's scope. ", "language": "en", "n_whitespaces": 11, "n_words": 10, "vocab_size": 10 }
def _installed_conda(self): if not self._is_conda: return None with Popen("conda list", shell=True, stdout=PIPE, stderr=PIPE) as conda: stdout, stderr = conda.communicate() if stderr: return "Could not get package list" installed = stdout.deco...
7,193
39,296
86
recommenders/models/sasrec/model.py
30
14
def embedding(self, input_seq): seq_embeddings = self.item_embedding_layer(input_seq) seq_embeddings = seq_embeddings * (self.embedding_dim ** 0.5) # FIXME positional_seq = tf.expand_dims(tf.range(tf.shape(input_seq)[1]), 0)
doc
embedding
d38dffc30c18e9e3280863b32dcc71d01757b181
recommenders
model.py
13
7
https://github.com/microsoft/recommenders.git
1
86
0
22
132
Python
{ "docstring": "Compute the sequence and positional embeddings.\n\n Args:\n input_seq (tf.Tensor): Input sequence\n \n Returns:\n tf.Tensor, tf.Tensor:\n - Sequence embeddings.\n - Positional embeddings.\n \n ", "language": "en", "n_wh...
def embedding(self, input_seq): seq_embeddings = self.item_embedding_layer(input_seq) seq_embeddings = seq_embeddings * (self.embedding_dim ** 0.5) # FIXME positional_seq = tf.expand_dims(tf.range(tf.shape(input_seq)[1]), 0) positional_seq = tf.tile(positional_seq, [tf...
78,648
266,902
808
lib/ansible/utils/display.py
223
36
def display(self, msg, color=None, stderr=False, screen_only=False, log_only=False, newline=True): nocolor = msg if not log_only: has_newline = msg.endswith(u'\n') if has_newline: msg2 = msg[:-1] else: msg2 = msg ...
Remove obsolete Python 2.x controller code.
display
6f445ca6e5c9c8b85ccc5062e00508c69ca26fde
ansible
display.py
16
34
https://github.com/ansible/ansible.git
13
229
0
128
385
Python
{ "docstring": " Display a message to the user\n\n Note: msg *must* be a unicode string to prevent UnicodeError tracebacks.\n ", "language": "en", "n_whitespaces": 32, "n_words": 17, "vocab_size": 15 }
def display(self, msg, color=None, stderr=False, screen_only=False, log_only=False, newline=True): nocolor = msg if not log_only: has_newline = msg.endswith(u'\n') if has_newline: msg2 = msg[:-1] else: msg2 = msg ...
78,254
265,983
105
netbox/extras/views.py
23
13
def get_queryset(self, request): queryset = SavedFilter.objects.all() user = request.user if user.is_superuser: return queryset if user.is_anonymous: return queryset.filter(shared=True)
Closes #9623: Implement saved filters (#10801) * Initial work on saved filters * Return only enabled/shared filters * Add tests * Clean up filtering of usable SavedFilters
get_queryset
484efdaf75f267a43f9321b938fda1bc967b9e53
netbox
views.py
11
10
https://github.com/netbox-community/netbox.git
3
62
0
18
101
Python
{ "docstring": "\n Return only shared SavedFilters, or those owned by the current user, unless\n this is a superuser.\n ", "language": "en", "n_whitespaces": 38, "n_words": 16, "vocab_size": 16 }
def get_queryset(self, request): queryset = SavedFilter.objects.all() user = request.user if user.is_superuser: return queryset if user.is_anonymous: return queryset.filter(shared=True) return queryset.filter( Q(shared=True) | Q(user=u...
77,779
264,666
264
netbox/extras/api/views.py
64
36
def list(self, request):
Save old JobResults
list
f13a00b2dd33bffc3048c861b494096df457f212
netbox
views.py
18
18
https://github.com/netbox-community/netbox.git
4
135
0
54
222
Python
{ "docstring": "\n Compile all reports and their related results (if any). Result data is deferred in the list view.\n ", "language": "en", "n_whitespaces": 32, "n_words": 17, "vocab_size": 17 }
def list(self, request): report_list = [] report_content_type = ContentType.objects.get(app_label='extras', model='report') results = { r.name: r for r in JobResult.objects.filter( obj_type=report_content_type, status__in=JobResult...
78,253
265,967
121
netbox/extras/filtersets.py
38
12
def _usable(self, queryset, name, value): user = self.request.user if self.request else None if not user or user.is_anonymous: if value: return queryset.filter(enabled=True, shared=True) return queryset.filter(Q(enabled=False) | Q(shared=False))
Closes #9623: Implement saved filters (#10801) * Initial work on saved filters * Return only enabled/shared filters * Add tests * Clean up filtering of usable SavedFilters
_usable
484efdaf75f267a43f9321b938fda1bc967b9e53
netbox
filtersets.py
15
9
https://github.com/netbox-community/netbox.git
6
127
0
27
199
Python
{ "docstring": "\n Return only SavedFilters that are both enabled and are shared (or belong to the current user).\n ", "language": "en", "n_whitespaces": 31, "n_words": 16, "vocab_size": 15 }
def _usable(self, queryset, name, value): user = self.request.user if self.request else None if not user or user.is_anonymous: if value: return queryset.filter(enabled=True, shared=True) return queryset.filter(Q(enabled=False) | Q(shared=False)) i...
14,040
65,853
12
erpnext/education/api.py
23
11
def get_current_enrollment(student, academic_year=None): current_academic_year = academic_year or frappe.defaul
style: format code with black
get_current_enrollment
494bd9ef78313436f0424b918f200dab8fc7c20b
erpnext
api.py
11
19
https://github.com/frappe/erpnext.git
3
55
0
21
85
Python
{ "docstring": "\n\t\tselect\n\t\t\tname as program_enrollment, student_name, program, student_batch_name as student_batch,\n\t\t\tstudent_category, academic_term, academic_year\n\t\tfrom\n\t\t\t`tabProgram Enrollment`\n\t\twhere\n\t\t\tstudent = %s and academic_year = %s\n\t\torder by creation", "language": "en", ...
def get_current_enrollment(student, academic_year=None): current_academic_year = academic_year or frappe.defaults.get_defaults().academic_year program_enrollment_list = frappe.db.sql( , (student, current_academic_year), as_dict=1, ) if program_enrollment_list: return program_enrollment_list[0] else: ret...
@keras_export("keras.applications.inception_resnet_v2.preprocess_input")
83,430
280,749
443
keras/applications/inception_resnet_v2.py
180
28
def inception_resnet_block(x, scale, block_type, block_idx, activation="relu"): if block_type == "block35": branch_0 = conv2d_bn(x, 32, 1) branch_1 = conv2d_bn(x, 32, 1) branch_1 = conv2d_bn(branch_1, 32, 3) branch_2 = conv2d_bn(x, 32, 1) branch_2 = conv2d_bn(branch_2, 4...
Removes the serialization of lambdas Keras tests where necessary and adds SafeModeScope all other lambda-based serialization tests. PiperOrigin-RevId: 495432774
inception_resnet_block
e52c89c7d1bd52d1f0db0da86a72322ba72c1dc1
keras
inception_resnet_v2.py
14
44
https://github.com/keras-team/keras.git
6
336
1
93
520
Python
{ "docstring": "Adds an Inception-ResNet block.\n\n This function builds 3 types of Inception-ResNet blocks mentioned\n in the paper, controlled by the `block_type` argument (which is the\n block name used in the official TF-slim implementation):\n - Inception-ResNet-A: `block_type='block35'`\n - Incep...
def inception_resnet_block(x, scale, block_type, block_idx, activation="relu"): if block_type == "block35": branch_0 = conv2d_bn(x, 32, 1) branch_1 = conv2d_bn(x, 32, 1) branch_1 = conv2d_bn(branch_1, 32, 3) branch_2 = conv2d_bn(x, 32, 1) branch_2 = conv2d_bn(branch_2, 4...
19,814
100,317
152
lib/gui/analysis/stats.py
38
14
def _get_calculations(self): for selection in self._selections: if selection == "raw": continue logger.debug("Calculating: %s", selection) method = getattr(self, f"_calc_{selection}") raw_keys = [key for key in self._stats if key.startswit...
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 -...
_get_calculations
c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf
faceswap
stats.py
15
10
https://github.com/deepfakes/faceswap.git
6
79
0
28
156
Python
{ "docstring": " Perform the required calculations and populate :attr:`stats`. ", "language": "en", "n_whitespaces": 8, "n_words": 7, "vocab_size": 7 }
def _get_calculations(self): for selection in self._selections: if selection == "raw": continue logger.debug("Calculating: %s", selection) method = getattr(self, f"_calc_{selection}") raw_keys = [key for key in self._stats if key.startswit...
36,917
157,377
809
ldm/models/diffusion/dpm_solver/dpm_solver.py
228
37
def multistep_dpm_solver_second_update(self, x, model_prev_list, t_prev_list, t, solver_type="dpm_solver"): if solver_type not in ['dpm_solver', 'taylor']: raise ValueError("'solver_type' must be either 'dpm_solver' or 'taylor', got {}".format(solver_type)) ns = self.noise_schedule ...
release more models
multistep_dpm_solver_second_update
ca86da3a30c4e080d4db8c25fca73de843663cb4
stablediffusion
dpm_solver.py
25
43
https://github.com/Stability-AI/stablediffusion.git
7
449
0
88
681
Python
{ "docstring": "\n Multistep solver DPM-Solver-2 from time `t_prev_list[-1]` to time `t`.\n Args:\n x: A pytorch tensor. The initial value at time `s`.\n model_prev_list: A list of pytorch tensor. The previous computed model values.\n t_prev_list: A list of pytorch tenso...
def multistep_dpm_solver_second_update(self, x, model_prev_list, t_prev_list, t, solver_type="dpm_solver"): if solver_type not in ['dpm_solver', 'taylor']: raise ValueError("'solver_type' must be either 'dpm_solver' or 'taylor', got {}".format(solver_type)) ns = self.noise_schedule ...
41,599
175,317
64
Lib/enum.py
25
17
def global_enum(cls, update_str=False): if issubclass(cls, Flag): cls.__repr__ = global_flag_repr else: cls.__repr__ = global_enum_repr if not issubclass(cls, ReprEnum) or update_str: cls.__str__ = global_str sys.modules[cls.__module__].__dict__.updat
bpo-40066: [Enum] update str() and format() output (GH-30582) Undo rejected PEP-663 changes: - restore `repr()` to its 3.10 status - restore `str()` to its 3.10 status New changes: - `IntEnum` and `IntFlag` now leave `__str__` as the original `int.__str__` so that str() and format() return the same result ...
global_enum
acf7403f9baea3ae1119fc6b4a3298522188bf96
cpython
enum.py
10
9
https://github.com/python/cpython.git
4
65
0
20
104
Python
{ "docstring": "\n decorator that makes the repr() of an enum member reference its module\n instead of its class; also exports all members to the enum's module's\n global namespace\n ", "language": "en", "n_whitespaces": 39, "n_words": 26, "vocab_size": 23 }
def global_enum(cls, update_str=False): if issubclass(cls, Flag): cls.__repr__ = global_flag_repr else: cls.__repr__ = global_enum_repr if not issubclass(cls, ReprEnum) or update_str: cls.__str__ = global_str sys.modules[cls.__module__].__dict__.update(cls.__members__) r...
80,939
272,022
584
keras/engine/training_v1.py
101
28
def create_training_target(self, target, run_eagerly=False): if self.has_training_target(): raise ValueError( "The training_target field for the _TrainingEndpoint " "instance has already been populated" ) if run_eagerly: # When...
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
create_training_target
84afc5193d38057e2e2badf9c889ea87d80d8fbf
keras
training_v1.py
17
35
https://github.com/keras-team/keras.git
7
172
0
64
276
Python
{ "docstring": "Create training_target instance and update the self.training_target.\n\n Note that the input target should just be a tensor or None, and\n corresponding training target will be created based on the output and\n loss_fn.\n\n Args:\n target: the target tensor for the...
def create_training_target(self, target, run_eagerly=False): if self.has_training_target(): raise ValueError( "The training_target field for the _TrainingEndpoint " "instance has already been populated" ) if run_eagerly: # When...
8,117
43,999
130
tests/models/test_dag.py
45
23
def test_set_task_instance_state(run_id, execution_date, session, dag_maker): start_date = datetime_tz(2020, 1, 1) with dag_maker("test_set_task_instance_state", start_date=start_date, session=session) as dag: task_1 = DummyOperator(task_id="task_1") task_2 = DummyOperator(task_id="ta
Use `DagRun.run_id` instead of `execution_date` when updating state of TIs(UI & REST API) (#18724) We can now use run_id as well as execution_date to update states of task instances Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com> Co-authored-by: Ash Berlin-Taylor <ash_github@firemirror.com>
test_set_task_instance_state
2b4bf7fe67fc656ceb7bdaad36453b7a5b83ef04
airflow
test_dag.py
12
39
https://github.com/apache/airflow.git
2
321
0
38
188
Python
{ "docstring": "Test that set_task_instance_state updates the TaskInstance state and clear downstream failed", "language": "en", "n_whitespaces": 10, "n_words": 11, "vocab_size": 11 }
def test_set_task_instance_state(run_id, execution_date, session, dag_maker): start_date = datetime_tz(2020, 1, 1) with dag_maker("test_set_task_instance_state", start_date=start_date, session=session) as dag: task_1 = DummyOperator(task_id="task_1") task_2 = DummyOperator(task_id="task_2"...
95,433
296,453
260
homeassistant/components/roon/config_flow.py
56
22
async def async_step_link(self, user_input=None): errors = {} if user_input is not None: # Do not authenticate if the host is already configured self._async_abort_entries_match({CONF_HOST: self._host}) try: info = await authenticate( ...
Improve roon integraton (#66000) * Update to new library, revise discovery to work with new library, specify port to work with new library. * Move user gui to fallback. * Revise tests. * Handle old config. * Improve debugging, refresh faster on load. * Remove duplicate. * Bump library version. * F...
async_step_link
23264c8fd4a3f8bcff5961ed11cab6388d3c67a4
core
config_flow.py
14
16
https://github.com/home-assistant/core.git
4
107
0
46
182
Python
{ "docstring": "Handle linking and authenticting with the roon server.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 8 }
async def async_step_link(self, user_input=None): errors = {} if user_input is not None: # Do not authenticate if the host is already configured self._async_abort_entries_match({CONF_HOST: self._host}) try: info = await authenticate( ...
54,138
215,744
24
tests/pytests/unit/utils/win_dacl/test_get_sid_string.py
12
10
def test_get_sid_string_none(): sid_obj = sa
Add tests, migrate some tests to pytest
test_get_sid_string_none
3bb43882e727b1d36abe2e501759c9c5e9048ecf
salt
test_get_sid_string.py
10
4
https://github.com/saltstack/salt.git
1
39
0
11
66
Python
{ "docstring": "\n Validate getting a null sid (S-1-0-0) when a null sid is passed\n ", "language": "en", "n_whitespaces": 19, "n_words": 12, "vocab_size": 9 }
def test_get_sid_string_none(): sid_obj = salt.utils.win_dacl.get_sid(None) assert isinstance(sid_obj, pywintypes.SIDType) assert salt.utils.win_dacl.get_sid_string(sid_obj) == "S-1-0-0"
118,175
322,461
31
paddlenlp/datasets/dataset.py
10
8
def read(self, filename, split='train'): label_list = self.get_labels() vocab_info = self.get_vocab()
[cblue] support converting labels of multi-tasks
read
ba3ea1cffa14d8fddb4d61239d691eba1d711a1d
PaddleNLP
dataset.py
8
40
https://github.com/PaddlePaddle/PaddleNLP.git
12
260
0
9
46
Python
{ "docstring": "\n Returns a dataset containing all the examples that can be read from the file path.\n\n If `self.lazy` is False, this eagerly reads all instances from `self._read()`\n and returns a `MapDataset`.\n\n If `self.lazy` is True, this returns an `IterDataset`, which internally\...
def read(self, filename, split='train'): label_list = self.get_labels() vocab_info = self.get_vocab()
16,279
74,629
47
wagtail/core/tests/test_whitelist.py
12
9
def test_no_rule_for_attr(self): tag = self.soup.b fn = attribute_rule({"snowman": "barbec
Reformat with black
test_no_rule_for_attr
d10f15e55806c6944827d801cd9c2d53f5da4186
wagtail
test_whitelist.py
11
5
https://github.com/wagtail/wagtail.git
1
38
0
11
70
Python
{ "docstring": "\n Test that attribute_rule() drops attributes for\n which no rule has been defined.\n ", "language": "en", "n_whitespaces": 34, "n_words": 12, "vocab_size": 12 }
def test_no_rule_for_attr(self): tag = self.soup.b fn = attribute_rule({"snowman": "barbecue"}) fn(tag) self.assertEqual(str(tag), "<b>baz</b>")
@DeveloperAPI
29,861
132,902
477
python/ray/util/check_serialize.py
103
26
def _inspect_generic_serialization(base_obj, depth, parent, failure_set): assert not inspect.isfunction(base_obj) functions = inspect.getmembers(base_obj, predicate=inspect.isfunction) found = False with _printer.indent(): for name, obj in functions: serializable, _ = inspect_se...
[CI] Format Python code with Black (#21975) See #21316 and #21311 for the motivation behind these changes.
_inspect_generic_serialization
7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065
ray
check_serialize.py
14
37
https://github.com/ray-project/ray.git
11
184
1
60
302
Python
{ "docstring": "Adds the first-found non-serializable element to the failure_set.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 7 }
def _inspect_generic_serialization(base_obj, depth, parent, failure_set): assert not inspect.isfunction(base_obj) functions = inspect.getmembers(base_obj, predicate=inspect.isfunction) found = False with _printer.indent(): for name, obj in functions: serializable, _ = inspect_se...
49,752
200,643
863
sympy/combinatorics/perm_groups.py
287
20
def is_dihedral(self): r if self._is_dihedral is not None: return self._is_dihedral order = self.order() if order % 2 == 1: self._is_dihedral = False return False if or
Add a `PermutationGroup.is_dihedral` property
is_dihedral
624e6f073d5d20e78484f5a0b477469f83678b88
sympy
perm_groups.py
12
75
https://github.com/sympy/sympy.git
18
314
0
131
508
Python
{ "docstring": "\n Return ``True`` if the group is dihedral.\n\n Examples\n ========\n\n >>> from sympy.combinatorics.perm_groups import PermutationGroup\n >>> from sympy.combinatorics.permutations import Permutation\n >>> from sympy.combinatorics.named_groups import Symmetri...
def is_dihedral(self): r if self._is_dihedral is not None: return self._is_dihedral order = self.order() if order % 2 == 1: self._is_dihedral = False return False if order == 2: self._is_dihedral = True return True ...
78,343
266,230
45
netbox/dcim/signals.py
14
12
def extend_rearport_cable_paths(instance, created, **kwargs): if created: rearport = instance.rear_port for cablepath in CablePath.objects.filter(_nodes__contains=rearport):
Fixes #10969: Update cable paths ending at associated rear port when creating new front ports
extend_rearport_cable_paths
4e27e8d3dd2cbfe3279bda3631ca92a7facdd334
netbox
signals.py
11
5
https://github.com/netbox-community/netbox.git
3
38
0
14
62
Python
{ "docstring": "\n When a new FrontPort is created, add it to any CablePaths which end at its corresponding RearPort.\n ", "language": "en", "n_whitespaces": 24, "n_words": 17, "vocab_size": 17 }
def extend_rearport_cable_paths(instance, created, **kwargs): if created: rearport = instance.rear_port for cablepath in CablePath.objects.filter(_nodes__contains=rearport): cablepath.retrace()
19,840
100,345
1,104
lib/gui/utils.py
281
50
def _load_images_to_cache(self, image_files, frame_dims, thumbnail_size): logger.debug("Number image_files: %s, frame_dims: %s, thumbnail_size: %s", len(image_files), frame_dims, thumbnail_size) num_images = (frame_dims[0] // thumbnail_size) * (frame_dims[1] // thumbnail_si...
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 -...
_load_images_to_cache
c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf
faceswap
utils.py
17
61
https://github.com/deepfakes/faceswap.git
13
488
0
176
811
Python
{ "docstring": " Load preview images to the image cache.\n\n Load new images and append to cache, filtering the cache the number of thumbnails that will\n fit inside the display panel.\n\n Parameters\n ----------\n image_files: list\n A list of new image files that have ...
def _load_images_to_cache(self, image_files, frame_dims, thumbnail_size): logger.debug("Number image_files: %s, frame_dims: %s, thumbnail_size: %s", len(image_files), frame_dims, thumbnail_size) num_images = (frame_dims[0] // thumbnail_size) * (frame_dims[1] // thumbnail_si...
79,173
267,897
25
test/lib/ansible_test/_internal/commands/integration/coverage.py
11
7
def target_profile(self) -> t.Optional[PosixProfile]: retur
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...
target_profile
3eb0485dd92c88cc92152d3656d94492db44b183
ansible
coverage.py
10
3
https://github.com/ansible/ansible.git
2
33
0
11
51
Python
{ "docstring": "The POSIX target profile, if it uses a different Python interpreter than the controller, otherwise None.", "language": "en", "n_whitespaces": 15, "n_words": 16, "vocab_size": 16 }
def target_profile(self) -> t.Optional[PosixProfile]: return t.cast(PosixProfile, self.profiles[0]) if self.profiles else None
85,817
286,444
2,754
openbb_terminal/portfolio/portfolio_model.py
512
71
def preprocess_transactions(self): p_bar = tqdm(range(14), desc="Preprocessing transactions") try: # 0. If optional fields not in the transactions add missing optional_fields = [ "Sector", "Industry", "Country", ...
Portfolio menu bug fixes (#3204) * normalized way moving average is treated and prevent huge exception prompt * changed descriptions on docs * change to check_positive_float * add integration tests * fix linting * add more integration tests * add more integration tests * fix linting * add some ...
preprocess_transactions
f9086d6f38cf5de4bf3e44be0b4ccd332dbaca46
OpenBBTerminal
portfolio_model.py
23
137
https://github.com/OpenBB-finance/OpenBBTerminal.git
14
838
0
267
1,446
Python
{ "docstring": "Method to preprocess, format and compute auxiliary fields.\n\n Preprocessing steps:\n 0. If optional fields not in the transactions add missing\n 1. Convert Date to datetime\n 2. Sort transactions by date\n 3. Capitalize Ticker and Type [of instrument...
def preprocess_transactions(self): p_bar = tqdm(range(14), desc="Preprocessing transactions") try: # 0. If optional fields not in the transactions add missing optional_fields = [ "Sector", "Industry", "Country", ...
79,831
269,013
39
keras/optimizers/optimizer_v2/optimizer_v2.py
27
7
def _var_key(var): # pylint: disable=protected-access # Get the distributed variable if it exists. if hasattr(var, "_distributed_container"): var = var._distributed_container() if getattr(var, "_in_g
Support checkpointing ShardedVariables in optimizer slot variables. PiperOrigin-RevId: 429577423
_var_key
75d70a610dffe927d89ceb400d79bb7f9027b26e
keras
optimizer_v2.py
10
6
https://github.com/keras-team/keras.git
3
39
0
23
69
Python
{ "docstring": "Key for representing a primary variable, for looking up slots.\n\n In graph mode the name is derived from the var shared name.\n In eager mode the name is derived from the var unique id.\n If distribution strategy exists, get the primary variable first.\n\n Args:\n var: the variable.\n\n Retur...
def _var_key(var): # pylint: disable=protected-access # Get the distributed variable if it exists. if hasattr(var, "_distributed_container"): var = var._distributed_container() if getattr(var, "_in_graph_mode", False): return var._shared_name return var._unique_id
76,836
261,492
57
sklearn/ensemble/tests/test_stacking.py
26
19
def test_stacking_classifier_base_regressor(): X_train, X_test, y_train, y_test = train_test_split( scale(X_iris), y_iris, stratify=y_iris, random_state=42 ) clf = StackingClassifier(estimators=[("ridge", Ridge())]) clf.fit(X_train, y_train) clf.predict(X_test) clf.predict_proba(X_t...
ENH StackingClassifier allows regressors in its first layer (#24538) Co-authored-by: Tom Dupré la Tour <tom.duprelatour.10@gmail.com> Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
test_stacking_classifier_base_regressor
b1807ff8ead319a08294beeaae90c3f03b2bb8ac
scikit-learn
test_stacking.py
13
9
https://github.com/scikit-learn/scikit-learn.git
1
79
0
25
121
Python
{ "docstring": "Check that a regressor can be used as the first layer in `StackingClassifier`.", "language": "en", "n_whitespaces": 12, "n_words": 13, "vocab_size": 13 }
def test_stacking_classifier_base_regressor(): X_train, X_test, y_train, y_test = train_test_split( scale(X_iris), y_iris, stratify=y_iris, random_state=42 ) clf = StackingClassifier(estimators=[("ridge", Ridge())]) clf.fit(X_train, y_train) clf.predict(X_test) clf.predict_proba(X_t...
23,079
108,151
580
lib/matplotlib/backends/backend_svg.py
145
27
def _get_style_dict(self, gc, rgbFace): attrib = {} forced_alpha = gc.get_forced_alpha() if gc.get_hatch() is not None: attrib['fill'] = "url(#%s)" % self._get_hatch(gc, rgbFace) if (rgbFace is not None and len(rgbFace) == 4 and rgbFace[3] != 1.0 ...
Deprecate functions in backends
_get_style_dict
ec410abbb3a721e31f3aaa61e9e4f941467e35e1
matplotlib
backend_svg.py
17
37
https://github.com/matplotlib/matplotlib.git
21
342
0
76
558
Python
{ "docstring": "Generate a style string from the GraphicsContext and rgbFace.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
def _get_style_dict(self, gc, rgbFace): attrib = {} forced_alpha = gc.get_forced_alpha() if gc.get_hatch() is not None: attrib['fill'] = "url(#%s)" % self._get_hatch(gc, rgbFace) if (rgbFace is not None and len(rgbFace) == 4 and rgbFace[3] != 1.0 ...
25,734
116,362
348
tests/unit/test_executor.py
85
28
def test_union(self, mock_handler): self.set_handler(mock_handler, name='pg', tables={'tasks': self.df}) # --- use predictor --- predictor = { 'name': 'task_model', 'predict': 'p', 'dtypes': { 'p': dtype.float, 'a': dtype.inte...
union command #2852
test_union
61f6f6c3c8154fa0629df8a016d449ceded99879
mindsdb
test_executor.py
14
35
https://github.com/mindsdb/mindsdb.git
1
201
0
53
346
Python
{ "docstring": "\n SELECT a as a1, b as target\n FROM pg.tasks\n UNION {union}\n SELECT model.a as a2, model.p as target2\n FROM pg.tasks as t\n JOIN mindsdb.task_model as model\n WHERE t.a=1 \n ", "language": "en",...
def test_union(self, mock_handler): self.set_handler(mock_handler, name='pg', tables={'tasks': self.df}) # --- use predictor --- predictor = { 'name': 'task_model', 'predict': 'p', 'dtypes': { 'p': dtype.float, 'a': dtype.inte...
8,522
45,252
89
tests/utils/test_db_cleanup.py
21
13
def test_run_cleanup_tables(self, clean_table_mock, table_names): base_kwargs = dict(
Add `db clean` CLI command for purging old data (#20838) CLI command to delete old rows from airflow metadata database. Notes: * Must supply "purge before date". * Can optionally provide table list. * Dry run will only print the number of rows meeting criteria. * If not dry run, will require the user to confirm b...
test_run_cleanup_tables
c75774d3a31efe749f55ba16e782737df9f53af4
airflow
test_db_cleanup.py
9
8
https://github.com/apache/airflow.git
2
52
0
21
79
Python
{ "docstring": "\n ``_cleanup_table`` should be called for each table in subset if one\n is provided else should be called for all tables.\n ", "language": "en", "n_whitespaces": 42, "n_words": 20, "vocab_size": 16 }
def test_run_cleanup_tables(self, clean_table_mock, table_names): base_kwargs = dict( clean_before_timestamp=None, dry_run=None, verbose=None, ) run_cleanup(**base_kwargs, table_names=table_names) assert clean_table_mock.call_count == len(tabl...
8,455
45,040
21
tests/models/test_xcom.py
7
6
def test_set_serialize_call_old_signature(self, get_import, session): serialize_watcher =
Add params dag_id, task_id etc to XCom.serialize_value (#19505) When implementing a custom XCom backend, in order to store XCom objects organized by dag_id, run_id etc, we need to pass those params to `serialize_value`.
test_set_serialize_call_old_signature
56285eee04285d8b6fac90911248d7e9dd5504d8
airflow
test_xcom.py
8
16
https://github.com/apache/airflow.git
1
82
0
7
26
Python
{ "docstring": "\n When XCom.serialize_value takes only param ``value``, other kwargs should be ignored.\n ", "language": "en", "n_whitespaces": 26, "n_words": 11, "vocab_size": 11 }
def test_set_serialize_call_old_signature(self, get_import, session): serialize_watcher = MagicMock()
69,715
241,856
152
scipy/stats/_stats_py.py
63
17
def gmean(a, axis=0, dtype=None, weights=None): if not isinstance(a, np.ndarray): # if not an ndarray object attempt to convert it log_a = np.log(np.array(a, dtype=dtype)) elif dtype: # Must change the default dtype allowing array type if isinstance(a, np.ma.MaskedArray): ...
ENH: stats: add `axis` tuple and `nan_policy` to `gmean` (#14657) * ENH: stats: add `axis` tuple and `nan_policy` to `gmean` Co-authored-by: Pamphile ROY <roy.pamphile@gmail.com>
gmean
465da5496a8dda099646e9d5947f24dfc0ec44e9
scipy
_stats_py.py
17
13
https://github.com/scipy/scipy.git
5
147
0
45
228
Python
{ "docstring": "Compute the geometric mean along the specified axis.\n\n Return the geometric average of the array elements.\n That is: n-th root of (x1 * x2 * ... * xn)\n\n Parameters\n ----------\n a : array_like\n Input array or object that can be converted to an array.\n axis : int or No...
def gmean(a, axis=0, dtype=None, weights=None): if not isinstance(a, np.ndarray): # if not an ndarray object attempt to convert it log_a = np.log(np.array(a, dtype=dtype)) elif dtype: # Must change the default dtype allowing array type if isinstance(a, np.ma.MaskedArray): ...
50,868
204,741
47
django/core/serializers/base.py
15
5
def handle_m2m_field(self, obj, field): raise NotImplementedError( "subclasses of Serializer must provide a handle_m2m_field() method" )
Refs #33476 -- Reformatted code with Black.
handle_m2m_field
9c19aff7c7561e3a82978a272ecdaad40dda5c00
django
base.py
8
4
https://github.com/django/django.git
1
15
0
15
27
Python
{ "docstring": "\n Called to handle a ManyToManyField.\n ", "language": "en", "n_whitespaces": 20, "n_words": 5, "vocab_size": 5 }
def handle_m2m_field(self, obj, field): raise NotImplementedError( "subclasses of Serializer must provide a handle_m2m_field() method" )
25,818
116,724
209
mindsdb/integrations/handlers/hana_handler/hana_handler.py
61
20
def check_connection(self) -> StatusResponse: response = StatusResponse(False) need_to_close = self.is_connected is False try: connection = self.connect() with connection.cursor() as cur: cur.execute('SELECT * FROM SYS.M_DATABASE') r...
feat: add sap hana integration
check_connection
db6291bc6a2cbea0154bd41c3abff3f6cfb7bc8a
mindsdb
hana_handler.py
13
20
https://github.com/mindsdb/mindsdb.git
6
103
0
42
188
Python
{ "docstring": "\n Check the connection of the SAP HANA database\n :return: success status and error message if error occurs\n ", "language": "en", "n_whitespaces": 39, "n_words": 17, "vocab_size": 15 }
def check_connection(self) -> StatusResponse: response = StatusResponse(False) need_to_close = self.is_connected is False try: connection = self.connect() with connection.cursor() as cur: cur.execute('SELECT * FROM SYS.M_DATABASE') r...
47,454
195,867
185
sympy/matrices/common.py
90
18
def extract(self, rowsList, colsList): r if not is_sequence(rowsList) or not is_sequence(colsList): rais
Improved documentation formatting
extract
cda8dfe6f45dc5ed394c2f5cda706cd6c729f713
sympy
common.py
12
56
https://github.com/sympy/sympy.git
15
136
0
49
208
Python
{ "docstring": "Return a submatrix by specifying a list of rows and columns.\n Negative indices can be given. All indices must be in the range\n $-n \\le i < n$ where $n$ is the number of rows or columns.\n\n Examples\n ========\n\n >>> from sympy import Matrix\n >>> m = Matr...
def extract(self, rowsList, colsList): r if not is_sequence(rowsList) or not is_sequence(colsList): raise TypeError("rowsList and colsList must be iterable") # ensure rowsList and colsList are lists of integers if rowsList and all(isinstance(i, bool) for i in rowsList): ...
48,217
196,850
144
sympy/integrals/integrals.py
48
16
def integrate(*args, meijerg=None, conds='piecewise', risch=None, heurisch=None, manual=None, **kwargs): doit_flags = { 'deep': False, 'meijerg': meijerg, 'conds': conds, 'risch': risch, 'heurisch': heurisch, 'manual': manual } integral = Integral(*ar...
Fix a few docstring formatting issues
integrate
1eeb01e15f06c6692a5bfd6fd2d2a3002d864a07
sympy
integrals.py
14
16
https://github.com/sympy/sympy.git
4
119
0
43
190
Python
{ "docstring": "integrate(f, var, ...)\n\n Explanation\n ===========\n\n Compute definite or indefinite integral of one or more variables\n using Risch-Norman algorithm and table lookup. This procedure is\n able to handle elementary algebraic and transcendental functions\n and also a huge class of s...
def integrate(*args, meijerg=None, conds='piecewise', risch=None, heurisch=None, manual=None, **kwargs): doit_flags = { 'deep': False, 'meijerg': meijerg, 'conds': conds, 'risch': risch, 'heurisch': heurisch, 'manual': manual } integral = Integral(*ar...
45,535
186,624
84
certbot-apache/certbot_apache/_internal/augeasparser.py
23
14
def parsed_paths(self) -> List[str]: res_paths: List[str] = [] paths = self.parser.existing_paths for directory
Add typing to certbot.apache (#9071) * Add typing to certbot.apache Co-authored-by: Adrien Ferrand <ferrand.ad@gmail.com>
parsed_paths
7d9e9a49005de7961e84d2a7c608db57dbab3046
certbot
augeasparser.py
14
16
https://github.com/certbot/certbot.git
3
57
0
20
89
Python
{ "docstring": "\n Returns a list of file paths that have currently been parsed into the parser\n tree. The returned list may include paths with wildcard characters, for\n example: ['/etc/apache2/conf.d/*.load']\n\n This is typically called on the root node of the ParserNode tree.\n\n ...
def parsed_paths(self) -> List[str]: res_paths: List[str] = [] paths = self.parser.existing_paths for directory in paths: for filename in paths[directory]: res_paths.append(os.path.join(directory, filename)) return res_paths
77,592
264,082
142
PyInstaller/building/utils.py
45
14
def _check_guts_toc_mtime(attr_name, old_toc, new_toc, last_build, pyc=False): for dest_name, src_name, typecode in old_toc: if misc.mtime(src_name) > last_build:
building: clean up the _check_guts_* helpers
_check_guts_toc_mtime
21655572a6af55cefb05d0b0afbeb0b0db39ea19
pyinstaller
utils.py
15
11
https://github.com/pyinstaller/pyinstaller.git
6
82
0
34
131
Python
{ "docstring": "\n Rebuild is required if mtimes of files listed in old TOC are newer than last_build.\n\n If pyc=True, check for .py files as well.\n\n Use this for calculated/analysed values read from cache.\n ", "language": "en", "n_whitespaces": 44, "n_words": 31, "vocab_size": 29 }
def _check_guts_toc_mtime(attr_name, old_toc, new_toc, last_build, pyc=False): for dest_name, src_name, typecode in old_toc: if misc.mtime(src_name) > last_build: logger.info("Building because %s changed", src_name) return True elif pyc and typecode == 'PYMODULE': ...
25,826
116,753
213
mindsdb/integrations/handlers/teradata_handler/teradata_handler.py
65
20
def check_connection(self) -> StatusResponse: response = StatusResponse(False) need_to_close = self.is_co
feat: add teradata integration
check_connection
47c5e0ac2d89807f8ff7239d423a3d346bd39a1e
mindsdb
teradata_handler.py
13
20
https://github.com/mindsdb/mindsdb.git
6
103
0
44
188
Python
{ "docstring": "\n Check the connection of the Teradata database\n :return: success status and error message if error occurs\n ", "language": "en", "n_whitespaces": 38, "n_words": 16, "vocab_size": 14 }
def check_connection(self) -> StatusResponse: response = StatusResponse(False) need_to_close = self.is_connected is False try: connection = self.connect() with connection.cursor() as cur: cur.execute('SELECT 1 FROM (SELECT 1 AS "dual") AS "dual"...
5,969
32,666
148
utils/prepare_for_doc_test.py
79
22
def process_doc_file(code_file, add_new_line=True): with open(code_file, "r", encoding="utf-8", newline="\n") as f: code = f.read() # fmt: off splits = code.split("```") if len(splits) % 2 != 1: raise ValueError("The number of occurrences of ``` should be an even number.") spl...
Add a check regarding the number of occurrences of ``` (#18389) Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
process_doc_file
bd6d1b430080aaf7d9a15f908b95631242da3fb0
transformers
prepare_for_doc_test.py
14
13
https://github.com/huggingface/transformers.git
5
132
0
57
236
Python
{ "docstring": "\n Process given file.\n\n Args:\n code_file (`str` or `os.PathLike`): The file in which we want to style the docstring.\n ", "language": "en", "n_whitespaces": 35, "n_words": 18, "vocab_size": 18 }
def process_doc_file(code_file, add_new_line=True): with open(code_file, "r", encoding="utf-8", newline="\n") as f: code = f.read() # fmt: off splits = code.split("```") if len(splits) % 2 != 1: raise ValueError("The number of occurrences of ``` should be an even number.") spl...
20,661
101,241
330
plugins/extract/align/_base.py
82
28
def finalize(self, batch): for face, landmarks in zip(batch["detected_faces"], batch["landmarks"]): if not isinstance(landmarks, np.ndarray): landmarks = np.array(landmarks) face._landmarks_xy = landmarks logger.trace("Item out: %s", {key: val.shape if ...
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
finalize
5e73437be47f2410439a3c6716de96354e6a0c94
faceswap
_base.py
13
18
https://github.com/deepfakes/faceswap.git
7
174
0
66
280
Python
{ "docstring": " Finalize the output from Aligner\n\n This should be called as the final task of each `plugin`.\n\n Pairs the detected faces back up with their original frame before yielding each frame.\n\n Parameters\n ----------\n batch : dict\n The final ``dict`` from ...
def finalize(self, batch): for face, landmarks in zip(batch["detected_faces"], batch["landmarks"]): if not isinstance(landmarks, np.ndarray): landmarks = np.array(landmarks) face._landmarks_xy = landmarks logger.trace("Item out: %s", {key: val.shape if ...
52,763
209,670
49
scapy/layers/dcerpc.py
27
8
def find_dcerpc_interface(name): try: return next(x for x in DCE_RPC_INTERFACES.values() if x.name == name) except StopItera
[MS-RPCE] and [MS-SMB] major update (#3683) * Various fixes regarding DCE/RPC build * DCE/RPC sessions * Cleanup unused code * Add missing GSS_WRAP algo names * Add find_dcerpc_interface * Split SMB client and server * Missing StrFixedLenFieldUtf16 * Remove unfinished smbserver feature * Friend...
find_dcerpc_interface
ca10c5cf00425d0178998ec0b006cbb65ddbfb54
scapy
dcerpc.py
12
5
https://github.com/secdev/scapy.git
4
35
0
27
62
Python
{ "docstring": "\n Find an interface object through the name in the IDL\n ", "language": "en", "n_whitespaces": 17, "n_words": 10, "vocab_size": 9 }
def find_dcerpc_interface(name): try: return next(x for x in DCE_RPC_INTERFACES.values() if x.name == name) except StopIteration: raise AttributeError("Unknown interface !") # --- NDR fields - [C706] chap 14
43,806
182,367
194
tests/test_animator.py
86
16
def test_animatable(): animatable = AnimateTest() # Fake wall-clock time time = 100.0 # Object that does the animation animation = SimpleAnimation( animatable, "bar", time, 3.0, start_value=Animatable(20.0), end_value=Animatable(50.0), ...
fix and test for animator
test_animatable
8be6ea91f6e8a8d24d385975f1a5a7714cf27894
textual
test_animator.py
11
23
https://github.com/Textualize/textual.git
1
170
0
49
222
Python
{ "docstring": "Test SimpleAnimation works with the Animatable protocol", "language": "en", "n_whitespaces": 6, "n_words": 7, "vocab_size": 7 }
def test_animatable(): animatable = AnimateTest() # Fake wall-clock time time = 100.0 # Object that does the animation animation = SimpleAnimation( animatable, "bar", time, 3.0, start_value=Animatable(20.0), end_value=Animatable(50.0), ...
53,068
211,340
650
ppdet/metrics/map_utils.py
125
38
def update(self, bbox, score, label, gt_box, gt_label, difficult=None): if difficult is None: difficult = np.zeros_like(gt_label) # record class gt count for gtl, diff in zip(gt_label, difficult): if self.evaluate_difficult or int(diff) == 0: sel...
Refactor rbox (#6704) * refactor rbox * modify the code of save results * fix some problem * add .gitignore in dataset/dota * fix test anno path
update
e55e41945d42db787a0f7c557d53d06a6b24536b
PaddleDetection
map_utils.py
19
31
https://github.com/PaddlePaddle/PaddleDetection.git
15
303
0
81
450
Python
{ "docstring": "\n Update metric statics from given prediction and ground\n truth infomations.\n ", "language": "en", "n_whitespaces": 32, "n_words": 10, "vocab_size": 10 }
def update(self, bbox, score, label, gt_box, gt_label, difficult=None): if difficult is None: difficult = np.zeros_like(gt_label) # record class gt count for gtl, diff in zip(gt_label, difficult): if self.evaluate_difficult or int(diff) == 0: sel...
16,182
73,936
77
wagtail/core/permission_policies/collections.py
20
12
def _get_permission_objects_for_actions(self, actions): permission_codenames = [ "%s_%s" % (action, self.model_name) for action in actions ] return Permission.objects.filter( content_ty
Reformat with black
_get_permission_objects_for_actions
d10f15e55806c6944827d801cd9c2d53f5da4186
wagtail
collections.py
10
7
https://github.com/wagtail/wagtail.git
2
42
0
20
66
Python
{ "docstring": "\n Get a queryset of the Permission objects for the given actions\n ", "language": "en", "n_whitespaces": 26, "n_words": 11, "vocab_size": 10 }
def _get_permission_objects_for_actions(self, actions): permission_codenames = [ "%s_%s" % (action, self.model_name) for action in actions ] return Permission.objects.filter( content_type=self._content_type, codename__in=permission_codenames )
117,569
321,163
411
qutebrowser/browser/webengine/webview.py
99
31
def createWindow(self, wintype): debug_type = debug.qenum_key(QWebEnginePage, wintype) background = config.val.tabs.background log.webview.debug("createWindow with type {}, background {}".format( debug_type, background)) if wintype == QWebEnginePage.WebWindowType.W...
Run scripts/dev/rewrite_enums.py
createWindow
0877fb0d78635692e481c8bde224fac5ad0dd430
qutebrowser
webview.py
14
25
https://github.com/qutebrowser/qutebrowser.git
7
172
0
60
287
Python
{ "docstring": "Called by Qt when a page wants to create a new window.\n\n This function is called from the createWindow() method of the\n associated QWebEnginePage, each time the page wants to create a new\n window of the given type. This might be the result, for example, of a\n JavaScrip...
def createWindow(self, wintype): debug_type = debug.qenum_key(QWebEnginePage, wintype) background = config.val.tabs.background log.webview.debug("createWindow with type {}, background {}".format( debug_type, background)) if wintype == QWebEnginePage.WebWindowType.W...
75,856
259,662
40
sklearn/ensemble/_gb.py
12
11
def predict(self, X): raw_predictions = self.decision_function(X) encode
DEP loss_ attribute in gradient boosting (#23079)
predict
0d669dc419524eff7f45032f4c18253e627a055b
scikit-learn
_gb.py
9
4
https://github.com/scikit-learn/scikit-learn.git
1
39
0
11
63
Python
{ "docstring": "Predict class for X.\n\n Parameters\n ----------\n X : {array-like, sparse matrix} of shape (n_samples, n_features)\n The input samples. Internally, it will be converted to\n ``dtype=np.float32`` and if a sparse matrix is provided\n to a sparse ``c...
def predict(self, X): raw_predictions = self.decision_function(X) encoded_labels = self._loss._raw_prediction_to_decision(raw_predictions) return self.classes_.take(encoded_labels, axis=0)
42,319
177,255
29
networkx/algorithms/operators/all.py
17
6
def union_all(graphs, rename=()): R = None
Make all.py generator friendly (#5984) * Make compose_all generator friendly * Make disjoint_union_all and intersection_all generator friendly * Refactor disjoint_union_all to yield relabeled graphs * Make union_all generator friendly * Fix intersection_all * Fix union_all signature * Allow passing a...
union_all
50ff08de69c6e9541cd6c029bede5dabf56cfe73
networkx
all.py
8
66
https://github.com/networkx/networkx.git
8
194
0
16
35
Python
{ "docstring": "Returns the union of all graphs.\n\n The graphs must be disjoint, otherwise an exception is raised.\n\n Parameters\n ----------\n graphs : iterable\n Iterable of NetworkX graphs\n\n rename : iterable , optional\n Node names of graphs can be changed by specifying the tuple\n ...
def union_all(graphs, rename=()): R = None seen_nodes = set() # rename graph to obtain disjoint node labels
76,685
261,192
123
sklearn/ensemble/_hist_gradient_boosting/tests/test_gradient_boosting.py
63
26
def test_unknown_category_that_are_negative(): rng = np.random.RandomState(42)
FIX Treat gradient boosting categoricals outside the bounds as unknown during predict (#24283)
test_unknown_category_that_are_negative
072b481600c48662fd4893fdce461113becd207a
scikit-learn
test_gradient_boosting.py
12
14
https://github.com/scikit-learn/scikit-learn.git
1
157
0
53
238
Python
{ "docstring": "Check that unknown categories that are negative does not error.\n\n Non-regression test for #24274.\n ", "language": "en", "n_whitespaces": 20, "n_words": 14, "vocab_size": 13 }
def test_unknown_category_that_are_negative(): rng = np.random.RandomState(42) n_samples = 1000 X = np.c_[rng.rand(n_samples), rng.randint(4, size=n_samples)] y = np.zeros(shape=n_samples) y[X[:, 1] % 2 == 0] = 1 hist = HistGradientBoostingRegressor( random_state=0, categor...
38,909
161,098
764
ppg_extractor/encoder/encoder_layer.py
225
32
def forward(self, x_input, mask, cache=None): if isinstance(x_input, tuple): x, pos_emb = x_input[0], x_input[1] else: x, pos_emb = x_input, None # whether to use macaron style if self.feed_forward_macaron is not None:
Init ppg extractor and ppg2mel (#375) * Init ppg extractor and ppg2mel * add preprocess and training * FIx known issues * Update __init__.py Allow to gen audio * Fix length issue * Fix bug of preparing fid * Fix sample issues * Add UI usage of PPG-vc
forward
b617a87ee40ab384767a27335313c2c65ee094ec
MockingBird
encoder_layer.py
14
53
https://github.com/babysor/MockingBird.git
19
449
0
80
699
Python
{ "docstring": "Compute encoded features.\n\n :param torch.Tensor x_input: encoded source features, w/o pos_emb\n tuple((batch, max_time_in, size), (1, max_time_in, size))\n or (batch, max_time_in, size)\n :param torch.Tensor mask: mask for x (batch, max_time_in)\n :param torch.Tens...
def forward(self, x_input, mask, cache=None): if isinstance(x_input, tuple): x, pos_emb = x_input[0], x_input[1] else: x, pos_emb = x_input, None # whether to use macaron style if self.feed_forward_macaron is not None: residual = x ...
46,502
191,364
58
tests/unit_tests/test_prompt.py
21
8
def test_prompt_invalid_template_format() -> None: template = "This is a {foo} test." input_variables = ["foo"] with pytest.raises(ValueError):
initial commit
test_prompt_invalid_template_format
18aeb720126a68201c7e3b5a617139c27c779496
langchain
test_prompt.py
11
8
https://github.com/hwchase17/langchain.git
1
37
0
20
69
Python
{ "docstring": "Test initializing a prompt with invalid template format.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 8 }
def test_prompt_invalid_template_format() -> None: template = "This is a {foo} test." input_variables = ["foo"] with pytest.raises(ValueError): Prompt( input_variables=input_variables, template=template, template_format="bar" )
73,140
249,805
205
tests/rest/admin/test_user.py
48
13
def test_medium_does_not_exist(self) -> None: # test for unknown medium url = "/_synapse/admin/v1/threepid/publickey/users/unknown-key" channel = self.make_request( "GET", url, access_token=self.admin_user_tok, ) self.assertEqual(404...
Add an Admin API endpoint for looking up users based on 3PID (#14405)
test_medium_does_not_exist
a3623af74e0af0d2f6cbd37b47dc54a1acd314d5
synapse
test_user.py
10
19
https://github.com/matrix-org/synapse.git
1
110
0
28
178
Python
{ "docstring": "Tests that both a lookup for a medium that does not exist and a user that\n doesn't exist with that third party ID returns a 404", "language": "en", "n_whitespaces": 32, "n_words": 26, "vocab_size": 19 }
def test_medium_does_not_exist(self) -> None: # test for unknown medium url = "/_synapse/admin/v1/threepid/publickey/users/unknown-key" channel = self.make_request( "GET", url, access_token=self.admin_user_tok, ) self.assertEqual(404...
@dataclass
121,103
337,646
282
src/accelerate/utils/dataclasses.py
88
19
def deepspeed_config_process(self, prefix="", mismatches=None, config=None, must_match=True, **kwargs): mismatches = [] if mismatches is None else mismatches if config is None: config = self.deepspeed_config for key, value in config.items(): if isinstance(value, ...
DeepSpeed Revamp (#405) * deepspeed revamp * Update dataclasses.py * Update deepspeed.py * quality * fixing code * quality * FIx imports * saving 16bit model in zero stage 3 1. Saving 16bit model in zero stage 3 2. zero init in stage 3 support using HFDeepSpeedConfig * quality * adding test and fixing bugs ...
deepspeed_config_process
1703b79a797dab765996764707186def7533d8fd
accelerate
dataclasses.py
14
17
https://github.com/huggingface/accelerate.git
7
137
1
68
228
Python
{ "docstring": "Process the DeepSpeed config with the values from the kwargs.", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 8 }
def deepspeed_config_process(self, prefix="", mismatches=None, config=None, must_match=True, **kwargs): mismatches = [] if mismatches is None else mismatches if config is None: config = self.deepspeed_config for key, value in config.items(): if isinstance(value, ...
83,169
279,889
125
keras/engine/training.py
27
10
def get_metrics_result(self): # Collect metrics to return return_metrics = {} for metric in self.metrics: result = metric.r
Expose Model get_metrics_result on Keras Model as a public API PiperOrigin-RevId: 475681912
get_metrics_result
8cf91871ce167d63069c99120f8580a4976a59d0
keras
training.py
13
9
https://github.com/keras-team/keras.git
3
50
0
22
84
Python
{ "docstring": "Returns the model's metrics values as a dict.\n\n If any of the metric result is a dict (containing multiple metrics),\n each of them gets added to the top level returned dict of this method.\n\n Returns:\n A `dict` containing values of the metrics listed in `self.metrics...
def get_metrics_result(self): # Collect metrics to return return_metrics = {} for metric in self.metrics: result = metric.result() if isinstance(result, dict): return_metrics.update(result) else: return_metrics[metric.n...
55,539
218,899
593
python3.10.4/Lib/lib2to3/refactor.py
95
23
def refactor_docstring(self, input, filename): result = [] block = None block_lineno = None indent = None lineno = 0 for line in input.splitlines(keepends=True): lineno += 1 if line.lstrip().startswith(self.PS1): if block i...
add python 3.10.4 for windows
refactor_docstring
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
refactor.py
18
31
https://github.com/XX-net/XX-Net.git
9
211
0
47
333
Python
{ "docstring": "Refactors a docstring, looking for doctests.\n\n This returns a modified version of the input string. It looks\n for doctests, which start with a \">>>\" prompt, and may be\n continued with \"...\" prompts, as long as the \"...\" is indented\n the same as the \">>>\".\n\n ...
def refactor_docstring(self, input, filename): result = [] block = None block_lineno = None indent = None lineno = 0 for line in input.splitlines(keepends=True): lineno += 1 if line.lstrip().startswith(self.PS1): if block i...
8,643
45,557
419
tests/utils/test_edgemodifier.py
89
23
def test_complex_reversed_dag(self, test_complex_taskgroup_dag, complex_dag_expected_edges): ( dag, group, ( group_dm1, group_dm2, group_dm3, dm_in1, dm_in2, dm_in3, ...
EdgeModifier refactoring (#21404)
test_complex_reversed_dag
ace8c6e942ff5554639801468b971915b7c0e9b9
airflow
test_edgemodifier.py
10
30
https://github.com/apache/airflow.git
1
150
0
50
210
Python
{ "docstring": "Tests the complex reversed dag with a TaskGroup and a Label", "language": "en", "n_whitespaces": 10, "n_words": 11, "vocab_size": 10 }
def test_complex_reversed_dag(self, test_complex_taskgroup_dag, complex_dag_expected_edges): ( dag, group, ( group_dm1, group_dm2, group_dm3, dm_in1, dm_in2, dm_in3, ...
118,121
322,323
80
paddlenlp/ops/faster_transformer/sample/plato_inference.py
30
12
def postprocess_response(token_ids, tokenizer): eos_pos = len(token_ids) for i, tok_id in enumerate(token_ids): if tok_id == tokenizer.sep_token_id: eos_pos = i break token_ids = token_ids[:eos_pos] tokens = tokenizer.convert_ids_to_tokens(token_ids) tokens = tok...
FasterUnifiedTransformer/PLATO support dy2sta (#1717) * support ut dy2sta * use jit load
postprocess_response
4c36ef9e41ea6b0e43935bdf6b2f1b4a1f8de809
PaddleNLP
plato_inference.py
10
10
https://github.com/PaddlePaddle/PaddleNLP.git
3
60
0
22
98
Python
{ "docstring": "Post-process the decoded sequence. Truncate from the first <eos>.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 8 }
def postprocess_response(token_ids, tokenizer): eos_pos = len(token_ids) for i, tok_id in enumerate(token_ids): if tok_id == tokenizer.sep_token_id: eos_pos = i break token_ids = token_ids[:eos_pos] tokens = tokenizer.convert_ids_to_tokens(token_ids) tokens = tok...
121,193
338,219
201
src/accelerate/accelerator.py
66
16
def clip_grad_norm_(self, parameters, max_norm, norm_type=2): if self.distributed_type == DistributedType.FSDP: self.unscale_gradients() parameters = [p for p in parameters] for model in self._models: if parameters == [p for p in model.parameters()]: ...
Return unclipped gradient from grad_clip_norm_ (#756)
clip_grad_norm_
693d46826e32507376d44f99967df4710886c984
accelerate
accelerator.py
14
11
https://github.com/huggingface/accelerate.git
7
101
0
48
156
Python
{ "docstring": "\n Should be used in place of `torch.nn.utils.clip_grad_norm_`.\n\n Returns:\n `torch.Tensor`: Total norm of the parameter gradients (viewed as a single vector).\n\n Example:\n\n ```python\n >>> from accelerate import Accelerator\n\n >>> accelerator...
def clip_grad_norm_(self, parameters, max_norm, norm_type=2): if self.distributed_type == DistributedType.FSDP: self.unscale_gradients() parameters = [p for p in parameters] for model in self._models: if parameters == [p for p in model.parameters()]: ...
56,689
222,663
399
python3.10.4/Lib/distutils/command/build_clib.py
108
15
def check_library_list(self, libraries): if not isinstance(libraries, list): raise DistutilsSetupError( "'libraries' option must be a list of tuples") for lib in libraries: if not isinstance(lib, tuple) and len(lib) != 2: raise Distutil...
add python 3.10.4 for windows
check_library_list
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
build_clib.py
14
20
https://github.com/XX-net/XX-Net.git
10
113
0
65
199
Python
{ "docstring": "Ensure that the list of libraries is valid.\n\n `library` is presumably provided as a command option 'libraries'.\n This method checks that it is a list of 2-tuples, where the tuples\n are (library_name, build_info_dict).\n\n Raise DistutilsSetupError if the structure is in...
def check_library_list(self, libraries): if not isinstance(libraries, list): raise DistutilsSetupError( "'libraries' option must be a list of tuples") for lib in libraries: if not isinstance(lib, tuple) and len(lib) != 2: raise Distutil...
3,366
20,431
563
pipenv/patched/notpip/_vendor/pygments/lexer.py
130
16
def _process_new_state(cls, new_state, unprocessed, processed): if isinstance(new_state, str): # an existing state if new_state == '#pop': return -1 elif new_state in unprocessed: return (new_state,) elif new_state == '#pus...
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...
_process_new_state
f3166e673fe8d40277b804d35d77dcdb760fc3b3
pipenv
lexer.py
15
30
https://github.com/pypa/pipenv.git
11
177
0
69
288
Python
{ "docstring": "Preprocess the state transition action of a token definition.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
def _process_new_state(cls, new_state, unprocessed, processed): if isinstance(new_state, str): # an existing state if new_state == '#pop': return -1 elif new_state in unprocessed: return (new_state,) elif new_state == '#pus...
75,661
259,226
169
sklearn/preprocessing/tests/test_encoders.py
89
25
def test_ohe_infrequent_two_levels_user_cats(): X_train = np.array( [["a"] * 5 + ["b"] * 20 + ["c"] * 10 + ["d"] * 3], dtyp
ENH Adds infrequent categories to OneHotEncoder (#16018) * ENH Completely adds infrequent categories * STY Linting * STY Linting * DOC Improves wording * DOC Lint * BUG Fixes * CLN Address comments * CLN Address comments * DOC Uses math to description float min_frequency * DOC Adds comment r...
test_ohe_infrequent_two_levels_user_cats
7f0006c8aad1a09621ad19c3db19c3ff0555a183
scikit-learn
test_encoders.py
16
18
https://github.com/scikit-learn/scikit-learn.git
2
203
0
67
332
Python
{ "docstring": "Test that the order of the categories provided by a user is respected.", "language": "en", "n_whitespaces": 12, "n_words": 13, "vocab_size": 12 }
def test_ohe_infrequent_two_levels_user_cats(): X_train = np.array( [["a"] * 5 + ["b"] * 20 + ["c"] * 10 + ["d"] * 3], dtype=object ).T ohe = OneHotEncoder( categories=[["c", "d", "a", "b"]], sparse=False, handle_unknown="infrequent_if_exist", max_categories=2, ...
76,200
260,354
119
sklearn/decomposition/_sparse_pca.py
34
14
def fit(self, X, y=None): self._v
MAINT Use _validate_params in SparsePCA and MiniBatchSparsePCA (#23710) Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com> Co-authored-by: jeremiedbb <jeremiedbb@yahoo.fr>
fit
db6123fe40400828918037f3fae949bfcc4d9d05
scikit-learn
_sparse_pca.py
10
11
https://github.com/scikit-learn/scikit-learn.git
2
85
0
24
135
Python
{ "docstring": "Fit the model from data in X.\n\n Parameters\n ----------\n X : array-like of shape (n_samples, n_features)\n Training vector, where `n_samples` is the number of samples\n and `n_features` is the number of features.\n\n y : Ignored\n Not use...
def fit(self, X, y=None): self._validate_params() random_state = check_random_state(self.random_state) X = self._validate_data(X) self.mean_ = X.mean(axis=0) X = X - self.mean_ if self.n_components is None: n_components = X.shape[1] else: ...
11,200
55,077
74
tests/cli/test_profile.py
21
11
def test_create_profile(): invoke_and_assert( ["profile", "create", "foo"], expected_output=( f ), ) profiles = load_profiles() assert profiles["foo"] == Profile( name="foo", settings={}, source=PREFECT_PROFI
Add tests for profile CLI
test_create_profile
808660dd04465fc796a34e835467e8ae1f2449b3
prefect
test_profile.py
11
21
https://github.com/PrefectHQ/prefect.git
1
52
0
20
89
Python
{ "docstring": "\n Created profile 'foo'.\n\n Switch to your new profile with:\n\n prefect profile use 'foo'\n\n Or, to use it for a single command, include the `-p` option:\n\n prefect -p 'foo' config view\n ", "language": "en", "n_whitesp...
def test_create_profile(): invoke_and_assert( ["profile", "create", "foo"], expected_output=( f ), ) profiles = load_profiles() assert profiles["foo"] == Profile( name="foo", settings={}, source=PREFECT_PROFILES_PATH.value() )
23,693
109,648
160
lib/matplotlib/tests/test_axes.py
97
21
def test_mixed_errorbar_polar_caps(): fig = plt.figure() ax = plt.subplot(111, projection='polar') # symmetric errorbars th_sym = [1, 2, 3] r_sym = [0.9]*3 ax.errorbar(th_sym, r_sym, xerr=0.35, yerr=0.2, fmt="o") # long errorbars th_long = [np.pi/2 + .1, np.pi + .1] r_long = [...
Curved polar errorbars - uses _interpolation_steps - prefers transform MarkerStyle in init over _transform property - adjusted what's new - added more tests for overlapping, asymmetric and long errorbars - combine all tests to a single figure - remove overlappnig since it does not work same on all platforms - r...
test_mixed_errorbar_polar_caps
907f78dbf959c0609ab484c59e840eea3eafee31
matplotlib
test_axes.py
11
17
https://github.com/matplotlib/matplotlib.git
1
273
0
72
348
Python
{ "docstring": "\n Mix several polar errorbar use cases in a single test figure.\n\n It is advisable to position individual points off the grid. If there are\n problems with reproducibility of this test, consider removing grid.\n ", "language": "en", "n_whitespaces": 46, "n_words": 33, "vocab_size...
def test_mixed_errorbar_polar_caps(): fig = plt.figure() ax = plt.subplot(111, projection='polar') # symmetric errorbars th_sym = [1, 2, 3] r_sym = [0.9]*3 ax.errorbar(th_sym, r_sym, xerr=0.35, yerr=0.2, fmt="o") # long errorbars th_long = [np.pi/2 + .1, np.pi + .1] r_long = [...
41,701
176,114
46
tests/test_eval_model.py
11
3
def test_edgeql_for_01(self): self.assert_test_query( r, {(1, 1), (2, 2), (3, 3)}, )
Pull assert_data_shape out of testbase.server and use it for model tests (#3315)
test_edgeql_for_01
20ca6e2fa7bab2adc8c37d8c42049076c692782e
edgedb
test_eval_model.py
9
7
https://github.com/edgedb/edgedb.git
1
33
0
11
46
Python
{ "docstring": "\n FOR X IN {1,2,3} UNION ((SELECT X), (SELECT X));\n ", "language": "en", "n_whitespaces": 32, "n_words": 9, "vocab_size": 9 }
def test_edgeql_for_01(self): self.assert_test_query( r, {(1, 1), (2, 2), (3, 3)}, )
117,320
320,737
78
qutebrowser/browser/downloadview.py
17
13
def on_clicked(self, index): if not index.isValid(): return item = self._model().data(index, downloads.ModelRole.item) if item.done and item.successful: item.open_file() item.remove()
mypy: Upgrade to PyQt5-stubs 5.15.6.0 For some unknown reason, those new stubs cause a *lot* of things now to be checked by mypy which formerly probably got skipped due to Any being implied somewhere. The stubs themselves mainly improved, with a couple of regressions too. In total, there were some 337 (!) new mypy e...
on_clicked
a20bb67a878b2e68abf8268c1b0a27f018d01352
qutebrowser
downloadview.py
10
7
https://github.com/qutebrowser/qutebrowser.git
4
54
0
16
91
Python
{ "docstring": "Handle clicking of an item.\n\n Args:\n index: The QModelIndex of the clicked item.\n ", "language": "en", "n_whitespaces": 38, "n_words": 13, "vocab_size": 11 }
def on_clicked(self, index): if not index.isValid(): return item = self._model().data(index, downloads.ModelRole.item) if item.done and item.successful: item.open_file() item.remove()
@add_start_docstrings( """ XLM-RoBERTa-xlarge Model transformer with a sequence classification/regression head on top (a linear layer on top of the pooled output) e.g. for GLUE tasks. """, XLM_ROBERTA_XL_START_DOCSTRING, )
6,311
34,690
44
src/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py
27
6
def _tie_weights(self): # To tie those two weights if they get disconnec
Add support for XLM-R XL and XXL models by modeling_xlm_roberta_xl.py (#13727) * add xlm roberta xl * add convert xlm xl fairseq checkpoint to pytorch * fix init and documents for xlm-roberta-xl * fix indention * add test for XLM-R xl,xxl * fix model hub name * fix some stuff * up * correct ini...
_tie_weights
e09473a817c5e5871e11cc81004355ef30250502
transformers
modeling_xlm_roberta_xl.py
8
2
https://github.com/huggingface/transformers.git
1
14
1
27
38
Python
{ "docstring": "\n XLM-RoBERTa-xlarge Model transformer with a sequence classification/regression head on top (a linear layer on top\n of the pooled output) e.g. for GLUE tasks.\n ", "language": "en", "n_whitespaces": 33, "n_words": 23, "vocab_size": 21 }
def _tie_weights(self): # To tie those two weights if they get disconnected (on TPU or when the bias is resized) self.bias = self.decoder.bias @add_start_docstrings( , XLM_ROBERTA_XL_START_DOCSTRING, )
3,071
19,706
23
pipenv/installers.py
9
5
def matches_minor(self, other): re
Issue 4993 Add standard pre commit hooks and apply linting. (#4994) * Add .pre-commit-config.yaml to the project and exclude tests (for now). This does not include the MyPy linting that pip does but does include everything else.
matches_minor
9a3b3ce70621af6f9adaa9eeac9cf83fa149319c
pipenv
installers.py
8
2
https://github.com/pypa/pipenv.git
1
28
0
9
43
Python
{ "docstring": "Check whether this version matches the other in (major, minor).", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
def matches_minor(self, other): return (self.major, self.minor) == (other.major, other.minor)
25,781
116,582
73
mindsdb/integrations/handlers/lightwood_handler/tests/test_lightwood_handler.py
24
15
def test_04_query_predictor_single_where_condition(self): time.sleep(120) # TODO query = f response = self.handler.native_query(query) self.assertTrue(response.type == RESPONSE_TYPE.TABLE) self.assertTrue(len(response.data_frame) == 1) self.assertTrue(response.data_frame...
test fix
test_04_query_predictor_single_where_condition
b999051fd8153a1d3624471cac5483867116f985
mindsdb
test_lightwood_handler.py
11
12
https://github.com/mindsdb/mindsdb.git
1
83
0
21
143
Python
{ "docstring": "\n SELECT target\n from {self.test_model_1}\n WHERE sqft=100\n ", "language": "en", "n_whitespaces": 47, "n_words": 6, "vocab_size": 6 }
def test_04_query_predictor_single_where_condition(self): time.sleep(120) # TODO query = f response = self.handler.native_query(query) self.assertTrue(response.type == RESPONSE_TYPE.TABLE) self.assertTrue(len(response.data_frame) == 1) self.assertTrue(response.data_frame...