complexity
int64
1
139
fun_name
stringlengths
1
80
code
stringlengths
101
62.2k
commit_id
stringlengths
40
40
ast_errors
stringlengths
0
3.11k
ast_levels
int64
6
36
file_name
stringlengths
5
79
n_ast_nodes
int64
17
19.2k
commit_message
stringlengths
3
15.3k
d_id
int64
12
121k
n_ast_errors
int64
0
9
n_whitespaces
int64
4
10.8k
token_counts
int64
5
3.06k
vocab_size
int64
4
1.11k
id
int64
20
338k
n_words
int64
4
4.82k
repo
stringlengths
3
22
n_identifiers
int64
2
176
path
stringlengths
7
134
language
stringclasses
1 value
nloc
int64
1
413
documentation
dict
url
stringlengths
31
59
3
spinner
def spinner(text="In progress..."): import streamlit.legacy_caching.caching as legacy_caching import streamlit.caching as caching from streamlit.elements.utils import clean_text from streamlit.proto.Spinner_pb2 import Spinner as SpinnerProto # @st.cache optionally uses spinner for long-running...
704eab3478cf69847825b23dabf15813a8ac9fa2
def spinner(text="In progress..."): """Temporarily displays a message while executing a block of code. Parameters ---------- text : str A message to display while executing that block Example ------- >>> with st.spinner('Wait for it...'): >>> time.sleep(5) >>> st.succe...
11
__init__.py
132
Rename and refactor `Report` machinery (#4141) This refactor renames (almost) everything related to the outdated "report" concept with more precise concepts that we use throughout our code, primarily "script run", "session", and "app".
26,274
1
202
124
80
118,532
110
streamlit
20
lib/streamlit/__init__.py
Python
22
{ "docstring": "Temporarily displays a message while executing a block of code.\n\n Parameters\n ----------\n text : str\n A message to display while executing that block\n\n Example\n -------\n\n >>> with st.spinner('Wait for it...'):\n >>> time.sleep(5)\n >>> st.success('Done!')\n...
https://github.com/streamlit/streamlit.git
3
process_queue
def process_queue(self): if not self.queue: logger.debug(f"No queued changes; aborting") return logger.debug(f"Processing {len(self.queue)} queued changes") # Iterate through the in-memory queue, creating Change instances changes = [] for key, ch...
a5308ea28e851a4ddb65a4e7ca2297b641e5891f
13
staging.py
183
Closes #10851: New staging mechanism (#10890) * WIP * Convert checkout() context manager to a class * Misc cleanup * Drop unique constraint from Change model * Extend staging tests * Misc cleanup * Incorporate M2M changes * Don't cancel wipe out creation records when an object is deleted * Rena...
78,296
0
281
98
52
266,109
63
netbox
20
netbox/netbox/staging.py
Python
18
{ "docstring": "\n Create Change instances for all actions stored in the queue.\n ", "language": "en", "n_whitespaces": 25, "n_words": 10, "vocab_size": 10 }
https://github.com/netbox-community/netbox.git
4
save
def save(self, commit=True): if self.errors: raise ValueError( "The %s could not be %s because the data didn't validate." % ( self.instance._meta.object_name, "created" if self.instance._state.adding else "changed", ...
9c19aff7c7561e3a82978a272ecdaad40dda5c00
15
models.py
130
Refs #33476 -- Reformatted code with Black.
51,322
0
279
71
54
206,002
70
django
13
django/forms/models.py
Python
15
{ "docstring": "\n Save this form's self.instance object if commit=True. Otherwise, add\n a save_m2m() method to the form which can be called after the instance\n is saved manually at a later time. Return the model instance.\n ", "language": "en", "n_whitespaces": 62, "n_words": 33, ...
https://github.com/django/django.git
14
solve
def solve(self, parameters=None, limit=None): self.pre_solve(parameters) coeff = self.coeff var = self.free_symbols if 1 in coeff: # negate coeff[] because input is of the form: ax + by + c == 0 # but is used as: ax + by == -c ...
bd9f607176c58dfba01e27c05c2b7d49ff97c901
19
diophantine.py
727
Improve loop performance in solvers
48,926
0
1,068
454
136
198,419
246
sympy
51
sympy/solvers/diophantine/diophantine.py
Python
148
{ "docstring": "\n base_solution_linear() can solve diophantine equations of the form:\n\n a*x + b*y == c\n\n We break down multivariate linear diophantine equations into a\n series of bivariate linear diophantine equations which can then\n be solved individually by base_solution_li...
https://github.com/sympy/sympy.git
1
disable_bracketed_paste
def disable_bracketed_paste(self) -> None: self.console.file.write("\x1b[?2004l") self.console.file.flush()
fe151a7f25cfd7f1134ebafbddc7eeade1c18ccb
9
driver.py
50
Support for bracketed paste mode (#567) * Detecting bracketed paste, sending paste events * Bracketed pasting support in TextInput * Restore debugging conditional * Handle pasting of text in text-input, improve scrolling * Fix ordering of handling in parser for bracketed pastes * Docstrings * Add doc...
44,330
0
27
27
6
183,771
6
textual
6
src/textual/driver.py
Python
5
{ "docstring": "Write the ANSI escape code `ESC[?2004l`, which\n disables bracketed paste mode.", "language": "en", "n_whitespaces": 17, "n_words": 11, "vocab_size": 11 }
https://github.com/Textualize/textual.git
2
get_training_arguments
def get_training_arguments(self) -> transformers.training_args.TrainingArguments: with self.as_directory() as checkpoint_path: training_args_path = os.path.join(checkpoint_path, TRAINING_ARGS_NAME) if os.path.exists(training_args_path): with open(training_args_pa...
ac1d21027da8a8c002cc7c28b8d1dc89c0d72fcf
16
huggingface_checkpoint.py
126
[AIR] Add framework-specific checkpoints (#26777)
27,836
0
132
72
23
125,331
29
ray
18
python/ray/train/huggingface/huggingface_checkpoint.py
Python
10
{ "docstring": "Retrieve the training arguments stored in this checkpoint.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 8 }
https://github.com/ray-project/ray.git
1
all_bursa
def all_bursa(): path = os.path.join(os.path.dirname(__file__), "data/bursa_open_hours.json") bursa = pd.read_json(path) # , orient="index") return bursa
33a041e5bf93ce93ab1a19adbc5ed74c2f1eb337
11
bursa_model.py
60
Trading hours stock feature (#1697)
84,728
0
27
34
12
284,458
14
OpenBBTerminal
9
openbb_terminal/stocks/tradinghours/bursa_model.py
Python
4
{ "docstring": "Get all exchanges from dictionary\n\n Parameters\n __________\n\n Returns\n _______\n pd.DataFrame\n All exchanges\n ", "language": "en", "n_whitespaces": 37, "n_words": 12, "vocab_size": 11 }
https://github.com/OpenBB-finance/OpenBBTerminal.git
3
get_git_changeset
def get_git_changeset(): # Repository may not be found if __file__ is undefined, e.g. in a frozen # module. if "__file__" not in globals(): return None repo_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) git_log = subprocess.run( "git log --pretty=format:%ct -...
9c19aff7c7561e3a82978a272ecdaad40dda5c00
13
version.py
188
Refs #33476 -- Reformatted code with Black.
51,708
0
153
107
49
206,790
62
django
27
django/utils/version.py
Python
18
{ "docstring": "Return a numeric identifier of the latest git changeset.\n\n The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.\n This value isn't guaranteed to be unique, but collisions are very unlikely,\n so it's sufficient for generating the development version numbers.\n ", ...
https://github.com/django/django.git
1
tournament_matrix
def tournament_matrix(G): r A = nx.adjacency_matrix(G) return A - A.T @not_implemented_for("undirected") @not_implemented_for("multigraph")
8a325d26aa7fdd3a72580c4720fa97f971bbefcb
@not_implemented_for("undirected") @not_implemented_for("multigraph")
8
tournament.py
56
Use scipy.sparse array datastructure (#6037) * Use scipy.sparse array datastructure * Add reminder to rm wrapper when scipy adds creation fns. * Rm mention of np matrix from code comment. * Update networkx/algorithms/bipartite/matrix.py Co-authored-by: Stefan van der Walt <sjvdwalt@gmail.com> Co-authore...
42,336
1
18
21
11
177,316
12
networkx
7
networkx/algorithms/tournament.py
Python
38
{ "docstring": "Returns the tournament matrix for the given tournament graph.\n\n This function requires SciPy.\n\n The *tournament matrix* of a tournament graph with edge set *E* is\n the matrix *T* defined by\n\n .. math::\n\n T_{i j} =\n \\begin{cases}\n +1 & \\text{if } (i, j) \\in E...
https://github.com/networkx/networkx.git
13
model_scaling
def model_scaling(layer_setting, arch_setting): # scale width new_layer_setting = copy.deepcopy(layer_setting) for layer_cfg in new_layer_setting: for block_cfg in layer_cfg: block_cfg[1] = make_divisible(block_cfg[1] * arch_setting[0], 8) # scale depth split_layer_setting ...
3f0f2a059743593fd07b629c261b609bd9a767e6
@BACKBONES.register_module()
16
efficientnet.py
510
[Feature] Support efficientnet in mmdetection. (#7514) * Initial implementation * Add missing import * Add MemoryEfficientSwishImplementation. Add docstrings * Add efficientnet2mmdet tool * Add config folder * Flake8 * Flake8 * Flake8 * Fix config * Requested changes * docformatter * U...
70,249
1
415
325
78
244,119
123
mmdetection
26
mmdet/models/backbones/efficientnet.py
Python
33
{ "docstring": "Scaling operation to the layer's parameters according to the\n arch_setting.", "language": "en", "n_whitespaces": 12, "n_words": 10, "vocab_size": 8 }
https://github.com/open-mmlab/mmdetection.git
17
polyfit
def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False): _check_arraylike("polyfit", x, y) deg = core.concrete_or_error(int, deg, "deg must be int") order = deg + 1 # check arguments if deg < 0: raise ValueError("expected deg >= 0") if x.ndim != 1: raise TypeError("expected 1D vector for x...
603bb3c5ca288674579211e64fa47c6b2b0fb7a6
@_wraps(np.poly, lax_description=_POLY_DOC) @jit
17
polynomial.py
700
lax_numpy: move poly functions into numpy.polynomial
26,696
1
463
424
155
119,831
293
jax
50
jax/_src/numpy/polynomial.py
Python
54
{ "docstring": "\\\nThis differs from np.poly when an integer array is given.\nnp.poly returns a result with dtype float64 in this case.\njax returns a result with an inexact type, but not necessarily\nfloat64.\n\nThis also differs from np.poly when the input array strictly\ncontains pairs of complex conjugates, e.g....
https://github.com/google/jax.git
1
key
def key(self) -> TaskInstanceKey: return TaskInstanceKey(self.dag_id, self.task_id, self.run_id, self.try_number, self.map_index)
6fc6edf6af7f676bfa54ff3a2e6e6d2edb938f2e
8
taskinstance.py
47
Make `airflow dags test` be able to execute Mapped Tasks (#21210) * Make `airflow dags test` be able to execute Mapped Tasks In order to do this there were two steps required: - The BackfillJob needs to know about mapped tasks, both to expand them, and in order to update it's TI tracking - The DebugExecutor ...
8,256
0
24
31
10
44,419
10
airflow
8
airflow/models/taskinstance.py
Python
3
{ "docstring": "Returns a tuple that identifies the task instance uniquely", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
https://github.com/apache/airflow.git
3
_check_guts_toc_mtime
def _check_guts_toc_mtime(attr_name, old_toc, new_toc, last_build): for dest_name, src_name, typecode in old_toc: if misc.mtime(src_name) > last_build: logger.info("Building because %s changed", src_name) return True return False
f5925fa56f713e78ab5723de2a58195ca346847f
12
utils.py
67
building: cleanup remove pyc argument from _check_guts_toc_mtime The only place where we use `_check_guts_toc_mtime` with `pyc` argument enabled is when checking the `Analysis.pure` TOC, and the source names of those entries already point to source .py files. So shortening the filenames by one character results in che...
77,596
0
62
43
23
264,086
24
pyinstaller
12
PyInstaller/building/utils.py
Python
6
{ "docstring": "\n Rebuild is required if mtimes of files listed in old TOC are newer than last_build.\n\n Use this for calculated/analysed values read from cache.\n ", "language": "en", "n_whitespaces": 33, "n_words": 23, "vocab_size": 23 }
https://github.com/pyinstaller/pyinstaller.git
6
fit
def fit(self, X, y=None): X = self._validate_data( X, accept_sparse=["csr", "csc"], dtype=[np.float64, np.float32] ) n_samples, n_features = X.shape if self.n_components == "auto": self.n_components_ = johnson_lindenstrauss_min_dim( n_sa...
8b6b519caf3b3b9602958a859b4d3a7eb1d9eadd
16
random_projection.py
357
ENH Preserving dtype for np.float32 in RandomProjection (#22114) Co-authored-by: takoika <> Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
75,247
0
760
220
109
258,487
185
scikit-learn
25
sklearn/random_projection.py
Python
43
{ "docstring": "Generate a sparse random projection matrix.\n\n Parameters\n ----------\n X : {ndarray, sparse matrix} of shape (n_samples, n_features)\n Training set: only the shape is used to find optimal random\n matrix dimensions based on the theory referenced in the\n ...
https://github.com/scikit-learn/scikit-learn.git
2
bisectors
def bisectors(self): # use lines containing sides so containment check during # intersection calculation can be avoided, thus reducing # the processing time for calculating the bisectors s = [Line(l) for l in self.sides] v = self.vertices c = self.incenter ...
498015021131af4dbb07eb110e5badaba8250c7b
14
polygon.py
213
Updated import locations
47,800
0
139
143
53
196,300
62
sympy
15
sympy/geometry/polygon.py
Python
8
{ "docstring": "The angle bisectors of the triangle.\n\n An angle bisector of a triangle is a straight line through a vertex\n which cuts the corresponding angle in half.\n\n Returns\n =======\n\n bisectors : dict\n Each key is a vertex (Point) and each value is the corre...
https://github.com/sympy/sympy.git
7
get_success_response
def get_success_response(self, *args, **params): status_code = params.pop("status_code", None) if status_code and status_code >= 400: raise Exception("status_code must be < 400") method = params.pop("method", self.method).lower() response = self.get_response(*args...
a68089d62f514557ec38e3744593e20af484e5e2
11
cases.py
212
ref(tests): Infer `status_code` from `method` (#34825)
18,674
0
255
126
47
90,548
76
sentry
15
src/sentry/testutils/cases.py
Python
17
{ "docstring": "\n Call `get_response` (see above) and assert the response's status code.\n\n :param params:\n * status_code: (Optional) Assert that the response's status code is\n a specific code. Omit to assert any successful status_code.\n :returns Response object\n ...
https://github.com/getsentry/sentry.git
1
starmap
def starmap(self, func, iterable, chunksize=None): return self._map_async( func, iterable, chunksize=chunksize, unpack_args=True ).get()
7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065
10
pool.py
52
[CI] Format Python code with Black (#21975) See #21316 and #21311 for the motivation behind these changes.
29,954
0
44
35
10
133,189
12
ray
8
python/ray/util/multiprocessing/pool.py
Python
4
{ "docstring": "Same as `map`, but unpacks each element of the iterable as the\n arguments to func like: [func(*args) for args in iterable].\n ", "language": "en", "n_whitespaces": 35, "n_words": 21, "vocab_size": 19 }
https://github.com/ray-project/ray.git
1
_get_char_x
def _get_char_x(self, linelength): return linelength + self.image_pad + self.line_number_width
f3166e673fe8d40277b804d35d77dcdb760fc3b3
8
img.py
30
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...
3,344
0
23
18
8
20,359
9
pipenv
5
pipenv/patched/notpip/_vendor/pygments/formatters/img.py
Python
2
{ "docstring": "\n Get the X coordinate of a character position.\n ", "language": "en", "n_whitespaces": 23, "n_words": 8, "vocab_size": 8 }
https://github.com/pypa/pipenv.git
1
test_evaluate_word_analogies
def test_evaluate_word_analogies(self): model = word2vec.Word2Vec(LeeCorpus()) score, sections = model.wv.evaluate_word_analogies(datapath('questions-words.txt')) score_cosmul, sections_cosmul = model.wv.evaluate_word_analogies( datapath('questions-words.txt'), s...
ac3bbcdf87b263f79d5e19cce173e6c709a15f9d
11
test_word2vec.py
206
streamlining most_similar_cosmul and evaluate_word_analogies (#2656) * streamlining most_similar_cosmul * Fix PR requested changes and add unit test * fix merge artifacts Co-authored-by: n3hrox <n3hrox@gmail.com> Co-authored-by: Michael Penkov <m@penkov.dev>
1,666
0
170
127
38
9,740
43
gensim
21
gensim/test/test_word2vec.py
Python
16
{ "docstring": "Test that evaluating analogies on KeyedVectors give sane results", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
https://github.com/RaRe-Technologies/gensim.git
2
get_default_locale
def get_default_locale(self): parent = self.get_parent() if parent is not None: return ( parent.specific_class.objects.defer() .select_related("locale") .get(id=parent.id) .locale ) return super().g...
d10f15e55806c6944827d801cd9c2d53f5da4186
17
__init__.py
94
Reformat with black
16,124
0
129
55
17
73,813
19
wagtail
12
wagtail/core/models/__init__.py
Python
10
{ "docstring": "\n Finds the default locale to use for this page.\n\n This will be called just before the initial save.\n ", "language": "en", "n_whitespaces": 40, "n_words": 18, "vocab_size": 17 }
https://github.com/wagtail/wagtail.git
4
_wait_for_data
async def _wait_for_data(self, func_name): # StreamReader uses a future to link the protocol feed_data() method # to a read coroutine. Running two read coroutines at the same time # would have an unexpected behaviour. It would not possible to know # which coroutine would get the...
8198943edd73a363c266633e1aa5b2a9e9c9f526
12
streams.py
133
add python 3.10.4 for windows
56,110
0
289
72
85
220,750
113
XX-Net
11
python3.10.4/Lib/asyncio/streams.py
Python
14
{ "docstring": "Wait until feed_data() or feed_eof() is called.\n\n If stream was paused, automatically resume it.\n ", "language": "en", "n_whitespaces": 28, "n_words": 14, "vocab_size": 14 }
https://github.com/XX-net/XX-Net.git
5
chi2
def chi2(X, y): # XXX: we might want to do some of the following in logspace instead for # numerical stability. X = check_array(X, accept_sparse="csr") if np.any((X.data if issparse(X) else X) < 0): raise ValueError("Input X must be non-negative.") # Use a sparse representation for Y ...
432778464cbffc8ca675c1df786c31f8c23fc62c
12
_univariate_selection.py
275
[MRG] chi2: reduce memory footprint (#21837) * added sparse_output=True to LabelBinarizer in chi2 * added changelog entry * Update sklearn/feature_selection/_univariate_selection.py Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> * Update sklearn/feature_selection/_univariate_selection.py Co-authored-by...
75,276
0
241
168
99
258,531
139
scikit-learn
29
sklearn/feature_selection/_univariate_selection.py
Python
15
{ "docstring": "Compute chi-squared stats between each non-negative feature and class.\n\n This score can be used to select the n_features features with the\n highest values for the test chi-squared statistic from X, which must\n contain only non-negative features such as booleans or frequencies\n (e.g., ...
https://github.com/scikit-learn/scikit-learn.git
3
equals
def equals(self, word1, word2): if self.reduce(word1*word2**-1) == self.identity: return True elif self._rewriting_system.is_confluent: return False return None
65be461082dda54c8748922f9c29a19af1279fe1
11
fp_groups.py
64
Remove abbreviations in documentation
48,440
0
66
40
14
197,297
16
sympy
8
sympy/combinatorics/fp_groups.py
Python
6
{ "docstring": "\n Compare `word1` and `word2` for equality in the group\n using the group's rewriting system. If the system is\n confluent, the returned answer is necessarily correct.\n (If it is not, `False` could be returned in some cases\n where in fact `word1 == word2`)\n\n ...
https://github.com/sympy/sympy.git
4
now
def now(parser, token): bits = token.split_contents() asvar = None if len(bits) == 4 and bits[-2] == "as": asvar = bits[-1] bits = bits[:-2] if len(bits) != 2: raise TemplateSyntaxError("'now' statement takes one argument") format_string = bits[1][1:-1] return NowNod...
9c19aff7c7561e3a82978a272ecdaad40dda5c00
@register.tag
11
defaulttags.py
141
Refs #33476 -- Reformatted code with Black.
51,441
1
81
81
31
206,250
40
django
12
django/template/defaulttags.py
Python
10
{ "docstring": "\n Display the date, formatted according to the given string.\n\n Use the same format as PHP's ``date()`` function; see https://php.net/date\n for all the possible values.\n\n Sample usage::\n\n It is {% now \"jS F Y H:i\" %}\n ", "language": "en", "n_whitespaces": 58, "n_w...
https://github.com/django/django.git
1
exradii
def exradii(self): side = self.sides a = side[0].length b = side[1].length c = side[2].length s = (a+b+c)/2 area = self.area exradii = {self.sides[0]: simplify(area/(s-a)), self.sides[1]: simplify(area/(s-b)), self.s...
498015021131af4dbb07eb110e5badaba8250c7b
13
polygon.py
169
Updated import locations
47,810
0
129
110
23
196,310
30
sympy
11
sympy/geometry/polygon.py
Python
11
{ "docstring": "The radius of excircles of a triangle.\n\n An excircle of the triangle is a circle lying outside the triangle,\n tangent to one of its sides and tangent to the extensions of the\n other two.\n\n Returns\n =======\n\n exradii : dict\n\n See Also\n ...
https://github.com/sympy/sympy.git
2
col_swap
def col_swap(self, i, j): for k in range(0, self.rows): self[k, i], self[k, j] = self[k, j], self[k, i]
59d22b6bb7287613d598611027f640d068ca5748
10
repmatrix.py
69
Moved imports to higher level
47,898
0
43
49
15
196,398
18
sympy
7
sympy/matrices/repmatrix.py
Python
3
{ "docstring": "Swap the two given columns of the matrix in-place.\n\n Examples\n ========\n\n >>> from sympy import Matrix\n >>> M = Matrix([[1, 0], [1, 0]])\n >>> M\n Matrix([\n [1, 0],\n [1, 0]])\n >>> M.col_swap(0, 1)\n >>> M\n Matrix([\...
https://github.com/sympy/sympy.git
2
renderable
def renderable(self) -> RenderableType: renderable = self.get_renderable() return Screen(renderable) if self._alt_screen else renderable
f3166e673fe8d40277b804d35d77dcdb760fc3b3
8
live.py
44
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...
3,534
0
34
26
12
20,769
13
pipenv
6
pipenv/patched/notpip/_vendor/rich/live.py
Python
8
{ "docstring": "Get the renderable that is being displayed\n\n Returns:\n RenderableType: Displayed renderable.\n ", "language": "en", "n_whitespaces": 36, "n_words": 11, "vocab_size": 11 }
https://github.com/pypa/pipenv.git
3
get_base_snippet_action_menu_items
def get_base_snippet_action_menu_items(model): menu_items = [ SaveMenuItem(order=0), DeleteMenuItem(order=10), ] for hook in hooks.get_hooks("register_snippet_action_menu_item"): action_menu_item = hook(model) if action_menu_item: menu_items.append(action_me...
d10f15e55806c6944827d801cd9c2d53f5da4186
11
action_menu.py
85
Reformat with black
16,441
0
74
51
18
75,927
20
wagtail
11
wagtail/snippets/action_menu.py
Python
10
{ "docstring": "\n Retrieve the global list of menu items for the snippet action menu,\n which may then be customised on a per-request basis\n ", "language": "en", "n_whitespaces": 31, "n_words": 21, "vocab_size": 20 }
https://github.com/wagtail/wagtail.git
1
has_key
def has_key(self, key, version=None): return ( self.get(key, self._missing_key, version=version) is not self._missing_key )
9c19aff7c7561e3a82978a272ecdaad40dda5c00
10
base.py
51
Refs #33476 -- Reformatted code with Black.
50,721
0
45
34
13
204,387
13
django
6
django/core/cache/backends/base.py
Python
4
{ "docstring": "\n Return True if the key is in the cache and has not expired.\n ", "language": "en", "n_whitespaces": 28, "n_words": 13, "vocab_size": 12 }
https://github.com/django/django.git
4
_read_all_pages
def _read_all_pages(self, endpoint): internal_data = [] while True: resp = self._session.get(endpoint) if resp.status_code == 200: internal_data += resp.json() if "next" in resp.links: endpoint = resp.links["next"]["ur...
0fdd3d56f43c8442a0c9ecd3cad07a88137ff7de
15
cleanup-tags.py
149
Changes the cleanup images workflow so it uses a OAuth token with the correct scope (GITHUB_TOKEN is not enough). Also prevents running if the token is not defined and generally does commenting/cleanups"
117,014
0
233
78
32
319,887
40
paperless-ngx
13
.github/scripts/cleanup-tags.py
Python
15
{ "docstring": "\n Internal function to read all pages of an endpoint, utilizing the\n next.url until exhausted\n ", "language": "en", "n_whitespaces": 36, "n_words": 14, "vocab_size": 14 }
https://github.com/paperless-ngx/paperless-ngx.git
3
_build_template
def _build_template(name, template, files, config, nav): # Run `pre_template` plugin events. template = config['plugins'].run_event( 'pre_template', template, template_name=name, config=config ) if utils.is_error_template(name): # Force absolute URLs in the nav of error pages and ...
dca7cbb43fcd6ea7c677c98ba585395b070d387b
14
build.py
221
Format code with `black -l100 --skip-string-normalization`
57,244
0
221
134
73
224,209
116
mkdocs
18
mkdocs/commands/build.py
Python
15
{ "docstring": "\n Return rendered output for given template as a string.\n ", "language": "en", "n_whitespaces": 16, "n_words": 9, "vocab_size": 9 }
https://github.com/mkdocs/mkdocs.git
2
get_build_datetime
def get_build_datetime() -> datetime: source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH') if source_date_epoch is None: return datetime.now(timezone.utc) return datetime.fromtimestamp(int(source_date_epoch), timezone.utc)
df3739d51903ab56771ac071a05b5aa9cdf9e129
10
__init__.py
76
Add a lot more type annotations, fix new type warnings (#2970) (including some behavior changes, assumed to be no-op) This is based on auto-generated annotations from "monkeytype".
57,432
0
35
45
14
224,944
16
mkdocs
11
mkdocs/utils/__init__.py
Python
11
{ "docstring": "\n Returns an aware datetime object.\n\n Support SOURCE_DATE_EPOCH environment variable for reproducible builds.\n See https://reproducible-builds.org/specs/source-date-epoch/\n ", "language": "en", "n_whitespaces": 27, "n_words": 14, "vocab_size": 14 }
https://github.com/mkdocs/mkdocs.git
2
test_read_video_from_file_audio_resampling
def test_read_video_from_file_audio_resampling(self, test_video, samples): # video related width, height, min_dimension, max_dimension = 0, 0, 0, 0 video_start_pts, video_end_pts = 0, -1 video_timebase_num, video_timebase_den = 0, 1 # audio related channels = 0 ...
c50d48845f7b1ca86d6a3b7f37a59be0ae11e36b
15
test_video_reader.py
327
Improve test_video_reader (#5498) * Improve test_video_reader * Fix linter error
46,871
0
605
228
80
192,301
123
vision
46
test/test_video_reader.py
Python
46
{ "docstring": "\n Test the case when decoder starts with a video file to decode frames, and\n audio waveform are resampled\n ", "language": "en", "n_whitespaces": 40, "n_words": 18, "vocab_size": 18 }
https://github.com/pytorch/vision.git
6
get_data
def get_data(filters): data = [] if erpnext.get_region() == "India": employee_pan_dict = frappe._dict( frappe.db.sql() ) component_types = frappe.db.sql( ) component_types = [comp_type[0] for comp_type in component_types] if not len(component_types): return [] conditions = get_conditions(filter...
494bd9ef78313436f0424b918f200dab8fc7c20b
15
income_tax_deductions.py
310
style: format code with black
14,386
0
47
184
57
66,950
78
erpnext
28
erpnext/payroll/report/income_tax_deductions/income_tax_deductions.py
Python
40
{ "docstring": " select employee, pan_number from `tabEmployee` select name from `tabSalary Component`\n\t\twhere is_income_tax_component = 1 select sal.employee, sal.employee_name, sal.posting_date, ded.salary_component, ded.amount,sal.gross_pay\n\t\tfrom `tabSalary Slip` sal, `tabSalary Detail` ded\n\t\twhere sal....
https://github.com/frappe/erpnext.git
2
smart_str
def smart_str(s, encoding="utf-8", strings_only=False, errors="strict"): if isinstance(s, Promise): # The input is the result of a gettext_lazy() call. return s return force_str(s, encoding, strings_only, errors) _PROTECTED_TYPES = ( type(None), int, float, Decimal, da...
9c19aff7c7561e3a82978a272ecdaad40dda5c00
7
encoding.py
97
Refs #33476 -- Reformatted code with Black.
51,599
0
78
39
35
206,640
36
django
16
django/utils/encoding.py
Python
4
{ "docstring": "\n Return a string representing 's'. Treat bytestrings using the 'encoding'\n codec.\n\n If strings_only is True, don't convert (some) non-string-like objects.\n ", "language": "en", "n_whitespaces": 33, "n_words": 20, "vocab_size": 20 }
https://github.com/django/django.git
2
mayDisableConsoleWindow
def mayDisableConsoleWindow(): # TODO: What about MSYS2? return isWin32Windows() or isMacOS()
613c31d98f20bdd9a4e5884c99826a06a3328438
8
Options.py
27
Standalone: Added support for requiring modes * For wx on macOS, console must be disabled, avoid the trap. * For the PySide2, on macOS the --onefile must be used when the application bundle is built or else signing has issues. * Recommend to use new option --disable-console for PySide2, PySide6 and wx on non-macO...
42,834
0
20
13
11
178,818
11
Nuitka
3
nuitka/Options.py
Python
2
{ "docstring": ":returns: bool derived from platform support of disabling the console,", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
https://github.com/Nuitka/Nuitka.git
1
test_as_ignores_mau
def test_as_ignores_mau(self): # Create and sync so that the MAU counts get updated token1 = self.create_user("kermit1") self.do_sync_for_user(token1) token2 = self.create_user("kermit2") self.do_sync_for_user(token2) # check we're testing what we think we are:...
7bc08f320147a1d80371eb13258328c88073fad0
16
test_mau.py
272
Remove remaining bits of groups code. (#12936) * Update worker docs to remove group endpoints. * Removes an unused parameter to `ApplicationService`. * Break dependency between media repo and groups. * Avoid copying `m.room.related_groups` state events during room upgrades.
72,300
0
333
163
79
248,480
100
synapse
28
tests/test_mau.py
Python
22
{ "docstring": "Test that application services can still create users when the MAU\n limit has been reached. This only works when application service\n user ip tracking is disabled.\n ", "language": "en", "n_whitespaces": 47, "n_words": 26, "vocab_size": 24 }
https://github.com/matrix-org/synapse.git
2
get_region_to_control_producer
def get_region_to_control_producer() -> KafkaProducer: global _publisher if _publisher is None: config = settings.KAFKA_TOPICS.get(settings.KAFKA_REGION_TO_CONTROL) _publisher = KafkaProducer( kafka_config.get_kafka_producer_cluster_options(config["cluster"]) )
941184cd24186324fd9f7f304b7f713041834726
14
producer.py
69
chore(hybrid-cloud): AuditLogEntry is a control silo model now (#39890) In the control silo, creating an audit log entry writes to the db directly, whilst in region silo mode creating an audit log entry will instead push to a new kafka producer that consumes into the control silo asynchronously.
18,181
0
59
48
15
86,878
18
sentry
10
src/sentry/region_to_control/producer.py
Python
14
{ "docstring": "\n Creates, if necessary, an arroyo.KafkaProducer client configured for region to control communication and returns\n it, caching it for future calls. Installs an exit handler to close the worker thread processes.\n ", "language": "en", "n_whitespaces": 41, "n_words": 30, "vocab_size...
https://github.com/getsentry/sentry.git
1
get_subplot
def get_subplot(self, row, col, secondary_y=False): from plotly._subplots import _get_grid_subplot return _get_grid_subplot(self, row, col, secondary_y) # Child property operations # -------------------------
5dc67fa7a7314cab97d4c96a30fdf4c5661c9039
7
basedatatypes.py
47
fix subplot imports
68,972
0
47
31
17
240,862
20
plotly.py
8
packages/python/plotly/plotly/basedatatypes.py
Python
3
{ "docstring": "\n Return an object representing the subplot at the specified row\n and column. May only be used on Figures created using\n plotly.tools.make_subplots\n\n Parameters\n ----------\n row: int\n 1-based index of subplot row\n col: int\n ...
https://github.com/plotly/plotly.py.git
2
_linear_eq_to_dict
def _linear_eq_to_dict(eqs, syms): coeffs = [] ind = [] symset = set(syms) for i, e in enumerate(eqs): c, d = _lin_eq2dict(e, symset) coeffs.append(d) ind.append(c) return coeffs, ind
e0aaa724190c49f2725bb7880eddd13ce4fef4b7
10
linsolve.py
95
more efficient coefficient extraction
49,169
0
66
58
22
199,152
27
sympy
14
sympy/polys/matrices/linsolve.py
Python
9
{ "docstring": "Convert a system Expr/Eq equations into dict form, returning\n the coefficient dictionaries and a list of syms-independent terms\n from each expression in ``eqs```.\n\n Examples\n ========\n\n >>> from sympy.polys.matrices.linsolve import _linear_eq_to_dict\n >>> from sympy.abc impor...
https://github.com/sympy/sympy.git
3
vector_reset
def vector_reset(self): self.cur_obs = [e.reset() for e in self.envs] self._timesteps = [0 for _ in range(self.num_envs)] return self.cur_obs
b52a81b3de6f4b7015c6694049d094f2964e1c96
11
model_vector_env.py
69
[RLlib] Preparation for gymnasium/gym0.26 upgrade: Deprecate `horizon` and `soft_horizon` settings. (#30583)
31,023
0
46
43
14
136,916
18
ray
10
rllib/env/wrappers/model_vector_env.py
Python
4
{ "docstring": "Override parent to store actual env obs for upcoming predictions.", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
https://github.com/ray-project/ray.git
1
cache_frame
def cache_frame(self, filename, image) -> None: frame_no = int(re.search(self.re_search, filename).group()) self.cache[frame_no] = image logger.trace("Added to cache. Frame no: %s", frame_no) logger.trace("Current cache: %s", sorted(self.cache.keys()))
60291d49c4da1cd260fbc0b04aa6a312eedfefbb
13
_base.py
105
ffmpeg writer: Create new filename if output pre-exists
20,072
0
59
64
22
100,610
24
faceswap
15
plugins/convert/writer/_base.py
Python
17
{ "docstring": " Add the incoming converted frame to the cache ready for writing out.\n\n Used for ffmpeg and gif writers to ensure that the frames are written out in the correct\n order.\n\n Parameters\n ----------\n filename: str\n The filename of the incoming frame, wh...
https://github.com/deepfakes/faceswap.git
1
allow_regional
def allow_regional(fn): def caller(*args, **kwargs): overrides = frappe.get_hooks("regional_overrides", {}).get(get_region()) function_path = f"{inspect.getmodule(fn).__name__}.{fn.__name__}" if not overrides or function_path not in overrides: return fn(*args, **kwargs) # Priority given to last install...
b68a99675d12a1ffbda538ee07a2020ba66fb3cc
13
__init__.py
152
fix: allow `regional_overrides` hook to be set in subsequent apps
13,605
0
26
10
27
64,335
35
erpnext
15
erpnext/__init__.py
Python
3
{ "docstring": "Decorator to make a function regionally overridable\n\n\tExample:\n\t@erpnext.allow_regional\n\tdef myfunction():\n\t pass", "language": "en", "n_whitespaces": 9, "n_words": 12, "vocab_size": 12 }
https://github.com/frappe/erpnext.git
3
getchannel
def getchannel(self, channel): self.load() if isinstance(channel, str): try: channel = self.getbands().index(channel) except ValueError as e: msg = f'The image has no channel "{channel}"' raise ValueError(msg) from e ...
2ae55ccbdad9c842929fb238ea1eb81d1f999024
14
Image.py
112
Improve exception traceback readability
70,094
0
124
65
27
243,725
29
Pillow
14
src/PIL/Image.py
Python
9
{ "docstring": "\n Returns an image containing a single channel of the source image.\n\n :param channel: What channel to return. Could be index\n (0 for \"R\" channel of \"RGB\") or channel name\n (\"A\" for alpha channel of \"RGBA\").\n :returns: An image in \"L\" mode.\n\n ...
https://github.com/python-pillow/Pillow.git
12
_update_legacy_config
def _update_legacy_config(self) -> bool: logger.debug("Checking for legacy state file update") priors = ["dssim_loss", "mask_type", "mask_type", "l2_reg_term"] new_items = ["loss_function", "learn_mask", "mask_type", "loss_function_2"] updated = False for old, new in zip...
94c3dcff7ebd02a5a5758f33a3eb2bfc66282117
13
model.py
471
Training updates - Add multiple selected loss functions - Unlock loss as a model configuration - Phaze-A remove encoder scaling max xap
20,323
0
846
272
116
100,872
217
faceswap
14
plugins/train/model/_base/model.py
Python
60
{ "docstring": " Legacy updates for new config additions.\n\n When new config items are added to the Faceswap code, existing model state files need to be\n updated to handle these new items.\n\n Current existing legacy update items:\n\n * loss - If old `dssim_loss` is ``true`` set new ...
https://github.com/deepfakes/faceswap.git
6
get_memos
def get_memos(self) -> Dict[bytes32, List[bytes]]: memos: Dict[bytes32, List[bytes]] = {} for coin_spend in self.coin_spends: result = Program.from_bytes(bytes(coin_spend.puzzle_reveal)).run( Program.from_bytes(bytes(coin_spend.solution)) ) fo...
89f15f591cc3cc3e8ae40e95ffc802f7f2561ece
17
spend_bundle.py
235
Merge standalone wallet into main (#9793) * wallet changes from pac * cat changes * pool tests * pooling tests passing * offers * lint * mempool_mode * black * linting * workflow files * flake8 * more cleanup * renamed * remove obsolete test, don't cast announcement * memos ar...
21,558
0
394
146
109
102,634
153
chia-blockchain
27
chia/types/spend_bundle.py
Python
18
{ "docstring": "\n Retrieves the memos for additions in this spend_bundle, which are formatted as a list in the 3rd parameter of\n CREATE_COIN. If there are no memos, the addition coin_id is not included. If they are not formatted as a list\n of bytes, they are not included. This is expensive to ...
https://github.com/Chia-Network/chia-blockchain.git
3
test_learning_curve_display_default_usage
def test_learning_curve_display_default_usage(pyplot, data): X, y = data estimator = DecisionTreeClassifier(random_state=0) train_sizes = [0.3, 0.6, 0.9] display = LearningCurveDisplay.from_estimator( estimator, X, y, train_sizes=train_sizes ) import matplotlib as mpl assert ...
758fe0d9c72ba343097003e7992c9239e58bfc63
11
test_plot.py
313
FEA add LearningCurveDisplay to show plot learning curve (#24084) Co-authored-by: jeremie du boisberranger <jeremiedbb@yahoo.fr> Co-authored-by: Arturo Amor <86408019+ArturoAmorQ@users.noreply.github.com>
76,917
0
199
211
68
261,652
98
scikit-learn
39
sklearn/model_selection/tests/test_plot.py
Python
27
{ "docstring": "Check the default usage of the LearningCurveDisplay class.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 7 }
https://github.com/scikit-learn/scikit-learn.git
1
test_climate_find_valid_targets
async def test_climate_find_valid_targets(): valid_targets = [10, 16, 17, 18, 19, 20] assert _find_valid_target_temp(7, valid_targets) == 10 assert _find_valid_target_temp(10, valid_targets) == 10 assert _find_valid_target_temp(11, valid_targets) == 16 assert _find_valid_target_temp(15, valid...
5ee2f4f438f8acb119308738639169138b15662c
8
test_climate.py
135
Sensibo Set temperature improvement (#72992)
102,059
0
81
94
26
303,231
51
core
3
tests/components/sensibo/test_climate.py
Python
10
{ "docstring": "Test function to return temperature from valid targets.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 8 }
https://github.com/home-assistant/core.git
1
test_send_push_single_worker
def test_send_push_single_worker(self): http_client_mock = Mock(spec_set=["post_json_get_json"]) http_client_mock.post_json_get_json.side_effect = ( lambda *_, **__: defer.succeed({}) ) self.make_worker_hs( "synapse.app.generic_worker", {"wor...
854a6884d81c95297bf93badcddc00a4cab93418
13
test_pusher_shard.py
213
Modernize unit tests configuration settings for workers. (#14568) Use the newer foo_instances configuration instead of the deprecated flags to enable specific features (e.g. start_pushers).
73,196
0
261
125
43
249,919
49
synapse
19
tests/replication/test_pusher_shard.py
Python
23
{ "docstring": "Test that registration works when using a pusher worker.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
https://github.com/matrix-org/synapse.git
1
test_load_existing_stream
def test_load_existing_stream(self) -> None: self._insert_rows("foobar1", "first", 3) self._insert_rows("foobar2", "second", 3) self._insert_rows("foobar2", "second", 1, update_stream_table=False) first_id_gen = self._create_id_generator("first", writers=["first", "second"]) ...
9d21ecf7ceab55bc19c4457b8b07401b0b1623a7
11
test_id_generators.py
330
Add type hints to tests files. (#12256)
71,927
0
198
190
61
247,794
79
synapse
12
tests/storage/test_id_generators.py
Python
17
{ "docstring": "Test creating ID gens with multiple tables that have rows from after\n the position in `stream_positions` table.\n ", "language": "en", "n_whitespaces": 31, "n_words": 17, "vocab_size": 17 }
https://github.com/matrix-org/synapse.git
4
test_notification_preferences_panel_reduced_for_non_moderators
def test_notification_preferences_panel_reduced_for_non_moderators(self): response = self.client.get(reverse("wagtailadmin_account")) # Find notifications panel through context notifications_panel = None for panelset in response.context["panels_by_tab"].values(): fo...
d10f15e55806c6944827d801cd9c2d53f5da4186
12
test_account_management.py
200
Reformat with black
15,750
0
195
115
33
71,800
43
wagtail
18
wagtail/admin/tests/test_account_management.py
Python
15
{ "docstring": "\n This tests that a user without publish permissions is not shown the\n notification preference for 'submitted' items\n ", "language": "en", "n_whitespaces": 39, "n_words": 17, "vocab_size": 17 }
https://github.com/wagtail/wagtail.git
2
as_dict
def as_dict(self) -> Dict[Text, Any]: serializable_graph_schema: Dict[Text, Dict[Text, Any]] = {"nodes": {}} for node_name, node in self.nodes.items(): serializable = dataclasses.asdict(node) # Classes are not JSON serializable (surprise) serializable["uses"...
9fc462da870f69f9976be3bc081675844b9f64c2
12
graph.py
137
fix type annotation in rasa.engine
38,299
0
107
72
28
159,507
35
rasa
16
rasa/engine/graph.py
Python
12
{ "docstring": "Returns graph schema in a serializable format.\n\n Returns:\n The graph schema in a format which can be dumped as JSON or other formats.\n ", "language": "en", "n_whitespaces": 48, "n_words": 23, "vocab_size": 19 }
https://github.com/RasaHQ/rasa.git
15
page_identity
def page_identity(self, response, request_json=None): request_path = response.request.path_url if request_path == '/migrations_notran/': raise exc.IsMigrating('You have been redirected to the migration-in-progress page.') request_method = response.request.method.lower() ...
68a44529b6b77d2d43d7099b654560bfd8bbf518
13
page.py
536
Register pages for the Instance peers and install bundle endpoints This includes exposing a new interface for Page objects, Page.bytes, to return the full bytestring contents of the response.
17,285
0
694
337
104
81,965
171
awx
47
awxkit/awxkit/api/pages/page.py
Python
44
{ "docstring": "Takes a `requests.Response` and\n returns a new __item_class__ instance if the request method is not a get, or returns\n a __class__ instance if the request path is different than the caller's `endpoint`.\n ", "language": "en", "n_whitespaces": 56, "n_words": 32, "vocab...
https://github.com/ansible/awx.git
2
call_categories
def call_categories(self, other_args): parser = argparse.ArgumentParser( prog="categories", add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, description=, ) parser.add_argument( "-l", "--limi...
09f753da1c2a2f03c41fe6a3ca2eb79f6ea58995
11
overview_controller.py
254
More Fixes to Crypto + key sort (#3244) * fix #3095 - autocomplete and command working + key sort * fix #3056 * fix [Bug] bugs #3048 * fix [Bug] bug #3017 * sort -> sortby, not ascend, tests * fix my goof ups Co-authored-by: james <jmaslek11@gmail.com>
85,786
0
494
161
63
286,399
72
OpenBBTerminal
31
openbb_terminal/cryptocurrency/overview/overview_controller.py
Python
43
{ "docstring": "Process top_categories commandShows top cryptocurrency categories by market capitalization. It includes categories like:\n stablecoins, defi, solana ecosystem, polkadot ecosystem and many others.\n You can sort by {}, using --sortby parameter", "language": "en", "n_whitespace...
https://github.com/OpenBB-finance/OpenBBTerminal.git
3
listify_tensors
def listify_tensors(x): if tf.is_tensor(x): x = x.numpy() if isinstance(x, np.ndarray): x = x.tolist() return x
84afc5193d38057e2e2badf9c889ea87d80d8fbf
10
preprocessing_utils.py
68
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
81,118
0
41
40
11
273,362
15
keras
9
keras/layers/preprocessing/preprocessing_utils.py
Python
6
{ "docstring": "Convert any tensors or numpy arrays to lists for config serialization.", "language": "en", "n_whitespaces": 10, "n_words": 11, "vocab_size": 11 }
https://github.com/keras-team/keras.git
1
test_key_query_cancellation
def test_key_query_cancellation(self) -> None: self.register_user("alice", "wonderland") alice_token = self.login("alice", "wonderland") bob = self.register_user("bob", "uncle") channel = make_request_with_cancellation_test( "test_key_query_cancellation", ...
d3d9ca156e323fe194b1bcb1af1628f65a2f3c1c
13
test_keys.py
177
Cancel the processing of key query requests when they time out. (#13680)
72,939
0
259
104
42
249,472
47
synapse
17
tests/rest/client/test_keys.py
Python
23
{ "docstring": "\n Tests that /keys/query is cancellable and does not swallow the\n CancelledError.\n ", "language": "en", "n_whitespaces": 33, "n_words": 11, "vocab_size": 11 }
https://github.com/matrix-org/synapse.git
4
trigsimp
def trigsimp(expr, inverse=False, **opts): from sympy.simplify.fu import fu expr = sympify(expr) _eval_trigsimp = getattr(expr, '_eval_trigsimp', None) if _eval_trigsimp is not None: return _eval_trigsimp(**opts) old = opts.pop('old', False) if not old: opts.pop('deep', N...
5fc97f8ef40cbc9363c7f7e0ff25f12c45a2203e
11
trigsimp.py
160
implemented inverse option for trigsimp
47,355
0
101
202
32
195,664
42
sympy
13
sympy/simplify/trigsimp.py
Python
26
{ "docstring": "Returns a reduced expression by using known trig identities.\n\n Parameters\n ==========\n\n inverse : bool, optional\n If ``inverse=True``, it will be assumed that a composition of inverse\n functions, such as sin and asin, can be cancelled in any order.\n For example, `...
https://github.com/sympy/sympy.git
1
db_supports_json
def db_supports_json(self): return not conf.get("database", "sql_alchemy_conn").startswith("mssql")
d8889da29ccfcbecd2c89b9e8e278c480767d678
11
sqlalchemy.py
42
Move the database configuration to a new section (#22284) Co-authored-by: gitstart-airflow <gitstart@users.noreply.github.com> Co-authored-by: GitStart <1501599+gitstart@users.noreply.github.com> Co-authored-by: Egbosi Kelechi <egbosikelechi@gmail.com>
9,072
0
20
21
6
47,330
6
airflow
5
airflow/utils/sqlalchemy.py
Python
2
{ "docstring": "Checks if the database supports JSON (i.e. is NOT MSSQL)", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
https://github.com/apache/airflow.git
8
coord_map_from_to
def coord_map_from_to(top_from, top_to): # We need to find a common ancestor of top_from and top_to. # We'll assume that all ancestors are equivalent here (otherwise the graph # is an inconsistent state (which we could improve this to check for)). # For now use a brute-force algorithm.
cc4d0564756ca067516f71718a3d135996525909
6
coord_map.py
19
Balanced joint maximum mean discrepancy for deep transfer learning
12,025
0
62
177
42
60,232
47
transferlearning
3
code/deep/BJMMD/caffe/python/caffe/coord_map.py
Python
28
{ "docstring": "\n Determine the coordinate mapping betweeen a top (from) and a top (to).\n Walk the graph to find a common ancestor while composing the coord maps for\n from and to until they meet. As a last step the from map is inverted.\n ", "language": "en", "n_whitespaces": 54, "n_words": 41, ...
https://github.com/jindongwang/transferlearning.git
4
plot_feature_importance
def plot_feature_importance(model, feature_names, pair, train_dir, count_max=50) -> None: try: import plotly.graph_objects as go from plotly.subplots import make_subplots except ImportError: logger.exception("Module plotly not found \n Please install using `pip3 install plotly`") ...
86aa875bc9d5edeba04f908fe45b011e52045c83
13
utils.py
261
plot features as html instead of png
34,972
0
189
229
67
151,197
84
freqtrade
34
freqtrade/freqai/utils.py
Python
37
{ "docstring": "\n Plot Best and Worst Features by importance for CatBoost model.\n Called once per sub-train.\n Usage: plot_feature_importance(\n model=model,\n feature_names=dk.training_features_list,\n pair=pair,\n train_dir=dk.data_path)\n ", "...
https://github.com/freqtrade/freqtrade.git
5
get_objects
async def get_objects(self) -> dict: replies = await asyncio.gather( *[ self._client.get_object_info(node_id, timeout=DEFAULT_RPC_TIMEOUT) for node_id in self._client.get_all_registered_raylet_ids() ] ) worker_stats = [] f...
30ab5458a7e4ba2351d5e1beef8c8797b5946493
16
state_aggregator.py
234
[State Observability] Tasks and Objects API (#23912) This PR implements ray list tasks and ray list objects APIs. NOTE: You can ignore the merge conflict for now. It is because the first PR was reverted. There's a fix PR open now.
31,404
0
518
140
80
138,395
107
ray
31
dashboard/state_aggregator.py
Python
32
{ "docstring": "List all object information from the cluster.\n\n Returns:\n {object_id -> object_data_in_dict}\n object_data_in_dict's schema is in ObjectState\n ", "language": "en", "n_whitespaces": 52, "n_words": 16, "vocab_size": 16 }
https://github.com/ray-project/ray.git
4
exec_
def exec_(_code_, _globs_=None, _locs_=None): if _globs_ is None: frame = sys._getframe(1) _globs_ = frame.f_globals if _locs_ is None: _locs_ = frame.f_locals del frame elif _locs_ is None: _locs_ = _globs_ exe...
f638f5d0e6c8ebed0e69a6584bc7f003ec646580
11
six.py
136
upd; format
13,487
0
140
56
22
63,729
38
transferlearning
11
.venv/lib/python3.8/site-packages/pip/_vendor/six.py
Python
10
{ "docstring": "Execute code in a namespace.exec _code_ in _globs_, _locs_def reraise(tp, value, tb=None):\n try:\n raise tp, value, tb\n finally:\n tb = None\ndef raise_from(value, from_value):\n try:\n raise value from from_value\n finally:\n value = None\n", "language": "e...
https://github.com/jindongwang/transferlearning.git
1
test_create_single_object_with_values
def test_create_single_object_with_values(self): data = { 'name': 'Site 3', 'slug': 'site-3', 'custom_fields': { 'text_field': 'bar', 'longtext_field': 'blah blah blah', 'number_field': 456, 'boolean_fie...
fa1e28e860c4bdb3e585a968bd248a2ac666e1f6
14
test_customfields.py
735
Initial work on #7006
77,615
0
491
420
82
264,128
102
netbox
26
netbox/extras/tests/test_customfields.py
Python
41
{ "docstring": "\n Create a single new site with a value for each type of custom field.\n ", "language": "en", "n_whitespaces": 29, "n_words": 14, "vocab_size": 13 }
https://github.com/netbox-community/netbox.git
7
shift
def shift(self, periods=1, freq=None, axis=0, fill_value=None, meta=no_default): if meta is no_default: with raise_on_meta_error("groupby.shift()", udf=False): meta_kwargs = _extract_meta( { "periods": periods, ...
336aac39ee8a616ac2645e532392123ae1bfddd1
15
groupby.py
391
Add groupby shift method (#8522) Implements the shift `method` following the `transform` and `apply` methods.
36,420
0
807
246
115
155,537
153
dask
43
dask/dataframe/groupby.py
Python
51
{ "docstring": "Parallel version of pandas GroupBy.shift\n\n This mimics the pandas version except for the following:\n\n If the grouper does not align with the index then this causes a full\n shuffle. The order of rows within each group may not be preserved.\n\n Parameters\n -----...
https://github.com/dask/dask.git
2
nice_decrease
def nice_decrease(self, pid): p = psutil.Process(pid) try: p.nice(p.nice() - 1) logger.info('Set nice level of process {} to {} (higher the priority)'.format(pid, p.nice())) except psutil.AccessDenied: logger.warning( 'Can not decrease...
917f01a8306055b21437deac35333dddd1210e39
13
processes.py
109
Update formater in the Makefile with flake8 and autopep8/autoflake
15,339
0
127
63
31
70,108
40
glances
12
glances/processes.py
Python
9
{ "docstring": "Decrease nice level\n On UNIX this is a number which usually goes from -20 to 20.\n The higher the nice value, the lower the priority of the process.", "language": "en", "n_whitespaces": 41, "n_words": 28, "vocab_size": 24 }
https://github.com/nicolargo/glances.git
4
_get_device_count
def _get_device_count(self): if self._is_plaidml: self._device_count = self._plaid.device_count elif IS_MACOS: self._device_count = metal.get_device_count() else: try: self._device_count = pynvml.nvmlDeviceGetCount() except...
444762114c1b1ad2e72c871e825373bd74880aba
13
gpu_stats.py
121
Initial somewhat working version
19,777
0
136
70
21
100,267
27
faceswap
14
lib/gpu_stats.py
Python
11
{ "docstring": " Detect the number of GPUs attached to the system and allocate to\n :attr:`_device_count`. ", "language": "en", "n_whitespaces": 21, "n_words": 13, "vocab_size": 11 }
https://github.com/deepfakes/faceswap.git
2
_handle_analyzed_df_message
def _handle_analyzed_df_message(self, type, data): key, value = data["key"], data["value"] pair, timeframe, candle_type = key # Skip any pairs that we don't have in the pairlist? # leader_pairlist = self._freqtrade.pairlists._whitelist # if pair not in leader_pairlist: ...
2b5f0678772bea0abaf4abe93efc55de43ea3e0e
10
rpc.py
169
Refactoring, minor improvements, data provider improvements
34,859
0
180
98
49
150,869
67
freqtrade
20
freqtrade/rpc/rpc.py
Python
10
{ "docstring": "\n Handles the analyzed dataframes from the Leaders\n\n :param type: The data_type of the data\n :param data: The data\n ", "language": "en", "n_whitespaces": 47, "n_words": 18, "vocab_size": 13 }
https://github.com/freqtrade/freqtrade.git
7
pdf
def pdf(self, x, *args, **kwds): # override base class version to correct # location for S1 parameterization if self._parameterization() == "S0": return super().pdf(x, *args, **kwds) elif self._parameterization() == "S1": (alpha, beta), delta, gamma = sel...
3a3727c022a361a0bc8a519ebc60e7de8124a5d9
21
__init__.py
498
DOC: stats: add levy_stable pdf/cdf/rvs docstring
69,756
0
703
330
101
242,037
154
scipy
37
scipy/stats/_levy_stable/__init__.py
Python
31
{ "docstring": "Probability density function of the Levy-stable distribution\n\n Parameters\n ----------\n x : array_like\n quantiles\n alpha, beta : array_like\n The shape parameters of the distribution. See the `levy_stable`\n object docstring for more in...
https://github.com/scipy/scipy.git
2
project_columns
def project_columns(self, columns): if columns == self.columns: return self func = copy.deepcopy(self) func._columns = columns return func
b946406a30cd12cd6989df3440011a734441a200
8
core.py
53
Add from_map function to Dask-DataFrame (#8911)
36,647
0
63
32
13
156,466
17
dask
7
dask/dataframe/io/orc/core.py
Python
6
{ "docstring": "Return a new ORCFunctionWrapper object with\n a sub-column projection.\n ", "language": "en", "n_whitespaces": 23, "n_words": 9, "vocab_size": 8 }
https://github.com/dask/dask.git
1
replace_embedding
def replace_embedding(embedding, masks): # currently we donnot support replace the embedding layer # because we donnot have the corressponding pruner return embedding
97d067e614243f06ed1f8e2d389512977fff8828
6
compress_modules.py
20
Speedup enhancement (#4925)
24,867
0
34
10
17
113,257
22
nni
3
nni/compression/pytorch/speedup/compress_modules.py
Python
2
{ "docstring": "\n Replace the embedding layer according the infered masks.\n We replace the embedding layer according the weight masks,\n ", "language": "en", "n_whitespaces": 27, "n_words": 17, "vocab_size": 11 }
https://github.com/microsoft/nni.git
5
get_edit_handler
def get_edit_handler(cls): if hasattr(cls, "edit_handler"): edit_handler = cls.edit_handler else: # construct a TabbedInterface made up of content_panels, promote_panels # and settings_panels, skipping any which are empty tabs = [] if cls.content_panels: ...
470d39e1fe86084f729997f7c4e13f551e7e8c73
@receiver(setting_changed)
18
panels.py
216
Split out bind_to(model) into a separate bind_to_model method
16,572
1
253
118
47
76,705
56
wagtail
19
wagtail/admin/panels.py
Python
19
{ "docstring": "\n Get the panel to use in the Wagtail admin when editing this page type.\n ", "language": "en", "n_whitespaces": 21, "n_words": 14, "vocab_size": 13 }
https://github.com/wagtail/wagtail.git
4
descendants_at_distance
def descendants_at_distance(G, source, distance): if source not in G: raise nx.NetworkXError(f"The node {source} is not in the graph.") bfs_generator = nx.bfs_layers(G, source) for i, layer in enumerate(bfs_generator): if i == distance: return set(layer) return set()
4a019f04d0e304ecd2f28b15d854e1282e03461d
11
breadth_first_search.py
96
Adds ```nx.bfs_layers``` method (#5879) * reformatted the files * reformatted the files * added final changes * changed descendants_at_distance * fixed comment in bfs_layers * fixed comment in bfs_layers
42,274
0
75
58
30
177,116
35
networkx
12
networkx/algorithms/traversal/breadth_first_search.py
Python
8
{ "docstring": "Returns all nodes at a fixed `distance` from `source` in `G`.\n\n Parameters\n ----------\n G : NetworkX graph\n A graph\n source : node in `G`\n distance : the distance of the wanted nodes from `source`\n\n Returns\n -------\n set()\n The descendants of `source` ...
https://github.com/networkx/networkx.git
1
test_unknown_device
def test_unknown_device(self) -> None: url = "/_synapse/admin/v2/users/%s/devices/unknown_device" % urllib.parse.quote( self.other_user ) channel = self.make_request( "GET", url, access_token=self.admin_user_tok, ) self.a...
c97042f7eef3748e17c90e48a4122389a89c4735
10
test_device.py
215
Use literals in place of `HTTPStatus` constants in tests (#13469)
72,587
0
258
138
31
249,080
50
synapse
18
tests/rest/admin/test_device.py
Python
26
{ "docstring": "\n Tests that a lookup for a device that does not exist returns either HTTPStatus.NOT_FOUND or 200.\n ", "language": "en", "n_whitespaces": 31, "n_words": 16, "vocab_size": 14 }
https://github.com/matrix-org/synapse.git
1
test_get_cache_path
def test_get_cache_path(setup): assert get_cache_path() == Path(setup.directory, ".spotdl", ".spotipy")
fa2ad657482aca9dc628e6d7062b8badf2706bb6
9
test_config.py
39
v4 init
5,356
0
14
21
8
30,157
8
spotify-downloader
5
tests/utils/test_config.py
Python
2
{ "docstring": "\n Tests if the path to the cache file is correct.\n ", "language": "en", "n_whitespaces": 17, "n_words": 10, "vocab_size": 9 }
https://github.com/spotDL/spotify-downloader.git
2
_get_cluster_uid
def _get_cluster_uid(self) -> str: # Default to an environment variable env_cluster_uid = os.environ.get("PREFECT_KUBERNETES_CLUSTER_UID") if env_cluster_uid: return env_cluster_uid # Read the UID from the cluster namespace with self.get_client() as client: ...
9ab65f6480a31ba022d9846fdfbfca1d17da8164
11
kubernetes.py
91
Add `PREFECT_KUBERNETES_CLUSTER_UID` to allow bypass of `kube-system` namespace read (#7864) Co-authored-by: Peyton <44583861+peytonrunyan@users.noreply.github.com>
11,992
0
115
49
29
60,149
37
prefect
14
src/prefect/infrastructure/kubernetes.py
Python
21
{ "docstring": "\n Gets a unique id for the current cluster being used.\n\n There is no real unique identifier for a cluster. However, the `kube-system`\n namespace is immutable and has a persistence UID that we use instead.\n\n PREFECT_KUBERNETES_CLUSTER_UID can be set in cases where the ...
https://github.com/PrefectHQ/prefect.git
1
get_default_mesh
def get_default_mesh(self): return self._default_mesh LayoutMap.get.__doc__ = LayoutMap.__getitem__.__doc__ @keras_export("keras.dtensor.experimental.layout_map_scope", v1=[]) @contextlib.contextmanager
84afc5193d38057e2e2badf9c889ea87d80d8fbf
@keras_export("keras.dtensor.experimental.layout_map_scope", v1=[]) @contextlib.contextmanager
8
layout_map.py
60
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
80,492
1
21
10
10
270,593
10
keras
11
keras/dtensor/layout_map.py
Python
2
{ "docstring": "Return the default `Mesh` set at instance creation.\n\n The `Mesh` can be used to create default replicated `Layout` when there\n isn't a match of the input string query.\n ", "language": "en", "n_whitespaces": 49, "n_words": 28, "vocab_size": 25 }
https://github.com/keras-team/keras.git
4
state
def state(self) -> MediaPlayerState: if self._tv.on and (self._tv.powerstate == "On" or self._tv.powerstate is None): return MediaPlayerState.ON return MediaPlayerState.OFF
52b5e1779f1ed6e5005dc0bdff4137040d7216fb
11
media_player.py
68
Use new media player enums [p] (#78058)
105,754
0
50
41
17
306,974
18
core
8
homeassistant/components/philips_js/media_player.py
Python
5
{ "docstring": "Get the device state. An exception means OFF state.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 8 }
https://github.com/home-assistant/core.git
1
to_json
def to_json(self, **kwargs): config = self.get_config() tokenizer_config = { "class_name": self.__class__.__name__, "config": config, } return json.dumps(tokenizer_config, **kwargs) @keras_export("keras.preprocessing.text.tokenizer_from_json")
84afc5193d38057e2e2badf9c889ea87d80d8fbf
@keras_export("keras.preprocessing.text.tokenizer_from_json")
10
text.py
82
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
81,467
1
74
42
17
275,788
18
keras
11
keras/preprocessing/text.py
Python
7
{ "docstring": "Returns a JSON string containing the tokenizer configuration.\n\n To load a tokenizer from a JSON string, use\n `keras.preprocessing.text.tokenizer_from_json(json_string)`.\n\n Args:\n **kwargs: Additional keyword arguments\n to be passed to `json.dumps()...
https://github.com/keras-team/keras.git
1
test_delete_view
def test_delete_view(self): delete_dict = {"post": "yes"} delete_url = reverse("admin:admin_views_article_delete", args=(self.a1.pk,)) # add user should not be able to delete articles self.client.force_login(self.adduser) response = self.client.get(delete_url) s...
9c19aff7c7561e3a82978a272ecdaad40dda5c00
14
tests.py
624
Refs #33476 -- Reformatted code with Black.
52,091
0
410
387
71
207,766
126
django
40
tests/admin_views/tests.py
Python
36
{ "docstring": "Delete view should restrict access and actually delete items.", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
https://github.com/django/django.git
4
tasks_from_url
def tasks_from_url(file_upload_ids, project, request, url): # process URL with tasks ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE try: filename = url.rsplit('/', 1)[-1] with urlopen(url, context=ctx) as file: # nosec ...
d8d6a0554bfd263f8ce12ff3ce5a69986edd9bc0
15
uploader.py
291
fix: DEV-2361: Fix bandit check in LabelStudio Opensource (#2379)
42,529
0
266
179
62
177,869
84
label-studio
40
label_studio/data_import/uploader.py
Python
22
{ "docstring": " Download file using URL and read tasks from it\n ", "language": "en", "n_whitespaces": 13, "n_words": 9, "vocab_size": 9 }
https://github.com/heartexlabs/label-studio.git
4
_multi_worker_concat
def _multi_worker_concat(v, strategy): replicas = strategy.gather(v, axis=0) # v might not have the same shape on different replicas if _is_per_replica_instance(v): shapes = tf.concat( [ tf.expand_dims(tf.shape(single_value)[0], axis=0) for single_val...
84afc5193d38057e2e2badf9c889ea87d80d8fbf
16
training.py
248
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
80,811
0
258
161
62
271,583
81
keras
26
keras/engine/training.py
Python
25
{ "docstring": "Order PerReplica objects for CollectiveAllReduceStrategy and concat.", "language": "en", "n_whitespaces": 6, "n_words": 7, "vocab_size": 7 }
https://github.com/keras-team/keras.git
2
shape
def shape(source, kind=None): return FunctionCall( 'shape', [_printable(source)] + ([_printable(kind)] if kind else []) )
498015021131af4dbb07eb110e5badaba8250c7b
13
fnodes.py
59
Updated import locations
47,541
0
44
36
14
196,041
14
sympy
5
sympy/codegen/fnodes.py
Python
6
{ "docstring": " Creates an AST node for a function call to Fortran's \"shape(...)\"\n\n Parameters\n ==========\n\n source : Symbol or String\n kind : expr\n\n Examples\n ========\n\n >>> from sympy import fcode\n >>> from sympy.codegen.fnodes import shape\n >>> shp = shape('x')\n >>> f...
https://github.com/sympy/sympy.git
3
test_interactive_annotating_with_drafts
def test_interactive_annotating_with_drafts(business_client, configured_project): # create project with predefined task set ml_backend = configured_project.ml_backends.first() ml_backend.is_interactive = True ml_backend.save() users = list(User.objects.all()) task = configured_project.tas...
4ec4614e5e8b74795ecf8620e414f0340c6b94ef
18
test_predictions.py
448
fix: DEV-2138: In interactive prediction only current user's draft should be sent (#2233) * fix: DEV-2138: In interactive prediction only current user's draft should be sent * Add test to check drafts in interactive prediction Co-authored-by: hlomzik <hlomzik@gmail.com>
42,498
0
326
260
74
177,774
97
label-studio
43
label_studio/tests/test_predictions.py
Python
29
{ "docstring": "\n Test interactive annotating with drafts\n :param business_client:\n :param configured_project:\n :return:\n ", "language": "en", "n_whitespaces": 26, "n_words": 10, "vocab_size": 9 }
https://github.com/heartexlabs/label-studio.git
2
_parse_distro_release_file
def _parse_distro_release_file(self, filepath): # type: (str) -> Dict[str, str] try: with open(filepath) as fp: # Only parse the first line. For instance, on SLES there # are multiple lines. We don't want them... return self._parse_dis...
f3166e673fe8d40277b804d35d77dcdb760fc3b3
13
distro.py
74
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...
3,218
0
185
39
51
20,072
57
pipenv
9
pipenv/patched/notpip/_vendor/distro.py
Python
6
{ "docstring": "\n Parse a distro release file.\n\n Parameters:\n\n * filepath: Path name of the distro release file.\n\n Returns:\n A dictionary containing all information items.\n ", "language": "en", "n_whitespaces": 69, "n_words": 22, "vocab_size": 19 }
https://github.com/pypa/pipenv.git
5
save_hyperparameters
def save_hyperparameters(self, ignore=[]): frame = inspect.currentframe().f_back _, _, _, local_vars = inspect.getargvalues(frame) self.hparams = {k:v for k, v in local_vars.items() if k not in set(ignore+['self']) and not k.startswith('_')} for k, v in s...
19aba1f059efad45e1466d47954b2cf54d45b106
15
mxnet.py
150
simplify d2l lib
74,148
0
105
94
25
253,601
36
d2l-en
17
d2l/mxnet.py
Python
7
{ "docstring": "Save function arguments into class attributes.\n\n Defined in :numref:`sec_utils`", "language": "en", "n_whitespaces": 15, "n_words": 9, "vocab_size": 9 }
https://github.com/d2l-ai/d2l-en.git
1
test_str_structvalue
def test_str_structvalue(self): block = SectionBlock() value = block.to_python({"title": "Hello", "body": "<i>italic</i> world"}) result = str(value) self.assertNotIn("<h1>", result) # The expected rendering should correspond to the native representation of an OrderedDic...
d10f15e55806c6944827d801cd9c2d53f5da4186
11
test_blocks.py
123
Reformat with black
16,224
0
132
65
48
74,148
55
wagtail
10
wagtail/core/tests/test_blocks.py
Python
8
{ "docstring": "\n The str() representation of a StructValue should NOT render the template, as that's liable\n to cause an infinite loop if any debugging / logging code attempts to log the fact that\n it rendered a template with this object in the context:\n https://github.com/wagtail/wag...
https://github.com/wagtail/wagtail.git
2
revert
def revert(self): if self._backup: self.set_state(self._backup) self._backup = None
b3587b52b25077f68116b9852b041d33e7fc6601
10
flow.py
42
make it black!
73,697
0
44
24
8
251,362
8
mitmproxy
4
mitmproxy/flow.py
Python
4
{ "docstring": "\n Revert to the last backed up state.\n ", "language": "en", "n_whitespaces": 22, "n_words": 7, "vocab_size": 7 }
https://github.com/mitmproxy/mitmproxy.git
1
test_fetch_period_api_with_no_timestamp
async def test_fetch_period_api_with_no_timestamp(recorder_mock, hass, hass_client): await async_setup_component(hass, "history", {}) client = await hass_client() response = await client.get("/api/history/period") assert response.status == HTTPStatus.OK
31a787558fd312331b55e5c2c4b33341fc3601fc
10
test_init.py
75
Ensure recorder test fixture is setup before hass fixture (#80528) * Ensure recorder test fixture is setup before hass fixture * Adjust more tests
88,517
0
36
43
18
289,375
21
core
11
tests/components/history/test_init.py
Python
5
{ "docstring": "Test the fetch period view for history with no timestamp.", "language": "en", "n_whitespaces": 9, "n_words": 10, "vocab_size": 10 }
https://github.com/home-assistant/core.git
3
test_print_info_with_numpy
def test_print_info_with_numpy(self, do_validation): model = keras.models.Sequential( [keras.layers.Dense(1, input_shape=(2,))] ) model.compile(loss="mse", optimizer="sgd") dataset = np.arange(200).reshape(100, 2) if do_validation: val_data = (...
84afc5193d38057e2e2badf9c889ea87d80d8fbf
14
training_arrays_test.py
280
Reformatting the codebase with black. PiperOrigin-RevId: 450093126
80,835
0
254
175
43
271,626
55
keras
35
keras/engine/training_arrays_test.py
Python
21
{ "docstring": "Print training info should work with val datasets (b/133391839).", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
https://github.com/keras-team/keras.git
1
q_mean_variance
def q_mean_variance(self, x_start, t): mean = (extract_into_tensor(self.sqrt_alphas_cumprod, t, x_start.shape) * x_start) variance = extract_into_tensor(1.0 - self.alphas_cumprod, t, x_start.shape) log_variance = extract_into_tensor(self.log_one_minus_alphas_cumprod, t, x_start.shape) ...
ca86da3a30c4e080d4db8c25fca73de843663cb4
11
ddpm.py
94
release more models
36,898
0
62
66
20
157,317
27
stablediffusion
12
ldm/models/diffusion/ddpm.py
Python
5
{ "docstring": "\n Get the distribution q(x_t | x_0).\n :param x_start: the [N x C x ...] tensor of noiseless inputs.\n :param t: the number of diffusion steps (minus 1). Here, 0 means one step.\n :return: A tuple (mean, variance, log_variance), all of x_start's shape.\n ", "langu...
https://github.com/Stability-AI/stablediffusion.git
3
getpalette
def getpalette(self, rawmode="RGB"): self.load() try: mode = self.im.getpalettemode() except ValueError: return None # no palette if rawmode is None: rawmode = mode return list(self.im.getpalette(mode, rawmode))
6be87277f71948bc7e4b945c46660cac3e5ce919
11
Image.py
91
Allow rawmode None to return the palette in the current mode
69,846
0
101
53
21
242,362
25
Pillow
9
src/PIL/Image.py
Python
9
{ "docstring": "\n Returns the image palette as a list.\n\n :param rawmode: The mode in which to return the palette. ``None`` will\n return the palette in its current mode.\n :returns: A list of color values [r, g, b, ...], or None if the\n image has no palette.\n ", ...
https://github.com/python-pillow/Pillow.git
1
test_get_mutable_invalid_value
def test_get_mutable_invalid_value(self, conf): option = 'keyhint.blacklist' obj = conf.get_mutable_obj(option) assert obj == [] obj.append(42) with pytest.raises(configexc.ValidationError): conf.update_mutables() obj = conf.get_mutable_obj(option) ...
8eecf3af83fc9a4e465744a83e86856fe1c6df10
10
test_config.py
101
config: Discard prior mutables before applying If we only clear existing mutables *after* applying, we get into an inconsistent state if there was an error in one of the config values: The improper value lingers around in self._mutables, and then gets returned when get_mutable_obj() (or update_mutables()) gets called...
117,490
0
91
58
15
321,036
24
qutebrowser
12
tests/unit/config/test_config.py
Python
9
{ "docstring": "Make sure invalid values aren't stored in mutables.", "language": "en", "n_whitespaces": 7, "n_words": 8, "vocab_size": 8 }
https://github.com/qutebrowser/qutebrowser.git
2
keras_model_summary
def keras_model_summary(name, data, step=None): summary_metadata = tf.compat.v1.SummaryMetadata() # Hard coding a plugin name. Please refer to go/tb-plugin-name-hardcode for # the rationale. summary_metadata.plugin_data.plugin_name = "graph_keras_model" # version number = 1 summary_metadata...
3613c3defc39c236fb1592c4f7ba1a9cc887343a
@keras_export("keras.callbacks.TensorBoard", v1=[])
14
callbacks.py
239
Remove pylint comments. PiperOrigin-RevId: 452353044
82,645
1
215
133
71
278,640
87
keras
31
keras/callbacks.py
Python
19
{ "docstring": "Writes a Keras model as JSON to as a Summary.\n\n Writing the Keras model configuration allows the TensorBoard graph plugin to\n render a conceptual graph, as opposed to graph of ops. In case the model\n fails to serialize as JSON, it ignores and returns False.\n\n Args:\n name: A nam...
https://github.com/keras-team/keras.git
10
_update_counters
def _update_counters(self, ti_status, session=None): tis_to_be_scheduled = [] refreshed_tis = [] TI = TaskInstance filter_for_tis = TI.filter_for_tis(list(ti_status.running.values())) if filter_for_tis is not None: refreshed_tis = session.query(TI).filter(fi...
6fc6edf6af7f676bfa54ff3a2e6e6d2edb938f2e
14
backfill_job.py
578
Make `airflow dags test` be able to execute Mapped Tasks (#21210) * Make `airflow dags test` be able to execute Mapped Tasks In order to do this there were two steps required: - The BackfillJob needs to know about mapped tasks, both to expand them, and in order to update it's TI tracking - The DebugExecutor ...
8,254
0
1,009
350
148
44,415
279
airflow
43
airflow/jobs/backfill_job.py
Python
47
{ "docstring": "\n Updates the counters per state of the tasks that were running. Can re-add\n to tasks to run in case required.\n\n :param ti_status: the internal status of the backfill job tasks\n ", "language": "en", "n_whitespaces": 59, "n_words": 30, "vocab_size": 23 }
https://github.com/apache/airflow.git
1
user_config_dir
def user_config_dir(self) -> str: return self._append_app_name_and_version(os.path.expanduser("~/Library/Preferences/"))
f3166e673fe8d40277b804d35d77dcdb760fc3b3
10
macos.py
40
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...
3,275
0
20
22
6
20,223
6
pipenv
7
pipenv/patched/notpip/_vendor/platformdirs/macos.py
Python
3
{ "docstring": ":return: config directory tied to the user, e.g. ``~/Library/Preferences/$appname/$version``", "language": "en", "n_whitespaces": 8, "n_words": 9, "vocab_size": 9 }
https://github.com/pypa/pipenv.git
6
future_sle_exists
def future_sle_exists(args, sl_entries=None): key = (args.voucher_type, args.voucher_no) if validate_future_sle_not_exists(args, key, sl_entries): return False elif get_cached_data(args, key): return True if not sl_entries: sl_entries = get_sle_entries_against_voucher(args) if not sl_entries: return ...
494bd9ef78313436f0424b918f200dab8fc7c20b
13
stock_controller.py
190
style: format code with black
13,986
0
31
123
41
65,680
52
erpnext
25
erpnext/controllers/stock_controller.py
Python
32
{ "docstring": "\n\t\tselect item_code, warehouse, count(name) as total_row\n\t\tfrom `tabStock Ledger Entry` force index (item_warehouse)\n\t\twhere\n\t\t\t({})\n\t\t\tand timestamp(posting_date, posting_time)\n\t\t\t\t>= timestamp(%(posting_date)s, %(posting_time)s)\n\t\t\tand voucher_no != %(voucher_no)s\n\t\t\tan...
https://github.com/frappe/erpnext.git
8
normalize_histogram_results
def normalize_histogram_results(fields, histogram_params, results): # zerofill and rename the columns while making sure to adjust for precision bucket_maps = {field: {} for field in fields} # Only one row in metrics result data = results["data"][0] for field in fields: histogram_column...
6307cf52c4c7f185f9023c6279e565dd7812c202
15
metrics_performance.py
249
feat(mep): Adding histogram support to metrics enhanced perf (#34462) - This uses the metrics dataset to supply histogram data in the same format discover expects - Outlier is currently based on p25 and p75, may change to using tags later
18,673
0
269
157
69
90,529
107
sentry
25
src/sentry/snuba/metrics_performance.py
Python
19
{ "docstring": "\n Normalizes the histogram results by renaming the columns to key and bin\n and make sure to zerofill any missing values.\n\n :param [str] fields: The list of fields for which you want to generate the\n histograms for.\n :param str key_column: The column of the key name.\n :para...
https://github.com/getsentry/sentry.git
5
inplace_swap_column
def inplace_swap_column(X, m, n): if m < 0: m += X.shape[1] if n < 0: n += X.shape[1] if isinstance(X, sp.csc_matrix): inplace_swap_row_csr(X, m, n) elif isinstance(X, sp.csr_matrix): inplace_swap_row_csc(X, m, n) else: _raise_typeerror(X)
a2c4d8b1f4471f52a4fcf1026f495e637a472568
10
sparsefuncs.py
120
DOC Ensures that inplace_swap_column passes numpydoc validation (#23476) Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> Co-authored-by: harshit5674 <harshit@Harshits-MacBook-Air.local>
76,051
0
85
78
20
260,053
32
scikit-learn
12
sklearn/utils/sparsefuncs.py
Python
11
{ "docstring": "\n Swap two columns of a CSC/CSR matrix in-place.\n\n Parameters\n ----------\n X : sparse matrix of shape (n_samples, n_features)\n Matrix whose two columns are to be swapped. It should be of\n CSR or CSC format.\n\n m : int\n Index of the column of X to be swapped...
https://github.com/scikit-learn/scikit-learn.git
1
map
def map(self, mapper): mapped = self._values.map(mapper) return Index(mapped, name=self.name)
521259299f7829da667ba39302ec77acedde9e5e
9
category.py
47
DOC: Improve doc summaries in series.rst (#45237)
39,400
0
30
29
9
163,192
9
pandas
7
pandas/core/indexes/category.py
Python
3
{ "docstring": "\n Map values using input an input mapping or function.\n\n Maps the values (their categories, not the codes) of the index to new\n categories. If the mapping correspondence is one-to-one the result is a\n :class:`~pandas.CategoricalIndex` which has the same order property ...
https://github.com/pandas-dev/pandas.git
4
get_original_fromname_by_regex
def get_original_fromname_by_regex(config_string, fromname): c = parse_config(config_string) for control in c: item = c[control].get('regex', {}) expression = control for key in item: expression = expression.replace(key, item[key]) pattern = re.compile(expression...
583b3cb3b03a36a30b3ce9fe96eb4fb28548a070
13
label_config.py
123
fix: DEV-1462: Fix changing label config for repeater tag (#2725) * fix: DEV-1462: Fix changing label config for repeater tag with created annotations
42,571
0
113
77
26
178,013
37
label-studio
16
label_studio/core/label_config.py
Python
12
{ "docstring": "\n Get from_name from config on from_name key from data after applying regex search or original fromname\n ", "language": "en", "n_whitespaces": 23, "n_words": 16, "vocab_size": 14 }
https://github.com/heartexlabs/label-studio.git