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
23,469
109,189
201
lib/matplotlib/tri/triinterpolate.py
89
20
def _roll_vectorized(M, roll_indices, axis): assert axis in [0, 1] ndim = M.ndim assert ndim == 3 ndim_roll = roll_indices.ndim assert ndim_roll == 1 sh = M.shape r, c = sh[-2:] assert sh[0] == roll_indices.shape[0] vec_indices = np.arange(sh[0], dtype=np.int32) # Builds th...
Clean up code in tri
_roll_vectorized
c739787b88f6bf36f5ac5603b84773287bcd98b7
matplotlib
triinterpolate.py
18
20
https://github.com/matplotlib/matplotlib.git
6
177
0
51
266
Python
{ "docstring": "\n Roll an array of matrices along *axis* (0: rows, 1: columns) according to\n an array of indices *roll_indices*.\n ", "language": "en", "n_whitespaces": 28, "n_words": 18, "vocab_size": 15 }
def _roll_vectorized(M, roll_indices, axis): assert axis in [0, 1] ndim = M.ndim assert ndim == 3 ndim_roll = roll_indices.ndim assert ndim_roll == 1 sh = M.shape r, c = sh[-2:] assert sh[0] == roll_indices.shape[0] vec_indices = np.arange(sh[0], dtype=np.int32) # Builds th...
999
6,463
256
tests/integration_tests/test_visualization_api.py
44
25
def test_calibration_1_vs_all_vis_api(experiment_to_use): experiment = experiment_to_use probabilities = experiment.probabilities viz_outputs = ("pdf", "png") with TemporaryDirectory() as tmpvizdir: for viz_output in viz_outputs: vis_output_pattern_pdf = os.path.join(tmpvizdir, ...
Added lightweight preprocessor for categorical features (#1761) * Added lightweight preprocessor for categorical features * Fix visualization tests. * Get the number of classes from metadata instead of figuring it out on the fly from ground truth labels. Co-authored-by: Justin Zhao <justinxzhao@gmail.com>
test_calibration_1_vs_all_vis_api
f277e3bff51842c93f99187605dfaf19b5790b29
ludwig
test_visualization_api.py
14
20
https://github.com/ludwig-ai/ludwig.git
2
110
0
40
178
Python
{ "docstring": "Ensure pdf and png figures can be saved via visualization API call.\n\n :param experiment_to_use: Object containing trained model and results to\n test visualization\n :return: None\n ", "language": "en", "n_whitespaces": 41, "n_words": 25, "vocab_size": 23 }
def test_calibration_1_vs_all_vis_api(experiment_to_use): experiment = experiment_to_use probabilities = experiment.probabilities viz_outputs = ("pdf", "png") with TemporaryDirectory() as tmpvizdir: for viz_output in viz_outputs: vis_output_pattern_pdf = os.path.join(tmpvizdir, ...
71,968
247,872
800
tests/rest/admin/test_server_notice.py
240
42
def test_send_server_notice_delete_room(self) -> None: # user has no room memberships self._check_invite_and_join_status(self.other_user, 0, 0) # send first message channel = self.make_request( "POST", self.url, access_token=self.admin_user_t...
Remove redundant `get_success` calls in test code (#12346) There are a bunch of places we call get_success on an immediate value, which is unnecessary. Let's rip them out, and remove the redundant functionality in get_success and friends.
test_send_server_notice_delete_room
33ebee47e4e96a2b6fdf72091769e59034dc550f
synapse
test_server_notice.py
14
55
https://github.com/matrix-org/synapse.git
1
443
0
122
715
Python
{ "docstring": "\n Tests that the user get server notice in a new room\n after the first server notice room was deleted.\n ", "language": "en", "n_whitespaces": 41, "n_words": 19, "vocab_size": 15 }
def test_send_server_notice_delete_room(self) -> None: # user has no room memberships self._check_invite_and_join_status(self.other_user, 0, 0) # send first message channel = self.make_request( "POST", self.url, access_token=self.admin_user_t...
47,232
195,244
46
projects/bb3/agents/utils.py
14
6
def is_request_failed_response(resp): return len( resp.get('failures', []) ) > 0 or APIUtils.METASEQ_FAIL_MESSAGE_TEXT in resp.get('text', '')
Patch 8322 (#4709) * add dafetymix teacher * safety_mix teacher * safety_mix teacher pos and neg teachers * add tests for teacher * add license info * improvement * add task list * add task list and lint * add init.py * adding some patch to director * seeker changes * th * 3 * ji...
is_request_failed_response
b1acb681207559da56a787ba96e16f0e23697d92
ParlAI
utils.py
12
4
https://github.com/facebookresearch/ParlAI.git
2
34
0
14
61
Python
{ "docstring": "\n Whether the requests to Metaseq worker have failed.\n\n It checks this based on the existences of the failure reasons as they get\n accumulated in `_make_request` functionn calls.\n ", "language": "en", "n_whitespaces": 56, "n_words": 27, "vocab_size": 25 }
def is_request_failed_response(resp): return len( resp.get('failures', []) ) > 0 or APIUtils.METASEQ_FAIL_MESSAGE_TEXT in resp.get('text', '')
23,337
108,776
96
lib/matplotlib/patches.py
36
9
def draw(self, renderer): if not self.get_visibl
Remove ineffective exclusion of Arcs without parent Axes. The `if not hasattr(self, 'axes'): raise RuntimeError(...)` check was ineffectual, as artists now always have an Axes attribute, which can just be None for some artists. In fact, small Arcs are drawn just fine without a parent Axes; e.g. ``` from pylab import ...
draw
cf995d1304bfa7f660e7158b5121a46e54f869f2
matplotlib
patches.py
9
50
https://github.com/matplotlib/matplotlib.git
11
404
0
31
74
Python
{ "docstring": "\n Draw the arc to the given *renderer*.\n\n Notes\n -----\n Ellipses are normally drawn using an approximation that uses\n eight cubic Bezier splines. The error of this approximation\n is 1.89818e-6, according to this unverified source:\n\n Lancaste...
def draw(self, renderer): if not self.get_visible(): return self._recompute_transform() width = self.convert_xunits(self.width) height = self.convert_yunits(self.height) # If the width and height of ellipse are not equal, take into account # stretc...
76,944
261,701
519
sklearn/utils/_param_validation.py
160
18
def validate_parameter_constraints(parameter_constraints, params, caller_name): for param_name, param_val in params.items(): # We allow parameters to not have a constraint so that third party estimators # can inherit from sklearn estimators without having to necessarily use the # valida...
MAINT Make param validation more lenient towards downstream dependencies (#25088)
validate_parameter_constraints
5e25f8e06dcf853d4079dbefa40e3e9558a1d976
scikit-learn
_param_validation.py
25
32
https://github.com/scikit-learn/scikit-learn.git
11
137
0
105
261
Python
{ "docstring": "Validate types and values of given parameters.\n\n Parameters\n ----------\n parameter_constraints : dict or {\"no_validation\"}\n If \"no_validation\", validation is skipped for this parameter.\n\n If a dict, it must be a dictionary `param_name: list of constraints`.\n A...
def validate_parameter_constraints(parameter_constraints, params, caller_name): for param_name, param_val in params.items(): # We allow parameters to not have a constraint so that third party estimators # can inherit from sklearn estimators without having to necessarily use the # valida...
77,461
263,844
162
PyInstaller/building/build_main.py
92
13
def _get_module_collection_mode(mode_dict, name): mode = 'pyc' # Default mode # No settings available - return default. if not mode_dict: return mode # Search the parent modules/pa
building & hooks: implement module collection mode setting Implement a mechanism for controlling the collection mode of modules and packages, with granularity ranging from top-level packages to individual sub-modules. Therefore, the hooks can now specify whether the hooked package should be collected as byte-compiled ...
_get_module_collection_mode
5b2ab7067ba954bd7950a79ed31e5ee177ff3f43
pyinstaller
build_main.py
13
11
https://github.com/pyinstaller/pyinstaller.git
4
71
0
64
125
Python
{ "docstring": "\n Determine the module/package collection mode for the given module name , based on the provided collection\n mode settings dictionary.\n ", "language": "en", "n_whitespaces": 29, "n_words": 19, "vocab_size": 15 }
def _get_module_collection_mode(mode_dict, name): mode = 'pyc' # Default mode # No settings available - return default. if not mode_dict: return mode # Search the parent modules/packages in top-down fashion, and take the last given setting. This ensures that # a setting given for the...
81,781
276,928
46
keras/utils/kernelized_utils.py
25
13
def exact_gaussian_kernel(x, y, stddev): r x_aligned, y_aligned = _align_matrices(x, y)
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
exact_gaussian_kernel
84afc5193d38057e2e2badf9c889ea87d80d8fbf
keras
kernelized_utils.py
11
29
https://github.com/keras-team/keras.git
1
56
0
23
85
Python
{ "docstring": "Computes exact Gaussian kernel value(s) for tensors x and y and stddev.\n\n The Gaussian kernel for vectors u, v is defined as follows:\n K(u, v) = exp(-||u-v||^2 / (2* stddev^2))\n where the norm is the l2-norm. x, y can be either vectors or matrices. If they\n are vectors, they must...
def exact_gaussian_kernel(x, y, stddev): r x_aligned, y_aligned = _align_matrices(x, y) diff_squared_l2_norm = tf.reduce_sum( tf.math.squared_difference(x_aligned, y_aligned), 2 ) return tf.exp(-diff_squared_l2_norm / (2 * stddev * stddev))
78,221
265,867
190
netbox/extras/models/models.py
42
27
def enqueue_job(cls, func, name, obj_type, user, schedule_at=None, *args, **kwargs): job_result: JobResult = cls.objects.create( name=name, obj_type=obj_type, user=user, job_id=uuid.uuid4() ) queue = django_rq.get_queue("default") ...
Job scheduling review changes
enqueue_job
ed2f7f12369fe0b8f2dc2a5910840c928126a1b8
netbox
models.py
14
16
https://github.com/netbox-community/netbox.git
2
132
0
35
199
Python
{ "docstring": "\n Create a JobResult instance and enqueue a job using the given callable\n\n func: The callable object to be enqueued for execution\n name: Name for the JobResult instance\n obj_type: ContentType to link to the JobResult instance obj_type\n user: User object to link...
def enqueue_job(cls, func, name, obj_type, user, schedule_at=None, *args, **kwargs): job_result: JobResult = cls.objects.create( name=name, obj_type=obj_type, user=user, job_id=uuid.uuid4() ) queue = django_rq.get_queue("default") ...
44,160
183,357
73
src/textual/dom.py
27
8
def text_style(self) -> Style: # TODO: Feels like there may be opportunity for caching here. style = Style() for node in reversed(self.an
auto sizing
text_style
efd4273a4ca8282b677e43f4732013e60926753b
textual
dom.py
10
14
https://github.com/Textualize/textual.git
2
32
0
24
55
Python
{ "docstring": "Get the text style object.\n\n A widget's style is influenced by its parent. For instance if a widgets background has an alpha,\n then its parent's background color will show through. Additionally, widgets will inherit their\n parent's text style (i.e. bold, italic etc).\n\n ...
def text_style(self) -> Style: # TODO: Feels like there may be opportunity for caching here. style = Style() for node in reversed(self.ancestors): style += node.styles.text_style return style
50,401
203,482
94
django/contrib/admin/sites.py
34
13
def get_app_list(self, request): app_dict = self._build_app_dict(request) # Sort the apps alphabetically.
Refs #33476 -- Reformatted code with Black.
get_app_list
9c19aff7c7561e3a82978a272ecdaad40dda5c00
django
sites.py
14
6
https://github.com/django/django.git
2
64
0
28
110
Python
{ "docstring": "\n Return a sorted list of all the installed apps that have been\n registered in this site.\n ", "language": "en", "n_whitespaces": 38, "n_words": 16, "vocab_size": 16 }
def get_app_list(self, request): app_dict = self._build_app_dict(request) # Sort the apps alphabetically. app_list = sorted(app_dict.values(), key=lambda x: x["name"].lower()) # Sort the models alphabetically within each app. for app in app_list: app["model...
56,635
222,558
431
python3.10.4/Lib/distutils/ccompiler.py
241
6
def find_library_file (self, dirs, lib, debug=0): raise NotImplementedError # -- Filename generation methods ----------------------------------- # The default implementation of the filename generating methods are # prejudiced towards the Unix/DOS/Windows view of the world: # * objec...
add python 3.10.4 for windows
find_library_file
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
ccompiler.py
6
2
https://github.com/XX-net/XX-Net.git
1
16
0
128
57
Python
{ "docstring": "Search the specified list of directories for a static or shared\n library file 'lib' and return the full path to that file. If\n 'debug' true, look for a debugging version (if that makes sense on\n the current platform). Return None if 'lib' wasn't found in any of\n the s...
def find_library_file (self, dirs, lib, debug=0): raise NotImplementedError # -- Filename generation methods ----------------------------------- # The default implementation of the filename generating methods are # prejudiced towards the Unix/DOS/Windows view of the world: # * objec...
71,988
247,900
200
tests/storage/databases/main/test_lock.py
74
13
def test_simple_lock(self): # First to acquire this lock, so it should complete lock = self.get_success(self.store.try_acquire_lock("name", "key")) assert lock is not None # Enter the context manager self.get_success(lock.__aenter__()) # Attempting to acquire t...
Add type hints for `tests/unittest.py`. (#12347) In particular, add type hints for get_success and friends, which are then helpful in a bunch of places.
test_simple_lock
f0b03186d96305fd44d74a89bf4230beec0c5c31
synapse
test_lock.py
11
12
https://github.com/matrix-org/synapse.git
1
138
0
46
236
Python
{ "docstring": "Test that we can take out a lock and that while we hold it nobody\n else can take it out.\n ", "language": "en", "n_whitespaces": 34, "n_words": 20, "vocab_size": 15 }
def test_simple_lock(self): # First to acquire this lock, so it should complete lock = self.get_success(self.store.try_acquire_lock("name", "key")) assert lock is not None # Enter the context manager self.get_success(lock.__aenter__()) # Attempting to acquire t...
23,536
109,341
69
lib/matplotlib/font_manager.py
19
8
def set_family(self, family): if family is None: family
Get rcParams from mpl
set_family
438d30b227b1fef7e8733578f851e76a8e360f24
matplotlib
font_manager.py
10
6
https://github.com/matplotlib/matplotlib.git
3
39
0
13
65
Python
{ "docstring": "\n Change the font family. May be either an alias (generic name\n is CSS parlance), such as: 'serif', 'sans-serif', 'cursive',\n 'fantasy', or 'monospace', a real font name or a list of real\n font names. Real font names are not supported when\n :rc:`text.usetex` i...
def set_family(self, family): if family is None: family = mpl.rcParams['font.family'] if isinstance(family, str): family = [family] self._family = family
24,992
113,656
26
nni/compression/pytorch/quantization/qat_quantizer.py
17
4
def update_ema(biased_ema, value, decay):
[Compression] remove pruning v1 & refactor directory (#5228)
update_ema
d68c786ff81bad19c04619d6a999ff34aaa724e7
nni
qat_quantizer.py
10
3
https://github.com/microsoft/nni.git
1
25
0
14
40
Python
{ "docstring": "\n calculate biased stat and unbiased stat in each step using exponential moving average method\n\n Parameters\n ----------\n biased_ema : float\n previous stat value\n value : float\n current stat value\n decay : float\n the weight of previous stat value, larger...
def update_ema(biased_ema, value, decay): biased_ema = biased_ema * decay + (1 - decay) * value return biased_ema
47,456
195,869
318
sympy/ntheory/partitions_.py
158
38
def npartitions(n, verbose=False): n = int(n) if n < 0: return 0 if n <= 5: return [1, 1, 2, 3, 5, 7][n] if '_factor' not in globals(): _pre() # Estimate number of bits in p(n). This formula could be tidied pbits = int(( math.pi*(2*n/3.)**0.5 - math.l...
Improved documentation formatting
npartitions
cda8dfe6f45dc5ed394c2f5cda706cd6c729f713
sympy
partitions_.py
18
27
https://github.com/sympy/sympy.git
7
298
0
116
450
Python
{ "docstring": "\n Calculate the partition function P(n), i.e. the number of ways that\n n can be written as a sum of positive integers.\n\n P(n) is computed using the Hardy-Ramanujan-Rademacher formula [1]_.\n\n\n The correctness of this implementation has been tested through $10^10$.\n\n Examples\n ...
def npartitions(n, verbose=False): n = int(n) if n < 0: return 0 if n <= 5: return [1, 1, 2, 3, 5, 7][n] if '_factor' not in globals(): _pre() # Estimate number of bits in p(n). This formula could be tidied pbits = int(( math.pi*(2*n/3.)**0.5 - math.l...
79,642
268,742
45
test/lib/ansible_test/_internal/host_profiles.py
17
13
def build_sleep_command(self) -> list[str]: doc
ansible-test - Improve container management. (#78550) See changelogs/fragments/ansible-test-container-management.yml for details.
build_sleep_command
cda16cc5e9aa8703fb4e1ac0a0be6b631d9076cc
ansible
host_profiles.py
11
15
https://github.com/ansible/ansible.git
1
46
0
16
90
Python
{ "docstring": "\n Build and return the command to put the container to sleep.\n\n The sleep duration below was selected to:\n\n - Allow enough time to perform necessary operations in the container before waking it.\n - Make the delay obvious if the wake command doesn't run or succeed....
def build_sleep_command(self) -> list[str]: docker_pull(self.args, self.config.image) inspect = docker_image_inspect(self.args, self.config.image) return ['sh', '-c', f'sleep 60; exec {shlex.join(inspect.cmd)}']
30,874
136,321
456
rllib/evaluation/tests/test_envs_that_crash.py
94
23
def test_crash_only_one_worker_during_sampling_but_ignore(self): config = ( pg.PGConfig() .rollouts( num_rollout_workers=2, num_envs_per_worker=3, # Ignore worker failures (continue with worker #2). ignore_worker_fa...
[RLlib] Fault tolerant and elastic WorkerSets used across RLlib's algorithms (for sampling and evaluation). (#30118)
test_crash_only_one_worker_during_sampling_but_ignore
76cb42c578adf19a70a6b4401098a7a21e0d3b29
ray
test_envs_that_crash.py
15
22
https://github.com/ray-project/ray.git
1
98
0
78
164
Python
{ "docstring": "Expect some sub-envs to fail (and not recover), but ignore.", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
def test_crash_only_one_worker_during_sampling_but_ignore(self): config = ( pg.PGConfig() .rollouts( num_rollout_workers=2, num_envs_per_worker=3, # Ignore worker failures (continue with worker #2). ignore_worker_fa...
75,660
259,225
77
sklearn/preprocessing/tests/test_encoders.py
45
17
def test_ohe_infrequent_three_levels_drop_infrequent_errors(drop): X_train = np.array([["a"] * 5 + ["b"] * 20 + ["c"] * 10 + ["d"] * 3
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_three_levels_drop_infrequent_errors
7f0006c8aad1a09621ad19c3db19c3ff0555a183
scikit-learn
test_encoders.py
16
8
https://github.com/scikit-learn/scikit-learn.git
1
82
0
38
149
Python
{ "docstring": "Test three levels and dropping the infrequent category.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 8 }
def test_ohe_infrequent_three_levels_drop_infrequent_errors(drop): X_train = np.array([["a"] * 5 + ["b"] * 20 + ["c"] * 10 + ["d"] * 3]).T ohe = OneHotEncoder( handle_unknown="infrequent_if_exist", sparse=False, max_categories=3, drop=drop ) msg = f"Unable to drop category {drop[0]!r} from...
120,552
334,185
79
utils/check_repo.py
30
4
def is_a_private_model(model): if model in PRIVATE_MODELS:
upload some cleaning tools
is_a_private_model
95f4256fc905b6e29e5ea0f245dcf88f72a9ddd1
diffusers
check_repo.py
8
10
https://github.com/huggingface/diffusers.git
5
45
0
20
82
Python
{ "docstring": "Returns True if the model should not be in the main init.", "language": "en", "n_whitespaces": 11, "n_words": 12, "vocab_size": 11 }
def is_a_private_model(model): if model in PRIVATE_MODELS: return True # Wrapper, Encoder and Decoder are all privates if model.endswith("Wrapper"): return True if model.endswith("Encoder"): return True if model.endswith("Decoder"): return True return False ...
@freeze_time("2019-01-10 10:00:00-08:00")
93,329
294,292
78
tests/components/tod/test_binary_sensor.py
33
10
async def test_midnight_turnover_before_midnight_outside_period(hass): config = { "binary_sensor": [ {"platform": "tod", "name": "Night", "after": "22:00", "before": "5:00"} ] } await async_setup_component(hass, "binary_sensor", config) await hass.async_block_till_done()...
Update Times of the Day tests to use freezegun (#68327)
test_midnight_turnover_before_midnight_outside_period
23a630e0bcbd2aec6a598a19ebaf2929eba97e5b
core
test_binary_sensor.py
12
10
https://github.com/home-assistant/core.git
1
62
1
31
131
Python
{ "docstring": "Test midnight turnover setting before midnight outside period.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 7 }
async def test_midnight_turnover_before_midnight_outside_period(hass): config = { "binary_sensor": [ {"platform": "tod", "name": "Night", "after": "22:00", "before": "5:00"} ] } await async_setup_component(hass, "binary_sensor", config) await hass.async_block_till_done()...
29,327
130,601
94
python/ray/data/impl/block_list.py
28
4
def _check_if_cleared(self) -> None: if self._blocks is None: raise ValueError( "This Dataset's blocks have been moved, which means that you " "can no longer use this Dataset." )
[CI] Format Python code with Black (#21975) See #21316 and #21311 for the motivation behind these changes.
_check_if_cleared
7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065
ray
block_list.py
11
7
https://github.com/ray-project/ray.git
2
21
0
27
41
Python
{ "docstring": "Raise an error if this BlockList has been previously cleared.", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
def _check_if_cleared(self) -> None: if self._blocks is None: raise ValueError( "This Dataset's blocks have been moved, which means that you " "can no longer use this Dataset." )
71,954
247,834
155
tests/rest/client/test_sync.py
38
17
def test_join_leave(self) -> None: channel = self.make_request("GET", "/sync", access_token=self.tok) self.assertEqual(channel.code, 200, channel.result) self.assertNotIn(self.excluded_room_id, channel.json_body["rooms"]["join"]) self.assertIn(self.included_room_id, channel.jso...
Add a configuration to exclude rooms from sync response (#12310)
test_join_leave
437a8ed9efdf8f1aefa092d0761076da3ae78100
synapse
test_sync.py
11
18
https://github.com/matrix-org/synapse.git
1
188
0
27
301
Python
{ "docstring": "Tests that rooms are correctly excluded from the 'join' and 'leave' sections of\n sync responses.\n ", "language": "en", "n_whitespaces": 29, "n_words": 15, "vocab_size": 15 }
def test_join_leave(self) -> None: channel = self.make_request("GET", "/sync", access_token=self.tok) self.assertEqual(channel.code, 200, channel.result) self.assertNotIn(self.excluded_room_id, channel.json_body["rooms"]["join"]) self.assertIn(self.included_room_id, channel.jso...
15,992
73,213
38
wagtail/contrib/modeladmin/tests/test_page_modeladmin.py
10
7
def test_short_description_is_used_as_field_label(self):
Reformat with black
test_short_description_is_used_as_field_label
d10f15e55806c6944827d801cd9c2d53f5da4186
wagtail
test_page_modeladmin.py
9
4
https://github.com/wagtail/wagtail.git
1
32
0
10
59
Python
{ "docstring": "\n A custom field has been added to the inspect view's `inspect_view_fields` and since\n this field has a `short_description` we expect it to be used as the field's label,\n and not use the name of the function.\n ", "language": "en", "n_whitespaces": 65, "n_words": 3...
def test_short_description_is_used_as_field_label(self): response = self.client.get("/admin/modeladmintest/author/inspect/1/") self.assertContains(response, "Birth information") self.assertNotContains(response, "author_birth_string")
14,584
67,630
103
erpnext/stock/doctype/item/item.py
127
14
def check_stock_uom_with_bin(item, stock_uom): if stock_uom == frappe.db.get_value("Item", item, "stock_uom"): return ref_uom = frappe.db.get_value("Stock Ledger Entry", {"item_code": item}, "stock_uom") if ref_uom: if cstr(ref_uom) != cstr(stock_uom): frappe.throw( _( "Default Unit of Measure for ...
style: format code with black
check_stock_uom_with_bin
494bd9ef78313436f0424b918f200dab8fc7c20b
erpnext
item.py
16
27
https://github.com/frappe/erpnext.git
5
122
0
84
204
Python
{ "docstring": "\n\t\t\tselect * from tabBin where item_code = %s\n\t\t\t\tand (reserved_qty > 0 or ordered_qty > 0 or indented_qty > 0 or planned_qty > 0)\n\t\t\t\tand stock_uom != %s\n\t\t\tupdate tabBin set stock_uom=%s where item_code=%s", "language": "en", "n_whitespaces": 30, "n_words": 34, "vocab_size"...
def check_stock_uom_with_bin(item, stock_uom): if stock_uom == frappe.db.get_value("Item", item, "stock_uom"): return ref_uom = frappe.db.get_value("Stock Ledger Entry", {"item_code": item}, "stock_uom") if ref_uom: if cstr(ref_uom) != cstr(stock_uom): frappe.throw( _( "Default Unit of Measure for ...
@click.command() @click.option( "--with-docs/--without-docs", default=False, help="Synchronize and repair embedded documentation. This " "is disabled by default.", ) @configuration
18,700
90,853
66
src/sentry/runner/commands/repair.py
33
16
def fix_group_counters(): from django.db import connection click.echo("Correcting Group.num_comments counter") cursor = connection.cursor() cursor.execute( , [ActivityType.NOTE.value], ) @click.command() @click.option( "--with-docs/--without-docs", default=False, help=...
ref(models): `ActivityType` (#34978) ## Objective: We want to separate enum logic from Model logic. This breaks a lot of circular dependencies.
fix_group_counters
b9f5a910dc841b85f58d46266ec049ae5a7fd305
sentry
repair.py
10
13
https://github.com/getsentry/sentry.git
1
38
1
32
109
Python
{ "docstring": "\n UPDATE sentry_groupedmessage SET num_comments = (\n SELECT COUNT(*) from sentry_activity\n WHERE type = %s and group_id = sentry_groupedmessage.id\n )\n ", "language": "en", "n_whitespaces": 59, "n_words": 19, "vocab_size": 17 }
def fix_group_counters(): from django.db import connection click.echo("Correcting Group.num_comments counter") cursor = connection.cursor() cursor.execute( , [ActivityType.NOTE.value], ) @click.command() @click.option( "--with-docs/--without-docs", default=False, help=...
18,769
91,564
1,158
src/sentry/search/events/filter.py
307
53
def get_filter(query=None, params=None, parser_config_overrides=None): # NOTE: this function assumes project permissions check already happened
fix(metric_alerts): Prevent date fields from being used as filters in metric alerts (#35762) Since metric alerts are relative alerts based on the current time and the timestamp, it doesn't make sense to filter on dates within them. There were also cases where people would use relative syntax like `-24h`, which would...
get_filter
0d29073264ceea2dd8b1528f98bedb6e6771d383
sentry
filter.py
19
87
https://github.com/getsentry/sentry.git
32
568
0
185
980
Python
{ "docstring": "\n Returns an eventstore filter given the search text provided by the user and\n URL params\n ", "language": "en", "n_whitespaces": 25, "n_words": 15, "vocab_size": 14 }
def get_filter(query=None, params=None, parser_config_overrides=None): # NOTE: this function assumes project permissions check already happened parsed_terms = [] if query is not None: try: parsed_terms = parse_search_query( query, params=params, config_overrides=pars...
4,094
21,956
139
pipenv/patched/pip/_vendor/chardet/universaldetector.py
36
14
def reset(self): self.result = {"en
Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir.
reset
cd5a9683be69c86c8f3adcd13385a9bc5db198ec
pipenv
universaldetector.py
10
13
https://github.com/pypa/pipenv.git
4
89
0
28
147
Python
{ "docstring": "\n Reset the UniversalDetector and all of its probers back to their\n initial states. This is called by ``__init__``, so you only need to\n call this directly in between analyses of different documents.\n ", "language": "en", "n_whitespaces": 62, "n_words": 32, "vo...
def reset(self): self.result = {"encoding": None, "confidence": 0.0, "language": None} self.done = False self._got_data = False self._has_win_bytes = False self._input_state = InputState.PURE_ASCII self._last_char = b"" if self._esc_charset_prober: ...
117,128
320,322
294
src/paperless/tests/test_settings.py
30
7
def test_redis_socket_parsing(self): for input, expected in [ (None, ("redis://localhost:6379", "redis://localhost:6379")), ( "redis+socket:///run/redis/redis.sock", ( "redis+socket:///run/redis/redis.sock", ...
Adds a layer to translate between differing formats of socket based Redis URLs
test_redis_socket_parsing
01d070b882ef9027bef9a046852c2060119edd5d
paperless-ngx
test_settings.py
10
20
https://github.com/paperless-ngx/paperless-ngx.git
2
62
0
20
103
Python
{ "docstring": "\n GIVEN:\n - Various Redis connection URI formats\n WHEN:\n - The URI is parsed\n THEN:\n - Socket based URIs are translated\n - Non-socket URIs are unchanged\n - None provided uses default\n ", "language": "en", "...
def test_redis_socket_parsing(self): for input, expected in [ (None, ("redis://localhost:6379", "redis://localhost:6379")), ( "redis+socket:///run/redis/redis.sock", ( "redis+socket:///run/redis/redis.sock", ...
73,612
251,156
79
mitmproxy/http.py
35
12
def path_components(self) -> tuple[str, ...]: path = urllib.parse.urlparse(self.url).path # This needs to be a tuple so that it's immutable. # Otherwise, this would fail silently: # request.path_comp
`pyupgrade --py39-plus **/*.py`
path_components
e83ec8390ad6be6a86cfcfc57bce14cb8861bf32
mitmproxy
http.py
11
7
https://github.com/mitmproxy/mitmproxy.git
3
48
0
33
81
Python
{ "docstring": "\n The URL's path components as a tuple of strings.\n Components are unquoted.\n ", "language": "en", "n_whitespaces": 34, "n_words": 12, "vocab_size": 12 }
def path_components(self) -> tuple[str, ...]: path = urllib.parse.urlparse(self.url).path # This needs to be a tuple so that it's immutable. # Otherwise, this would fail silently: # request.path_components.append("foo") return tuple(url.unquote(i) for i in path.split("...
76,769
261,349
164
sklearn/utils/__init__.py
68
15
def gen_batches(n, batch_size, *, min_batch_size=0): if not isinstance(batch_size, numbers.Integral): raise TypeError( "gen_batches got batch_size=%s, must be an integer" % batch_size ) if batch_size <= 0: raise ValueError("gen_batches got batch_size=%s, must be positive...
DOC Ensure that gen_batches passes numpydoc validation (#24609)
gen_batches
0003ee0492e420783fd9aa665903d9d489736369
scikit-learn
__init__.py
11
16
https://github.com/scikit-learn/scikit-learn.git
6
91
0
46
155
Python
{ "docstring": "Generator to create slices containing `batch_size` elements from 0 to `n`.\n\n The last slice may contain less than `batch_size` elements, when\n `batch_size` does not divide `n`.\n\n Parameters\n ----------\n n : int\n Size of the sequence.\n batch_size : int\n Number ...
def gen_batches(n, batch_size, *, min_batch_size=0): if not isinstance(batch_size, numbers.Integral): raise TypeError( "gen_batches got batch_size=%s, must be an integer" % batch_size ) if batch_size <= 0: raise ValueError("gen_batches got batch_size=%s, must be positive...
70,917
245,868
917
tests/test_models/test_dense_heads/test_condinst_head.py
228
55
def test_condinst_maskhead_loss(self): s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'pad_shape': (s, s, 3), 'scale_factor': 1, }] condinst_bboxhead = CondInstBboxHead( num_classes=4, in_channels=1, feat_ch...
[Feature]: Support Condinst (#9223) * [Feature]: support condinst for instance segmentation * update * update * update * fix config name and add test unit * fix squeeze error * add README and chang mask to poly
test_condinst_maskhead_loss
79c8295801acedee0cbdbf128a01b9fe162646b0
mmdetection
test_condinst_head.py
16
56
https://github.com/open-mmlab/mmdetection.git
2
412
0
134
641
Python
{ "docstring": "Tests condinst maskhead loss when truth is empty and non-empty.", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
def test_condinst_maskhead_loss(self): s = 256 img_metas = [{ 'img_shape': (s, s, 3), 'pad_shape': (s, s, 3), 'scale_factor': 1, }] condinst_bboxhead = CondInstBboxHead( num_classes=4, in_channels=1, feat_ch...
43,431
181,643
23
tests/feature_transformers_tests.py
11
10
def test_ContinuousSelector_2(): cs = ContinuousSelector(threshold=5, svd_solver='randomized') X_transformed = cs.transform(iris_da
Revert "Deployed 7ccda9a with MkDocs version: 1.3.0" This reverts commit bd9629c40e01241766197119b581a99409b07068.
test_ContinuousSelector_2
388616b6247ca4ea8de4e2f340d6206aee523541
tpot
feature_transformers_tests.py
10
4
https://github.com/EpistasisLab/tpot.git
1
43
0
10
71
Python
{ "docstring": "Assert that ContinuousSelector works as expected with threshold=5.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 8 }
def test_ContinuousSelector_2(): cs = ContinuousSelector(threshold=5, svd_solver='randomized') X_transformed = cs.transform(iris_data[0:16, :]) assert_equal(X_transformed.shape[1],3)
52,111
207,807
1,100
tests/admin_views/tests.py
342
62
def test_add_view(self): add_dict = { "title": "Døm ikke", "content": "<p>great article</p>", "date_0": "2008-03-18", "date_1": "10:54:39", "section": self.s1.pk, } # Change User should not have access to add articles s...
Refs #33476 -- Reformatted code with Black.
test_add_view
9c19aff7c7561e3a82978a272ecdaad40dda5c00
django
tests.py
13
85
https://github.com/django/django.git
1
718
0
189
1,201
Python
{ "docstring": "Test add view restricts access and actually adds items.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
def test_add_view(self): add_dict = { "title": "Døm ikke", "content": "<p>great article</p>", "date_0": "2008-03-18", "date_1": "10:54:39", "section": self.s1.pk, } # Change User should not have access to add articles s...
78,490
266,595
315
lib/ansible/galaxy/collection/__init__.py
76
34
def install(collection, path, artifacts_manager): # FIXME: mv to dataclasses? # type: (Candidate, str, ConcreteArtifactsManager) -> None b_artifact_path = ( artifacts_manager.get_artifact_path if collection.is_concrete_artifact else artifacts_manager.get_galaxy_artifact_path )(collecti...
ansible-galaxy - add signature verification of the MANIFEST.json (#76681) * ansible-galaxy collection install|verify: - Support verifying the origin of the MANIFEST.json when the Galaxy server has provided signatures. - Allow supplemental signatures to use during verification on the CLI/requirements file. *...
install
43e55db20821a1341d21ffa1e4e7e6185b244105
ansible
__init__.py
13
33
https://github.com/ansible/ansible.git
6
170
0
62
262
Python
{ "docstring": "Install a collection under a given path.\n\n :param collection: Collection to be installed.\n :param path: Collection dirs layout path.\n :param artifacts_manager: Artifacts manager.\n ", "language": "en", "n_whitespaces": 35, "n_words": 23, "vocab_size": 18 }
def install(collection, path, artifacts_manager): # FIXME: mv to dataclasses? # type: (Candidate, str, ConcreteArtifactsManager) -> None b_artifact_path = ( artifacts_manager.get_artifact_path if collection.is_concrete_artifact else artifacts_manager.get_galaxy_artifact_path )(collecti...
52,353
208,492
1,014
IPython/core/magics/code.py
214
45
def edit(self, parameter_s='',last_call=['','']): opts,args = self.parse_options(parameter_s,'prxn:') try: filename, lineno, is_temp = self._find_edit_target(self.shell, args, opts, last_call) except MacroToEdit as e: ...
Fix EncodingWarning on Python 3.10
edit
23276ac4770f380ce1d5808950dd412a35594af1
ipython
code.py
17
54
https://github.com/ipython/ipython.git
15
364
0
142
634
Python
{ "docstring": "Bring up an editor and execute the resulting code.\n\n Usage:\n %edit [options] [args]\n\n %edit runs IPython's editor hook. The default version of this hook is\n set to call the editor specified by your $EDITOR environment variable.\n If this isn't found, it will ...
def edit(self, parameter_s='',last_call=['','']): opts,args = self.parse_options(parameter_s,'prxn:') try: filename, lineno, is_temp = self._find_edit_target(self.shell, args, opts, last_call) except MacroToEdit as e: ...
45,438
186,299
64
src/textual/strip.py
25
7
def cell_length(self) -> int: # Done on demand and cached, as this is an O(n) operation
adds Strip primitive
cell_length
6f82ad9c4a2e17812a68d3c76d7eae89aee3a515
textual
strip.py
11
5
https://github.com/Textualize/textual.git
2
31
0
22
53
Python
{ "docstring": "Get the number of cells required to render this object.", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
def cell_length(self) -> int: # Done on demand and cached, as this is an O(n) operation if self._cell_length is None: self._cell_length = Segment.get_line_length(self._segments) return self._cell_length
117,445
320,933
22
tests/unit/mainwindow/test_messageview.py
10
10
def test_show_message_twice(view): view.show_message(message.MessageInfo(usertypes.MessageLevel.info, 'test')) view.show_message(message.MessageInfo(usertypes.MessageLevel.info, 'test')) assert len(view._messages) == 1
Add a MessageInfo data class Preparation for #7246
test_show_message_twice
5616a99eff34f7074641d1391ed77d6b4b743529
qutebrowser
test_messageview.py
11
4
https://github.com/qutebrowser/qutebrowser.git
1
49
0
8
83
Python
{ "docstring": "Show the same message twice -> only one should be shown.", "language": "en", "n_whitespaces": 10, "n_words": 11, "vocab_size": 11 }
def test_show_message_twice(view): view.show_message(message.MessageInfo(usertypes.MessageLevel.info, 'test')) view.show_message(message.MessageInfo(usertypes.MessageLevel.info, 'test')) assert len(view._messages) == 1
17,401
82,438
15
cms/utils/plugins.py
9
8
def create_default_plugins(request, placeholders, template, lang): from cms.api import add_plug
ci: Added codespell (#7355) Co-authored-by: Christian Clauss <cclauss@me.com> * ci: codespell config taken from #7292
create_default_plugins
c1290c9ff89cb00caa5469129fd527e9d82cd820
django-cms
plugins.py
6
11
https://github.com/django-cms/django-cms.git
4
87
0
9
28
Python
{ "docstring": "\n Create all default plugins for the given ``placeholders`` if they have\n a \"default_plugins\" configuration value in settings.\n return all plugins, children, grandchildren (etc.) created\n ", "language": "en", "n_whitespaces": 37, "n_words": 24, "vocab_size": 23 }
def create_default_plugins(request, placeholders, template, lang): from cms.api import add_plugin
69,908
242,745
658
src/PIL/Jpeg2KImagePlugin.py
198
30
def _parse_jp2_header(fp): # Find the JP2 header box reader = BoxReader(fp) header = None mimetype = None while reader.has_next_box(): tbox = reader.next_box_type() if tbox == b"jp2h": header = reader.read_boxes() break elif tbox == b"ftyp": ...
Remove redundant parentheses
_parse_jp2_header
ee85e387bab535e2339b9d3cd1ab87c61d23af15
Pillow
Jpeg2KImagePlugin.py
18
46
https://github.com/python-pillow/Pillow.git
20
285
0
101
476
Python
{ "docstring": "Parse the JP2 header box to extract size, component count,\n color space information, and optionally DPI information,\n returning a (size, mode, mimetype, dpi) tuple.", "language": "en", "n_whitespaces": 29, "n_words": 24, "vocab_size": 23 }
def _parse_jp2_header(fp): # Find the JP2 header box reader = BoxReader(fp) header = None mimetype = None while reader.has_next_box(): tbox = reader.next_box_type() if tbox == b"jp2h": header = reader.read_boxes() break elif tbox == b"ftyp": ...
72,125
248,145
774
tests/storage/databases/main/test_events_worker.py
78
26
def _populate_events(self) -> None: self.get_success( self.store.db_pool.simple_upsert( "rooms", {"room_id": self.room_id}, {"room_version": RoomVersions.V4.identifier}, ) ) self.event_ids: List[str] = [] f...
Add a consistency check on events read from the database (#12620) I've seen a few errors which can only plausibly be explained by the calculated event id for an event being different from the ID of the event in the database. It should be cheap to check this, so let's do so and raise an exception.
_populate_events
96e0cdbc5af0563ee805ec4e588e1df14899af66
synapse
test_events_worker.py
15
54
https://github.com/matrix-org/synapse.git
2
208
0
55
351
Python
{ "docstring": "Ensure that there are test events in the database.\n\n When testing with the in-memory SQLite database, all the events are lost during\n the simulated outage.\n\n To ensure consistency between `room_id`s and `event_id`s before and after the\n outage, rows are built and inse...
def _populate_events(self) -> None: self.get_success( self.store.db_pool.simple_upsert( "rooms", {"room_id": self.room_id}, {"room_version": RoomVersions.V4.identifier}, ) ) self.event_ids: List[str] = [] f...
@instrumented_task( name="sentry.tasks.weekly_reports.schedule_organizations", queue="reports.prepare", max_retries=5, acks_late=True, )
18,455
88,840
41
src/sentry/tasks/weekly_reports.py
26
12
def check_if_ctx_is_empty(ctx): return all(check_if_project_is_empty(project_ctx) for project_ctx in ctx.projects.values
fix(weekly-email): skip organization report if report is empty (#41620) This PR adds logic to skip sending the organization weekly report if there is no context for any of the projects
check_if_ctx_is_empty
2ab29056f48c587870e0897a4feaef9ac7fd3b53
sentry
weekly_reports.py
11
2
https://github.com/getsentry/sentry.git
2
24
1
26
74
Python
{ "docstring": "\n Check if the context is empty. If it is, we don't want to send an email.\n ", "language": "en", "n_whitespaces": 23, "n_words": 16, "vocab_size": 16 }
def check_if_ctx_is_empty(ctx): return all(check_if_project_is_empty(project_ctx) for project_ctx in ctx.projects.values()) # The entry point. This task is scheduled to run every week. @instrumented_task( name="sentry.tasks.weekly_reports.schedule_organizations", queue="reports.prepare", max_retr...
57,070
223,797
84
python3.10.4/Lib/email/message.py
23
9
def __delitem__(self, name): name = name.lower() newheaders = [] for k, v in self._headers: if k.lower() != name: newheaders.append((k, v)) self._headers = newheade
add python 3.10.4 for windows
__delitem__
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
message.py
12
7
https://github.com/XX-net/XX-Net.git
3
52
0
20
85
Python
{ "docstring": "Delete all occurrences of a header, if present.\n\n Does not raise an exception if the header is missing.\n ", "language": "en", "n_whitespaces": 32, "n_words": 18, "vocab_size": 17 }
def __delitem__(self, name): name = name.lower() newheaders = [] for k, v in self._headers: if k.lower() != name: newheaders.append((k, v)) self._headers = newheaders
32,804
142,807
106
python/ray/tune/execution/placement_groups.py
30
13
def update_status(self): self.cleanup() ready = True while ready: # Use a loop as `ready` might return futures one by one ready, _ = ray.wait(list(self._staging_futures.keys()), timeout=0)
[tune/structure] Introduce execution package (#26015) Execution-specific packages are moved to tune.execution. Co-authored-by: Xiaowei Jiang <xwjiang2010@gmail.com>
update_status
0959f44b6fc217a4f2766ed46a721eb79b067b2c
ray
placement_groups.py
15
7
https://github.com/ray-project/ray.git
3
51
0
27
86
Python
{ "docstring": "Update placement group status.\n\n Moves ready placement groups from `self._staging` to\n `self._ready`.\n ", "language": "en", "n_whitespaces": 33, "n_words": 12, "vocab_size": 11 }
def update_status(self): self.cleanup() ready = True while ready: # Use a loop as `ready` might return futures one by one ready, _ = ray.wait(list(self._staging_futures.keys()), timeout=0) for ready_fut in ready: self.handle_ready_fut...
13,542
63,968
72
erpnext/patches/v13_0/trim_whitespace_from_serial_nos.py
101
32
def execute(): broken_sles = frappe.db.sql(, ( " %", # leading whitespace "% ", # trailing whitespace "%\n %", # leading whitespace on newline "% \n%", # trailing whitespace on newline ), as_dict=True, ) frappe.db.MAX_WRITES_PER_TRANSACTION += len(broken_sles) if not broken_sles: ...
fix(patch): serial no whitespace trimming old data can contain trailing/leading whitespace which doesn't work well with code to find last SLE for serial no.
execute
0faa116f9799f6d921ce8868a8f8eac1756ae008
erpnext
trim_whitespace_from_serial_nos.py
13
46
https://github.com/frappe/erpnext.git
8
198
0
70
335
Python
{ "docstring": "\n\t\t\tselect name, serial_no\n\t\t\tfrom `tabStock Ledger Entry`\n\t\t\twhere\n\t\t\t\tis_cancelled = 0\n\t\t\t\tand (serial_no like %s or serial_no like %s or serial_no like %s or serial_no like %s)\n\t\t\t\n\t\t\t\t\t\t\tselect name\n\t\t\t\t\t\t\tfrom `tabSerial No`\n\t\t\t\t\t\t\twhere status='A...
def execute(): broken_sles = frappe.db.sql(, ( " %", # leading whitespace "% ", # trailing whitespace "%\n %", # leading whitespace on newline "% \n%", # trailing whitespace on newline ), as_dict=True, ) frappe.db.MAX_WRITES_PER_TRANSACTION += len(broken_sles) if not broken_sles: ...
72,178
248,247
91
tests/config/test_cache.py
20
11
def test_individual_caches_from_environ(self): config = {} self.config._environ = { "SYNAPSE_CACHE_FACTOR_SOMETHING_OR_OTHER": "2", "SYNAPSE_NOT_CACHE": "BLAH", } self.config.read_config(config, config_dir_path="", data_dir_path="") self.config.re...
Reload cache factors from disk on SIGHUP (#12673)
test_individual_caches_from_environ
d38d242411b8910dfacde1e61fd3a0ec5cbcaa66
synapse
test_cache.py
11
9
https://github.com/matrix-org/synapse.git
1
70
0
19
121
Python
{ "docstring": "\n Individual cache factors will be loaded from the environment.\n ", "language": "en", "n_whitespaces": 24, "n_words": 9, "vocab_size": 9 }
def test_individual_caches_from_environ(self): config = {} self.config._environ = { "SYNAPSE_CACHE_FACTOR_SOMETHING_OR_OTHER": "2", "SYNAPSE_NOT_CACHE": "BLAH", } self.config.read_config(config, config_dir_path="", data_dir_path="") self.config.re...
7,690
42,688
216
kubernetes_tests/test_kubernetes_pod_operator.py
43
27
def test_already_checked_on_success(self): pod_name = "t
Use "remote" pod when patching KPO pod as "checked" (#23676) When patching as "checked", we have to use the current version of the pod otherwise we may get an error when trying to patch it, e.g.: ``` Operation cannot be fulfilled on pods \"test-kubernetes-pod-db9eedb7885c40099dd40cd4edc62415\": the object has been...
test_already_checked_on_success
6bbe015905bd2709e621455d9f71a78b374d1337
airflow
test_kubernetes_pod_operator.py
12
19
https://github.com/apache/airflow.git
1
131
0
37
221
Python
{ "docstring": "\n When ``is_delete_operator_pod=False``, pod should have 'already_checked'\n label, whether pod is successful or not.\n ", "language": "en", "n_whitespaces": 35, "n_words": 13, "vocab_size": 12 }
def test_already_checked_on_success(self): pod_name = "test-" + str(random.randint(0, 1000000)) k = KubernetesPodOperator( namespace='default', image="ubuntu:16.04", cmds=["bash", "-cx"], arguments=["echo 10"], labels={"foo": "bar"}, ...
13,860
65,338
23
erpnext/accounts/report/sales_register/sales_register.py
40
20
def get_invoice_cc_wh_map(invoice_list): si_items = frappe.db.sql( % ", ".join(["%s"] * len(invoice_list)), tuple(inv.name fo
style: format code with black
get_invoice_cc_wh_map
494bd9ef78313436f0424b918f200dab8fc7c20b
erpnext
sales_register.py
17
20
https://github.com/frappe/erpnext.git
5
124
0
31
201
Python
{ "docstring": "select parent, cost_center, warehouse\n\t\tfrom `tabSales Invoice Item` where parent in (%s)\n\t\tand (ifnull(cost_center, '') != '' or ifnull(warehouse, '') != '')", "language": "en", "n_whitespaces": 19, "n_words": 22, "vocab_size": 19 }
def get_invoice_cc_wh_map(invoice_list): si_items = frappe.db.sql( % ", ".join(["%s"] * len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1, ) invoice_cc_wh_map = {} for d in si_items: if d.cost_center: invoice_cc_wh_map.setdefault(d.parent, frappe._dict()).setdefault("cost_center"...
27,449
123,800
175
lib/core/common.py
59
24
def parseSqliteTableSchema(value): retVal = False value = extractRegexResult(r"(?s)\((?P<result>.+)\)", value) if value: table = {} columns = OrderedDict() value = re.sub(r"\(.+?\)", "", value).strip() for match in re.finditer(r"(?:\A|,)\s*(([\"'`]).+?\2|\w+)(?:\s+(...
Improving SQLite table schema parsing (#2678)
parseSqliteTableSchema
86ac3025edb83ce49d563b6787df4fc6ca305ce6
sqlmap
common.py
15
16
https://github.com/sqlmapproject/sqlmap.git
6
146
0
43
260
Python
{ "docstring": "\n Parses table column names and types from specified SQLite table schema\n\n >>> kb.data.cachedColumns = {}\n >>> parseSqliteTableSchema(\"CREATE TABLE users(\\\\n\\\\t\\\\tid INTEGER,\\\\n\\\\t\\\\tname TEXT\\\\n);\")\n True\n >>> tuple(kb.data.cachedColumns[conf.db][conf.tbl].items()...
def parseSqliteTableSchema(value): retVal = False value = extractRegexResult(r"(?s)\((?P<result>.+)\)", value) if value: table = {} columns = OrderedDict() value = re.sub(r"\(.+?\)", "", value).strip() for match in re.finditer(r"(?:\A|,)\s*(([\"'`]).+?\2|\w+)(?:\s+(...
56,955
223,532
334
python3.10.4/Lib/email/_header_value_parser.py
64
16
def get_phrase(value): phrase = Phrase() try: token, value = get_word(value) phrase.append(token) except errors.HeaderParseError: phrase.defects.append(errors.InvalidHeaderDefect( "phrase does not start with word")) while value and value[0] not in PHRASE_ENDS: ...
add python 3.10.4 for windows
get_phrase
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
_header_value_parser.py
20
26
https://github.com/XX-net/XX-Net.git
7
149
0
41
253
Python
{ "docstring": " phrase = 1*word / obs-phrase\n obs-phrase = word *(word / \".\" / CFWS)\n\n This means a phrase can be a sequence of words, periods, and CFWS in any\n order as long as it starts with at least one word. If anything other than\n words is detected, an ObsoleteHeaderDefect is added to th...
def get_phrase(value): phrase = Phrase() try: token, value = get_word(value) phrase.append(token) except errors.HeaderParseError: phrase.defects.append(errors.InvalidHeaderDefect( "phrase does not start with word")) while value and value[0] not in PHRASE_ENDS: ...
98,219
299,285
311
tests/components/cast/test_media_player.py
172
33
async def test_group_media_states(hass, mz_mock): entity_id = "media_player.speaker" reg = er.async_get(hass) info = get_fake_chromecast_info() chromecast, _ = await async_setup_media_player_cast(hass, info) _, conn_status_cb, media_status_cb, group_media_status_cb = get_status_callbacks( ...
Add state buffering to media_player and use it in cast (#70802)
test_group_media_states
66551e6fcbd063e53c13adc8a6462b8e00ce1450
core
test_media_player.py
11
41
https://github.com/home-assistant/core.git
1
275
0
76
474
Python
{ "docstring": "Test media states are read from group if entity has no state.", "language": "en", "n_whitespaces": 11, "n_words": 12, "vocab_size": 12 }
async def test_group_media_states(hass, mz_mock): entity_id = "media_player.speaker" reg = er.async_get(hass) info = get_fake_chromecast_info() chromecast, _ = await async_setup_media_player_cast(hass, info) _, conn_status_cb, media_status_cb, group_media_status_cb = get_status_callbacks( ...
15,578
70,904
59
wagtail/core/tests/test_blocks.py
17
14
def test_deserialize(self): block = blocks.PageChooserBlock() christmas_page = Page.objects.get(slug='christmas') self.assertEqual(block.to_python(christmas_page.id), christmas_page) # None should deserialize to None sel
Improve asserts in wagtail. These improvements were based on flake8-assertive, which compiled an extensive list of patterns to replace with more precise assertions. This should make the error messages better in case of failures.
test_deserialize
a0ef2477a68f2deb83cdc9a0bb709cb644be028b
wagtail
test_blocks.py
10
5
https://github.com/wagtail/wagtail.git
1
51
0
15
88
Python
{ "docstring": "The serialized value of a PageChooserBlock (an ID) should deserialize to a Page object", "language": "en", "n_whitespaces": 13, "n_words": 14, "vocab_size": 13 }
def test_deserialize(self): block = blocks.PageChooserBlock() christmas_page = Page.objects.get(slug='christmas') self.assertEqual(block.to_python(christmas_page.id), christmas_page) # None should deserialize to None self.assertIsNone(block.to_python(None))
80,124
269,492
53
keras/backend.py
31
6
def _is_current_explicit_device(device_type): device_type
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
_is_current_explicit_device
84afc5193d38057e2e2badf9c889ea87d80d8fbf
keras
backend.py
10
6
https://github.com/keras-team/keras.git
3
48
0
26
85
Python
{ "docstring": "Check if the current device is explicitly set on the device type specified.\n\n Args:\n device_type: A string containing `GPU` or `CPU` (case-insensitive).\n\n Returns:\n A boolean indicating if the current device scope is explicitly set on the\n device type.\n\n Raises:\...
def _is_current_explicit_device(device_type): device_type = device_type.upper() if device_type not in ["CPU", "GPU"]: raise ValueError('`device_type` should be either "CPU" or "GPU".') device = _get_current_tf_device() return device is not None and device.device_type == device_type.upper() ...
78,610
266,828
212
lib/ansible/module_utils/common/parameters.py
72
20
def _return_datastructure_name(obj): if isinstance(obj, (text_type, binary_type)): if obj: yield to_native(obj, errors='surrogate_or_strict') return elif isinstance(obj, Mapping): for element in obj.items(): for subelement in _return_datastructure_name(elemen...
module_utils - Fix type hinting issues.
_return_datastructure_name
12865139472f0a2fa95b94983dcedb4d57e93b10
ansible
parameters.py
14
19
https://github.com/ansible/ansible.git
12
136
0
49
222
Python
{ "docstring": " Return native stringified values from datastructures.\n\n For use with removing sensitive values pre-jsonification.", "language": "en", "n_whitespaces": 16, "n_words": 13, "vocab_size": 12 }
def _return_datastructure_name(obj): if isinstance(obj, (text_type, binary_type)): if obj: yield to_native(obj, errors='surrogate_or_strict') return elif isinstance(obj, Mapping): for element in obj.items(): for subelement in _return_datastructure_name(elemen...
35,130
151,751
84
freqtrade/rpc/api_server/ws/message_stream.py
30
8
async def __aiter__(self): waiter = self._waiter while True: # Shield the future from being cancelled by a task waiting on it message, t
log warning if channel too far behind, add docstrings to message stream
__aiter__
afc00bc30a94abd64fee000535e66287fd91595f
freqtrade
message_stream.py
11
5
https://github.com/freqtrade/freqtrade.git
2
31
0
27
55
Python
{ "docstring": "\n Iterate over the messages in the message stream\n ", "language": "en", "n_whitespaces": 23, "n_words": 8, "vocab_size": 7 }
async def __aiter__(self): waiter = self._waiter while True: # Shield the future from being cancelled by a task waiting on it message, ts, waiter = await asyncio.shield(waiter) yield message, ts
23,593
109,448
22
lib/matplotlib/axes/_base.py
8
3
def get_gridspec(self):
Merge SubplotBase into AxesBase.
get_gridspec
c73f4c455514cf5422d27bf38c93250de8316b21
matplotlib
_base.py
9
2
https://github.com/matplotlib/matplotlib.git
2
20
0
8
34
Python
{ "docstring": "Return the `.GridSpec` associated with the subplot, or None.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 8 }
def get_gridspec(self): return self._subplotspec.get_gridspec() if self._subplotspec else None
9,622
48,856
20
modules/image/classification/esnet_x0_5_imagenet/model.py
11
9
def ESNet_x0_5(pretrained=False, use_ssld=False, **kwargs): mo
add clas modules
ESNet_x0_5
33c9d1a8e4d7fd0a023819e27ba6c3819cda6b4b
PaddleHub
model.py
11
3
https://github.com/PaddlePaddle/PaddleHub.git
1
37
0
10
56
Python
{ "docstring": "\n ESNet_x0_5\n Args:\n pretrained: bool=False or str. If `True` load pretrained parameters, `False` otherwise.\n If str, means the path of the pretrained model.\n use_ssld: bool=False. Whether using distillation pretrained model when pretrained=True.\n Return...
def ESNet_x0_5(pretrained=False, use_ssld=False, **kwargs): model = ESNet(scale=0.5, stages_pattern=MODEL_STAGES_PATTERN["ESNet"], **kwargs) return model
6,820
37,515
13
src/transformers/testing_utils.py
7
5
def require_rjieba(test_case):
Update all require decorators to use skipUnless when possible (#16999)
require_rjieba
57e6464ac9a31156f1c93e59107323e6ec01309e
transformers
testing_utils.py
10
2
https://github.com/huggingface/transformers.git
1
20
0
7
37
Python
{ "docstring": "\n Decorator marking a test that requires rjieba. These tests are skipped when rjieba isn't installed.\n ", "language": "en", "n_whitespaces": 22, "n_words": 15, "vocab_size": 15 }
def require_rjieba(test_case): return unittest.skipUnless(is_rjieba_available(), "test requires rjieba")(test_case)
23,495
109,257
54
lib/matplotlib/axes/_base.py
25
8
def get_yaxis(self): return self.yaxis get_xgridlines = _axis_method_wrapper("xaxis", "get_gridlines") get_xticklines = _axis_method_wrapper("xaxis", "g
Add discouraged admonitions The [*Discouraged*] prefix in the summary line is added in analogy to the [*Deprecated*] prefix we add automatically. We do this so that these "labels" are prominently visible also in summary overviews of the functions in the docs. Since we rarely discourage whole functions, for now I just...
get_yaxis
5af97515b3823b2efa1961253a11e2d77df88637
matplotlib
_base.py
7
2
https://github.com/matplotlib/matplotlib.git
1
10
0
18
84
Python
{ "docstring": "\n [*Discouraged*] Return the YAxis instance.\n\n .. admonition:: Discouraged\n\n The use of this function is discouraged. You should instead\n directly access the attribute ``ax.yaxis``.\n ", "language": "en", "n_whitespaces": 67, "n_words": 23, "voc...
def get_yaxis(self): return self.yaxis get_xgridlines = _axis_method_wrapper("xaxis", "get_gridlines") get_xticklines = _axis_method_wrapper("xaxis", "get_ticklines") get_ygridlines = _axis_method_wrapper("yaxis", "get_gridlines") get_yticklines = _axis_method_wrapper("yaxis", "get_tic...
80,141
269,510
16
keras/backend.py
7
2
def disable_tf_random_generator():
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
disable_tf_random_generator
84afc5193d38057e2e2badf9c889ea87d80d8fbf
keras
backend.py
6
3
https://github.com/keras-team/keras.git
1
10
0
6
20
Python
{ "docstring": "Disable the `tf.random.Generator` as the RNG for Keras.\n\n See `tf.keras.backend.experimental.is_tf_random_generator_enabled` for more\n details.\n ", "language": "en", "n_whitespaces": 22, "n_words": 13, "vocab_size": 11 }
def disable_tf_random_generator(): global _USE_GENERATOR_FOR_RNG _USE_GENERATOR_FOR_RNG = False
@skip_pyarrow @pytest.mark.parametrize( "date_string", ["32/32/2019", "02/30/2019", "13/13/2019", "13/2019", "a3/11/2018", "10/11/2o17"], )
40,744
171,994
187
pandas/tests/io/parser/test_parse_dates.py
54
28
def test_parse_timezone(all_parsers): # see gh-22256 parser = all_parsers data = result = parser.read_csv(StringIO(data), parse_dates=["dt"]) dti = DatetimeIndex( list( date_range( start="2018-01-04 09:01:00", end="2018-01-04 09:05:00", ...
API: default to stdlib timezone objects for fixed-offsets (#49677) * API: default to stdlib timezone objects for fixed-offsets * update docstrings * flesh out whatsnew * handle strings * skip on windows
test_parse_timezone
5a372d892a8c45a2442ab1e744aea3241d2c26a8
pandas
test_parse_dates.py
18
23
https://github.com/pandas-dev/pandas.git
1
103
1
45
215
Python
{ "docstring": "dt,val\n 2018-01-04 09:01:00+09:00,23350\n 2018-01-04 09:02:00+09:00,23400\n 2018-01-04 09:03:00+09:00,23400\n 2018-01-04 09:04:00+09:00,23400\n 2018-01-04 09:05:00+09:00,23400", "language": "en", "n_whitespaces": 75, "n_words": 11...
def test_parse_timezone(all_parsers): # see gh-22256 parser = all_parsers data = result = parser.read_csv(StringIO(data), parse_dates=["dt"]) dti = DatetimeIndex( list( date_range( start="2018-01-04 09:01:00", end="2018-01-04 09:05:00", ...
73,690
251,340
70
mitmproxy/connection.py
19
8
def alpn_proto_negotiated(self) -> Optional[bytes]: # pragma: no cover warnings.warn( "Connection.alpn_proto_negotiated is deprecated, use Connection.alpn instead.", DeprecationWarnin
make it black!
alpn_proto_negotiated
b3587b52b25077f68116b9852b041d33e7fc6601
mitmproxy
connection.py
8
7
https://github.com/mitmproxy/mitmproxy.git
1
24
0
19
42
Python
{ "docstring": "*Deprecated:* An outdated alias for Connection.alpn.", "language": "en", "n_whitespaces": 5, "n_words": 6, "vocab_size": 6 }
def alpn_proto_negotiated(self) -> Optional[bytes]: # pragma: no cover warnings.warn( "Connection.alpn_proto_negotiated is deprecated, use Connection.alpn instead.", DeprecationWarning, ) return self.alpn
113,101
314,495
158
homeassistant/components/velux/cover.py
36
17
def device_class(self) -> CoverDeviceClass: if isinstance(self.node, Awning): return CoverDeviceClass.AWNING if isinstance
Adjust CoverEntity property type hints in components (#73943) * Adjust CoverEntity property type hints in components * Revert changes to rflink * Revert changes to wilight
device_class
10dc38e0ec27f7bef990ee431459342f9c3c52b4
core
cover.py
8
15
https://github.com/home-assistant/core.git
7
96
0
19
148
Python
{ "docstring": "Define this cover as either awning, blind, garage, gate, shutter or window.", "language": "en", "n_whitespaces": 11, "n_words": 12, "vocab_size": 12 }
def device_class(self) -> CoverDeviceClass: if isinstance(self.node, Awning): return CoverDeviceClass.AWNING if isinstance(self.node, Blind): return CoverDeviceClass.BLIND if isinstance(self.node, GarageDoor): return CoverDeviceClass.GARAGE if...
84,774
284,522
148
openbb_terminal/economy/investingcom_model.py
32
13
def get_yieldcurve(country) -> pd.DataFrame: data = investpy.bonds.get_bonds
Feature/yieldcurve (#1734) * Adds yield curves * Adds yield curves for several countries * Adds yield curves for several countries * Adds yield curves for several countries * Adds yield curves for several countries * Adds yield curves for several countries * ycrv plots by default * Limits source c...
get_yieldcurve
4f692f26e6f3935b7454e8b448838c8a87b98f23
OpenBBTerminal
investingcom_model.py
11
23
https://github.com/OpenBB-finance/OpenBBTerminal.git
1
85
0
31
152
Python
{ "docstring": "Get country yield curve [Source: Investing.com]\n\n Returns\n -------\n pd.DataFrame\n Country yield curve\n ", "language": "en", "n_whitespaces": 31, "n_words": 12, "vocab_size": 10 }
def get_yieldcurve(country) -> pd.DataFrame: data = investpy.bonds.get_bonds_overview(country) data.drop(columns=data.columns[0], axis=1, inplace=True) data.rename( columns={ "name": "Tenor", "last": "Current", "last_close": "Previous", "high": "...
90,659
291,554
246
tests/components/alexa/test_capabilities.py
53
7
async def test_report_humidifier_humidity_state(hass): hass.states.async_set( "humidifier.dry", "on", { "friendly_name": "Humidifier dry", "supported_features": 0, "humidity": 25, "min_humidity": 20, "max_humidity": 90, ...
Add humidifier support for Alexa (#81329)
test_report_humidifier_humidity_state
5d4c4a1293b00e864f6ad202fbc565388d613e71
core
test_capabilities.py
10
27
https://github.com/home-assistant/core.git
1
112
0
33
204
Python
{ "docstring": "Test PercentageController, PowerLevelController reports humidifier humidity correctly.", "language": "en", "n_whitespaces": 6, "n_words": 7, "vocab_size": 7 }
async def test_report_humidifier_humidity_state(hass): hass.states.async_set( "humidifier.dry", "on", { "friendly_name": "Humidifier dry", "supported_features": 0, "humidity": 25, "min_humidity": 20, "max_humidity": 90, ...
77,612
264,125
48
netbox/extras/models/customfields.py
16
7
def serialize(self, value): if self.type == CustomFieldTypeChoices.TYPE_OBJECT and value is not None: return value.pk
Initial work on #7006
serialize
fa1e28e860c4bdb3e585a968bd248a2ac666e1f6
netbox
customfields.py
8
4
https://github.com/netbox-community/netbox.git
3
28
0
14
45
Python
{ "docstring": "\n Prepare a value for storage as JSON data.\n ", "language": "en", "n_whitespaces": 23, "n_words": 8, "vocab_size": 8 }
def serialize(self, value): if self.type == CustomFieldTypeChoices.TYPE_OBJECT and value is not None: return value.pk return value
19,791
100,290
246
tools/manual/detected_faces.py
59
34
def revert_to_saved(self, frame_index): if frame_index not in self._updated_frame_indices: logger.debug("Alignments not amended. Returning") return logger.verbose("Reverting alignments for frame_index %s", frame
Bugfixes - Sort - Fix rare help-text parsing bug - Manual - Fix issue where frame count is incorrect when een > 1 used on extract
revert_to_saved
23d92c1f0d83ce1cdcc51480cfe37af074a981b3
faceswap
detected_faces.py
11
22
https://github.com/deepfakes/faceswap.git
5
172
0
47
278
Python
{ "docstring": " Revert the frame's alignments to their saved version for the given frame index.\n\n Parameters\n ----------\n frame_index: int\n The frame that should have their faces reverted to their saved version\n ", "language": "en", "n_whitespaces": 69, "n_words": 2...
def revert_to_saved(self, frame_index): if frame_index not in self._updated_frame_indices: logger.debug("Alignments not amended. Returning") return logger.verbose("Reverting alignments for frame_index %s", frame_index) print(frame_index) print(len(self._s...
45,621
186,787
224
tools/finish_release.py
102
18
def parse_args(args): # Use the file's docstring for the help text and don't let argparse reformat it. parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--css', type=str, required=True, h...
Add Signed Windows Installer Workflow (#9076) * Add Code Signing action for Windows Installer * Clean up variable names and input * Amend and add to documentation per PR guidelines * Update tools/finish_release.py Co-authored-by: Brad Warren <bmw@users.noreply.github.com> * Update tools/finish_release.p...
parse_args
6e1696ba32ef8c1162bb0cd85df5a22113952828
certbot
finish_release.py
10
10
https://github.com/certbot/certbot.git
1
90
0
71
160
Python
{ "docstring": "Parse command line arguments.\n\n :param args: command line arguments with the program name removed. This is\n usually taken from sys.argv[1:].\n :type args: `list` of `str`\n\n :returns: parsed arguments\n :rtype: argparse.Namespace\n\n ", "language": "en", "n_whitespaces": ...
def parse_args(args): # Use the file's docstring for the help text and don't let argparse reformat it. parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('--css', type=str, required=True, h...
48,545
197,437
62
sympy/physics/vector/fieldfunctions.py
37
8
def is_conservative(field): # Field is conservative irrespective of frame # Take the first frame
Some pep8 cleanup of sympy.physics.vector.
is_conservative
9a3ffc6781bd44c47cf49e128ef154389c32876a
sympy
fieldfunctions.py
11
5
https://github.com/sympy/sympy.git
2
45
0
28
77
Python
{ "docstring": "\n Checks if a field is conservative.\n\n Parameters\n ==========\n\n field : Vector\n The field to check for conservative property\n\n Examples\n ========\n\n >>> from sympy.physics.vector import ReferenceFrame\n >>> from sympy.physics.vector import is_conservative\n ...
def is_conservative(field): # Field is conservative irrespective of frame # Take the first frame in the result of the separate method of Vector if field == Vector(0): return True frame = list(field.separate())[0] return curl(field, frame).simplify() == Vector(0)
56,852
223,020
213
python3.10.4/Lib/distutils/tests/support.py
77
19
def fixup_build_ext(cmd): if os.name == 'nt': cmd.debug = sys.executable.endswith('_d.exe') elif sysconfig.get_config_var('Py_ENABLE_SHARED'): # To further add to the shared builds fun on Unix, we can't just add # library_dirs to the Extension() instance because that doesn't get ...
add python 3.10.4 for windows
fixup_build_ext
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
support.py
20
13
https://github.com/XX-net/XX-Net.git
7
102
0
57
182
Python
{ "docstring": "Function needed to make build_ext tests pass.\n\n When Python was built with --enable-shared on Unix, -L. is not enough to\n find libpython<blah>.so, because regrtest runs in a tempdir, not in the\n source directory where the .so lives.\n\n When Python was built with in debug mode on Windo...
def fixup_build_ext(cmd): if os.name == 'nt': cmd.debug = sys.executable.endswith('_d.exe') elif sysconfig.get_config_var('Py_ENABLE_SHARED'): # To further add to the shared builds fun on Unix, we can't just add # library_dirs to the Extension() instance because that doesn't get ...
14,564
67,581
6
erpnext/stock/doctype/batch/batch.py
9
7
def batch_uses_naming_series(): use_naming_series
style: format code with black
batch_uses_naming_series
494bd9ef78313436f0424b918f200dab8fc7c20b
erpnext
batch.py
11
3
https://github.com/frappe/erpnext.git
1
25
0
9
47
Python
{ "docstring": "\n\tVerify if the Batch is to be named using a naming series\n\t:return: bool\n\t", "language": "en", "n_whitespaces": 12, "n_words": 14, "vocab_size": 14 }
def batch_uses_naming_series(): use_naming_series = cint(frappe.db.get_single_value("Stock Settings", "use_naming_series")) return bool(use_naming_series)
2,296
12,444
449
jina/parsers/orchestrate/runtimes/remote.py
110
15
def mixin_http_gateway_parser(parser=None): gp = add_arg_group(parser, title='HTTP Gateway') gp.add_argument( '--title', type=str, help='The title of this HTTP server. It will be used in automatics docs such as Swagger UI.', ) gp.add_argument(
refactor: remove unnecessary code (#4865) * refactor: remove unnecessary code * refactor: remove unnecessary code * fix: #4866 * refactor: grpc compression arg * style: fix overload and cli autocomplete * fix: #4864 Co-authored-by: Jina Dev Bot <dev-bot@jina.ai>
mixin_http_gateway_parser
1b05b842d7a2c851b5de2150591198ad0d9987dc
jina
remote.py
10
80
https://github.com/jina-ai/jina.git
1
204
0
57
346
Python
{ "docstring": "Add the options to rest server\n\n :param parser: the parser\n \n If set, a CORS middleware is added to FastAPI frontend to allow cross-origin access.\n \n If set, `/index`, `/search`, `/update`, `/delete` endpoints are removed from HTTP interface.\n\n Any executor th...
def mixin_http_gateway_parser(parser=None): gp = add_arg_group(parser, title='HTTP Gateway') gp.add_argument( '--title', type=str, help='The title of this HTTP server. It will be used in automatics docs such as Swagger UI.', ) gp.add_argument( '--description', ...
2,104
11,747
56
tests/unit/helloworld/multimodal/test_executors.py
28
19
def test_image_crafter_index(encoder_doc_array, tmpdir): create_test_img(path=str(tmpdir), file_name='1.jpg') with Flow().add(uses=ImageCrafter) as f: res = f.index(inputs=encoder_doc_array) as
test: fix tests failing after new docarray patch (#4449) * test: fix tests failing after new docarray patch * test: fix failing tests
test_image_crafter_index
217a11bb8dc613ed1136b8b541a68e6d53ca4fc1
jina
test_executors.py
12
8
https://github.com/jina-ai/jina.git
1
71
0
24
120
Python
{ "docstring": "In this test, we input one ``DocumentArray`` with one ``Document``,\n and the `craft` method in the ``ImageCrafter`` returns chunks.\n In the ``ImageCrafter``, we filtered out all the modalities and only kept `image/jpeg`.\n So the 2 chunks should left only 1 chunk.\n And the tensor value ...
def test_image_crafter_index(encoder_doc_array, tmpdir): create_test_img(path=str(tmpdir), file_name='1.jpg') with Flow().add(uses=ImageCrafter) as f: res = f.index(inputs=encoder_doc_array) assert len(res) == 1 doc = res[0] assert doc.mime_type == 'image/jpeg' assert doc.tensor is ...
54,609
216,492
173
salt/fileserver/roots.py
58
13
def find_file(path, saltenv="base", **kwargs): actual_saltenv = saltenv if "env" in kwargs: # "env" is not supported; Use "saltenv". kwargs.pop("env") path = os.path.normpath(path) fnd = {"path": "", "rel": ""} if os.path.isabs(path): return fnd if saltenv not in __...
add __env__ substitution inside file and pillar root paths
find_file
52e1d0b8116c86777c85cb6c3d940e2c04a518c4
salt
roots.py
12
38
https://github.com/saltstack/salt.git
13
256
0
40
170
Python
{ "docstring": "\n Search the environment for the relative path.\n ", "language": "en", "n_whitespaces": 14, "n_words": 7, "vocab_size": 6 }
def find_file(path, saltenv="base", **kwargs): actual_saltenv = saltenv if "env" in kwargs: # "env" is not supported; Use "saltenv". kwargs.pop("env") path = os.path.normpath(path) fnd = {"path": "", "rel": ""} if os.path.isabs(path): return fnd if saltenv not in __...
75,226
258,357
20
haystack/nodes/prompt/prompt_node.py
6
7
def get_prompt_templates(cls) -> List[PromptTemplate]: return list(cls.prompt_templates.values())
feat: Expand LLM support with PromptModel, PromptNode, and PromptTemplate (#3667) Co-authored-by: ZanSara <sarazanzo94@gmail.com>
get_prompt_templates
9ebf164cfdfb320503b7161493420c1b0ec577a3
haystack
prompt_node.py
10
6
https://github.com/deepset-ai/haystack.git
1
22
0
6
38
Python
{ "docstring": "\n Returns the list of supported prompt templates.\n :return: List of supported prompt templates.\n ", "language": "en", "n_whitespaces": 35, "n_words": 13, "vocab_size": 9 }
def get_prompt_templates(cls) -> List[PromptTemplate]: return list(cls.prompt_templates.values())
26,187
118,187
602
tests/integration_tests/flows/test_company_independent.py
81
21
def test_views(self, postgres_db): query = for cid, char in [(CID_A, 'a'), (CID_B, 'b')]: self.sql_via_http( query.format(f'test_view_{char}', char), company_id=cid, expected_resp_type=RESPONSE_TYPE.OK ) tables = sel...
fix tests
test_views
b96825c643cb2ce062d80868a5b7824d99bca07f
mindsdb
test_company_independent.py
13
54
https://github.com/mindsdb/mindsdb.git
3
200
0
43
309
Python
{ "docstring": "\n CREATE VIEW mindsdb.{}\n FROM test_integration_{} (\n select * from rentals limit 50\n )\n ", "language": "en", "n_whitespaces": 69, "n_words": 13, "vocab_size": 13 }
def test_views(self, postgres_db): query = for cid, char in [(CID_A, 'a'), (CID_B, 'b')]: self.sql_via_http( query.format(f'test_view_{char}', char), company_id=cid, expected_resp_type=RESPONSE_TYPE.OK ) tables = sel...
23,286
108,653
430
lib/matplotlib/testing/compare.py
155
30
def convert(filename, cache): path = Path(filename) if not path.exists(): raise IOError(f"{path} does not exist") if path.suffix[1:] not in converter: import pytest pytest.skip(f"Don't know how to convert {path.suffix} files to png") newpath = path.parent / f"{path.stem}_{pa...
Support not embedding glyphs in svg mathtests.
convert
740235060519c8330e6e733a10d8795e40e19b54
matplotlib
compare.py
14
29
https://github.com/matplotlib/matplotlib.git
11
219
0
104
397
Python
{ "docstring": "\n Convert the named file to png; return the name of the created file.\n\n If *cache* is True, the result of the conversion is cached in\n `matplotlib.get_cachedir() + '/test_cache/'`. The caching is based on a\n hash of the exact contents of the input file. Old cache entries are\n au...
def convert(filename, cache): path = Path(filename) if not path.exists(): raise IOError(f"{path} does not exist") if path.suffix[1:] not in converter: import pytest pytest.skip(f"Don't know how to convert {path.suffix} files to png") newpath = path.parent / f"{path.stem}_{pa...
69,796
242,234
985
src/PIL/Image.py
245
35
def resize(self, size, resample=None, box=None, reducing_gap=None): if resample is None: type_special = ";" in self.mode resample = Resampling.NEAREST if type_special else Resampling.BICUBIC elif resample not in ( Resampling.NEAREST, Resampling.B...
Added enums
resize
f8e4e9c2dd94c6f4789639dd891b8a6d5fb16e14
Pillow
Image.py
18
60
https://github.com/python-pillow/Pillow.git
20
520
0
134
816
Python
{ "docstring": "\n Returns a resized copy of this image.\n\n :param size: The requested size in pixels, as a 2-tuple:\n (width, height).\n :param resample: An optional resampling filter. This can be\n one of :py:data:`PIL.Image.Resampling.NEAREST`,\n :py:data:`PIL.I...
def resize(self, size, resample=None, box=None, reducing_gap=None): if resample is None: type_special = ";" in self.mode resample = Resampling.NEAREST if type_special else Resampling.BICUBIC elif resample not in ( Resampling.NEAREST, Resampling.B...
21,491
102,176
49
tools/test/test_gen_backend_stubs.py
24
6
def test_unrecognized_key(self) -> None: yaml_str = output_error = self.get_errors_from_gen_backend_stubs(yaml_str) self.assertExpectedInline(output_error, ) # noqa: B950 # if use_out_as_primary is provided, it must
Revert "Revert D32498569: allow external backend codegen to toggle whether to generate out= and inplace kernels" (#69950) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/69950 This reverts commit f6cad53443704dfe5a20cc62bee14d91e3bffcaa. Test Plan: Imported from OSS Reviewed By: albanD Diff...
test_unrecognized_key
bb5b4cceb6f737448eaaa6817cd773b6f4b0e77d
pytorch
test_gen_backend_stubs.py
8
9
https://github.com/pytorch/pytorch.git
1
26
0
22
49
Python
{ "docstring": "\\\nbackend: XLA\ncpp_namespace: torch_xla\nsupported:\n- abs\ninvalid_key: invalid_val contains unexpected keys: invalid_key. Only the following keys are supported: backend, cpp_namespace, extra_headers, supported, autograd, full_codegen", "language": "en", "n_whitespaces": 20, "n_words": 26, ...
def test_unrecognized_key(self) -> None: yaml_str = output_error = self.get_errors_from_gen_backend_stubs(yaml_str) self.assertExpectedInline(output_error, ) # noqa: B950 # if use_out_as_primary is provided, it must be a bool
38,648
160,521
31
numpy/f2py/capi_maps.py
19
4
def f2cexpr(expr):
ENH: Support character string arrays TST: added test for issue #18684 ENH: f2py opens files with correct encoding, fixes #635 TST: added test for issue #6308 TST: added test for issue #4519 TST: added test for issue #3425 ENH: Implement user-defined hooks support for post-processing f2py data structure. Implement...
f2cexpr
d4e11c7a2eb64861275facb076d47ccd135fa28c
numpy
capi_maps.py
9
3
https://github.com/numpy/numpy.git
1
21
0
18
38
Python
{ "docstring": "Rewrite Fortran expression as f2py supported C expression.\n\n Due to the lack of a proper expression parser in f2py, this\n function uses a heuristic approach that assumes that Fortran\n arithmetic expressions are valid C arithmetic expressions when\n mapping Fortran function calls to the...
def f2cexpr(expr): # TODO: support Fortran `len` function with optional kind parameter expr = re.sub(r'\blen\b', 'f2py_slen', expr) return expr
21,327
101,950
328
lib/gui/wrapper.py
108
26
def build_args(self, category, command=None, generate=False): logger.debug("Build cli arguments: (category: %s, command: %s, generate: %s)", category, command, generate) command = self.command if not command else command script = f"{category}.py" pathexecscr...
Typing - lib.gui.display_command
build_args
dab823a3eb7a5257cb1e0818ee10ed234d3de97f
faceswap
wrapper.py
17
21
https://github.com/deepfakes/faceswap.git
12
183
0
70
309
Python
{ "docstring": " Build the faceswap command and arguments list.\n\n If training, pass the model folder and name to the training\n :class:`lib.gui.analysis.Session` for the GUI.\n ", "language": "en", "n_whitespaces": 44, "n_words": 22, "vocab_size": 18 }
def build_args(self, category, command=None, generate=False): logger.debug("Build cli arguments: (category: %s, command: %s, generate: %s)", category, command, generate) command = self.command if not command else command script = f"{category}.py" pathexecscr...
29,251
130,365
114
python/ray/autoscaler/_private/aliyun/utils.py
28
11
def describe_v_switches(self, vpc_id=None): request = DescribeVSwitchesRequest() if vpc_id
[CI] Format Python code with Black (#21975) See #21316 and #21311 for the motivation behind these changes.
describe_v_switches
7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065
ray
utils.py
12
10
https://github.com/ray-project/ray.git
3
63
0
21
110
Python
{ "docstring": "Queries one or more VSwitches.\n\n :param vpc_id: The ID of the VPC to which the VSwitch belongs.\n :return: VSwitch list.\n ", "language": "en", "n_whitespaces": 41, "n_words": 20, "vocab_size": 18 }
def describe_v_switches(self, vpc_id=None): request = DescribeVSwitchesRequest() if vpc_id is not None: request.set_VpcId(vpc_id) response = self._send_request(request) if response is not None: return response.get("VSwitches").get("VSwitch") else:...
22,482
106,863
611
py/visdom/__init__.py
183
25
def line(self, Y, X=None, win=None, env=None, opts=None, update=None, name=None): if update is not None: if update == "re
apply black py to all python files
line
5b8b7f267cfaf76a2a39a727ef31a62b3909a093
visdom
__init__.py
16
40
https://github.com/fossasia/visdom.git
12
389
0
101
601
Python
{ "docstring": "\n This function draws a line plot. It takes in an `N` or `NxM` tensor\n `Y` that specifies the values of the `M` lines (that connect `N` points)\n to plot. It also takes an optional `X` tensor that specifies the\n corresponding x-axis values; `X` can be an `N` tensor (in w...
def line(self, Y, X=None, win=None, env=None, opts=None, update=None, name=None): if update is not None: if update == "remove": return self.scatter( X=None, Y=None, opts=opts, win=win, ...
8,910
46,519
87
tests/providers/databricks/operators/test_databricks_repos.py
20
18
def test_delete_with_id(self, db_mock_class): op = DatabricksReposDeleteOperator(task_id=TASK_ID, repo_id="123") db_mock = db_mock_class.return_value db_mock.delete_repo.re
More operators for Databricks Repos (#22422)
test_delete_with_id
352d7f72dd1e21f1522d69b71917142430548d66
airflow
test_databricks_repos.py
10
9
https://github.com/apache/airflow.git
1
64
0
18
105
Python
{ "docstring": "\n Test the execute function using Repo ID.\n ", "language": "en", "n_whitespaces": 22, "n_words": 7, "vocab_size": 7 }
def test_delete_with_id(self, db_mock_class): op = DatabricksReposDeleteOperator(task_id=TASK_ID, repo_id="123") db_mock = db_mock_class.return_value db_mock.delete_repo.return_value = None op.execute(None) db_mock_class.assert_called_once_with( DEFAULT_CON...
18,096
86,306
182
tests/sentry/models/test_groupsnooze.py
30
21
def test_user_rate_reached(self): for i in range(5): group = self.store_event( data={ "fingerprint": ["group1"], "timestamp": iso_format(before_now(minutes=5 + i)), "tags": {"sentry:user": i},
ref(perf issues): Enable ignore in a time period (#39120) Enable ignoring a performance issue in a time period e.g. ignore this until it happens 10x / hr or ignore until 10 users experience it in an hour.
test_user_rate_reached
d745edbd591063f2c3241cd1960c361834058823
sentry
test_groupsnooze.py
20
12
https://github.com/getsentry/sentry.git
2
94
0
29
153
Python
{ "docstring": "Test that ignoring an error issue until it's hit by 10 users in an hour works.", "language": "en", "n_whitespaces": 15, "n_words": 16, "vocab_size": 15 }
def test_user_rate_reached(self): for i in range(5): group = self.store_event( data={ "fingerprint": ["group1"], "timestamp": iso_format(before_now(minutes=5 + i)), "tags": {"sentry:user": i}, }, ...
56,631
222,552
860
python3.10.4/Lib/distutils/archive_util.py
203
34
def make_zipfile(base_name, base_dir, verbose=0, dry_run=0): zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) # If zipfile module is not available, try spawning an external # 'zip' command. if zipfile is None: if verbose: zipoptions =...
add python 3.10.4 for windows
make_zipfile
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
archive_util.py
22
41
https://github.com/XX-net/XX-Net.git
11
290
0
134
638
Python
{ "docstring": "Create a zip file from all the files under 'base_dir'.\n\n The output zip file will be named 'base_name' + \".zip\". Uses either the\n \"zipfile\" Python module (if available) or the InfoZIP \"zip\" utility\n (if installed and found on the default search path). If neither tool is\n avail...
def make_zipfile(base_name, base_dir, verbose=0, dry_run=0): zip_filename = base_name + ".zip" mkpath(os.path.dirname(zip_filename), dry_run=dry_run) # If zipfile module is not available, try spawning an external # 'zip' command. if zipfile is None: if verbose: zipoptions =...
71,413
246,929
224
tests/rest/client/test_upgrade_room.py
56
16
def test_power_levels_user_default(self): # The other
Replace assertEquals and friends with non-deprecated versions. (#12092)
test_power_levels_user_default
02d708568b476f2f7716000b35c0adfa4cbd31b3
synapse
test_upgrade_room.py
10
17
https://github.com/matrix-org/synapse.git
1
104
0
39
165
Python
{ "docstring": "\n Another user can upgrade the room if the default power level for users is increased.\n ", "language": "en", "n_whitespaces": 30, "n_words": 15, "vocab_size": 14 }
def test_power_levels_user_default(self): # The other user doesn't have the proper power level. channel = self._upgrade_room(self.other_token) self.assertEqual(403, channel.code, channel.result) # Increase the power levels so that this user can upgrade. power_levels = s...
14,461
67,267
8
erpnext/regional/report/uae_vat_201/uae_vat_201.py
22
11
def get_exempt_total(filters): conditions = get_conditions(filters) try: return ( frappe.db.sql( .format( where_conditions=conditions ), filters, )[0][0]
style: format code with black
get_exempt_total
494bd9ef78313436f0424b918f200dab8fc7c20b
erpnext
uae_vat_201.py
16
24
https://github.com/frappe/erpnext.git
3
52
0
20
84
Python
{ "docstring": "Returns the sum of each Sales Invoice Item Amount which is Vat Exempt.\n\t\t\tselect\n\t\t\t\tsum(i.base_amount) as total\n\t\t\tfrom\n\t\t\t\t`tabSales Invoice Item` i inner join `tabSales Invoice` s\n\t\t\ton\n\t\t\t\ti.parent = s.name\n\t\t\twhere\n\t\t\t\ts.docstatus = 1 and i.is_exempt = 1\n\t\t...
def get_exempt_total(filters): conditions = get_conditions(filters) try: return ( frappe.db.sql( .format( where_conditions=conditions ), filters, )[0][0] or 0 ) except (IndexError, TypeError): return 0
52,673
209,428
176
scapy/layers/kerberos.py
86
18
def encrypt(self, key, text, confounder=None, key_usage_number=None): if key_usage_number is None: key_usage_number = self.get_usage()[0] self.cipher = key.encrypt(key_usage_number, text, confounder=confounder) EncryptionKey = lambda **kwargs: ASN1F_SEQUENCE( Int32("keytype", ...
Kerberos update (#3688) * Kerberos over TCP * Kerberos: add FAST & PKCA * Many user-friendly improvements * RFC3961 crypto * Summary, Sessions, Examples, Bugs * More tests, _n_fold edge case * Ignore potatoe (kerberos tests) from codespell
encrypt
b26f2283379d3bba48d575c1fffd1c3cdeaf64c2
scapy
kerberos.py
11
4
https://github.com/secdev/scapy.git
2
49
0
76
274
Python
{ "docstring": "\n Encrypt text and set it into cipher.\n\n :param key: the key to use for encryption\n :param text: the bytes value to encode\n :param confounder: (optional) specify the confounder bytes. Random otherwise\n :param key_usage_number: (optional) specify the key usage n...
def encrypt(self, key, text, confounder=None, key_usage_number=None): if key_usage_number is None: key_usage_number = self.get_usage()[0] self.cipher = key.encrypt(key_usage_number, text, confounder=confounder) EncryptionKey = lambda **kwargs: ASN1F_SEQUENCE( Int32("keytype", ...
29,238
130,352
114
python/ray/autoscaler/_private/aliyun/utils.py
29
15
def create_v_switch(self, vpc_id, zone_id, cidr_block): request = CreateVSwitchRequest() request.set_ZoneId(zone_
[CI] Format Python code with Black (#21975) See #21316 and #21311 for the motivation behind these changes.
create_v_switch
7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065
ray
utils.py
11
11
https://github.com/ray-project/ray.git
2
68
0
26
114
Python
{ "docstring": "Create vSwitches to divide the VPC into one or more subnets\n\n :param vpc_id: The ID of the VPC to which the VSwitch belongs.\n :param zone_id: The ID of the zone to which\n the target VSwitch belongs.\n :param cidr_block: The CIDR block of the VSwitch.\n ...
def create_v_switch(self, vpc_id, zone_id, cidr_block): request = CreateVSwitchRequest() request.set_ZoneId(zone_id) request.set_VpcId(vpc_id) request.set_CidrBlock(cidr_block) response = self._send_request(request) if response is not None: return res...
3,579
20,835
24
pipenv/patched/notpip/_vendor/rich/style.py
10
5
def transparent_background(self) -> bool: return self.bgcolor is None or self.bgcolor.is_default
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...
transparent_background
f3166e673fe8d40277b804d35d77dcdb760fc3b3
pipenv
style.py
8
3
https://github.com/pypa/pipenv.git
2
20
0
10
34
Python
{ "docstring": "Check if the style specified a transparent background.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 8 }
def transparent_background(self) -> bool: return self.bgcolor is None or self.bgcolor.is_default
4,448
22,757
118
primelib/primelib.py
61
9
def isPerfectNumber(number): # precondition assert isinstance(number, int) and ( number > 1 ), "'number' must been an int and >= 1" divisors = getDivisors(number) # precondition ass
refactor: clean code Signed-off-by: slowy07 <slowy.arfy@gmail.com>
isPerfectNumber
f0af0c43340763724f139fa68aa1e5a9ffe458b4
Python
primelib.py
13
11
https://github.com/geekcomputers/Python.git
4
73
0
47
120
Python
{ "docstring": "\n input: positive integer 'number' > 1\n returns true if 'number' is a perfect number otherwise false.\n ", "language": "en", "n_whitespaces": 26, "n_words": 16, "vocab_size": 15 }
def isPerfectNumber(number): # precondition assert isinstance(number, int) and ( number > 1 ), "'number' must been an int and >= 1" divisors = getDivisors(number) # precondition assert ( isinstance(divisors, list) and (divisors[0] == 1) and (divisors[len(d...
@_api.deprecated( '3.6', pending=True, alternative="``matplotlib.colormaps.unregister_cmap(name)``" )
23,578
109,426
108
lib/matplotlib/cm.py
56
17
def _get_cmap(name=None, lut=None): if name is None: name = mpl.rcParams['image.cmap'] if isinstance(name, colors.Colormap): retu
API: Add pending deprecation to mpl.cm top level functions - matplotlib.cm.get_cmap - matplotlib.cm.register_cmap - matplotlib.cm.unregister_cmap - matplotlib.pyplot.register_cmap in preference for working with the ColormapRegistry on the top level module. Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com>
_get_cmap
bc4b0295161db92fe7232eb46ddb97eba287287d
matplotlib
cm.py
11
10
https://github.com/matplotlib/matplotlib.git
4
72
1
43
175
Python
{ "docstring": "\n Get a colormap instance, defaulting to rc values if *name* is None.\n\n Colormaps added with :func:`register_cmap` take precedence over\n built-in colormaps.\n\n Parameters\n ----------\n name : `matplotlib.colors.Colormap` or str or None, default: None\n If a `.Colormap` i...
def _get_cmap(name=None, lut=None): if name is None: name = mpl.rcParams['image.cmap'] if isinstance(name, colors.Colormap): return name _api.check_in_list(sorted(_colormaps), name=name) if lut is None: return _colormaps[name] else: return _colormaps[name].resamp...
56,438
221,578
127
python3.10.4/Lib/concurrent/futures/_base.py
25
10
def cancel(self): with self._condition: if self._state in [RUNNING, FINISHED]: return False if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: return True self._state =
add python 3.10.4 for windows
cancel
8198943edd73a363c266633e1aa5b2a9e9c9f526
XX-Net
_base.py
10
10
https://github.com/XX-net/XX-Net.git
3
56
0
18
93
Python
{ "docstring": "Cancel the future if possible.\n\n Returns True if the future was cancelled, False otherwise. A future\n cannot be cancelled if it is running or has already completed.\n ", "language": "en", "n_whitespaces": 48, "n_words": 27, "vocab_size": 22 }
def cancel(self): with self._condition: if self._state in [RUNNING, FINISHED]: return False if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]: return True self._state = CANCELLED self._condition.notify_all() ...
5,990
32,823
100
src/transformers/utils/hub.py
46
20
def get_hub_metadata(url, token=None): if token is None: token = HfFolder.get_token()
Use new huggingface_hub tools for download models (#18438) * Draft new cached_file * Initial draft for config and model * Small fixes * Fix first batch of tests * Look in cache when internet is down * Fix last tests * Bad black, not fixing all quality errors * Make diff less * Implement change ...
get_hub_metadata
5cd40323684c183c30b34758aea1e877996a7ac9
transformers
hub.py
11
14
https://github.com/huggingface/transformers.git
4
119
0
33
200
Python
{ "docstring": "\n Returns the commit hash and associated etag for a given url.\n ", "language": "en", "n_whitespaces": 18, "n_words": 11, "vocab_size": 11 }
def get_hub_metadata(url, token=None): if token is None: token = HfFolder.get_token() headers = {"user-agent": http_user_agent()} headers["authorization"] = f"Bearer {token}" r = huggingface_hub.file_download._request_with_retry( method="HEAD", url=url, headers=headers, allow_redir...
70,416
244,523
35
mmdet/models/dense_heads/anchor_free_head.py
10
6
def aug_test(self, aug_batch_feats, aug_batch_img_metas, rescale=False): return self.aug_test_bboxes( aug_batch_feats, aug_batch_img_metas, rescal
Refactor interface of base dense free head and fcos head
aug_test
015f8a9bafe808fbe3db673d629f126a804a9207
mmdetection
anchor_free_head.py
8
3
https://github.com/open-mmlab/mmdetection.git
1
27
0
8
40
Python
{ "docstring": "Test function with test time augmentation.\n\n Args:\n aug_batch_feats (list[Tensor]): the outer list indicates test-time\n augmentations and inner Tensor should have a shape NxCxHxW,\n which contains features for all images in the batch.\n au...
def aug_test(self, aug_batch_feats, aug_batch_img_metas, rescale=False): return self.aug_test_bboxes( aug_batch_feats, aug_batch_img_metas, rescale=rescale)
29,328
130,602
128
python/ray/data/impl/block_list.py
39
18
def ensure_schema_for_first_block(self) -> Optional[Union["pyarrow.Schema", type]]: get_schema = cached_remote_fn(_get_schema) try: block = next(self.iter_blocks()) except (StopIteration, ValueError): # Dataset is empty (no blocks) or was manually
[CI] Format Python code with Black (#21975) See #21316 and #21311 for the motivation behind these changes.
ensure_schema_for_first_block
7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065
ray
block_list.py
12
13
https://github.com/ray-project/ray.git
2
68
0
32
113
Python
{ "docstring": "Ensure that the schema is set for the first block.\n\n Returns None if the block list is empty.\n ", "language": "en", "n_whitespaces": 32, "n_words": 18, "vocab_size": 15 }
def ensure_schema_for_first_block(self) -> Optional[Union["pyarrow.Schema", type]]: get_schema = cached_remote_fn(_get_schema) try: block = next(self.iter_blocks()) except (StopIteration, ValueError): # Dataset is empty (no blocks) or was manually cleared. ...
@pytest.fixture(params=["string", "pathlike", "buffer"])
40,362
168,984
25
pandas/tests/io/formats/test_format.py
14
8
def get_local_am_pm(): am_local = time(1).strftime("%p") pm_local = time(13).strftime("%p") return am_local, pm_local @pytest.fixture(params=["string", "pa
BUG: Fixed Unicode decoding error in `Period.strftime` when a locale-specific directive is used (#46405) * Added test representative of #46319. Should fail on CI * Added a gha worker with non utf 8 zh_CN encoding * Attempt to fix the encoding so that locale works * Added the fix, but not using it for now, unt...
get_local_am_pm
ae6dc976d334e791b3e215cf6e63a267675cccbe
pandas
test_format.py
10
4
https://github.com/pandas-dev/pandas.git
1
31
1
12
86
Python
{ "docstring": "Return the AM and PM strings returned by strftime in current locale.", "language": "en", "n_whitespaces": 11, "n_words": 12, "vocab_size": 12 }
def get_local_am_pm(): am_local = time(1).strftime("%p") pm_local = time(13).strftime("%p") return am_local, pm_local @pytest.fixture(params=["string", "pathlike", "buffer"])
7,309
40,010
49
dash/_validate.py
12
7
def validate_pages_layout(module, page): try: getattr(page, "layout") except AttributeError: raise exceptions.NoLayoutException( f )
update 2 after review
validate_pages_layout
9d622aca0ce4d2d6a3cbc56079c6978b46219a98
dash
_validate.py
14
10
https://github.com/plotly/dash.git
2
26
0
12
53
Python
{ "docstring": "\n No layout found in {module + \".py\"}\n A variable or a function named \"layout\" is required.\n ", "language": "en", "n_whitespaces": 50, "n_words": 16, "vocab_size": 16 }
def validate_pages_layout(module, page): try: getattr(page, "layout") except AttributeError: raise exceptions.NoLayoutException( f )
29,435
130,950
673
python/ray/serve/tests/test_autoscaling_policy.py
278
22
def test_upscale_downscale_delay(): upscale_delay_s = 30.0 downscale_delay_s = 600.0 config = AutoscalingConfig( min_replicas=1, max_replicas=2, target_num_ongoing_requests_per_replica=1, upscale_delay_s=30.0, downscale_delay_s=600.0, ) policy = BasicA...
[CI] Format Python code with Black (#21975) See #21316 and #21311 for the motivation behind these changes.
test_upscale_downscale_delay
7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065
ray
test_autoscaling_policy.py
11
67
https://github.com/ray-project/ray.git
7
358
0
92
534
Python
{ "docstring": "Unit test for upscale_delay_s and downscale_delay_s.", "language": "en", "n_whitespaces": 5, "n_words": 6, "vocab_size": 6 }
def test_upscale_downscale_delay(): upscale_delay_s = 30.0 downscale_delay_s = 600.0 config = AutoscalingConfig( min_replicas=1, max_replicas=2, target_num_ongoing_requests_per_replica=1, upscale_delay_s=30.0, downscale_delay_s=600.0, ) policy = BasicA...