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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | image | def image(self) -> ImageTk.PhotoImage:
assert self._preview_image_tk is not None
return self._preview_image_tk
| 2e8ef5e3c8f2df0f1cca9b342baa8aaa6f620650 | 7 | image.py | 35 | GUI - Preview updates
- Training preview. Embed preview pop-out window
- Bugfix - convert/extract previews | 21,352 | 0 | 32 | 21 | 10 | 101,978 | 11 | faceswap | 5 | lib/gui/utils/image.py | Python | 4 | {
"docstring": ":class:`PIL.ImageTk.PhotoImage` The preview image for displaying in a tkinter canvas ",
"language": "en",
"n_whitespaces": 10,
"n_words": 10,
"vocab_size": 10
} | https://github.com/deepfakes/faceswap.git | |
11 | _join_by_index | def _join_by_index(self, other_modin_frames, how, sort, ignore_index):
if how == "outer":
raise NotImplementedError("outer join is not supported in HDK engine")
lhs = self._maybe_materialize_rowid()
reset_index_names = False
for rhs in other_modin_frames:
... | e5b1888cd932909e49194d58035da34b210b91c4 | 16 | dataframe.py | 498 | FEAT-#4946: Replace OmniSci with HDK (#4947)
Co-authored-by: Iaroslav Igoshev <Poolliver868@mail.ru>
Signed-off-by: Andrey Pavlenko <andrey.a.pavlenko@gmail.com> | 36,066 | 0 | 912 | 315 | 113 | 154,556 | 171 | modin | 44 | modin/experimental/core/execution/native/implementations/hdk_on_native/dataframe/dataframe.py | Python | 57 | {
"docstring": "\n Perform equi-join operation for multiple frames by index columns.\n\n Parameters\n ----------\n other_modin_frames : list of HdkOnNativeDataframe\n Frames to join with.\n how : str\n A type of join.\n sort : bool\n Sort the ... | https://github.com/modin-project/modin.git | |
9 | _get_suitable_downloader | def _get_suitable_downloader(info_dict, params={}):
# if (info_dict.get('start_time') or info_dict.get('end_time')) and not info_dict.get('requested_formats') and FFmpegFD.can_download(info_dict):
# return FFmpegFD
external_downloader = params.get('external_downloader')
if external_downloader... | 92d73ef3936ed6de9770f613fddf2260731becc9 | 10 | __init__.py | 200 | [niconico] Implement heartbeat for download | 22,343 | 0 | 153 | 105 | 40 | 106,288 | 69 | youtube-dl | 15 | youtube_dl/downloader/__init__.py | Python | 14 | {
"docstring": "Get the downloader class that can handle the info dict.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | https://github.com/ytdl-org/youtube-dl.git | |
1 | test_having_condition_with_preventing_aggregate_metrics_only | def test_having_condition_with_preventing_aggregate_metrics_only(self):
response = self.do_request(
{
"field": ["transaction", "project", "p50(transaction.duration)"],
"query": "event.type:transaction p50(transaction.duration):<50",
"dataset":... | d3b8c9dd7bef6bccb5e70d2ccf3cda8463444a34 | 12 | test_organization_events_mep.py | 109 | chore(discover): Cleanup events tests (#36797)
- Delete the deprecated eventsv2 tests
- Move MEP tests to its own file | 18,970 | 0 | 168 | 59 | 28 | 93,148 | 28 | sentry | 8 | tests/snuba/api/endpoints/test_organization_events_mep.py | Python | 12 | {
"docstring": "same as the previous test, but with the dataset on explicit metrics\n which should throw a 400 error instead",
"language": "en",
"n_whitespaces": 25,
"n_words": 19,
"vocab_size": 18
} | https://github.com/getsentry/sentry.git | |
4 | test_unknown_sequence_followed_by_known_sequence | def test_unknown_sequence_followed_by_known_sequence(parser, chunk_size):
unknown_sequence = "\x1b[?"
known_sequence = "\x1b[8~" # key = 'end'
sequence = unknown_sequence + known_sequence
events = []
parser.more_data = lambda: True
for chunk in chunks(sequence, chunk_size):
event... | 3f0955cbe5405bdb3d1dda756ee3a1e000695dff | 12 | test_xterm_parser.py | 156 | fix tests | 44,934 | 0 | 117 | 92 | 36 | 185,184 | 51 | textual | 18 | tests/test_xterm_parser.py | Python | 15 | {
"docstring": "When we feed the parser an unknown sequence followed by a known\n sequence. The characters in the unknown sequence are delivered as keys,\n and the known escape sequence that follows is delivered as expected.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 34,
"vocab_size": 26
... | https://github.com/Textualize/textual.git | |
1 | test_block_tag | def test_block_tag(self):
user = self.get_staff()
page = create_page('Test', 'col_two.html', 'en', published=True)
ex1 = Example1(
date_field=datetime.date(2012, 1, 1),
**FOUR_CHARS
)
ex1.save()
# This template does not render anything as content ... | b8750ebc0ebaa52ec51945f1d4824a80d806f479 | 14 | test_toolbar.py | 672 | ci: sync isort line length (#7353) | 17,440 | 0 | 921 | 379 | 97 | 82,563 | 254 | django-cms | 31 | cms/tests/test_toolbar.py | Python | 114 | {
"docstring": "{% extends \"base.html\" %}\n{% load cms_tags %}\n\n{% block content %}\n{% render_model_block instance as rendered_model %}\n {{ instance }}\n <h1>{{ instance.char_1 }} - {{ instance.char_2 }}</h1>\n {{ instance.date_field|date:\"Y\" }}\n {% if instance.char_1 %}\n <a href=\"{% url 'd... | https://github.com/django-cms/django-cms.git | |
1 | test_connect_more_newlines | def test_connect_more_newlines(tctx):
server = Placeholder(Server)
playbook = Playbook(http.HttpLayer(tctx, HTTPMode.regular))
nl = Placeholder(layer.NextLayer)
assert (
playbook
>> DataReceived(tctx.client, b"CONNECT example.com:80 HTTP/1.1\r\n\r\n\r\n")
<< http.HttpConnec... | b3587b52b25077f68116b9852b041d33e7fc6601 | 17 | test_http.py | 212 | make it black! | 73,851 | 0 | 128 | 118 | 33 | 251,848 | 44 | mitmproxy | 22 | test/mitmproxy/proxy/layers/http/test_http.py | Python | 16 | {
"docstring": "Ignore superfluous \\r\\n in CONNECT request, https://github.com/mitmproxy/mitmproxy/issues/4870",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/mitmproxy/mitmproxy.git | |
1 | set_as_test_mirror | def set_as_test_mirror(self, primary_settings_dict):
self.connection.settings_dict["NAME"] = primary_settings_dict["NAME"]
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 9 | creation.py | 38 | Refs #33476 -- Reformatted code with Black. | 50,921 | 0 | 20 | 21 | 6 | 204,842 | 6 | django | 5 | django/db/backends/base/creation.py | Python | 2 | {
"docstring": "\n Set this database up to be used in testing as a mirror of a primary\n database whose settings are given.\n ",
"language": "en",
"n_whitespaces": 42,
"n_words": 20,
"vocab_size": 18
} | https://github.com/django/django.git | |
1 | themed_values | def themed_values(self) -> dict[str, Any] | None:
return getattr(self, '__themed_values__', None)
| 528d85e642340ef30ec91f30b65c7c43370f648d | 8 | has_props.py | 39 | Normalize built-in types and remove `Unknown` (#12252)
* Use lower case names for built-in types
Also incidentally apply TypeAlias marker.
* Drop `Unknown` in favour of consistent usage of `Any`
* Enable lazy annotations in conftest.py | 53,247 | 0 | 25 | 24 | 11 | 212,474 | 11 | bokeh | 6 | bokeh/core/has_props.py | Python | 11 | {
"docstring": " Get any theme-provided overrides.\n\n Results are returned as a dict from property name to value, or\n ``None`` if no theme overrides any values for this instance.\n\n Returns:\n dict or None\n\n ",
"language": "en",
"n_whitespaces": 70,
"n_words": 30,
"... | https://github.com/bokeh/bokeh.git | |
4 | is_cgi | def is_cgi(self):
collapsed_path = _url_collapse_path(self.path)
dir_sep = collapsed_path.find('/', 1)
while dir_sep > 0 and not collapsed_path[:dir_sep] in self.cgi_directories:
dir_sep = collapsed_path.find('/', dir_sep+1)
if dir_sep > 0:
head, tail = c... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 12 | server.py | 153 | add python 3.10.4 for windows | 54,974 | 0 | 132 | 85 | 30 | 217,867 | 43 | XX-Net | 11 | python3.10.4/Lib/http/server.py | Python | 10 | {
"docstring": "Test whether self.path corresponds to a CGI script.\n\n Returns True and updates the cgi_info attribute to the tuple\n (dir, rest) if self.path requires running a CGI script.\n Returns False otherwise.\n\n If any exception is raised, the caller should assume that\n s... | https://github.com/XX-net/XX-Net.git | |
7 | to_euler | def to_euler(self, seq):
extrinsic = _check_sequence(seq)
i, j, k = seq.lower()
i = _elementary_axis_index(i)
j = _elementary_axis_index(j)
k = _elementary_axis_index(k)
if not extrinsic:
i, k = k, i
# check if sequence is symmetric
... | 69baa8d90fe079b799a80c8c06735c3ebd4bfe33 | 13 | quaternion.py | 404 | added reference | 49,727 | 0 | 521 | 258 | 104 | 200,603 | 197 | sympy | 26 | sympy/algebras/quaternion.py | Python | 33 | {
"docstring": "Returns Euler angles representing same in the sequence given by\n `seq`. This implements the method described in [1]_.\n\n Parameters\n ==========\n\n seq : string of length 3\n Represents the sequence of rotations.\n For intrinsic rotations, seq but b... | https://github.com/sympy/sympy.git | |
2 | quantiles | def quantiles(self) -> np.ndarray:
if not self.count:
return np.ndarray([], dtype=np.float32)
else:
return np.nanpercentile(
self.items[: self.count], [0, 10, 50, 90, 100]
).tolist()
| 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | 15 | window_stat.py | 97 | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 33,098 | 0 | 90 | 63 | 20 | 144,040 | 21 | ray | 10 | rllib/utils/metrics/window_stat.py | Python | 8 | {
"docstring": "Returns ndarray with 0, 10, 50, 90, and 100 percentiles.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/ray-project/ray.git | |
1 | test_copy_with_credential | def test_copy_with_credential(self):
expression = "col1, col2"
op = DatabricksCopyIntoOperator(
file_location=COPY_FILE_LOCATION,
file_format='CSV',
table_name='test',
task_id=TASK_ID,
expression_list=expression,
credential={'AZURE_... | 401419432082d222b823e4f2a66f21e5cc3ab28d | 12 | test_databricks_sql.py | 102 | Add new options to DatabricksCopyIntoOperator (#22076)
This includes:
* `encryption` - to specify encryption options for a given location
* `credential` - to specify authentication options for a given location
* `validate` - to control validation of schema & data | 8,743 | 0 | 145 | 56 | 21 | 45,916 | 23 | airflow | 15 | tests/providers/databricks/operators/test_databricks_sql.py | Python | 17 | {
"docstring": "COPY INTO test\nFROM (SELECT {expression} FROM '{COPY_FILE_LOCATION}' WITH (CREDENTIAL (AZURE_SAS_TOKEN = 'abc') ))\nFILEFORMAT = CSV\n",
"language": "en",
"n_whitespaces": 14,
"n_words": 17,
"vocab_size": 15
} | https://github.com/apache/airflow.git | |
1 | test_press_button | async def test_press_button(hass):
helper = await setup_test_component(hass, create_switch_with_setup_button)
# Helper will be for the primary entity, which is the outlet. Make a helper for the button.
button = Helper(
hass,
"button.testdevice_setup",
helper.pairing,
he... | 58b8c30221a6f6e5acbbe98b7e3298b03fb741f5 | 11 | test_button.py | 129 | Improve homekit_controller tests (#65266) | 110,119 | 0 | 172 | 78 | 42 | 311,454 | 50 | core | 19 | tests/components/homekit_controller/test_button.py | Python | 21 | {
"docstring": "Test a switch service that has a button characteristic is correctly handled.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 11
} | https://github.com/home-assistant/core.git | |
1 | describe_an_sg_2 | def describe_an_sg_2(ec2_client_stub, security_group):
ec2_client_stub.add_response(
"describe_security_groups",
expected_params={"GroupIds": [security_group["GroupId"]]},
service_response={"SecurityGroups": [security_group]},
)
| 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | 13 | stubs.py | 66 | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 29,476 | 0 | 40 | 38 | 10 | 131,108 | 10 | ray | 6 | python/ray/tests/aws/utils/stubs.py | Python | 6 | {
"docstring": "Same as last function, different input param format.\n\n A call with this input parameter format is made when sg.ip_permissions is\n accessed in aws/config.py.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 23,
"vocab_size": 21
} | https://github.com/ray-project/ray.git | |
1 | wait_for_style_to_equal | def wait_for_style_to_equal(self, selector, style, val, timeout=None):
return self._wait_for(
method=style_to_equal,
args=(selector, style, val),
timeout=timeout,
msg=f"style val => {style} {val} not found within {timeout or self._wait_timeout}s",
... | c3c84b9ecf16bcc61ed80ec39d511af92fe07f2c | 12 | browser.py | 81 | f-strings everywhere! fffff | 7,360 | 0 | 90 | 45 | 24 | 40,221 | 25 | dash | 12 | dash/testing/browser.py | Python | 7 | {
"docstring": "Explicit wait until the element's style has expected `value` timeout\n if not set, equals to the fixture's `wait_timeout` shortcut to\n `WebDriverWait` with customized `style_to_equal` condition.",
"language": "en",
"n_whitespaces": 38,
"n_words": 25,
"vocab_size": 23
} | https://github.com/plotly/dash.git | |
17 | get_rendered_html_form | def get_rendered_html_form(self, data, view, method, request):
# See issue #2089 for refactoring this.
serializer = getattr(data, 'serializer', None)
if serializer and not getattr(serializer, 'many', False):
instance = getattr(serializer, 'instance', None)
if isi... | c10f2266222c434485889b08cc1463acdb8fa169 | 17 | renderers.py | 503 | Refactor: Replace try/except with contextlib.suppress() (#8676) | 9,563 | 0 | 902 | 308 | 111 | 48,672 | 215 | django-rest-framework | 30 | rest_framework/renderers.py | Python | 45 | {
"docstring": "\n Return a string representing a rendered HTML form, possibly bound to\n either the input or output data.\n\n In the absence of the View having an associated form then return None.\n ",
"language": "en",
"n_whitespaces": 59,
"n_words": 30,
"vocab_size": 27
} | https://github.com/encode/django-rest-framework.git | |
5 | get_expected_metric_variable_names | def get_expected_metric_variable_names(var_names, name_suffix=""):
if tf.__internal__.tf2.enabled() or tf.executing_eagerly():
# In V1 eager mode and V2 variable names are not made unique.
return [n + ":0" for n in var_names]
# In V1 graph mode variable names are made unique using a suffix.... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 10 | test_utils.py | 85 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81,647 | 0 | 77 | 49 | 34 | 276,385 | 51 | keras | 9 | keras/testing_infra/test_utils.py | Python | 4 | {
"docstring": "Returns expected metric variable names given names and prefix/suffix.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 8
} | https://github.com/keras-team/keras.git | |
1 | test_incorrect_lookup_parameters | def test_incorrect_lookup_parameters(self):
changelist_url = reverse("admin:admin_views_thing_changelist")
response = self.client.get(changelist_url, {"notarealfield": "5"})
self.assertRedirects(response, "%s?e=1" % changelist_url)
# Spanning relationships through a nonexistent... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | tests.py | 207 | Refs #33476 -- Reformatted code with Black. | 52,112 | 0 | 160 | 116 | 35 | 207,811 | 58 | django | 8 | tests/admin_views/tests.py | Python | 12 | {
"docstring": "Ensure incorrect lookup parameters are handled gracefully.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/django/django.git | |
2 | load_items | def load_items(self) -> Dict[str, List[int]]:
faces: Dict[str, List[int]] = {}
for face in cast(List[Tuple[str, "PNGHeaderDict"]], self.file_list_sorted):
src = face[1]["source"]
faces.setdefault(src["source_filename"], []).append(src["face_index"])
logger.trace(... | c79175cbde5600bebd65785f3821fc74b3a80cbe | 13 | media.py | 138 | Alignments Tool updates
- Copy info back to alignments file from faces | 21,163 | 0 | 85 | 87 | 25 | 101,759 | 27 | faceswap | 16 | tools/alignments/media.py | Python | 14 | {
"docstring": " Load the face names into dictionary.\n\n Returns\n -------\n dict\n The source filename as key with list of face indices for the frame as value\n ",
"language": "en",
"n_whitespaces": 64,
"n_words": 24,
"vocab_size": 21
} | https://github.com/deepfakes/faceswap.git | |
4 | row_join | def row_join(self, other):
# A null matrix can always be stacked (see #10770)
if self.cols == 0 and self.rows != other.rows:
return self._new(other.rows, 0, []).row_join(other)
if self.rows != other.rows:
raise ShapeError(
"The matrices have inc... | 9b2351534f8f02bcd5b9691d5e7a06150685beca | 12 | common.py | 118 | Make ShapeError more readable | 49,553 | 0 | 133 | 74 | 39 | 200,153 | 45 | sympy | 9 | sympy/matrices/common.py | Python | 8 | {
"docstring": "Concatenates two matrices along self's last and rhs's first column\n\n Examples\n ========\n\n >>> from sympy import zeros, ones\n >>> M = zeros(3)\n >>> V = ones(3, 1)\n >>> M.row_join(V)\n Matrix([\n [0, 0, 0, 1],\n [0, 0, 0, 1],\n ... | https://github.com/sympy/sympy.git | |
1 | test_permission_with_proxy_content_type_created | def test_permission_with_proxy_content_type_created(self):
opts = UserProxy._meta
codename = get_permission_codename("add", opts)
self.assertTrue(
Permission.objects.filter(
content_type__model=opts.model_name,
content_type__app_label=opts.app... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 13 | test_management.py | 83 | Refs #33476 -- Reformatted code with Black. | 49,919 | 0 | 118 | 51 | 15 | 201,335 | 16 | django | 16 | tests/auth_tests/test_management.py | Python | 10 | {
"docstring": "\n A proxy model's permissions use its own content type rather than the\n content type of the concrete model.\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 18,
"vocab_size": 15
} | https://github.com/django/django.git | |
2 | get_bboxes_list | def get_bboxes_list(end2end_result, structure_master_result):
# end2end
end2end_xyxy_list = []
end2end_xywh_list = []
for end2end_item in end2end_result:
src_bbox = end2end_item['bbox']
end2end_xyxy_list.append(src_bbox)
xywh_bbox = xyxy2xywh(src_bbox)
end2end_xywh_l... | ddaa2c2552e19635cd6cdf38619f1f176c358f89 | 10 | table_master_match.py | 159 | add SLANet | 4,761 | 0 | 143 | 93 | 37 | 24,519 | 64 | PaddleOCR | 18 | ppstructure/table/table_master_match.py | Python | 16 | {
"docstring": "\n This function is use to convert end2end results and structure master results to\n List of xyxy bbox format and List of xywh bbox format\n :param end2end_result: bbox's format is xyxy\n :param structure_master_result: bbox's format is xywh\n :return: 4 kind list of bbox ()\n ",
"... | https://github.com/PaddlePaddle/PaddleOCR.git | |
6 | make_modal | def make_modal(self):
if not self._is_window_created('tried Window.make_modal'):
return
if running_mac() and ENABLE_MAC_MODAL_DISABLE_PATCH:
return
# if modal windows have been disabled globally
if not DEFAULT_MODAL_WINDOWS_ENABLED:
return
... | ef3746cb06a9ee6bc93bc3c163ba961fd1b9c413 | 11 | PySimpleGUI.py | 116 | set_options - new parm disable_modal_windows provides ability to disable modal setting for all windows including popups | 53,310 | 0 | 164 | 63 | 32 | 212,647 | 38 | PySimpleGUI | 13 | PySimpleGUI.py | Python | 13 | {
"docstring": "\n Makes a window into a \"Modal Window\"\n This means user will not be able to interact with other windows until this one is closed\n\n NOTE - Sorry Mac users - you can't have modal windows.... lobby your tkinter Mac devs\n ",
"language": "en",
"n_whitespaces": 69,
"... | https://github.com/PySimpleGUI/PySimpleGUI.git | |
1 | set_interpret_parameters | def set_interpret_parameters(self, segments=8):
self.interpretation_segments = segments
return self
| 9e4541822770333ab5191bc01aa3edc9738f17ff | 7 | components.py | 29 | Blocks-Components
- move audio component | 43,002 | 0 | 29 | 17 | 8 | 179,703 | 8 | gradio | 4 | gradio/components.py | Python | 3 | {
"docstring": "\n Calculates interpretation score of audio subsections by splitting the audio into subsections, then using a \"leave one out\" method to calculate the score of each subsection by removing the subsection and measuring the delta of the output value.\n Parameters:\n segments (int): ... | https://github.com/gradio-app/gradio.git | |
3 | with_csv_dialect | def with_csv_dialect(name, **kwargs) -> Iterator[None]:
import csv
_BUILTIN_DIALECTS = {"excel", "excel-tab", "unix"}
if name in _BUILTIN_DIALECTS:
raise ValueError("Cannot override builtin dialect.")
csv.register_dialect(name, **kwargs)
try:
yield
finally:
csv.un... | f538568afc2c76c2d738d32e3544cf9fe6742960 | @contextmanager | 10 | contexts.py | 103 | TYP: misc return type annotations (#47558) | 40,048 | 1 | 69 | 55 | 27 | 167,592 | 28 | pandas | 10 | pandas/_testing/contexts.py | Python | 28 | {
"docstring": "\n Context manager to temporarily register a CSV dialect for parsing CSV.\n\n Parameters\n ----------\n name : str\n The name of the dialect.\n kwargs : mapping\n The parameters for the dialect.\n\n Raises\n ------\n ValueError : the name of the dialect conflicts ... | https://github.com/pandas-dev/pandas.git |
6 | adjust_legend_subtitles | def adjust_legend_subtitles(legend):
# Legend title not in rcParams until 3.0
font_size = plt.rcParams.get("legend.title_fontsize", None)
hpackers = legend.findobj(mpl.offsetbox.VPacker)[0].get_children()
for hpack in hpackers:
draw_area, text_area = hpack.get_children()
handles = d... | 6460a21555ba6557e1f6f06f4d677d9c19148169 | 15 | utils.py | 165 | Workaround for matplotlib rc_context issue (#2925)
* Workaround for matplotlib rc_context issue
Fixes #2914
* Add some additional comments about this workaround | 7,477 | 0 | 138 | 100 | 34 | 42,077 | 46 | seaborn | 22 | seaborn/utils.py | Python | 11 | {
"docstring": "\n Make invisible-handle \"subtitles\" entries look more like titles.\n\n Note: This function is not part of the public API and may be changed or removed.\n\n ",
"language": "en",
"n_whitespaces": 34,
"n_words": 24,
"vocab_size": 24
} | https://github.com/mwaskom/seaborn.git | |
2 | _prepare_skip_target_masks | def _prepare_skip_target_masks(self):
return [l is None for l in self.loss_functions]
| 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 8 | training_v1.py | 30 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,930 | 0 | 24 | 18 | 10 | 272,002 | 10 | keras | 4 | keras/engine/training_v1.py | Python | 2 | {
"docstring": "Boolean mask for whether the target in the output list should be skipped.\n\n If the loss function corresponding to a model output is None, then this\n output will be skipped during total loss calculation and feed targets\n preparation.\n\n Returns:\n A boolean lis... | https://github.com/keras-team/keras.git | |
4 | update_terminal | def update_terminal():
poetry_hash = sha256sum("poetry.lock")
completed_process = subprocess.run("git pull", shell=True, check=False) # nosec
if completed_process.returncode != 0:
return completed_process.returncode
new_poetry_hash = sha256sum("poetry.lock")
if poetry_hash == new_po... | 82747072c511beb1b2672846ae2ee4aec53eb562 | 10 | terminal_helper.py | 163 | Terminal Wide Rich (#1161)
* My idea for how we handle Rich moving forward
* remove independent consoles
* FIxed pylint issues
* add a few vars
* Switched print to console
* More transitions
* Changed more prints
* Replaced all prints
* Fixing tabulate
* Finished replace tabulate
* Finish... | 83,890 | 0 | 150 | 94 | 46 | 281,593 | 70 | OpenBBTerminal | 12 | gamestonk_terminal/terminal_helper.py | Python | 18 | {
"docstring": "Updates the terminal by running git pull in the directory. Runs poetry install if needed",
"language": "en",
"n_whitespaces": 15,
"n_words": 15,
"vocab_size": 14
} | https://github.com/OpenBB-finance/OpenBBTerminal.git | |
1 | test_serialize_post_error_mock | def test_serialize_post_error_mock(self, stream_mock):
obj = QPoint()
stream_mock.__lshift__.side_effect = lambda _other: self._set_status(
stream_mock, QDataStream.Status.ReadCorruptData)
with pytest.raises(OSError, match="The data stream has read corrupt "
... | 0877fb0d78635692e481c8bde224fac5ad0dd430 | 12 | test_qtutils.py | 108 | Run scripts/dev/rewrite_enums.py | 117,730 | 0 | 125 | 64 | 26 | 321,448 | 27 | qutebrowser | 19 | tests/unit/utils/test_qtutils.py | Python | 8 | {
"docstring": "Test serialize_stream with an error while serializing.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/qutebrowser/qutebrowser.git | |
5 | _validate_fill_value | def _validate_fill_value(self, value):
dtype = self.dtype
if isinstance(dtype, np.dtype) and dtype.kind not in ["m", "M"]:
try:
return np_can_hold_element(dtype, value)
except ValueError as err:
# re-raise as TypeError for consistency
... | 3977d7335f0792c012013e3b459a7950dfd31a7d | 11 | base.py | 109 | REF: consolidate _validate_fill_logic in np_can_hold_element (#45216) | 39,405 | 0 | 154 | 67 | 33 | 163,219 | 41 | pandas | 13 | pandas/core/indexes/base.py | Python | 10 | {
"docstring": "\n Check if the value can be inserted into our array without casting,\n and convert it to an appropriate native type if necessary.\n\n Raises\n ------\n TypeError\n If the value cannot be inserted into an array of this dtype.\n ",
"language": "en"... | https://github.com/pandas-dev/pandas.git | |
7 | __anext__ | async def __anext__(self):
if isinstance(self.iterator, Iterator):
if not self._iterate_sync_in_thread: | 5a0830cfb6bfa33dcffb38681f86efe5f6f0f97c | 9 | helper.py | 39 | refactor: avoid run in executor creating threads (#5518) | 2,797 | 0 | 38 | 108 | 8 | 14,004 | 9 | jina | 6 | jina/serve/stream/helper.py | Python | 27 | {
"docstring": "\n An `Iterator` indicates \"blocking\" code, which might block all tasks in the event loop.\n Hence we iterate in the default executor provided by asyncio.\n ",
"language": "en",
"n_whitespaces": 58,
"n_words": 24,
"vocab_size": 22
} | https://github.com/jina-ai/jina.git | |
6 | __new__ | def __new__(cls, name, bases, ns, total=True):
# Create new typed dict class object.
# This method is called directly when TypedDict is subclassed,
# or via _typeddict_new when TypedDict is instantiated. This way
# TypedDict supports all three syntaxes described in its do... | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | """A simple typed name space. At runtimeequivalent to a plain dict.
TypedDict creates a dictionary type that expects all ofto a plain dictinstances to have a certain set ofwith eachassociated with a value of a consistent type. This expectation
is not checked at runtime but is only enforced by type chec... | 12 | typing_extensions.py | 495 | 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,614 | 9 | 565 | 221 | 116 | 20,914 | 162 | pipenv | 80 | pipenv/patched/notpip/_vendor/typing_extensions.py | Python | 27 | {
"docstring": "A simple typed name space. At runtime it is equivalent to a plain dict.\n\n TypedDict creates a dictionary type that expects all of its\n instances to have a certain set of keys, with each key\n associated with a value of a consistent type. This expectation\n is not checked... | https://github.com/pypa/pipenv.git |
7 | _set_dependencies | def _set_dependencies(self, analysis, path):
for toc in (analysis.binaries, analysis.datas):
for i, tpl in enumerate(toc):
if not tpl[1] in self._dependencies:
logger.debug("Adding dependency %s located in %s", tpl[1], path)
self._depe... | 04984a040c2396127f234518f783cbed088408bb | 18 | api.py | 365 | building: move filename processing of EXTENSION entries to analysis stage
Move filename processing of EXTENSION TOC entries (i.e., converting
the module name to file path and adding the suffix) from the
build stage (i.e., `assemble` in `PKG`, `COLLECT`, and `BUNDLE`)
into analysis stage.
This ensures that during the ... | 77,548 | 0 | 807 | 237 | 129 | 263,997 | 216 | pyinstaller | 24 | PyInstaller/building/api.py | Python | 22 | {
"docstring": "\n Synchronize the Analysis result with the needed dependencies.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 7
} | https://github.com/pyinstaller/pyinstaller.git | |
3 | break_up_by_substrings | def _break_up_by_substrings(self):
new_submobjects = []
curr_index = 0
for tex_string in self.tex_strings:
sub_tex_mob = SingleStringMathTex(
tex_string,
tex_environment=self.tex_environment,
tex_template=self.tex_template,
... | 902e7eb4f0147b5882a613b67467e38a1d47f01e | 17 | tex_mobject.py | 230 | Hide more private methods from the docs. (#2468)
* hide privs from text_mobject.py
* hide privs from tex_mobject.py
* hide privs from code_mobject.py
* hide privs from svg_mobject.py
* remove SVGPath and utils from __init__.py
* don't import string_to_numbers
* hide privs from geometry.py
* hide p... | 46,082 | 0 | 394 | 142 | 61 | 189,478 | 88 | manim | 23 | manim/mobject/svg/tex_mobject.py | Python | 23 | {
"docstring": "\n Reorganize existing submobjects one layer\n deeper based on the structure of tex_strings (as a list\n of tex_strings)\n ",
"language": "en",
"n_whitespaces": 46,
"n_words": 17,
"vocab_size": 16
} | https://github.com/ManimCommunity/manim.git | |
2 | delimitedList | def delimitedList(expr, delim=",", combine=False):
dlName = _ustr(expr) + " [" + _ustr(delim) + " " + _ustr(expr) + "]..."
if combine:
return Combine(expr + ZeroOrMore(delim + expr)).setName(dlName)
else:
return (expr + ZeroOrMore(Suppress(delim) + expr)).setName(dlName)
| f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 17 | pyparsing.py | 132 | upd; format | 13,253 | 0 | 60 | 77 | 21 | 63,322 | 34 | transferlearning | 10 | .venv/lib/python3.8/site-packages/pip/_vendor/pyparsing.py | Python | 6 | {
"docstring": "Helper to define a delimited list of expressions - the delimiter\n defaults to ','. By default, the list elements and delimiters can\n have intervening whitespace, and comments, but this can be\n overridden by passing ``combine=True`` in the constructor. If\n ``combine`` is set to ``True``... | https://github.com/jindongwang/transferlearning.git | |
2 | _gcd_import | def _gcd_import(name, package=None, level=0):
_sanity_check(name, package, level)
if level > 0:
name = _resolve_name(name, package, level)
return _find_and_load(name, _gcd_import)
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 10 | _bootstrap.py | 66 | add python 3.10.4 for windows | 55,125 | 0 | 38 | 44 | 17 | 218,095 | 19 | XX-Net | 7 | python3.10.4/Lib/importlib/_bootstrap.py | Python | 5 | {
"docstring": "Import and return the module based on its name, the package the call is\n being made from, and the level adjustment.\n\n This function represents the greatest common denominator of functionality\n between import_module and __import__. This includes setting __package__ if\n the loader did n... | https://github.com/XX-net/XX-Net.git | |
1 | get_transactions | def get_transactions(self):
df = self.__transactions[
[
"Date",
"Type",
"Ticker",
"Side",
"Price",
"Quantity",
"Fees",
"Investment",
"Currency",
... | 8e9e6bd57f4bc5d57ccedfacccda6342d5881266 | 11 | portfolio_model.py | 157 | Incorporate portfolio class into SDK (#3401)
* create functions to interact with portfolio
* fix some docstrings
* view docstrings
* make portfolio loading available in sdk
* reorder some methods
* fix bug
* update controller
* update website
* remove import
* change input name
* regenera... | 85,861 | 0 | 299 | 87 | 28 | 286,538 | 33 | OpenBBTerminal | 13 | openbb_terminal/portfolio/portfolio_model.py | Python | 22 | {
"docstring": "Get formatted transactions\n\n Returns\n -------\n pd.DataFrame: formatted transactions\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 8,
"vocab_size": 6
} | https://github.com/OpenBB-finance/OpenBBTerminal.git | |
1 | get_global_params | def get_global_params():
GlobalParams = namedtuple('GlobalParams', [
'drop_connect_rate', 'width_coefficient', 'depth_coefficient',
'depth_divisor', 'image_size'
])
global_params = GlobalParams(
drop_connect_rate=0.3,
width_coefficient=1.2... | 6e607a0fa1cefbf0388dac86c84debf4781cec48 | 10 | rec_efficientb3_pren.py | 83 | [Feature] Add PREN Scene Text Recognition Model(Accepted in CVPR2021) (#5563)
* [Feature] add PREN scene text recognition model
* [Patch] Optimize yml File
* [Patch] Save Label/Pred Preprocess Time Cost
* [BugFix] Modify Shape Conversion to Fit for Inference Model Exportion
* [Patch] ?
* [Patch] ?
* ... | 4,585 | 0 | 134 | 55 | 20 | 23,379 | 22 | PaddleOCR | 9 | ppocr/modeling/backbones/rec_efficientb3_pren.py | Python | 12 | {
"docstring": "\n The fllowing are efficientnetb3's arch superparams, but to fit for scene \n text recognition task, the resolution(image_size) here is changed \n from 300 to 64.\n ",
"language": "en",
"n_whitespaces": 54,
"n_words": 23,
"vocab_size": 22
} | https://github.com/PaddlePaddle/PaddleOCR.git | |
1 | get_extra_addanother_params | def get_extra_addanother_params(self, request, params):
return {}
#
# Request handlers
#
| 8b1a462a6070cb6054af8bb59589c9a2e785afc2 | 6 | object_views.py | 25 | #10094 changes from code review | 78,139 | 0 | 34 | 13 | 9 | 265,553 | 11 | netbox | 4 | netbox/netbox/views/generic/object_views.py | Python | 2 | {
"docstring": "\n Return a dictionary of extra parameters to use on the Add Another button.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 13
} | https://github.com/netbox-community/netbox.git | |
2 | _ensure_html_header | def _ensure_html_header(response):
# type: (Response) -> None
content_type = response.headers.get("Content-Type", "")
if not content_type.lower().startswith("text/html"):
raise _NotHTML(content_type, response.request.method)
| f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 11 | collector.py | 76 | upd; format | 12,262 | 0 | 36 | 42 | 17 | 60,723 | 17 | transferlearning | 10 | .venv/lib/python3.8/site-packages/pip/_internal/index/collector.py | Python | 4 | {
"docstring": "Check the Content-Type header to ensure the response contains HTML.\n\n Raises `_NotHTML` if the content type is not text/html.\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 19,
"vocab_size": 17
} | https://github.com/jindongwang/transferlearning.git | |
1 | test_get_next_txn | def test_get_next_txn(self) -> None:
# Prefill table with 7 rows written by 'master'
self._insert_rows("master", 7)
id_gen = self._create_id_generator()
self.assertEqual(id_gen.get_positions(), {"master": 7})
self.assertEqual(id_gen.get_current_token_for_writer("maste... | 9d21ecf7ceab55bc19c4457b8b07401b0b1623a7 | 10 | test_id_generators.py | 94 | Add type hints to tests files. (#12256) | 71,924 | 0 | 101 | 98 | 41 | 247,791 | 45 | synapse | 8 | tests/storage/test_id_generators.py | Python | 10 | {
"docstring": "Test that the `get_next_txn` function works correctly.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/matrix-org/synapse.git | |
11 | sanitize_index | def sanitize_index(ind):
from dask.array.utils import asanyarray_safe
if ind is None:
return None
elif isinstance(ind, slice):
return slice(
_sanitize_index_element(ind.start),
_sanitize_index_element(ind.stop),
_sanitize_index_element(ind.step),
... | cccb9d8d8e33a891396b1275c2448c352ef40c27 | 17 | slicing.py | 371 | absolufy-imports - No relative - PEP8 (#8796)
Conversation in https://github.com/dask/distributed/issues/5889 | 36,528 | 0 | 356 | 235 | 72 | 156,063 | 103 | dask | 38 | dask/array/slicing.py | Python | 35 | {
"docstring": "Sanitize the elements for indexing along one axis\n\n >>> sanitize_index([2, 3, 5])\n array([2, 3, 5])\n >>> sanitize_index([True, False, True, False])\n array([0, 2])\n >>> sanitize_index(np.array([1, 2, 3]))\n array([1, 2, 3])\n >>> sanitize_index(np.array([False, True, True]))\... | https://github.com/dask/dask.git | |
2 | test_process_messages_cardinality_limited | def test_process_messages_cardinality_limited(caplog, settings, monkeypatch) -> None:
settings.SENTRY_METRICS_INDEXER_DEBUG_LOG_SAMPLE_RATE = 1.0
| c48fda09e252018a4d2b831bb84e1c68a739c085 | 7 | test_multiprocess_steps.py | 28 | feat(metrics): Add cardinality limiter to indexer [sns-1651] (#38428)
Reopen of https://github.com/getsentry/sentry/pull/38302 to avoid
notification spam
See #38257 and
https://www.notion.so/sentry/Metrics-Dimensionality-Limiting-df010a6a6d4e467ca3c5c19230db862b#4966fb9c07fc4394b720ad161c99a096.
This is just th... | 18,024 | 0 | 15 | 170 | 9 | 85,651 | 9 | sentry | 5 | tests/sentry/sentry_metrics/test_multiprocess_steps.py | Python | 28 | {
"docstring": "\n Test that the message processor correctly calls the cardinality limiter.\n ",
"language": "en",
"n_whitespaces": 17,
"n_words": 10,
"vocab_size": 9
} | https://github.com/getsentry/sentry.git | |
2 | dag_id | def dag_id(self) -> str:
if self.dag:
return self.dag.dag_id
return "_in_memory_dag_"
| 34154803ac73d62d3e969e480405df3073032622 | 9 | taskmixin.py | 38 | Show tasks in grid view based on topological sort. (#22741)
This takes the existing topological sort that existed on a DAG and moves
it down to TaskGroup.
In order to do this (and not have duplicated sort) the existing sort on
DAG is re-implemented on top of the new method.
This also surfaced a tiny bug in des... | 9,007 | 0 | 42 | 21 | 9 | 46,825 | 10 | airflow | 4 | airflow/models/taskmixin.py | Python | 5 | {
"docstring": "Returns dag id if it has one or an adhoc/meaningless ID",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | https://github.com/apache/airflow.git | |
1 | compress | def compress(summary, epsilon):
# TODO(b/184863356): remove the numpy escape hatch here.
return tf.numpy_function(
lambda s: _compress_summary_numpy(s, epsilon), [summary], tf.float32
)
| 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 10 | discretization.py | 49 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81,077 | 0 | 39 | 31 | 20 | 272,922 | 20 | keras | 8 | keras/layers/preprocessing/discretization.py | Python | 4 | {
"docstring": "Compress a summary to within `epsilon` accuracy.\n\n The compression step is needed to keep the summary sizes small after merging,\n and also used to return the final target boundaries. It finds the new bins\n based on interpolating cumulative weight percentages from the large summary.\n T... | https://github.com/keras-team/keras.git | |
2 | Head | def Head(num_classes=1000, name=None):
if name is None:
name = str(backend.get_uid("head"))
| 2d1086447a25d281f9428832d046c473d80ad761 | 13 | convnext.py | 49 | Corrected preprocess_input docstring in regnet.py and convnext.py | 79,999 | 0 | 23 | 32 | 9 | 269,278 | 10 | keras | 6 | keras/applications/convnext.py | Python | 5 | {
"docstring": "Implementation of classification head of RegNet.\n\n Args:\n num_classes: number of classes for Dense layer\n name: name prefix\n\n Returns:\n Classification head function.\n ",
"language": "en",
"n_whitespaces": 33,
"n_words": 21,
"vocab_size": 18
} | https://github.com/keras-team/keras.git | |
1 | require_tpu | def require_tpu(test_case):
return unittest.skipUnless(is_tpu_available(), "test requires TPU")(test_case)
| e5c17f36a8b5bf8b9478d416c4a80841a353fb19 | 10 | testing.py | 37 | Clean up tests + fix import (#330) | 121,064 | 0 | 13 | 20 | 7 | 337,462 | 7 | accelerate | 5 | src/accelerate/test_utils/testing.py | Python | 2 | {
"docstring": "\n Decorator marking a test that requires TPUs. These tests are skipped when there are no TPUs available.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 17,
"vocab_size": 16
} | https://github.com/huggingface/accelerate.git | |
6 | _identify_infrequent | def _identify_infrequent(self, category_count, n_samples, col_idx):
if isinstance(self.min_frequency, numbers.Integral):
infrequent_mask = category_count < self.min_frequency
elif isinstance(self.min_frequency, numbers.Real):
min_frequency_abs = n_samples * self.min_freq... | 7f0006c8aad1a09621ad19c3db19c3ff0555a183 | 13 | _encoders.py | 227 | 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... | 75,639 | 0 | 237 | 146 | 56 | 259,201 | 78 | scikit-learn | 26 | sklearn/preprocessing/_encoders.py | Python | 16 | {
"docstring": "Compute the infrequent indices.\n\n Parameters\n ----------\n category_count : ndarray of shape (n_cardinality,)\n Category counts.\n\n n_samples : int\n Number of samples.\n\n col_idx : int\n Index of the current category. Only used ... | https://github.com/scikit-learn/scikit-learn.git | |
1 | test_port_editor | def test_port_editor(self, mock_unity3d):
_ = Unity3DEnv(port=None)
args, kwargs = mock_unity3d.call_args
mock_unity3d.assert_called_once()
self.assertEqual(5004, kwargs.get("base_port"))
| 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | 10 | test_unity3d_env.py | 70 | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 32,988 | 0 | 48 | 41 | 12 | 143,428 | 13 | ray | 12 | rllib/env/wrappers/tests/test_unity3d_env.py | Python | 5 | {
"docstring": "Test if the environment uses the editor port\n when no environment file is provided",
"language": "en",
"n_whitespaces": 20,
"n_words": 14,
"vocab_size": 12
} | https://github.com/ray-project/ray.git | |
5 | get_create_field_function | def get_create_field_function(self, type):
create_field_function = getattr(self, "create_%s_field" % type, None)
if create_field_function:
return create_field_function
else:
import inspect
method_list = [
f[0]
for f in... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 15 | forms.py | 149 | Reformat with black | 15,920 | 0 | 254 | 89 | 48 | 72,986 | 55 | wagtail | 15 | wagtail/contrib/forms/forms.py | Python | 17 | {
"docstring": "\n Takes string of field type and returns a Django Form Field Instance.\n Assumes form field creation functions are in the format:\n 'create_fieldtype_field'\n ",
"language": "en",
"n_whitespaces": 51,
"n_words": 22,
"vocab_size": 21
} | https://github.com/wagtail/wagtail.git | |
1 | image_entity | def image_entity(props):
return DOM.create_element(
"embed",
{
"embedtype": "image",
"format": props.get("format"),
"id": props.get("id"),
"alt": props.get("alt"),
},
)
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 12 | contentstate.py | 91 | Reformat with black | 16,356 | 0 | 90 | 48 | 16 | 75,104 | 16 | wagtail | 5 | wagtail/images/rich_text/contentstate.py | Python | 10 | {
"docstring": "\n Helper to construct elements of the form\n <embed alt=\"Right-aligned image\" embedtype=\"image\" format=\"right\" id=\"1\"/>\n when converting from contentstate data\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 18,
"vocab_size": 18
} | https://github.com/wagtail/wagtail.git | |
5 | _linab | def _linab(arg, symbol):
arg = factor_terms(arg.expand())
ind, dep = arg.as_independent(symbol)
if arg.is_Mul and dep.is_Add:
a, b, x = _linab(dep, symbol)
return ind*a, ind*b, x
if not arg.is_Add:
b = 0
a, x = ind, dep
else:
b = ind
a, x = separa... | 59d22b6bb7287613d598611027f640d068ca5748 | 13 | bivariate.py | 188 | Moved imports to higher level | 47,919 | 0 | 136 | 118 | 33 | 196,419 | 56 | sympy | 16 | sympy/solvers/bivariate.py | Python | 16 | {
"docstring": "Return ``a, b, X`` assuming ``arg`` can be written as ``a*X + b``\n where ``X`` is a symbol-dependent factor and ``a`` and ``b`` are\n independent of ``symbol``.\n\n Examples\n ========\n\n >>> from sympy.solvers.bivariate import _linab\n >>> from sympy.abc import x, y\n >>> from ... | https://github.com/sympy/sympy.git | |
6 | __getattr__ | def __getattr__(self, name):
attr = None
if name.startswith('do_'):
module = name.replace('do_', '')
if module_loader.find_plugin(module):
setattr(self, name, lambda arg, module=module: self.default(module + ' ' + arg))
attr = object.__ge... | 34f8168afc1d7047c47adec3730c591a58f4f899 | 17 | console.py | 240 | ansible-console fixes (#78064)
* list collection task actions too
* dynamically add execute/help functions when module is found
* handle redirection and short names | 78,939 | 0 | 217 | 138 | 38 | 267,520 | 60 | ansible | 16 | lib/ansible/cli/console.py | Python | 15 | {
"docstring": " handle not found to populate dynamically a module function if module matching name exists ",
"language": "en",
"n_whitespaces": 15,
"n_words": 14,
"vocab_size": 13
} | https://github.com/ansible/ansible.git | |
1 | test_blacklisted_ip_specific | def test_blacklisted_ip_specific(self) -> None:
self.lookups["example.com"] = [(IPv4Address, "192.168.1.1")]
channel = self.make_request(
"GET", "preview_url?url=http://example.com", shorthand=False
)
# No requests made.
self.assertEqual(len(self.reactor.tc... | 32c828d0f760492711a98b11376e229d795fd1b3 | 11 | test_url_preview.py | 139 | Add type hints to `tests/rest`. (#12208)
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> | 71,729 | 0 | 175 | 81 | 36 | 247,541 | 38 | synapse | 13 | tests/rest/media/v1/test_url_preview.py | Python | 17 | {
"docstring": "\n Blacklisted IP addresses, found via DNS, are not spidered.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | https://github.com/matrix-org/synapse.git | |
1 | verbatim | def verbatim(parser, token):
nodelist = parser.parse(("endverbatim",))
parser.delete_first_token()
return VerbatimNode(nodelist.render(Context()))
@register.tag | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | @register.tag | 11 | defaulttags.py | 70 | Refs #33476 -- Reformatted code with Black. | 51,443 | 1 | 21 | 36 | 10 | 206,254 | 10 | django | 11 | django/template/defaulttags.py | Python | 4 | {
"docstring": "\n Stop the template engine from rendering the contents of this block tag.\n\n Usage::\n\n {% verbatim %}\n {% don't process this %}\n {% endverbatim %}\n\n You can also designate a specific closing tag block (allowing the\n unrendered use of ``{% endverbatim %}``)... | https://github.com/django/django.git |
3 | test_large_batch_mixed_efficiency | def test_large_batch_mixed_efficiency(self):
with override_settings(DEBUG=True):
connection.queries_log.clear()
TwoFields.objects.bulk_create(
[
TwoFields(id=i if i % 2 == 0 else None, f1=i, f2=i + 1)
for i in range(100000,... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 16 | tests.py | 120 | Refs #33476 -- Reformatted code with Black. | 50,024 | 0 | 155 | 76 | 28 | 201,942 | 29 | django | 18 | tests/bulk_create/tests.py | Python | 10 | {
"docstring": "\n Test inserting a large batch with objects having primary key set\n mixed together with objects without PK set.\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 18,
"vocab_size": 16
} | https://github.com/django/django.git | |
1 | test_subdag_pools | def test_subdag_pools(self):
dag = DAG('parent', default_args=default_args)
subdag = DAG('parent.child', default_args=default_args)
session = airflow.settings.Session()
pool_1 = airflow.models.Pool(pool='test_pool_1', slots=1)
pool_10 = airflow.models.Pool(pool='test_po... | 49e336ae0302b386a2f47269a6d13988382d975f | 11 | test_subdag_operator.py | 287 | Replace usage of `DummyOperator` with `EmptyOperator` (#22974)
* Replace usage of `DummyOperator` with `EmptyOperator` | 9,191 | 0 | 183 | 169 | 38 | 47,650 | 53 | airflow | 25 | tests/operators/test_subdag_operator.py | Python | 17 | {
"docstring": "\n Subdags and subdag tasks can't both have a pool with 1 slot\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 12
} | https://github.com/apache/airflow.git | |
6 | test_loss_of_perfect_prediction | def test_loss_of_perfect_prediction(loss, sample_weight):
if not loss.is_multiclass:
# Use small values such that exp(value) is not nan.
raw_prediction = np.array([-10, -0.1, 0, 0.1, 3, 10])
# If link is identity, we must respect the interval of y_pred:
if isinstance(loss.link, ... | 75a94f518f7bd7d0bf581ffb67d9f961e3c4efbc | @pytest.mark.parametrize("loss", LOSS_INSTANCES, ids=loss_instance_name)
@pytest.mark.parametrize("sample_weight", [None, "range"]) | 15 | test_loss.py | 446 | ENH migrate GLMs / TweedieRegressor to linear loss (#22548)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> | 75,769 | 1 | 438 | 266 | 110 | 259,435 | 159 | scikit-learn | 43 | sklearn/_loss/tests/test_loss.py | Python | 32 | {
"docstring": "Test value of perfect predictions.\n\n Loss of y_pred = y_true plus constant_to_optimal_zero should sums up to\n zero.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 17,
"vocab_size": 16
} | https://github.com/scikit-learn/scikit-learn.git |
2 | set_cmap | def set_cmap(cmap):
cmap = colormaps[cmap]
rc('image', cmap=cmap.name)
im = gci()
if im is not None:
im.set_cmap(cmap)
@_copy_docstring_and_deprecators(matplotlib.image.imread) | a17f4f3bd63e3ca3754f96d7db4ce5197720589b | @_copy_docstring_and_deprecators(matplotlib.image.imread) | 9 | pyplot.py | 82 | MNT: convert tests and internal usage way from using mpl.cm.get_cmap | 23,562 | 1 | 38 | 39 | 15 | 109,381 | 17 | matplotlib | 11 | lib/matplotlib/pyplot.py | Python | 6 | {
"docstring": "\n Set the default colormap, and applies it to the current image if any.\n\n Parameters\n ----------\n cmap : `~matplotlib.colors.Colormap` or str\n A colormap instance or the name of a registered colormap.\n\n See Also\n --------\n colormaps\n matplotlib.cm.register_cma... | https://github.com/matplotlib/matplotlib.git |
1 | test_ddp_sharded_strategy_fit_ckpt_path | def test_ddp_sharded_strategy_fit_ckpt_path(tmpdir):
model = BoringModel()
trainer = Trainer(strategy="ddp_sharded_spawn", num_processes=2, fast_dev_run=True)
trainer.fit(model)
checkpoint_path = os.path.join(tmpdir, "model.pt")
trainer.save_checkpoint(checkpoint_path)
model = BoringMode... | 650c710efacd633fa283955145342bb64063c883 | @pytest.mark.skip(reason="Not a critical test, skip till drone CI performance improves.") # todo
@pytest.mark.skip(reason="Currently unsupported restarting training on different number of devices.")
@RunIf(min_gpus=2, skip_windows=True, fairscale=True) | 10 | test_sharded_strategy.py | 197 | Rename training plugin test files & names to strategy (#11303) | 69,606 | 1 | 75 | 82 | 40 | 241,581 | 50 | lightning | 24 | tests/strategies/test_sharded_strategy.py | Python | 9 | {
"docstring": "Test to ensure that resuming from checkpoint works.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/Lightning-AI/lightning.git |
4 | get_provider | def get_provider(moduleOrReq):
if isinstance(moduleOrReq, Requirement):
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
try:
module = sys.modules[moduleOrReq]
except KeyError:
__import__(moduleOrReq)
module = sys.modules[moduleOrReq]
loader = get... | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 13 | __init__.py | 124 | upd; format | 13,146 | 0 | 73 | 77 | 22 | 63,100 | 27 | transferlearning | 17 | .venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py | Python | 10 | {
"docstring": "Return an IResourceProvider for the named module or requirement",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/jindongwang/transferlearning.git | |
2 | get_template_env | def get_template_env(self) -> jinja2.Environment:
dag = self.get_dag()
if dag:
return dag.get_template_env()
return SandboxedEnvironment(cache_size=0)
| ff3bbc3db24f9f3f4f88033d48859fb08fc3237b | 9 | base.py | 57 | Implement enough interface for MappedOperator to be baggable (#20945) | 8,186 | 0 | 52 | 33 | 12 | 44,167 | 13 | airflow | 8 | airflow/models/base.py | Python | 6 | {
"docstring": "Fetch a Jinja template environment from the DAG or instantiate empty environment if no DAG.",
"language": "en",
"n_whitespaces": 14,
"n_words": 15,
"vocab_size": 14
} | https://github.com/apache/airflow.git | |
2 | load | def load(self):
try:
return signing.loads(
self.session_key,
serializer=self.serializer,
# This doesn't handle non-default expiry dates, see #19201
max_age=self.get_session_cookie_age(),
salt="django.contrib.ses... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 12 | signed_cookies.py | 81 | Refs #33476 -- Reformatted code with Black. | 50,693 | 0 | 197 | 47 | 36 | 204,312 | 39 | django | 11 | django/contrib/sessions/backends/signed_cookies.py | Python | 11 | {
"docstring": "\n Load the data from the key itself instead of fetching from some\n external data store. Opposite of _get_session_key(), raise BadSignature\n if signature fails.\n ",
"language": "en",
"n_whitespaces": 52,
"n_words": 23,
"vocab_size": 19
} | https://github.com/django/django.git | |
5 | mlsd | def mlsd(self, path="", facts=[]):
if facts:
self.sendcmd("OPTS MLST " + ";".join(facts) + ";")
if path:
cmd = "MLSD %s" % path
else:
cmd = "MLSD"
lines = []
self.retrlines(cmd, lines.append)
for line in lines:
fact... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 14 | ftplib.py | 222 | add python 3.10.4 for windows | 54,776 | 0 | 214 | 129 | 45 | 217,427 | 58 | XX-Net | 23 | python3.10.4/Lib/ftplib.py | Python | 16 | {
"docstring": "List a directory in a standardized format by using MLSD\n command (RFC-3659). If path is omitted the current directory\n is assumed. \"facts\" is a list of strings representing the type\n of information desired (e.g. [\"type\", \"size\", \"perm\"]).\n\n Return a generator o... | https://github.com/XX-net/XX-Net.git | |
1 | callbacks | def callbacks(self, callbacks_class) -> "TrainerConfig":
self.callbacks_class = callbacks_class
return self
| 2eaa54bd763ae0e63158ae0d939633c804394b78 | 7 | trainer_config.py | 31 | [RLlib] POC: Config objects instead of dicts (PPO only). (#23491) | 34,012 | 0 | 31 | 17 | 10 | 147,576 | 10 | ray | 3 | rllib/agents/trainer_config.py | Python | 14 | {
"docstring": "Sets the callbacks configuration.\n\n Args:\n callbacks_class: Callbacks class, whose methods will be run during\n various phases of training and environment sample collection.\n See the `DefaultCallbacks` class and\n `examples/custom_metr... | https://github.com/ray-project/ray.git | |
2 | print_help | def print_help(self):
source_txt = CRYPTO_SOURCES.get(self.source, "?") if self.source != "" else ""
help_text = f
console.print(text=help_text, menu="Crypto - Due Diligence")
| a6f7e111e68346aeab315985b3704c2710693b38 | 10 | dd_controller.py | 86 | Bounty Hunter mood: 11 bugs fixed (#1853)
* fix #1850
* fix #1831
* add extra check to Reddit API keys
* ignore warning message to update praw api
* improve OpenBB links
* fix quick performance only on stocks class because I'm James bitch
* fix quick performance only on stocks class because I'm James... | 84,832 | 0 | 48 | 42 | 18 | 284,582 | 20 | OpenBBTerminal | 12 | openbb_terminal/cryptocurrency/due_diligence/dd_controller.py | Python | 56 | {
"docstring": "Print help[cmds]\n load load a specific cryptocurrency for analysis\n\n[param]Coin: [/param]{self.coin}\n[param]Source: [/param]{source_txt}\n\n[src]CoinGecko[/src]\n info basic information about loaded coin\n market market stats about loaded coin\n ath ... | https://github.com/OpenBB-finance/OpenBBTerminal.git | |
1 | __call__ | def __call__(self, hidden_states):
# layer norm should always be calculated in float32
variance = jnp.power(hidden_states.astype("f4"), 2).mean(axis=-1, keepdims=True)
hidden_states = hidden_states / jnp.sqrt(variance + self.eps)
return self.weight * hidden_states
# Copied fr... | a72f1c9f5b907f96cbb7de3bbb02a1d431d34071 | 13 | modeling_flax_longt5.py | 91 | Add `LongT5` model (#16792)
* Initial commit
* Make some fixes
* Make PT model full forward pass
* Drop TF & Flax implementation, fix copies etc
* Add Flax model and update some corresponding stuff
* Drop some TF things
* Update config and flax local attn
* Add encoder_attention_type to config
... | 5,713 | 0 | 68 | 55 | 30 | 31,263 | 34 | transformers | 13 | src/transformers/models/longt5/modeling_flax_longt5.py | Python | 4 | {
"docstring": "\n Construct a layernorm module in the LongT5 style; No bias and no subtraction of mean.\n ",
"language": "en",
"n_whitespaces": 30,
"n_words": 15,
"vocab_size": 15
} | https://github.com/huggingface/transformers.git | |
11 | partitionwise_graph | def partitionwise_graph(func, layer_name, *args, **kwargs):
pairs = []
numblocks = {}
for arg in args:
if isinstance(arg, _Frame):
pairs.extend([arg._name, "i"])
numblocks[arg._name] = (arg.npartitions,)
elif isinstance(arg, Scalar):
pairs.extend([arg... | 2a9d34aff0a38be5fc8bfcdec38e5c4a7bafcf0e | 20 | core.py | 437 | Move DataFrame ACA aggregations to HLG (#8468) | 36,437 | 0 | 449 | 264 | 67 | 155,618 | 107 | dask | 22 | dask/dataframe/core.py | Python | 34 | {
"docstring": "\n Apply a function partition-wise across arguments to create layer of a graph\n\n This applies a function, ``func``, in an embarrassingly parallel fashion\n across partitions/chunks in the provided arguments. It handles Dataframes,\n Arrays, and scalars smoothly, and relies on the ``bloc... | https://github.com/dask/dask.git | |
4 | cancel | def cancel(self, msg=None):
self._log_traceback = False
if self.done():
return False
if self._fut_waiter is not None:
if self._fut_waiter.cancel(msg=msg):
# Leave self._fut_waiter; it may be a Task that
# catches and ignores the ca... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 10 | tasks.py | 98 | add python 3.10.4 for windows | 56,134 | 0 | 201 | 58 | 45 | 220,825 | 63 | XX-Net | 8 | python3.10.4/Lib/asyncio/tasks.py | Python | 10 | {
"docstring": "Request that this task cancel itself.\n\n This arranges for a CancelledError to be thrown into the\n wrapped coroutine on the next cycle through the event loop.\n The coroutine then has a chance to clean up or even deny\n the request using try/except/finally.\n\n Unl... | https://github.com/XX-net/XX-Net.git | |
2 | _dictionary | def _dictionary(self):
# type: () -> Dict[str, Any]
# NOTE: Dictionaries are not populated if not loaded. So, conditionals
# are not needed here.
retval = {}
for variant in OVERRIDE_ORDER:
retval.update(self._config[variant])
return retval
| f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 11 | configuration.py | 50 | upd; format | 12,237 | 0 | 100 | 28 | 28 | 60,671 | 34 | transferlearning | 7 | .venv/lib/python3.8/site-packages/pip/_internal/configuration.py | Python | 5 | {
"docstring": "A dictionary representing the loaded configuration.\n ",
"language": "en",
"n_whitespaces": 13,
"n_words": 6,
"vocab_size": 6
} | https://github.com/jindongwang/transferlearning.git | |
3 | _transpose_for_tf_conv | def _transpose_for_tf_conv(lhs, rhs, dimension_numbers):
# TODO(marcvanzee): Add tests for this ops for shape polymorphism.
lhs_perm, rhs_perm, _ = dimension_numbers
# TODO(marcvanzee): Consider merging tranposes if we want to optimize.
# For `lhs_perm` / `output_perm`, perm (0, 1, 2, 3) corresponds to "NCH... | 4e224bcfb99c3bd9b6a32b8ad7836d12517e788f | 10 | impl_no_xla.py | 192 | [jax2tf] Add support for common audio convolutions (1D variants, dilated depthwise, transpose with SAME padding).
PiperOrigin-RevId: 458266485 | 27,024 | 0 | 195 | 121 | 96 | 121,058 | 163 | jax | 12 | jax/experimental/jax2tf/impl_no_xla.py | Python | 11 | {
"docstring": "Tranposes lhs and rhs to respectively NHWC and HWIO so they can be passed to TF functions.",
"language": "en",
"n_whitespaces": 16,
"n_words": 17,
"vocab_size": 15
} | https://github.com/google/jax.git | |
3 | test_pprint_heap_allocated_type | def test_pprint_heap_allocated_type():
module_name = "xxlimited" if sys.version_info < (3, 10) else "xxlimited_35"
expected_output = (
"xxlimited.Null" if sys.version_info < (3, 11) else "xxlimited_35.Null"
)
xxlimited = pytest.importorskip(module_name)
output = pretty.pretty(xxlimited.... | d858213d4088237e1481038865bc52ccdd074053 | 10 | test_pretty.py | 100 | xxlimited_35 module now has the same name in repr in Py 3.11
See https://github.com/python/cpython/commit/a87c9b538fbfc42883417c4d5e69f1a5922690e3 | 52,497 | 0 | 62 | 59 | 24 | 208,740 | 34 | ipython | 11 | IPython/lib/tests/test_pretty.py | Python | 8 | {
"docstring": "\n Test that pprint works for heap allocated types.\n ",
"language": "en",
"n_whitespaces": 15,
"n_words": 8,
"vocab_size": 8
} | https://github.com/ipython/ipython.git | |
1 | test_delete_missing_version | def test_delete_missing_version(self) -> None:
e = self.get_failure(
self.handler.delete_version(self.local_user, "1"), SynapseError
)
res = e.value.code
self.assertEqual(res, 404)
| 652d1669c5a103b1c20478770c4aaf18849c09a3 | 11 | test_e2e_room_keys.py | 72 | Add missing type hints to tests.handlers. (#14680)
And do not allow untyped defs in tests.handlers. | 73,359 | 0 | 62 | 44 | 15 | 250,281 | 16 | synapse | 12 | tests/handlers/test_e2e_room_keys.py | Python | 7 | {
"docstring": "Check that we get a 404 on deleting nonexistent versions",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/matrix-org/synapse.git | |
10 | name | def name(self, pretty=False):
# type: (bool) -> str
name = (
self.os_release_attr("name")
or self.lsb_release_attr("distributor_id")
or self.distro_release_attr("name")
or self.uname_attr("name")
)
if pretty:
name = sel... | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | 15 | distro.py | 186 | 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,230 | 0 | 251 | 102 | 31 | 20,087 | 53 | pipenv | 8 | pipenv/patched/notpip/_vendor/distro.py | Python | 17 | {
"docstring": "\n Return the name of the OS distribution, as a string.\n\n For details, see :func:`distro.name`.\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 14,
"vocab_size": 13
} | https://github.com/pypa/pipenv.git | |
1 | test_extra_serialized_field_and_multiple_operator_links | def test_extra_serialized_field_and_multiple_operator_links(self, dag_maker):
test_date = timezone.DateTime(2019, 8, 1, tzinfo=timezone.utc)
with dag_maker(dag_id='simple_dag', start_date=test_date) as dag:
CustomOperator(task_id='simple_task', bash_command=["echo", "true"])
... | 0ebd6428e6b484790bfbbe1b8687ef4e6cae10e9 | 12 | test_dag_serialization.py | 430 | Switch XCom implementation to use run_id (#20975) | 8,435 | 0 | 494 | 246 | 98 | 44,997 | 148 | airflow | 33 | tests/serialization/test_dag_serialization.py | Python | 34 | {
"docstring": "\n Assert extra field exists & OperatorLinks defined in Plugins and inbuilt Operator Links.\n\n This tests also depends on GoogleLink() registered as a plugin\n in tests/plugins/test_plugin.py\n\n The function tests that if extra operator links are registered in plugin\n ... | https://github.com/apache/airflow.git | |
5 | get_mac_addr | def get_mac_addr(self):
if (
self.bulb.host_firmware_version
and AwesomeVersion(self.bulb.host_firmware_version) >= FIX_MAC_FW
):
octets = [int(octet, 16) for octet in self.mac_addr.split(":")]
octets[5] = (octets[5] + 1) % 256
return ... | a0974e0c7297537149985f93544dd6f8ed8cfded | 13 | light.py | 131 | Refactor LIFX discovery to prevent duplicate discovery response handling (#72213)
* Partially revert #70458 and allow duplicate LIFX discoveries
Signed-off-by: Avi Miller <me@dje.li>
* Only process one discovery at a time
* Revert all LIFX duplicate/inflight discovery checks
Also remember LIFX Switches and... | 112,213 | 0 | 116 | 78 | 28 | 313,595 | 33 | core | 12 | homeassistant/components/lifx/light.py | Python | 9 | {
"docstring": "Increment the last byte of the mac address by one for FW>3.70.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 11
} | https://github.com/home-assistant/core.git | |
2 | metrics_names | def metrics_names(self):
# This property includes all output names including `loss` and per-output
# losses for backward compatibility.
return [m.name for m in self.metrics]
| 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 8 | training.py | 32 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,791 | 0 | 52 | 18 | 22 | 271,550 | 24 | keras | 5 | keras/engine/training.py | Python | 2 | {
"docstring": "Returns the model's display labels for all outputs.\n\n Note: `metrics_names` are available only after a `keras.Model` has been\n trained/evaluated on actual data.\n\n Examples:\n\n >>> inputs = tf.keras.layers.Input(shape=(3,))\n >>> outputs = tf.keras.layers.Dense(... | https://github.com/keras-team/keras.git | |
5 | from_collections | def from_collections(cls, name, layer, dependencies=()):
if len(dependencies) == 1:
return cls._from_collection(name, layer, dependencies[0])
layers = {name: layer}
deps = {name: set()}
for collection in toolz.unique(dependencies, key=id):
if is_dask_coll... | dfdc4bbab43678927e30866f06df509483ac5d24 | 16 | highlevelgraph.py | 260 | Collections with HLG must always implement __dask_layers__ (#8548)
Without ``__dask_layers__``, ``HighLevelGraph.from_collections`` will produce a broken layer dependency graph and things will fall apart down the line. Given this, it seems likely that no users should have the use case in production, so it should be sa... | 36,421 | 0 | 324 | 165 | 44 | 155,542 | 56 | dask | 26 | dask/highlevelgraph.py | Python | 53 | {
"docstring": "Construct a HighLevelGraph from a new layer and a set of collections\n\n This constructs a HighLevelGraph in the common case where we have a single\n new layer and a set of old collections on which we want to depend.\n\n This pulls out the ``__dask_layers__()`` method of the colle... | https://github.com/dask/dask.git | |
1 | test_hf_classification_bin | def test_hf_classification_bin(self, mock_handler):
# create predictor
create_sql =
model_name = 'spam_classifier'
predict_sql =
self.hf_test_run(mock_handler, model_name, create_sql, predict_sql)
# one line prediction
predict_sql =
# use predictor... | cc6313a0f791ba42782082b1161b6a62578e45f4 | 12 | test_ml_handlers.py | 98 | fixed one line prediction for new ml handler api | 25,865 | 0 | 106 | 54 | 26 | 116,887 | 34 | mindsdb | 13 | tests/unit/test_ml_handlers.py | Python | 23 | {
"docstring": "\n CREATE PREDICTOR huggingface.spam_classifier\n predict PRED\n USING\n task='text-classification',\n model_name= \"mrm8488/bert-tiny-finetuned-sms-spam-detection\",\n input_column = 'text_spammy',\n labels=[... | https://github.com/mindsdb/mindsdb.git | |
5 | update_denormalized_fields | def update_denormalized_fields(sender, instance, created, raw, **kwargs):
# Skip for new objects or those being populated from raw data
if created or raw:
return
# Look up any denormalized fields referencing this model from the application registry
for model, field_name, mappings in regist... | e96620260a6c1b5cf8cff2112d40d061984a7b2c | 13 | denormalized.py | 180 | Closes #9903: Implement a mechanism for automatically updating denormalized fields | 78,111 | 0 | 223 | 104 | 79 | 265,476 | 105 | netbox | 24 | netbox/netbox/denormalized.py | Python | 13 | {
"docstring": "\n Check if the sender has denormalized fields registered, and update them as necessary.\n ",
"language": "en",
"n_whitespaces": 20,
"n_words": 13,
"vocab_size": 13
} | https://github.com/netbox-community/netbox.git | |
7 | aimport | def aimport(self, parameter_s="", stream=None):
modname = parameter_s
if not modname:
to_reload = sorted(self._reloader.modules.keys())
to_skip = sorted(self._reloader.skip_modules.keys())
if stream is None:
stream = sys.stdout
if ... | 8a66e854a87b5147d811bd3bc92c5c2a382633e1 | 17 | autoreload.py | 308 | Improve parsing for `%aimport` | 52,549 | 0 | 344 | 175 | 49 | 208,820 | 69 | ipython | 28 | IPython/extensions/autoreload.py | Python | 20 | {
"docstring": "%aimport => Import modules for automatic reloading.\n\n %aimport\n List modules to automatically import and not to import.\n\n %aimport foo\n Import module 'foo' and mark it to be autoreloaded for %autoreload 1\n\n %aimport foo, bar\n Import modules 'foo', 'ba... | https://github.com/ipython/ipython.git | |
5 | format_datetime | def format_datetime(dt, usegmt=False):
now = dt.timetuple()
if usegmt:
if dt.tzinfo is None or dt.tzinfo != datetime.timezone.utc:
raise ValueError("usegmt option requires a UTC datetime")
zone = 'GMT'
elif dt.tzinfo is None:
zone = '-0000'
else:
zone = d... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 12 | utils.py | 125 | add python 3.10.4 for windows | 57,131 | 0 | 97 | 72 | 31 | 223,881 | 40 | XX-Net | 13 | python3.10.4/Lib/email/utils.py | Python | 11 | {
"docstring": "Turn a datetime into a date string as specified in RFC 2822.\n\n If usegmt is True, dt must be an aware datetime with an offset of zero. In\n this case 'GMT' will be rendered instead of the normal +0000 required by\n RFC2822. This is to support HTTP headers involving date stamps.\n ",
... | https://github.com/XX-net/XX-Net.git | |
3 | get_controller_target_connections | def get_controller_target_connections(self) -> t.List[SshConnection]:
return list(itertools.chain.from_iterable([target.get_controller_target_connections() for
target in self.target_profiles if isinstance(target, SshTargetHostProfile)]))
| 3eb0485dd92c88cc92152d3656d94492db44b183 | 13 | provisioning.py | 70 | ansible-test - Use more native type hints. (#78435)
* ansible-test - Use more native type hints.
Simple search and replace to switch from comments to native type hints for return types of functions with no arguments.
* ansible-test - Use more native type hints.
Conversion of simple single-line function annota... | 79,309 | 0 | 77 | 44 | 13 | 268,035 | 13 | ansible | 13 | test/lib/ansible_test/_internal/provisioning.py | Python | 4 | {
"docstring": "Return SSH connection(s) for accessing all target hosts from the controller.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | https://github.com/ansible/ansible.git | |
8 | getAvailableActions | def getAvailableActions(self):
action = list()
for i in range(self.size):
for j in range(self.size):
if self.state[i][j] == 0:
if i > 0:
action.append(2)
if j > 0:
action.append(0... | f0af0c43340763724f139fa68aa1e5a9ffe458b4 | 15 | eight_puzzle.py | 161 | refactor: clean code
Signed-off-by: slowy07 <slowy.arfy@gmail.com> | 4,328 | 0 | 286 | 100 | 24 | 22,423 | 45 | Python | 10 | Eight_Puzzle_Solver/eight_puzzle.py | Python | 15 | {
"docstring": "\n Parameters: Current State\n Returns: Available Actions for Current State\n 0 - Left 1 - Right 2 - Top 3 - Bottom\n Restrictions: state is self.size x self.size Array\n ",
"language": "en",
"n_whitespaces": 73,
"n_words": 28,
"vocab_size": 22
} | https://github.com/geekcomputers/Python.git | |
4 | check_picklelib | def check_picklelib(cls, value):
try:
pickler = from_qualified_name(value)
except (ImportError, AttributeError) as exc:
raise ValueError(
f"Failed to import requested pickle library: {value!r}."
) from exc
if not hasattr(pickler, "dum... | 83002be7b3d6ec51edcb8252484e52d918c514c1 | 12 | serializers.py | 125 | Begin sketch of deployment/packager/manifest relationship | 11,574 | 0 | 224 | 65 | 41 | 56,867 | 60 | prefect | 10 | src/prefect/packaging/serializers.py | Python | 16 | {
"docstring": "\n Check that the given pickle library is importable and has dumps/loads methods.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 12
} | https://github.com/PrefectHQ/prefect.git | |
4 | dates | def dates(self, field_name, kind, order="ASC"):
if kind not in ("year", "month", "week", "day"):
raise ValueError("'kind' must be one of 'year', 'month', 'week', or 'day'.")
if order not in ("ASC", "DESC"):
raise ValueError("'order' must be either 'ASC' or 'DESC'.")
... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 22 | query.py | 197 | Refs #33476 -- Reformatted code with Black. | 51,213 | 0 | 229 | 113 | 58 | 205,782 | 70 | django | 19 | django/db/models/query.py | Python | 15 | {
"docstring": "\n Return a list of date objects representing all available dates for\n the given field_name, scoped to 'kind'.\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 17,
"vocab_size": 17
} | https://github.com/django/django.git | |
62 | commentArgs | def commentArgs():
# A ton of cases to consider, pylint: disable=too-many-branches,too-many-statements
# Inform the user about potential issues with the running version. e.g. unsupported
# version.
if python_version_str not in getSupportedPythonVersions():
# Do not disturb run of automatic... | a24d709ad2350c081a9a41cd76db72288b8ab014 | 20 | Options.py | 941 | UI: Added warning when following stdlib in accelerated mode
* That's not going to work at this time, so we should inform the
user to not use it. | 42,687 | 0 | 1,656 | 523 | 221 | 178,405 | 514 | Nuitka | 57 | nuitka/Options.py | Python | 136 | {
"docstring": "Comment on options, where we know something is not having the intended effect.\n\n :meta private:\n\n You did not specify to follow or include anything but main %s. Check options and \\\nmake sure that is intended.Detected static libpython to exist, consider '--static-libpython=yes' for better p... | https://github.com/Nuitka/Nuitka.git | |
1 | forward | def forward(self, c):
batch, cond_channels, cond_length = c.shape
c = self.input_conv(c)
c = c + self.residual_conv(c)
k = self.kernel_conv(c)
b = self.bias_conv(c)
kernels = k.contiguous().view(batch,
self.conv_layers,
... | 0caed984e39c07849a13662894f4cbdbe0a98091 | 10 | modules.py | 163 | The new vocoder Fre-GAN is now supported (#546)
* The new vocoder Fre-GAN is now supported
* Improved some fregan details | 38,950 | 0 | 389 | 107 | 27 | 161,257 | 39 | MockingBird | 21 | vocoder/fregan/modules.py | Python | 17 | {
"docstring": "\n Args:\n c (Tensor): the conditioning sequence (batch, cond_channels, cond_length)\n Returns:\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 10,
"vocab_size": 10
} | https://github.com/babysor/MockingBird.git | |
7 | _parse_codestream | def _parse_codestream(fp):
hdr = fp.read(2)
lsiz = struct.unpack(">H", hdr)[0]
siz = hdr + fp.read(lsiz - 2)
lsiz, rsiz, xsiz, ysiz, xosiz, yosiz, _, _, _, _, csiz = struct.unpack_from(
">HHIIIIIIIIH", siz
)
ssiz = [None] * csiz
xrsiz = [None] * csiz
yrsiz = [None] * csiz
... | ee85e387bab535e2339b9d3cd1ab87c61d23af15 | 12 | Jpeg2KImagePlugin.py | 311 | Remove redundant parentheses | 69,907 | 0 | 244 | 196 | 67 | 242,744 | 115 | Pillow | 23 | src/PIL/Jpeg2KImagePlugin.py | Python | 27 | {
"docstring": "Parse the JPEG 2000 codestream to extract the size and component\n count from the SIZ marker segment, returning a PIL (size, mode) tuple.",
"language": "en",
"n_whitespaces": 25,
"n_words": 23,
"vocab_size": 21
} | https://github.com/python-pillow/Pillow.git | |
1 | _get_postgis_func | def _get_postgis_func(self, func):
# Close out the connection. See #9437.
with self.connection.temporary_connection() as cursor:
cursor.execute("SELECT %s()" % func)
return cursor.fetchone()[0]
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | operations.py | 66 | Refs #33476 -- Reformatted code with Black. | 50,549 | 0 | 64 | 36 | 20 | 203,832 | 20 | django | 8 | django/contrib/gis/db/backends/postgis/operations.py | Python | 4 | {
"docstring": "\n Helper routine for calling PostGIS functions and returning their result.\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 10
} | https://github.com/django/django.git | |
5 | can_publish_subpage | def can_publish_subpage(self):
if not self.user.is_active:
return False
specific_class = self.page.specific_class
if specific_class is None or not specific_class.creatable_subpage_models():
return False
return self.user.is_superuser or ("publish" in self... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 9 | __init__.py | 86 | Reformat with black | 16,134 | 0 | 82 | 51 | 18 | 73,833 | 25 | wagtail | 9 | wagtail/core/models/__init__.py | Python | 7 | {
"docstring": "\n Niggly special case for creating and publishing a page in one go.\n Differs from can_publish in that we want to be able to publish subpages of root, but not\n to be able to publish root itself. (Also, can_publish_subpage returns false if the page\n does not allow subpage... | https://github.com/wagtail/wagtail.git | |
1 | binary_mask_dice_loss | def binary_mask_dice_loss(self, mask_preds, gt_masks):
mask_preds = mask_preds.flatten(1)
gt_masks = gt_masks.flatten(1).float()
numerator = 2 * torch.einsum('nc,mc->nm', mask_preds, gt_masks)
denominator = mask_preds.sum(-1)[:, None] + gt_masks.sum(-1)[None, :]
loss = 1... | cac356380d505bf15587f07c0529218cc36b9652 | 11 | match_cost.py | 146 | [Feature] Add Maskformer to mmdet (#7212)
* first commit
* add README
* move model description from config to readme
add description for binary_input
add description for dice loss
add a independent panoptic gt processing function
add a independent panoptic gt processing function
remove compatibili... | 70,203 | 0 | 86 | 92 | 28 | 244,031 | 37 | mmdetection | 13 | mmdet/core/bbox/match_costs/match_cost.py | Python | 7 | {
"docstring": "\n Args:\n mask_preds (Tensor): Mask prediction in shape (num_query, *).\n gt_masks (Tensor): Ground truth in shape (num_gt, *)\n store 0 or 1, 0 for negative class and 1 for\n positive class.\n\n Returns:\n Tensor: Dice cost... | https://github.com/open-mmlab/mmdetection.git | |
5 | _DropCommonSuffixes | def _DropCommonSuffixes(filename):
for suffix in ('test.cc', 'regtest.cc', 'unittest.cc',
'inl.h', 'impl.h', 'internal.h'):
if (filename.endswith(suffix) and len(filename) > len(suffix) and
filename[-len(suffix) - 1] in ('-', '_')):
return filename[:-len(suffix) - 1]
return os.... | cc4d0564756ca067516f71718a3d135996525909 | 15 | cpp_lint.py | 143 | Balanced joint maximum mean discrepancy for deep transfer learning | 12,140 | 0 | 64 | 84 | 25 | 60,412 | 30 | transferlearning | 8 | code/deep/BJMMD/caffe/scripts/cpp_lint.py | Python | 7 | {
"docstring": "Drops common suffixes like _test.cc or -inl.h from filename.\n\n For example:\n >>> _DropCommonSuffixes('foo/foo-inl.h')\n 'foo/foo'\n >>> _DropCommonSuffixes('foo/bar/foo.cc')\n 'foo/bar/foo'\n >>> _DropCommonSuffixes('foo/foo_internal.h')\n 'foo/foo'\n >>> _DropCommonSuffixes('... | https://github.com/jindongwang/transferlearning.git | |
2 | _text_words | def _text_words(self, length, truncate):
words = self._wrapped.split()
if len(words) > length:
words = words[:length]
return self.add_truncation_text(" ".join(words), truncate)
return " ".join(words)
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 12 | text.py | 92 | Refs #33476 -- Reformatted code with Black. | 51,669 | 0 | 71 | 55 | 18 | 206,737 | 21 | django | 10 | django/utils/text.py | Python | 6 | {
"docstring": "\n Truncate a string after a certain number of words.\n\n Strip newlines in the string.\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 14,
"vocab_size": 13
} | https://github.com/django/django.git | |
1 | ulid | def ulid() -> str:
ulid_bytes = int(time.time() * 1000).to_bytes(6, byteorder="big") + int(
getrandbits(80)
).to_bytes(10, byteorder="big")
# This is base32 crockford encoding with the loop unrolled for performance
#
# This code is adapted from:
# https://github.com/ahawker/ulid/bl... | 2a9f043039dc60fc25bc14bab724419bedf746bb | 36 | ulid.py | 856 | Use ULID short format for context ids (#71119) | 98,556 | 0 | 484 | 614 | 99 | 299,641 | 262 | core | 9 | homeassistant/util/ulid.py | Python | 49 | {
"docstring": "Generate a ULID.\n\n This ulid should not be used for cryptographically secure\n operations.\n\n 01AN4Z07BY 79KA1307SR9X4MV3\n |----------| |----------------|\n Timestamp Randomness\n 48bits 80bits\n\n This string can be loaded directly with https... | https://github.com/home-assistant/core.git | |
2 | _train_with_recompute | def _train_with_recompute(n_steps):
img_dim, n_channels, batch_size = 256, 1, 4
x, y = _get_dummy_data(img_dim, n_channels, batch_size)
# This model is the same model as _get_big_cnn_model but split into 3 parts.
models = _get_split_cnn_model(
img_dim, n_channels, num_partitions=3, blocks_p... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | @tf_test_utils.with_eager_op_as_function | 13 | gradient_checkpoint_test.py | 288 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,977 | 1 | 284 | 176 | 82 | 272,207 | 110 | keras | 42 | keras/integration_test/gradient_checkpoint_test.py | Python | 28 | {
"docstring": "Trains a single large model with gradient checkpointing using tf.recompute_grad.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/keras-team/keras.git |
2 | test_edit_post | def test_edit_post(self):
# Send request
response = self.client.post(
reverse("wagtaildocs:edit_multiple", args=(self.doc.id,)),
{
"doc-%d-%s" % (self.doc.id, field): data
for field, data in self.edit_post_data.items()
},
... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 14 | test_admin_views.py | 246 | Reformat with black | 16,323 | 0 | 214 | 147 | 38 | 74,807 | 46 | wagtail | 24 | wagtail/documents/tests/test_admin_views.py | Python | 17 | {
"docstring": "\n This tests that a POST request to the edit view edits the document\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 12
} | https://github.com/wagtail/wagtail.git | |
1 | clamped | def clamped(self) -> Offset:
x, y = self
return Offset(max(x, 0), max(y, 0))
| 7bca184192191689b8a7247c92392d6b238df3d7 | 9 | geometry.py | 48 | tweak for colors | 44,981 | 0 | 34 | 30 | 13 | 185,337 | 13 | textual | 6 | src/textual/geometry.py | Python | 8 | {
"docstring": "Ensure x and y are above zero.\n\n Returns:\n Offset: New offset.\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 11,
"vocab_size": 11
} | https://github.com/Textualize/textual.git | |
1 | make_authors_file_lines | def make_authors_file_lines(git_people):
# define new lines for the file
header = filldedent().lstrip()
header_extra = f"There are a total of {len(git_people)} authors. | 5373c833ee895fb95f791849c6082ceb698b8dcc | 11 | mailmap_check.py | 108 | maint: tweaks in mailmap_check.py | 47,395 | 0 | 29 | 53 | 20 | 195,742 | 21 | sympy | 11 | bin/mailmap_check.py | Python | 15 | {
"docstring": "\n All people who contributed to SymPy by sending at least a patch or\n more (in the order of the date of their first contribution), except\n those who explicitly didn't want to be mentioned. People with a * next\n to their names are not found in the metadata of the git his... | https://github.com/sympy/sympy.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.