complexity int64 1 56 | n_identifiers int64 1 114 | code stringlengths 19 12.7k | path stringlengths 8 134 | n_ast_nodes int64 12 2.35k | ast_errors stringlengths 0 4.01k | repo stringlengths 3 28 | documentation dict | n_words int64 2 866 | language stringclasses 1
value | vocab_size int64 2 323 | commit_id stringlengths 40 40 | file_name stringlengths 5 79 | id int64 243 338k | nloc int64 1 228 | token_counts int64 5 1.4k | fun_name stringlengths 1 77 | url stringlengths 31 60 | commit_message stringlengths 3 15.3k | n_whitespaces int64 1 3.23k | n_ast_errors int64 0 20 | d_id int64 74 121k | ast_levels int64 4 29 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2 | 11 | def faces_count(self) -> int:
retval = sum(len(val["faces"]) for val in self._data.values())
logger.trace(retval) # type:ignore
return retval
| lib/align/alignments.py | 66 | faceswap | {
"docstring": " int: The total number of faces that appear in the alignments :attr:`data`. ",
"language": "en",
"n_whitespaces": 13,
"n_words": 12,
"vocab_size": 12
} | 16 | Python | 15 | e5356a417e7c2124e75c4a2994ed604fc0a3cc74 | alignments.py | 101,699 | 5 | 38 | faces_count | https://github.com/deepfakes/faceswap.git | Alignments update:
- Store face embeddings in PNG header when sorting
- typing + refactor
- Update alignments keys for 'identity' and 'video_meta' + bump to v2.3
- General typing fixes | 45 | 0 | 21,103 | 12 | |
1 | 15 | async def test_loading_race_condition(hass):
store = auth_store.AuthStore(hass)
with patch(
"homeassistant.helpers.entity_registry.async_get"
) as mock_ent_registry, patch(
"homeassistant.helpers.device_registry.async_get"
) as mock_dev_registry, patch(
"homeassistant.helper... | tests/auth/test_auth_store.py | 152 | core | {
"docstring": "Test only one storage load called when concurrent loading occurred .",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 35 | Python | 28 | 69cc6ab5f1d58adc586c3b300a4f7f0cde2cd0c2 | test_auth_store.py | 300,810 | 14 | 86 | test_loading_race_condition | https://github.com/home-assistant/core.git | Clean up accessing entity_registry.async_get_registry helper via hass (#72005) | 109 | 0 | 99,666 | 13 | |
2 | 15 | def test_get_resource_deprecation_warning(self):
hook = AwsBaseHook(aws_conn_id='aws_default', resource_type='dynamodb')
warning_message =
with pytest.warns(DeprecationWarning) as warnings:
hook.get_resource_type('dynamodb')
assert warning_message in [str(w.message) for ... | tests/providers/amazon/aws/hooks/test_base_aws.py | 91 | airflow | {
"docstring": "resource_type is deprecated. Set resource_type from class attribute.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 7
} | 21 | Python | 18 | 774ca085d2d2d58d4292b43c3511a145cc07154b | test_base_aws.py | 46,201 | 6 | 51 | test_get_resource_deprecation_warning | https://github.com/apache/airflow.git | Enable JSON serialization for connections (#19857)
Previously in general we could only store connections in the Airflow URI format. With this change we can serialize as JSON. The Airflow URI format can be very tricky to work with and although we have for some time had a convenience method Connection.get_uri, using J... | 64 | 0 | 8,811 | 12 | |
2 | 17 | def pip_install(self, reqs):
if not reqs:
return
log.info('Calling pip to install %s', reqs)
cmd = [
sys.executable, '-m', 'pip', 'install', '--ignore-installed',
'--prefix', self.path] + list(reqs)
check_call(
cmd,
std... | .venv/lib/python3.8/site-packages/pip/_vendor/pep517/envbuild.py | 120 | transferlearning | {
"docstring": "Install dependencies into this env by calling pip in a subprocess",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 32 | Python | 32 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | envbuild.py | 62,982 | 12 | 74 | pip_install | https://github.com/jindongwang/transferlearning.git | upd; format | 140 | 0 | 13,085 | 11 | |
3 | 8 | def _get_classifier_artifacts(fitted_estimator, prefix, X, y_true, sample_weight):
import sklearn
if not _is_plotting_supported():
return []
| mlflow/sklearn/utils.py | 41 | mlflow | {
"docstring": "\n Draw and record various common artifacts for classifier\n\n For all classifiers, we always log:\n (1) confusion matrix:\n https://scikit-learn.org/stable/modules/generated/sklearn.metrics.plot_confusion_matrix.html\n\n For only binary classifiers, we will log:\n (2) precision reca... | 13 | Python | 13 | 847eb6b22d03f0cffef945996cf835272870435a | utils.py | 19,198 | 48 | 187 | _get_classifier_artifacts | https://github.com/mlflow/mlflow.git | Improve confusion matrix plot (#5273)
* update
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
* fix
Signed-off-by: Weichen Xu <weichen.xu@databricks.com>
* update
Signed-off-by: Weichen Xu <weichen.xu@databricks.com> | 29 | 0 | 2,909 | 8 | |
1 | 21 | def mock_stretch() -> Generator[None, MagicMock, None]:
chosen_env = "stretch_v31"
with patch(
"homeassistant.components.plugwise.gateway.Smile", autospec=True
) as smile_mock:
smile = smile_mock.return_value
smile.gateway_id = "259882df3c05415b99c2d962534ce820"
smile.h... | tests/components/plugwise/conftest.py | 171 | @pytest.fixture | core | {
"docstring": "Create a Mock Stretch environment for testing exceptions.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 50 | Python | 39 | 6abf677092e2d45d39c515c8d4fa7e1787394766 | conftest.py | 288,912 | 17 | 90 | mock_stretch | https://github.com/home-assistant/core.git | Bump plugwise to v0.25.0 and adapt relevant plugwise code (#80129) | 145 | 1 | 88,061 | 11 |
1 | 8 | def _model_version(self) -> int:
retval = int(self._model_full_name[self._model_full_name.rfind("_") + 2:])
self.logger.trace(retval) # type: ignore
return retval
| lib/utils.py | 68 | faceswap | {
"docstring": " int: The model's version number from the model full name. ",
"language": "en",
"n_whitespaces": 11,
"n_words": 10,
"vocab_size": 10
} | 15 | Python | 14 | 91fecc47b2157d684ab9c219a860df51543222a3 | utils.py | 101,008 | 5 | 39 | _model_version | https://github.com/deepfakes/faceswap.git | lib.Utils - add DPI detector | 44 | 0 | 20,451 | 14 | |
3 | 29 | def rolling_mean_by_h(x, h, w, name):
# Aggregate over h
df = pd.DataFrame({'x': x, 'h': h})
df2 = (
df.groupby('h').agg(['sum', 'count']).reset_index().sort_values('h')
)
xs = df2['x']['sum'].values
ns = df2['x']['count'].values
hs = df2.h.values
trailing_i = len(df2) - 1
... | python/prophet/diagnostics.py | 376 | prophet | {
"docstring": "Compute a rolling mean of x, after first aggregating by h.\n\n Right-aligned. Computes a single mean for each unique value of h. Each\n mean is over at least w samples.\n\n Parameters\n ----------\n x: Array.\n h: Array of horizon for each value in x.\n w: Integer window size (num... | 147 | Python | 101 | e665430adcd7690a1ea7565803f34043596045fe | diagnostics.py | 3,288 | 25 | 228 | rolling_mean_by_h | https://github.com/facebook/prophet.git | Improved execution time of rolling_mean_by_h (#2142) | 321 | 0 | 430 | 16 | |
1 | 5 | def as_dict(self) -> dict[str, Any]:
| homeassistant/helpers/restore_state.py | 22 | core | {
"docstring": "Return a dict representation of the extra data.\n\n Must be serializable by Home Assistant's JSONEncoder.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 15,
"vocab_size": 15
} | 5 | Python | 5 | 009b31941a45c3d880b69dcf91d14edeb61a78a7 | restore_state.py | 312,884 | 5 | 13 | as_dict | https://github.com/home-assistant/core.git | Support restoring SensorEntity native_value (#66068) | 12 | 0 | 111,515 | 6 | |
1 | 27 | def test_consume_barcode_unsupported_jpg_file(self, m):
test_file = os.path.join(
os.path.dirname(__file__),
"samples",
"simple.jpg",
)
dst = os.path.join(settings.SCRATCH_DIR, "simple.jpg")
shutil.copy(test_file, dst)
with self.assert... | src/documents/tests/test_tasks.py | 258 | paperless-ngx | {
"docstring": "\n This test assumes barcode and TIFF support are enabled and\n the user uploads an unsupported image file (e.g. jpg)\n\n The function shouldn't try to scan for separating barcodes\n and continue archiving the file as is.\n ",
"language": "en",
"n_whitespaces": 7... | 45 | Python | 42 | 6d0fdc751027809a13e0430c16b8f248b3eb03e8 | test_tasks.py | 319,336 | 23 | 150 | test_consume_barcode_unsupported_jpg_file | https://github.com/paperless-ngx/paperless-ngx.git | add tests
fix indention
add more documentation
Signed-off-by: Florian Brandes <florian.brandes@posteo.de> | 242 | 0 | 116,934 | 12 | |
1 | 10 | def test_get_pdu_returns_nothing_when_event_does_not_exist(self):
remote_pdu = self.get_success(
self.hs.get_federation_client().get_pdu(
["yet.another.server"],
"event_should_not_exist",
RoomVersions.V9,
)
)
self.a... | tests/federation/test_federation_client.py | 71 | synapse | {
"docstring": "No event should be returned when the event does not exist",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 10
} | 13 | Python | 12 | 0f971ca68e808dd16f53f5594a6b33b7bddcc9a9 | test_federation_client.py | 248,920 | 9 | 42 | test_get_pdu_returns_nothing_when_event_does_not_exist | https://github.com/matrix-org/synapse.git | Update `get_pdu` to return the original, pristine `EventBase` (#13320)
Update `get_pdu` to return the untouched, pristine `EventBase` as it was originally seen over federation (no metadata added). Previously, we returned the same `event` reference that we stored in the cache which downstream code modified in place and... | 108 | 0 | 72,511 | 13 | |
1 | 6 | def config_dicts(self) -> Dict[str, Any]:
return self._config_dicts
| tools/preview/preview.py | 28 | faceswap | {
"docstring": " dict: The convert configuration options in dictionary form.",
"language": "en",
"n_whitespaces": 8,
"n_words": 8,
"vocab_size": 8
} | 7 | Python | 7 | 1022651eb8a7741014f5d2ec7cbfe882120dfa5f | preview.py | 101,425 | 3 | 17 | config_dicts | https://github.com/deepfakes/faceswap.git | Bugfix: convert - Gif Writer
- Fix non-launch error on Gif Writer
- convert plugins - linting
- convert/fs_media/preview/queue_manager - typing
- Change convert items from dict to Dataclass | 21 | 0 | 20,839 | 6 | |
1 | 22 | def test_prune_gap_if_old(self):
# Advance the clock for many days to make the old extremity "old". We
# also set the depth to "lots".
self.reactor.advance(7 * 24 * 60 * 60)
# Fudge a second event which points to an event we don't have. This is a
# state event so that ... | tests/storage/test_events.py | 218 | synapse | {
"docstring": "Test that we drop extremities after a gap when the previous extremity\n is \"old\"\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 14,
"vocab_size": 14
} | 113 | Python | 84 | b83bc5fab57b37f75a79d02213d6032c586fd36e | test_events.py | 248,370 | 21 | 124 | test_prune_gap_if_old | https://github.com/matrix-org/synapse.git | Pull out less state when handling gaps mk2 (#12852) | 390 | 0 | 72,247 | 13 | |
1 | 6 | def tree(self) -> Tree:
highlighter = ReprHighlighter()
tree = Tree(highlighter(repr(self)))
| src/textual/dom.py | 45 | textual | {
"docstring": "Get a Rich tree object which will recursively render the structure of the node tree.\n\n Returns:\n Tree: A Rich object which may be printed.\n ",
"language": "en",
"n_whitespaces": 49,
"n_words": 24,
"vocab_size": 20
} | 10 | Python | 9 | 2635f58e7c3d10b161ee69a15ebfe6499ac26daa | dom.py | 181,943 | 11 | 35 | tree | https://github.com/Textualize/textual.git | docstrings and tidy | 31 | 0 | 43,682 | 12 | |
1 | 6 | def synchronized_update_sequences(self) -> tuple[str, str]:
return (
self._synchronized_update_start_sequence(),
self._synchronized_update_end_sequence(),
)
| src/textual/_terminal_features.py | 45 | textual | {
"docstring": "\n Returns the ANSI sequence that we should send to the terminal to tell it that\n it should buffer the content we're about to send, as well as the ANIS sequence to end the buffering.\n If the terminal doesn't seem to support synchronised updates both strings will be empty.\n\n ... | 10 | Python | 10 | d14659c1a3760eade2dd3479b66eb8b2e7711db0 | _terminal_features.py | 183,562 | 14 | 28 | synchronized_update_sequences | https://github.com/Textualize/textual.git | [terminal buffering] Add support for the "mode 2026"
That task is definitely way more complicated that it seemed to be 😅 | 53 | 0 | 44,251 | 8 | |
5 | 19 | def _filter_args(args):
distrib_args = distrib_run.get_args_parser()
known_args, _ = distrib_args.parse_known_args()
for arg in list(vars(args).keys()):
if arg not in vars(known_args).keys():
delattr(args, arg)
distrib_args = distrib_run.parse_args(vars(args))
for key, value... | src/accelerate/utils/launch.py | 177 | accelerate | {
"docstring": "\n Filters out all `accelerate` specific args\n ",
"language": "en",
"n_whitespaces": 13,
"n_words": 6,
"vocab_size": 6
} | 39 | Python | 28 | 9fd08d79f9a72973073d2cdef6bf23f367b75d6f | launch.py | 338,065 | 12 | 107 | _filter_args | https://github.com/huggingface/accelerate.git | Fully remove `subprocess` from the multi-gpu launcher (#623)
* Remove one of the subprocesses! | 95 | 0 | 121,158 | 12 | |
5 | 7 | def create_endpoint(endpoint_type=0):
if endpoint_type == 1:
try:
endpoint = f"http://api.openweathermap.org/data/2.5/weather?zip={APP_DATA['Postal']},{APP_DATA['Country']}&appid={API_KEY}&units={APP_DATA['Units']}"
return endpoint
except ConnectionError:
ret... | DemoPrograms/Demo_Desktop_Widget_Weather.py | 163 | PySimpleGUI | {
"docstring": " Create the api request endpoint\n {0: default, 1: zipcode, 2: city_name}",
"language": "en",
"n_whitespaces": 14,
"n_words": 11,
"vocab_size": 11
} | 38 | Python | 21 | 186b16e77ac2b54eb966bafc0e5f092e028e7ed8 | Demo_Desktop_Widget_Weather.py | 212,784 | 15 | 45 | create_endpoint | https://github.com/PySimpleGUI/PySimpleGUI.git | Addition of county to the Weather Desktop Widget | 162 | 0 | 53,400 | 17 | |
6 | 34 | def install(collection, path, artifacts_manager): # FIXME: mv to dataclasses?
# type: (Candidate, str, ConcreteArtifactsManager) -> None
b_artifact_path = (
artifacts_manager.get_artifact_path if collection.is_concrete_artifact
else artifacts_manager.get_galaxy_artifact_path
)(collecti... | lib/ansible/galaxy/collection/__init__.py | 262 | ansible | {
"docstring": "Install a collection under a given path.\n\n :param collection: Collection to be installed.\n :param path: Collection dirs layout path.\n :param artifacts_manager: Artifacts manager.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 23,
"vocab_size": 18
} | 76 | Python | 62 | 43e55db20821a1341d21ffa1e4e7e6185b244105 | __init__.py | 266,595 | 33 | 170 | install | https://github.com/ansible/ansible.git | ansible-galaxy - add signature verification of the MANIFEST.json (#76681)
* ansible-galaxy collection install|verify:
- Support verifying the origin of the MANIFEST.json when the Galaxy server has provided signatures.
- Allow supplemental signatures to use during verification on the CLI/requirements file.
*... | 315 | 0 | 78,490 | 13 | |
1 | 2 | def validate(self) -> None:
| src/sentry/utils/services.py | 16 | sentry | {
"docstring": "\n Validates the settings for this backend (i.e. such as proper connection\n info).\n\n Raise ``InvalidConfiguration`` if there is a configuration error.\n ",
"language": "en",
"n_whitespaces": 49,
"n_words": 20,
"vocab_size": 20
} | 4 | Python | 4 | fbe987561d2b9df070f34652785294cc430b41e4 | services.py | 96,505 | 7 | 8 | validate | https://github.com/getsentry/sentry.git | typing: Add type hints to sentry/utils/services.py (#31984)
We use these service backends in a lot of places that are typed. Adding typing here adds a lot of
value since we can now properly introspect things that inherit from `Service` and related. | 11 | 0 | 19,322 | 6 | |
13 | 35 | def scanString(self, instring, maxMatches=_MAX_INT, overlap=False):
if not self.streamlined:
self.streamline()
for e in self.ignoreExprs:
e.streamline()
if not self.keepTabs:
instring = _ustr(instring).expandtabs()
instrlen = len(instring)
... | .venv/lib/python3.8/site-packages/pip/_vendor/pyparsing.py | 354 | transferlearning | {
"docstring": "\n Scan the input string for expression matches. Each match will return the\n matching tokens, start location, and end location. May be called with optional\n ``maxMatches`` argument, to clip scanning after 'n' matches are found. If\n ``overlap`` is specified, then overl... | 135 | Python | 80 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | pyparsing.py | 63,394 | 41 | 217 | scanString | https://github.com/jindongwang/transferlearning.git | upd; format | 789 | 0 | 13,285 | 20 | |
2 | 14 | def _get_related_events(self) -> List[str]:
# Request the relations of the event.
channel = self.make_request(
"GET",
f"/_matrix/client/unstable/rooms/{self.room}/relations/{self.parent_id}",
access_token=self.user_token,
)
self.assertEquals(2... | tests/rest/client/test_relations.py | 109 | synapse | {
"docstring": "\n Requests /relations on the parent ID and returns a list of event IDs.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 13
} | 27 | Python | 26 | 1da0f79d5455b594f2aa989106a672786f5b990f | test_relations.py | 247,707 | 11 | 59 | _get_related_events | https://github.com/matrix-org/synapse.git | Refactor relations tests (#12232)
* Moves the relation pagination tests to a separate class.
* Move the assertion of the response code into the `_send_relation` helper.
* Moves some helpers into the base-class. | 102 | 0 | 71,860 | 11 | |
3 | 13 | def _express_axis(self, axis, frame):
try:
ax_mat = axis.to_matrix(self.parent_interframe)
except ValueError:
ax_mat = axis.to_matrix(self.child_interframe)
try:
self.parent_interframe.dcm(frame) # Check if connected
int_frame = self.pare... | sympy/physics/mechanics/joint.py | 118 | sympy | {
"docstring": "Helper function to get an axis expressed in a specified frame.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 30 | Python | 22 | 7c199e306648513c13c9b5c5b5fad06e5f1c3020 | joint.py | 199,355 | 11 | 72 | _express_axis | https://github.com/sympy/sympy.git | Fix failing test and simplify joint orient methods | 128 | 0 | 49,253 | 12 | |
1 | 3 | def limits(self):
return self.args[1]
| sympy/geometry/curve.py | 23 | sympy | {
"docstring": "The limits for the curve.\n\n Returns\n =======\n\n limits : tuple\n Contains parameter and lower and upper limits.\n\n Examples\n ========\n\n >>> from sympy.abc import t\n >>> from sympy import Curve\n >>> C = Curve([t, t**3], (t, -2... | 4 | Python | 4 | 498015021131af4dbb07eb110e5badaba8250c7b | curve.py | 196,265 | 2 | 13 | limits | https://github.com/sympy/sympy.git | Updated import locations | 18 | 0 | 47,765 | 7 | |
8 | 24 | def extract(self, member, path="", set_attrs=True):
self._check("r")
if isinstance(member, str):
tarinfo = self.getmember(member)
else:
tarinfo = member
# Prepare the link target for makelink().
if tarinfo.islnk():
tarinfo._link_targ... | pipenv/patched/notpip/_vendor/distlib/_backport/tarfile.py | 279 | pipenv | {
"docstring": "Extract a member from the archive to the current working directory,\n using its full name. Its file information is extracted as accurately\n as possible. `member' may be a filename or a TarInfo object. You can\n specify a different directory using `path'. File attributes ... | 76 | Python | 52 | c69d55f7c82d5ae2cce542bcfb98d043ca4836a0 | tarfile.py | 21,475 | 24 | 170 | extract | https://github.com/pypa/pipenv.git | Vendor in pip 22.1.2 | 372 | 0 | 3,863 | 19 | |
2 | 8 | def formatmonthname(self, theyear, themonth, withyear=True):
if withyear:
s = '%s %s' % (month_name[themonth], theyear)
else:
s = '%s' % month_name[themonth]
return '<tr><th colspan="7" class="%s">%s</th></tr>' % (
self.cssclass_month_head, s)
| python3.10.4/Lib/calendar.py | 80 | XX-Net | {
"docstring": "\n Return a month name as a table row.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 7
} | 28 | Python | 24 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | calendar.py | 221,244 | 7 | 49 | formatmonthname | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 89 | 0 | 56,291 | 11 | |
2 | 6 | def unicode_is_ascii(u_string):
assert isinstance(u_string, str)
try:
u_string.encode("ascii")
return True
except UnicodeEncodeError:
return False
| pipenv/patched/pip/_vendor/requests/_internal_utils.py | 50 | pipenv | {
"docstring": "Determine if unicode string only contains ASCII characters.\n\n :param str u_string: unicode string to check. Must be unicode\n and not Python 2 `str`.\n :rtype: bool\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 25,
"vocab_size": 22
} | 13 | Python | 12 | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | _internal_utils.py | 22,039 | 7 | 28 | unicode_is_ascii | https://github.com/pypa/pipenv.git | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | 46 | 0 | 4,128 | 10 | |
1 | 8 | def test_do_nothing_if_converted(self, run_convert_mock):
stdout, _ = self.call_command()
run_convert_mock.assert_not_called()
self.assertIn("Converting all PNG thumbnails to WebP", stdout)
| src/documents/tests/test_management_convert_thumbnail.py | 53 | paperless-ngx | {
"docstring": "\n GIVEN:\n - Document exists with default WebP thumbnail path\n WHEN:\n - Thumbnail conversion is attempted\n THEN:\n - Nothing is converted\n ",
"language": "en",
"n_whitespaces": 82,
"n_words": 20,
"vocab_size": 17
} | 15 | Python | 15 | 08c3d6e84b17da2acfb10250438fe357398e5e0e | test_management_convert_thumbnail.py | 319,727 | 4 | 30 | test_do_nothing_if_converted | https://github.com/paperless-ngx/paperless-ngx.git | Fixes existing testing, adds test coverage of new command | 43 | 0 | 116,987 | 8 | |
2 | 6 | def set_rollback(self, rollback):
if not self.in_atomic_block:
raise TransactionManagementError(
"The rollback flag doesn't work outside of an 'atomic' block."
)
self.needs_rollback = rollback
| django/db/backends/base/base.py | 43 | django | {
"docstring": "\n Set or unset the \"needs rollback\" flag -- for *advanced use* only.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 12
} | 22 | Python | 21 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | base.py | 204,826 | 6 | 24 | set_rollback | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 80 | 0 | 50,909 | 10 | |
1 | 12 | def test_warning_does_not_halt(self):
self.write_settings(
"settings.py",
apps=[
"admin_scripts.app_raising_warning",
"django.contrib.auth",
"django.contrib.contenttypes",
],
sdict={"DEBUG": True},
... | tests/admin_scripts/tests.py | 139 | django | {
"docstring": "\n When there are only warnings or less serious messages, then Django\n should not prevent user from launching their project, so `check`\n command should not raise `CommandError` exception.\n\n In this test we also test output format.\n ",
"language": "en",
"n_wh... | 49 | Python | 42 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 207,400 | 22 | 71 | test_warning_does_not_halt | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 268 | 0 | 51,951 | 11 | |
1 | 15 | def test_from(self) -> None:
self._create_users_with_media(20, 2)
channel = self.make_request(
"GET",
self.url + "?from=5",
access_token=self.admin_user_tok,
)
self.assertEqual(200, channel.code, msg=channel.json_body)
self.assertEqu... | tests/rest/admin/test_statistics.py | 168 | synapse | {
"docstring": "\n Testing list of media with a defined starting point (from)\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 10
} | 25 | Python | 25 | c97042f7eef3748e17c90e48a4122389a89c4735 | test_statistics.py | 249,167 | 15 | 103 | test_from | https://github.com/matrix-org/synapse.git | Use literals in place of `HTTPStatus` constants in tests (#13469) | 121 | 0 | 72,674 | 11 | |
1 | 2 | def period(self):
return self["period"]
| packages/python/plotly/plotly/graph_objs/layout/polar/_angularaxis.py | 22 | plotly.py | {
"docstring": "\n Set the angular period. Has an effect only when\n `angularaxis.type` is \"category\".\n\n The 'period' property is a number and may be specified as:\n - An int or float in the interval [0, inf]\n\n Returns\n -------\n int|float\n ",
"langu... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _angularaxis.py | 232,103 | 2 | 11 | period | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 63,547 | 7 | |
6 | 21 | def operand_to_template_torchscript(op_id, oper):
shape_parts = ["("]
for d, s in enumerate(oper.shape):
if s > 0:
# Fixed shape dimension: just add the value.
shape_parts.append(str(s))
else:
# Flexible shape dimension: it... | torch/backends/_nnapi/serializer.py | 238 | pytorch | {
"docstring": "Return a TorchScript expression to build a template for a given operand.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 10
} | 77 | Python | 62 | d9106116aa5e399f7d63feeb7fc77f92a076dd93 | serializer.py | 102,109 | 21 | 120 | operand_to_template_torchscript | https://github.com/pytorch/pytorch.git | nnapi: Add int32 type torchscript expressions (#70197)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/70197
Test Plan:
* `pytest test/test_nnapi.py`
* Testing via ops following this commit
Reviewed By: anshuljain1, dreiss
Differential Revision: D33237917
fbshipit-source-id: f0493620f28a62a... | 322 | 0 | 21,468 | 14 | |
1 | 14 | def test_ignore_model_permissions_with_unauthenticated_user(self):
request = factory.get('/', format='json')
request.resolver_match = ResolverMatch('get', (), {})
response = ignored_get_queryset_list_view(request)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZ... | tests/test_permissions.py | 86 | django-rest-framework | {
"docstring": "\n We check that the ``_ignore_model_permissions`` attribute\n doesn't ignore the authentication.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 10,
"vocab_size": 9
} | 16 | Python | 14 | c0d95cb9678b1693f8f1a8658d4665c51de87ddf | test_permissions.py | 48,708 | 5 | 50 | test_ignore_model_permissions_with_unauthenticated_user | https://github.com/encode/django-rest-framework.git | Fix #8771 - Checking for authentication even if `_ignore_model_permissions = True` (#8772) | 51 | 0 | 9,572 | 10 | |
2 | 8 | def skipUnlessAnyDBFeature(*features):
return _deferredSkip(
lambda: not any(
getattr(connection.features, feature, False) for feature in features
),
"Database doesn't support any of the feature(s): %s" % ", ".join(features),
"skipUnlessAnyDBFeature",
)
| django/test/testcases.py | 72 | django | {
"docstring": "Skip a test unless a database has any of the named features.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 11
} | 28 | Python | 28 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | testcases.py | 206,470 | 8 | 43 | skipUnlessAnyDBFeature | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 76 | 0 | 51,534 | 14 | |
3 | 10 | def installed_models(self, tables):
tables = set(map(self.identifier_converter, tables))
return {
m
for m in self.get_migratable_models()
if self.identifier_converter(m._meta.db_table) in tables
}
| django/db/backends/base/introspection.py | 73 | django | {
"docstring": "\n Return a set of all models represented by the provided list of table\n names.\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 14,
"vocab_size": 13
} | 19 | Python | 16 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | introspection.py | 204,850 | 7 | 46 | installed_models | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 80 | 0 | 50,928 | 12 | |
16 | 32 | def customize_compiler(compiler):
if compiler.compiler_type == "unix":
if sys.platform == "darwin":
# Perform first-time customization of compiler-related
# config vars on OS X now that we know we need a compiler.
# This is primarily to support Pythons from binary
... | python3.10.4/Lib/distutils/sysconfig.py | 658 | XX-Net | {
"docstring": "Do any platform-specific customization of a CCompiler instance.\n\n Mainly needed on Unix, so we can plug in the information that\n varies across Unices and is stored in Python's Makefile.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 29,
"vocab_size": 28
} | 303 | Python | 147 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | sysconfig.py | 223,004 | 50 | 369 | customize_compiler | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 957 | 0 | 56,846 | 17 | |
1 | 9 | def activate_previous_tab(self) -> None:
current_tab_index = self.find_tab_by_name(self._active_tab_name)
previous_tab_index = current_tab_index - 1
previous_tab_name = self.tabs[previous_tab_index].name
self._active_tab_name = previous_tab_name
| src/textual/widgets/tabs.py | 63 | textual | {
"docstring": "Activate the tab to the left of the currently active tab",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 8
} | 18 | Python | 13 | 18a3fb4b576f06e1e82e8a030d95bea2df1836b1 | tabs.py | 182,359 | 6 | 38 | activate_previous_tab | https://github.com/Textualize/textual.git | Tidying Tabs, adding docstrings | 53 | 0 | 43,804 | 9 | |
10 | 34 | def transform(self, node, results):
head = results["head"]
method = results["method"][0] # Extract node for method name
tail = results["tail"]
syms = self.syms
method_name = method.value
isiter = method_name.startswith("iter")
isview = method_name.startswith("view... | python3.10.4/Lib/lib2to3/fixes/fix_dict.py | 416 | XX-Net | {
"docstring": "for_stmt< 'for' any 'in' node=any ':' any* >\n | comp_for< 'for' any 'in' node=any any* >\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 16,
"vocab_size": 10
} | 127 | Python | 81 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | fix_dict.py | 218,645 | 27 | 232 | transform | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 440 | 0 | 55,443 | 15 | |
1 | 5 | def __lt__(self, other):
return self.sort_key() < sympify(other).sort_key()
| sympy/combinatorics/partitions.py | 40 | sympy | {
"docstring": "\n Checks if a partition is less than the other.\n\n Examples\n ========\n\n >>> from sympy.combinatorics import Partition\n >>> a = Partition([1, 2], [3, 4, 5])\n >>> b = Partition([1], [2, 3], [4], [5])\n >>> a.rank, b.rank\n (9, 34)\n >... | 7 | Python | 7 | 498015021131af4dbb07eb110e5badaba8250c7b | partitions.py | 196,112 | 2 | 23 | __lt__ | https://github.com/sympy/sympy.git | Updated import locations | 21 | 0 | 47,612 | 10 | |
2 | 8 | def get_key(self):
return (
RayWrapper.materialize(self.key)
if isinstance(self.key, ray.ObjectRef)
else self.key
)
| modin/core/execution/ray/implementations/cudf_on_ray/partitioning/partition.py | 51 | modin | {
"docstring": "\n Get integer key of this partition in dict-storage of `self.gpu_manager`.\n\n Returns\n -------\n int\n ",
"language": "en",
"n_whitespaces": 49,
"n_words": 13,
"vocab_size": 12
} | 11 | Python | 11 | 1dc16415333bf2428ee2b1f4d31ff94e66b9a0a6 | partition.py | 154,522 | 6 | 32 | get_key | https://github.com/modin-project/modin.git | REFACTOR-#5009: use RayWrapper.materialize instead of ray.get (#5010)
Signed-off-by: Myachev <anatoly.myachev@intel.com> | 65 | 0 | 36,045 | 10 | |
18 | 26 | def find_common_type(types):
if not types:
raise ValueError("no types given")
first = types[0]
# workaround for find_common_type([np.dtype('datetime64[ns]')] * 2)
# => object
if lib.dtypes_all_equal(list(types)):
return first
# get unique types (dict.fromkeys is used as o... | pandas/core/dtypes/cast.py | 322 | pandas | {
"docstring": "\n Find a common data type among the given dtypes.\n\n Parameters\n ----------\n types : list of dtypes\n\n Returns\n -------\n pandas extension or numpy dtype\n\n See Also\n --------\n numpy.find_common_type\n\n ",
"language": "en",
"n_whitespaces": 61,
"n_words... | 131 | Python | 74 | aa889881863d2f47edd4580f128be4e138ae1e80 | cast.py | 163,074 | 24 | 194 | find_common_type | https://github.com/pandas-dev/pandas.git | CLN: assorted follow-ups (#45184) | 317 | 0 | 39,366 | 14 | |
2 | 4 | def _get_text_color(self, style):
if style['color'] is not None:
fill = '#' + style['color']
else:
fill = '#000'
return fill
| pipenv/patched/notpip/_vendor/pygments/formatters/img.py | 60 | pipenv | {
"docstring": "\n Get the correct color for the token from the style.\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 8
} | 19 | Python | 15 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | img.py | 20,339 | 6 | 32 | _get_text_color | https://github.com/pypa/pipenv.git | 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... | 69 | 0 | 3,330 | 11 | |
2 | 14 | async def async_added_to_hass(self) -> None:
self.async_on_remove(
async_dispatcher_connect(
self.hass,
SIA_EVENT.format(self.port, self.account),
self.async_handle_event,
)
)
self.handle_last_state(await self.async... | homeassistant/components/sia/sia_entity_base.py | 95 | core | {
"docstring": "Run when entity about to be added to hass.\n\n Overridden from Entity.\n\n 1. register the dispatcher and add the callback to on_remove\n 2. get previous state from storage and pass to entity specific function\n 3. if available: create availability cb\n ",
"languag... | 18 | Python | 17 | af4e37339a39badd5596e8bc9ba86d6c1994aa1b | sia_entity_base.py | 291,940 | 19 | 58 | async_added_to_hass | https://github.com/home-assistant/core.git | Add Connectivity sensor to SIA (#64305)
* implemented connectivity sensor
* further cleanup off update code
* cleanup and tighter behaviour for attributes
* added seperate connectivity class to binary sensor
* callbacks and keys
* redid name and unique_id logic, non-breaking result
* using entry more... | 131 | 0 | 91,043 | 12 | |
1 | 16 | def test_metadata(self):
checkpoint = self._prepare_fs_checkpoint()
# Convert into dict checkpoint
data_dict = checkpoint.to_dict()
self.assertIsInstance(data_dict, dict)
data_dict["my_marker"] = "marked"
# Create from dict
checkpoint = Checkpoint.from... | python/ray/air/tests/test_checkpoints.py | 142 | ray | {
"docstring": "Test conversion with metadata involved.\n\n a. from fs to dict checkpoint;\n b. drop some marker to dict checkpoint;\n c. convert back to fs checkpoint;\n d. convert back to dict checkpoint.\n\n Assert that the marker should still be there.",
"language": "en",
"n... | 39 | Python | 27 | cc53a1e28bdb0dc7121f4378c651e6290b7bc84d | test_checkpoints.py | 141,909 | 10 | 79 | test_metadata | https://github.com/ray-project/ray.git | [air] update checkpoint.py to deal with metadata in conversion. (#25727)
This is carved out from https://github.com/ray-project/ray/pull/25558.
tlrd: checkpoint.py current doesn't support the following
```
a. from fs to dict checkpoint;
b. drop some marker to dict checkpoint;
c. convert back to fs checkpoint;
d... | 130 | 0 | 32,525 | 12 | |
3 | 13 | def get_reverse_charge_recoverable_total(filters):
query_filters = get_filters(filters)
query_filters.append(["reverse_charge", "=", "Y"])
query_filters.append(["recoverable_reverse_charge", ">", "0"])
query_filters.append(["docstatus", "=", 1])
try:
return (
frappe.db.get_all(
"Purchase Invoice", filte... | erpnext/regional/report/uae_vat_201/uae_vat_201.py | 162 | erpnext | {
"docstring": "Returns the sum of the total of each Purchase invoice made with recoverable reverse charge.",
"language": "en",
"n_whitespaces": 14,
"n_words": 15,
"vocab_size": 13
} | 33 | Python | 30 | 494bd9ef78313436f0424b918f200dab8fc7c20b | uae_vat_201.py | 67,268 | 14 | 96 | get_reverse_charge_recoverable_total | https://github.com/frappe/erpnext.git | style: format code with black | 19 | 0 | 14,462 | 16 | |
1 | 4 | def find_distributions(self, context=Context()):
| python3.10.4/Lib/importlib/metadata/__init__.py | 22 | XX-Net | {
"docstring": "\n Find distributions.\n\n Return an iterable of all Distribution instances capable of\n loading the metadata for packages matching the ``context``,\n a DistributionFinder.Context instance.\n ",
"language": "en",
"n_whitespaces": 58,
"n_words": 22,
"vocab_siz... | 3 | Python | 3 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | __init__.py | 218,263 | 8 | 12 | find_distributions | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 10 | 0 | 55,232 | 7 | |
1 | 22 | def test_multiple_doc_paths(self):
doc_a = Document.objects.create(
title="does not matter",
created=timezone.make_aware(datetime.datetime(2020, 6, 25, 7, 36, 51, 153)),
mime_type="application/pdf",
pk=2,
checksum="2",
archive_seri... | src/documents/tests/test_file_handling.py | 262 | paperless-ngx | {
"docstring": "\n GIVEN:\n - Two documents, each with different storage paths\n WHEN:\n - the filename is generated for the documents\n THEN:\n - Each document generated filename uses its storage path\n ",
"language": "en",
"n_whitespaces": 90,
"n_wo... | 49 | Python | 33 | 69ef26dab04d51e7e102dcb33cd98ddc6ad975fd | test_file_handling.py | 319,621 | 26 | 170 | test_multiple_doc_paths | https://github.com/paperless-ngx/paperless-ngx.git | Feature: Dynamic document storage pathes (#916)
* Added devcontainer
* Add feature storage pathes
* Exclude tests and add versioning
* Check escaping
* Check escaping
* Check quoting
* Echo
* Escape
* Escape :
* Double escape \
* Escaping
* Remove if
* Escape colon
* Missing \
... | 323 | 0 | 116,978 | 13 | |
9 | 3 | def download(self, url):
| django/core/management/templates.py | 15 | django | {
"docstring": "\n Download the given URL and return the file name.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 8
} | 3 | Python | 3 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | templates.py | 204,713 | 37 | 261 | download | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 10 | 0 | 50,847 | 6 | |
3 | 8 | def media_album_name(self) -> str | None:
if self._playing and self._is_feature_available(FeatureName.Album):
return self._playing.album
return None
| homeassistant/components/apple_tv/media_player.py | 53 | core | {
"docstring": "Album name of current playing media, music track only.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 14 | Python | 13 | 5276d849ec497ccd0cecf3cb6a8dacae4fa6f845 | media_player.py | 306,846 | 5 | 32 | media_album_name | https://github.com/home-assistant/core.git | Improve type hints in apple_tv media player (#77940) | 46 | 0 | 105,629 | 9 | |
3 | 17 | def get_model_params(model_name, override_params):
if model_name.startswith('efficientnet'):
w, d, _, p = efficientnet_params(model_name)
blocks_args, global_params = efficientnet(width_coefficient=w, depth_coefficient=d, dropout_rate=p)
else:
raise NotImplementedError('model name i... | modules/image/text_to_image/disco_diffusion_ernievil_base/vit_b_16x/ernievil2/transformers/efficientnet.py | 116 | PaddleHub | {
"docstring": " Get the block args and global params for a given model ",
"language": "en",
"n_whitespaces": 12,
"n_words": 11,
"vocab_size": 11
} | 35 | Python | 29 | ffcde21305c61d950a9f93e57e6180c9a9665b87 | efficientnet.py | 50,243 | 9 | 71 | get_model_params | https://github.com/PaddlePaddle/PaddleHub.git | add disco_diffusion_ernievil_base | 78 | 0 | 10,062 | 12 | |
3 | 11 | def load(self, path):
path = os.path.normpath(path)
mtime = os.stat(path).st_mtime
if path not in self or self[path].mtime != mtime:
manifest = self.build(path)
self[path] = self.manifest_mod(manifest, mtime)
return self[path].manifest
| .venv/lib/python3.8/site-packages/pip/_vendor/pkg_resources/__init__.py | 111 | transferlearning | {
"docstring": "\n Load a manifest at path or return a suitable manifest already loaded.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 10
} | 27 | Python | 23 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | __init__.py | 63,184 | 7 | 71 | load | https://github.com/jindongwang/transferlearning.git | upd; format | 84 | 0 | 13,190 | 10 | |
1 | 6 | async def test_default_discovery_in_progress(hass, manager):
mock_integration(hass, MockModule("comp"))
mock_entity_platform(hass, "config_flow.comp", None)
| tests/test_config_entries.py | 45 | core | {
"docstring": "Test that a flow using default discovery can only be triggered once.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | 9 | Python | 9 | 7cd68381f1d4f58930ffd631dfbfc7159d459832 | test_config_entries.py | 316,440 | 21 | 165 | test_default_discovery_in_progress | https://github.com/home-assistant/core.git | Search/replace RESULT_TYPE_* by FlowResultType enum (#74642) | 18 | 0 | 115,018 | 10 | |
1 | 14 | def test_override(self) -> None:
self.get_success(
self.store.register_user(
self.user_id,
self.pwhash,
approved=True,
)
)
user = self.get_success(self.store.get_user_by_id(self.user_id))
self.assertIsNotNo... | tests/storage/test_registration.py | 150 | synapse | {
"docstring": "Tests that if we require approval for new accounts, but we explicitly say the\n new user should be considered approved, they're marked as approved.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 24,
"vocab_size": 22
} | 26 | Python | 23 | be76cd8200b18f3c68b895f85ac7ef5b0ddc2466 | test_registration.py | 249,580 | 17 | 94 | test_override | https://github.com/matrix-org/synapse.git | Allow admins to require a manual approval process before new accounts can be used (using MSC3866) (#13556) | 156 | 0 | 73,002 | 11 | |
1 | 9 | def test_action_column_class(self):
response = self.client.get(reverse("admin:admin_views_subscriber_changelist"))
self.assertIsNotNone(response.context["action_form"])
self.assertContains(response, "action-checkbox-column")
| tests/admin_views/test_actions.py | 69 | django | {
"docstring": "The checkbox column class is present in the response.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 8 | Python | 8 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | test_actions.py | 207,495 | 4 | 38 | test_action_column_class | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 36 | 0 | 51,985 | 11 | |
5 | 27 | async def async_load_history_from_system() -> dict[str, BluetoothServiceInfoBleak]:
if platform.system() != "Linux":
return {}
from bluetooth_adapters import ( # pylint: disable=import-outside-toplevel
BlueZDBusObjects,
)
bluez_dbus = BlueZDBusObjects()
await bluez_dbus.load()... | homeassistant/components/bluetooth/util.py | 233 | core | {
"docstring": "Load the device and advertisement_data history if available on the current system.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 11
} | 55 | Python | 51 | 1589c06203c0bc9f87adcc97fe34d5c52aaf403a | util.py | 290,029 | 28 | 153 | async_load_history_from_system | https://github.com/home-assistant/core.git | Significantly reduce clock_gettime syscalls on platforms with broken vdso (#81257) | 261 | 0 | 89,155 | 14 | |
1 | 7 | def open(self, filename):
self.filename = filename
self.file = io.open(self.filename, 'r', errors=self.errors)
self.current_line = 0
| python3.10.4/Lib/distutils/text_file.py | 62 | XX-Net | {
"docstring": "Open a new file named 'filename'. This overrides both the\n 'filename' and 'file' arguments to the constructor.",
"language": "en",
"n_whitespaces": 27,
"n_words": 17,
"vocab_size": 16
} | 14 | Python | 12 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | text_file.py | 223,376 | 4 | 38 | open | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 42 | 0 | 56,871 | 10 | |
7 | 23 | def execute(self, sql, params=()):
# Don't perform the transactional DDL check if SQL is being collected
# as it's not going to be executed anyway.
if (
not self.collect_sql
and self.connection.in_atomic_block
and not self.connection.features.can_roll... | django/db/backends/base/schema.py | 264 | django | {
"docstring": "Execute the given SQL statement, with optional parameters.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 117 | Python | 91 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | schema.py | 204,916 | 26 | 154 | execute | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 420 | 0 | 50,973 | 19 | |
1 | 3 | def disconnect(self):
self.is_connected = False
return
| mindsdb/integrations/handlers/pinot_handler/pinot_handler.py | 23 | mindsdb | {
"docstring": " Close any existing connections\r\n\r\n Should switch self.is_connected.\r\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | 6 | Python | 6 | b6a81acd4cff972d66bffa341782e76f2897e134 | pinot_handler.py | 115,957 | 3 | 12 | disconnect | https://github.com/mindsdb/mindsdb.git | updated the logic of the disconnect() method | 27 | 0 | 25,613 | 7 | |
1 | 8 | def test_rl_backward_kill_word(lineedit, text, deleted, rest):
_validate_deletion(lineedit,
readlinecommands.rl_backward_kill_word, [],
text, deleted, rest)
| tests/unit/components/test_readlinecommands.py | 41 | qutebrowser | {
"docstring": "Delete to word beginning and see if it comes back with yank.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | 11 | Python | 9 | ab65c542a0551abf105eeb58803cd08bd040753b | test_readlinecommands.py | 320,679 | 4 | 29 | test_rl_backward_kill_word | https://github.com/qutebrowser/qutebrowser.git | Add :rl-rubout and :rl-filename-rubout
Closes #4561 | 61 | 0 | 117,273 | 8 | |
1 | 8 | def test_upload_ban(self) -> None:
data = b"Some evil data"
self.helper.upload_media(
self.upload_resource, data, tok=self.tok, expect_code=400
)
| tests/rest/media/v1/test_media_storage.py | 54 | synapse | {
"docstring": "Attempt to upload some data that includes bytes \"evil\", which should\n get rejected by the spam checker.\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 17,
"vocab_size": 17
} | 15 | Python | 15 | 32c828d0f760492711a98b11376e229d795fd1b3 | test_media_storage.py | 247,517 | 8 | 34 | test_upload_ban | https://github.com/matrix-org/synapse.git | Add type hints to `tests/rest`. (#12208)
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com> | 54 | 0 | 71,710 | 9 | |
1 | 7 | def ismethod(obj):
return _inspect.ismethod(tf.__internal__.decorator.unwrap(obj)[1])
| keras/utils/tf_inspect.py | 42 | keras | {
"docstring": "TFDecorator-aware replacement for inspect.ismethod.",
"language": "en",
"n_whitespaces": 3,
"n_words": 4,
"vocab_size": 4
} | 4 | Python | 4 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | tf_inspect.py | 277,059 | 2 | 25 | ismethod | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 10 | 0 | 81,836 | 12 | |
3 | 13 | def get_sales_orders(quotations):
if not quotations:
return []
quotation_names = [q.name for q in quotations]
return frappe.db.sql(
.format(
", ".join(["%s"] * len(quotation_names))
),
tuple(quotation_names),
as_dict=1,
) # nosec
| erpnext/selling/report/territory_wise_sales/territory_wise_sales.py | 98 | erpnext | {
"docstring": "\n\tSELECT so.`name`, so.`base_grand_total`, soi.prevdoc_docname as quotation\n\tFROM `tabSales Order` so, `tabSales Order Item` soi\n\tWHERE so.docstatus=1 AND so.name = soi.parent AND soi.prevdoc_docname in ({0})\n\t",
"language": "en",
"n_whitespaces": 21,
"n_words": 24,
"vocab_size": 21
} | 27 | Python | 26 | 494bd9ef78313436f0424b918f200dab8fc7c20b | territory_wise_sales.py | 67,455 | 15 | 59 | get_sales_orders | https://github.com/frappe/erpnext.git | style: format code with black | 17 | 0 | 14,529 | 14 | |
1 | 25 | def test_bug_13636():
pi, ki, pf = tensor_heads("pi, ki, pf", [LorentzIndex])
i0, i1, i2, i3, i4 = tensor_indices("i0:5", LorentzIndex)
x = Symbol("x")
pis = pi(i2) * G(-i2)
kis = ki(i3) * G(-i3)
pfs = pf(i4) * G(-i4)
a = pfs * G(i0) * kis * G(i1) * pis * G(-i1) * kis * G(-i0)
b = ... | sympy/physics/hep/tests/test_gamma_matrices.py | 416 | sympy | {
"docstring": "Test issue 13636 regarding handling traces of sums of products \n of GammaMatrix mixed with other factors.",
"language": "en",
"n_whitespaces": 19,
"n_words": 16,
"vocab_size": 14
} | 119 | Python | 58 | 83a11729046d30d413b4a8b82512ff765f11e0b5 | test_gamma_matrices.py | 198,989 | 18 | 254 | test_bug_13636 | https://github.com/sympy/sympy.git | Fixes issue #13636 regarding handling traces of sums of products of GammaMatrix mixed with other factors. | 181 | 0 | 49,072 | 15 | |
2 | 7 | def SyncBatchNorm(*args, **kwargs):
if paddle.get_device() == 'cpu':
return nn.BatchNorm2D(*args, **kwargs)
else:
return nn.SyncBatchNorm(*args, **kwargs)
| modules/image/semantic_segmentation/ann_resnet50_cityscapes/layers.py | 74 | PaddleHub | {
"docstring": "In cpu environment nn.SyncBatchNorm does not have kernel so use nn.BatchNorm2D instead",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | 14 | Python | 12 | 1e69d066aa7f762a4b242c0519818577b7222e4c | layers.py | 48,758 | 5 | 43 | SyncBatchNorm | https://github.com/PaddlePaddle/PaddleHub.git | add 10 segmentation model | 37 | 0 | 9,594 | 11 | |
4 | 13 | def bellman_ford_path_length(G, source, target, weight="weight"):
if source == target:
if source not in G:
raise nx.NodeNotFound(f"Node {source} not found in graph")
return 0
weight = _weight_function(G, weight)
length = _bellman_ford(G, [source], weight, target=target)
... | networkx/algorithms/shortest_paths/weighted.py | 138 | networkx | {
"docstring": "Returns the shortest path length from source to target\n in a weighted graph.\n\n Parameters\n ----------\n G : NetworkX graph\n\n source : node label\n starting node for path\n\n target : node label\n ending node for path\n\n weight : string or function (default=\"w... | 49 | Python | 40 | b5d41847b8db0c82372faf69cd3a339d11da7ef0 | weighted.py | 176,294 | 11 | 81 | bellman_ford_path_length | https://github.com/networkx/networkx.git | DOC: Update documentation to include callables for weight argument (#5307)
Update docs to include functions as valid input for weight argument. | 106 | 0 | 41,811 | 13 | |
1 | 23 | def test_in_flight_requests_stop_being_in_flight(self) -> None:
req1 = ensureDeferred(
self.state_datastore._get_state_for_group_using_inflight_cache(
42, StateFilter.all()
)
)
self.pump(by=0.1)
# This should have gone to the database
... | tests/storage/databases/test_state_store.py | 295 | synapse | {
"docstring": "\n Tests that in-flight request deduplication doesn't somehow 'hold on'\n to completed requests: once they're done, they're taken out of the\n in-flight cache.\n ",
"language": "en",
"n_whitespaces": 51,
"n_words": 22,
"vocab_size": 20
} | 88 | Python | 55 | 546b9c9e648f5e2b25bb7c8350570787ff9befae | test_state_store.py | 246,370 | 29 | 186 | test_in_flight_requests_stop_being_in_flight | https://github.com/matrix-org/synapse.git | Add more tests for in-flight state query duplication. (#12033) | 330 | 0 | 71,182 | 12 | |
1 | 5 | def wait_for_handle(self, handle, timeout=None):
return self._wait_for_handle(handle, timeout, False)
| python3.10.4/Lib/asyncio/windows_events.py | 35 | XX-Net | {
"docstring": "Wait for a handle.\n\n Return a Future object. The result of the future is True if the wait\n completed, or False if the wait did not complete (on timeout).\n ",
"language": "en",
"n_whitespaces": 50,
"n_words": 29,
"vocab_size": 24
} | 8 | Python | 8 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | windows_events.py | 220,981 | 2 | 23 | wait_for_handle | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 22 | 0 | 56,179 | 7 | |
2 | 9 | def make_dist(name, version, **kwargs):
summary = kwargs.pop('summary', 'Placeholder for summary')
md = Metadata(**kwargs)
md.name = name
md.version = version
md.summary = summary or 'Placeholder for summary'
return Distribution(md)
| .venv/lib/python3.8/site-packages/pip/_vendor/distlib/database.py | 87 | transferlearning | {
"docstring": "\n A convenience method for making a dist given just a name and version.\n ",
"language": "en",
"n_whitespaces": 20,
"n_words": 13,
"vocab_size": 12
} | 28 | Python | 21 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | database.py | 61,935 | 7 | 50 | make_dist | https://github.com/jindongwang/transferlearning.git | upd; format | 49 | 0 | 12,759 | 9 | |
6 | 44 | def create_posix_inventory(args, path, target_hosts, needs_ssh=False): # type: (EnvironmentConfig, str, t.List[HostProfile], bool) -> None
target_hosts = t.cast(t.List[SshTargetHostProfile], target_hosts)
if len(target_hosts) != 1:
raise Exception()
target_host = target_hosts[0]
if isin... | test/lib/ansible_test/_internal/inventory.py | 365 | ansible | {
"docstring": "Create and return inventory for use in POSIX integration tests.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 94 | Python | 65 | a06fa496d3f837cca3c437ab6e9858525633d147 | inventory.py | 266,784 | 45 | 234 | create_posix_inventory | https://github.com/ansible/ansible.git | ansible-test - Code cleanup and refactoring. (#77169)
* Remove unnecessary PyCharm ignores.
* Ignore intentional undefined attribute usage.
* Add missing type hints. Fix existing type hints.
* Fix docstrings and comments.
* Use function to register completion handler.
* Pass strings to display functions.
* Fix C... | 571 | 0 | 78,587 | 22 | |
11 | 35 | def smart_resize(x, size, interpolation='bilinear'):
if len(size) != 2:
raise ValueError('Expected `size` to be a tuple of 2 integers, '
f'but got: {size}.')
img = tf.convert_to_tensor(x)
if img.shape.rank is not None:
if img.shape.rank < 3 or img.shape.rank > 4:
raise ValueE... | keras/utils/image_utils.py | 646 | keras | {
"docstring": "Resize images to a target size without aspect ratio distortion.\n\n Warning: `tf.keras.preprocessing.image.smart_resize` is not recommended for\n new code. Prefer `tf.keras.layers.Resizing`, which provides the same\n functionality as a preprocessing layer and adds `tf.RaggedTensor` support. See\n ... | 226 | Python | 122 | 9dc9a78cc6502226775a99725c654fab3298aa5f | image_utils.py | 269,108 | 43 | 404 | smart_resize | https://github.com/keras-team/keras.git | Expose all utilities in `keras.utils.__init__.py`, and resolve the hourglass import issues that led to the creation of an extraneous `all_utils.py` file / library.
PiperOrigin-RevId: 435725558 | 360 | 0 | 79,905 | 15 | |
1 | 2 | def test_get_api_representation_calls_same_method_on_fields_with_context(self):
| wagtail/core/tests/test_blocks.py | 13 | wagtail | {
"docstring": "\n The get_api_representation method of a StructBlock should invoke\n the block's get_api_representation method on each field and the\n context should be passed on.\n ",
"language": "en",
"n_whitespaces": 51,
"n_words": 22,
"vocab_size": 18
} | 2 | Python | 2 | d10f15e55806c6944827d801cd9c2d53f5da4186 | test_blocks.py | 74,165 | 17 | 85 | test_get_api_representation_calls_same_method_on_fields_with_context | https://github.com/wagtail/wagtail.git | Reformat with black | 9 | 0 | 16,227 | 6 | |
4 | 11 | def device_class(self) -> BinarySensorDeviceClass | None:
if self._coordinator is None:
return None
if self._sensor_type is PlaatoKeg.Pins.LEAK_DETECTION:
return BinarySensorDeviceClass.PROBLEM
if self._sensor_type is PlaatoKeg.Pins.POURING:
return Bi... | homeassistant/components/plaato/binary_sensor.py | 82 | core | {
"docstring": "Return the class of this device, from BinarySensorDeviceClass.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 26 | Python | 16 | 3393b78e080f2e456337205d5bd1c9d2cd810625 | binary_sensor.py | 310,232 | 9 | 51 | device_class | https://github.com/home-assistant/core.git | Remove plaato from mypy ignore list (#64516)
Co-authored-by: epenet <epenet@users.noreply.github.com> | 94 | 0 | 108,919 | 8 | |
1 | 13 | 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... | mmdet/core/bbox/match_costs/match_cost.py | 146 | mmdetection | {
"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... | 37 | Python | 28 | cac356380d505bf15587f07c0529218cc36b9652 | match_cost.py | 244,031 | 7 | 92 | binary_mask_dice_loss | https://github.com/open-mmlab/mmdetection.git | [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... | 86 | 0 | 70,203 | 11 | |
1 | 2 | def tab_clickable_evt() -> str:
return
| openbb_terminal/jupyter/widget_helpers.py | 20 | OpenBBTerminal | {
"docstring": "Adds javascript code within HTML at the bottom that allows the interactivity with tabs.\n\n Returns\n -------\n str\n javascript code in HTML to process interactive tabs\n \n <script>\n function menu(evt, menu_name) {\n var i, tabcontent, tablinks;\n ... | 5 | Python | 5 | f47e10918a3193c5e0c85981fb769e1b680f5f9d | widget_helpers.py | 284,435 | 33 | 9 | tab_clickable_evt | https://github.com/OpenBB-finance/OpenBBTerminal.git | Simplify way to generate report templates (#1788)
* simplify way to generate report templates
* add documentation
Co-authored-by: James Maslek <jmaslek11@gmail.com> | 12 | 0 | 84,718 | 6 | |
1 | 8 | def register_search(cls):
model = cls.model
label = f'{model._meta.app_label}.{model._meta.model_name}'
registry['search'][label] = cls
return cls
| netbox/netbox/search/__init__.py | 66 | netbox | {
"docstring": "\n Decorator for registering a SearchIndex class.\n ",
"language": "en",
"n_whitespaces": 13,
"n_words": 6,
"vocab_size": 6
} | 13 | Python | 10 | 9628dead07ccef9608b32906aa8194bc948e5a09 | __init__.py | 265,888 | 5 | 26 | register_search | https://github.com/netbox-community/netbox.git | Closes #10560: New global search (#10676)
* Initial work on new search backend
* Clean up search backends
* Return only the most relevant result per object
* Clear any pre-existing cached entries on cache()
* #6003: Implement global search functionality for custom field values
* Tweak field weights & do... | 28 | 0 | 78,228 | 10 | |
1 | 5 | def increment_iterations(self) -> None:
self._iterations += 1
self._sessions[self._session_id]["iterations"] += 1
| plugins/train/model/_base/model.py | 45 | faceswap | {
"docstring": " Increment :attr:`iterations` and session iterations by 1. ",
"language": "en",
"n_whitespaces": 8,
"n_words": 7,
"vocab_size": 7
} | 10 | Python | 8 | ff6b0209dd5ad57b81b0aca570df7f39a7119bfb | model.py | 100,841 | 4 | 26 | increment_iterations | https://github.com/deepfakes/faceswap.git | Refactoring and TravisCI to Github Actions (#1239)
* refactor training
* travis to actions | 31 | 0 | 20,292 | 9 | |
1 | 3 | def slice_tensors(data, tensor_slice):
| src/accelerate/utils.py | 15 | accelerate | {
"docstring": "\n Recursively takes a slice in a nested list/tuple/dictionary of tensors.\n\n Args:\n data (nested list/tuple/dictionary of `torch.Tensor`):\n The data to slice.\n tensor_slice (`slice`):\n The slice to take.\n\n Returns:\n The same data structure a... | 3 | Python | 3 | fb5ed62c102c0323486b89805e1888495de3db15 | utils.py | 337,294 | 3 | 19 | slice_tensors | https://github.com/huggingface/accelerate.git | Convert documentation to the new front (#271)
* Main conversion
* Doc styling
* Style
* New front deploy
* Fixes
* Fixes
* Fix new docstrings
* Style | 6 | 0 | 121,008 | 6 | |
1 | 7 | def get_metric(self):
metrics = combine_results(self.results, rec_flag=False)
self.reset()
return metrics
| ppocr/metrics/ct_metric.py | 44 | PaddleOCR | {
"docstring": "\n Input format: y0,x0, ..... yn,xn. Each detection is separated by the end of line token ('\\n')'\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 16,
"vocab_size": 16
} | 9 | Python | 8 | b5268dc3a0847dce2668265e07ff50d54265b2d8 | ct_metric.py | 25,044 | 4 | 25 | get_metric | https://github.com/PaddlePaddle/PaddleOCR.git | add centripetal text model | 37 | 0 | 4,849 | 9 | |
1 | 7 | def database_forwards(self, app_label, schema_editor, from_state, to_state):
raise NotImplementedError(
"subclasses of Operation must provide a database_forwards() method"
)
| django/db/migrations/operations/base.py | 31 | django | {
"docstring": "\n Perform the mutation on the database schema in the normal\n (forwards) direction.\n ",
"language": "en",
"n_whitespaces": 34,
"n_words": 12,
"vocab_size": 10
} | 17 | Python | 17 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | base.py | 205,316 | 4 | 19 | database_forwards | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 49 | 0 | 51,091 | 8 | |
3 | 6 | def asList(self):
return [res.asList() if isinstance(res, ParseResults) else res for res in self.__toklist]
| .venv/lib/python3.8/site-packages/pip/_vendor/pyparsing.py | 46 | transferlearning | {
"docstring": "\n Returns the parse results as a nested list of matching tokens, all converted to strings.\n\n Example::\n\n patt = OneOrMore(Word(alphas))\n result = patt.parseString(\"sldkj lsdkj sldkj\")\n # even though the result prints in string-like form, it is ac... | 13 | Python | 12 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | pyparsing.py | 63,303 | 2 | 29 | asList | https://github.com/jindongwang/transferlearning.git | upd; format | 27 | 0 | 13,240 | 9 | |
2 | 20 | def _load(self, config_changeable_items):
logger.debug("Loading State")
if not os.path.exists(self._filename):
logger.info("No existing state file found. Generating.")
return
state = self._serializer.load(self._filename)
self._name = state.get("name", sel... | plugins/train/model/_base.py | 214 | faceswap | {
"docstring": " Load a state file and set the serialized values to the class instance.\n\n Updates the model's config with the values stored in the state file.\n\n Parameters\n ----------\n config_changeable_items: dict\n Configuration options that can be altered when resuming ... | 43 | Python | 35 | c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf | _base.py | 100,383 | 13 | 125 | _load | https://github.com/deepfakes/faceswap.git | Update code to support Tensorflow versions up to 2.8 (#1213)
* Update maximum tf version in setup + requirements
* - bump max version of tf version in launcher
- standardise tf version check
* update keras get_custom_objects for tf>2.6
* bugfix: force black text in GUI file dialogs (linux)
* dssim loss -... | 142 | 0 | 19,869 | 10 | |
1 | 18 | def _roots_with_zeros(p, num_leading_zeros):
# Avoid lapack errors when p is all zero
p = _where(len(p) == num_leading_zeros, 1.0, p)
# Roll any leading zeros to the end & compute the roots
roots = _roots_no_zeros(roll(p, -num_leading_zeros))
# Sort zero roots to the end.
roots = lax.sort_key_val(roots == 0... | jax/_src/numpy/polynomial.py | 147 | @_wraps(np.roots, lax_description="""\
Unlike the numpy version of this function, the JAX version returns the roots in
a complex array regardless of the values of the roots. Additionally, the jax
version of this function adds the ``strip_zeros`` function which must be set to
False for the function to be compatible with... | jax | {
"docstring": "\\\nUnlike the numpy version of this function, the JAX version returns the roots in\na complex array regardless of the values of the roots. Additionally, the jax\nversion of this function adds the ``strip_zeros`` function which must be set to\nFalse for the function to be compatible with JIT and other... | 68 | Python | 51 | f6476f7a03f8390627c1a8e2a2ec8702d8a320e5 | polynomial.py | 121,009 | 5 | 80 | _roots_with_zeros | https://github.com/google/jax.git | jnp.roots: better support for computation under JIT | 73 | 1 | 27,011 | 11 |
1 | 11 | def test_config_overrides_environ(self):
config = {"caches": {"per_cache_factors": {"foo": 2, "bar": 3}}}
self.config._environ = {
"SYNAPSE_CACHE_FACTOR_SOMETHING_OR_OTHER": "2",
"SYNAPSE_CACHE_FACTOR_FOO": 1,
}
self.config.read_config(config, config_dir_... | tests/config/test_cache.py | 163 | synapse | {
"docstring": "\n Individual cache factors defined in the environment will take precedence\n over those in the config.\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 13
} | 31 | Python | 28 | d38d242411b8910dfacde1e61fd3a0ec5cbcaa66 | test_cache.py | 248,246 | 12 | 98 | test_config_overrides_environ | https://github.com/matrix-org/synapse.git | Reload cache factors from disk on SIGHUP (#12673) | 131 | 0 | 72,177 | 13 | |
1 | 3 | def test_issue_5131(monkeypatch, tmpdir):
| tests/functional/test_regression.py | 15 | pyinstaller | {
"docstring": "\n While fixing the endless recursion when the package's __init__ module is an extension (see\n tests/unit/test_modulegraph_more.py::package_init_is_extension_*), another error occurred:\n PyInstaller.building._utils._load_code() tried to complete the source code for extension module - trigge... | 3 | Python | 3 | 1a7d704ffbabb433007e3ba04750c2f13ade48e5 | test_regression.py | 262,858 | 25 | 194 | test_issue_5131 | https://github.com/pyinstaller/pyinstaller.git | Fix typos (#6782) [skip ci] | 6 | 0 | 77,409 | 6 | |
11 | 22 | def update_billed_amount_based_on_so(so_detail, update_modified=True):
# Billed against Sales Order directly
billed_against_so = frappe.db.sql(, so_detail)
billed_against_so = billed_against_so and billed_against_so[0][0] or 0
# Get all Delivery Note Item rows against the Sales Order Item row
dn_details = frappe.... | erpnext/stock/doctype/delivery_note/delivery_note.py | 331 | erpnext | {
"docstring": "select sum(si_item.amount)\n\t\tfrom `tabSales Invoice Item` si_item, `tabSales Invoice` si\n\t\twhere\n\t\t\tsi_item.parent = si.name\n\t\t\tand si_item.so_detail=%s\n\t\t\tand (si_item.dn_detail is null or si_item.dn_detail = '')\n\t\t\tand si_item.docstatus=1\n\t\t\tand si.update_stock = 0\n\t\tsel... | 145 | Python | 75 | b50036c04a116b2a3aa1784daf161a2f618765a8 | delivery_note.py | 64,240 | 44 | 205 | update_billed_amount_based_on_so | https://github.com/frappe/erpnext.git | fix: consider returned_qty while updating billed_amt
(cherry picked from commit 63aaa1e357280b24c537a502a479f7bb7a6654e4) | 112 | 0 | 13,584 | 17 | |
5 | 16 | def parse_apps_and_model_labels(labels):
apps = set()
models = set()
for label in labels:
if "." in label:
try:
model = installed_apps.get_model(label)
except LookupError:
raise CommandError("Unknown model: %s" % label)
models... | django/core/management/utils.py | 152 | django | {
"docstring": "\n Parse a list of \"app_label.ModelName\" or \"app_label\" strings into actual\n objects and return a two-element tuple:\n (set of model classes, set of app_configs).\n Raise a CommandError if some specified models or apps don't exist.\n ",
"language": "en",
"n_whitespaces": 54... | 44 | Python | 35 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | utils.py | 204,726 | 17 | 87 | parse_apps_and_model_labels | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 199 | 0 | 50,857 | 17 | |
1 | 20 | def test_double_stamping(self, subtests):
self.app.conf.task_always_eager = True
self.app.conf.task_store_eager_result = True
self.app.conf.result_extended = True
sig_1 = self.add.s(2, 2)
sig_1.stamp(stamp1="stamp1")
sig_1.stamp(stamp2="stamp2")
sig_1_re... | t/unit/tasks/test_canvas.py | 291 | celery | {
"docstring": "\n Test manual signature stamping with two different stamps.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 8
} | 57 | Python | 37 | 1c4ff33bd22cf94e297bd6449a06b5a30c2c1fbc | test_canvas.py | 208,123 | 15 | 162 | test_double_stamping | https://github.com/celery/celery.git | Canvas Header Stamping (#7384)
* Strip down the header-stamping PR to the basics.
* Serialize groups.
* Add groups to result backend meta data.
* Fix spelling mistake.
* Revert changes to canvas.py
* Revert changes to app/base.py
* Add stamping implementation to canvas.py
* Send task to AMQP with ... | 174 | 0 | 52,214 | 12 | |
1 | 13 | def deform_sampling(self, feat, offset):
# it is an equivalent implementation of bilinear interpolation
b, c, h, w = feat.shape
weight = feat.new_ones(c, 1, 1, 1)
y = deform_conv2d(feat, offset, weight, 1, 0, 1, c, c)
return y
| mmdet/models/dense_heads/tood_head.py | 79 | mmdetection | {
"docstring": "Sampling the feature x according to offset.\n\n Args:\n feat (Tensor): Feature\n offset (Tensor): Spatial offset for feature sampling\n ",
"language": "en",
"n_whitespaces": 54,
"n_words": 18,
"vocab_size": 15
} | 37 | Python | 30 | b403751bd409795cf63fcc6aa7ee280326358bac | tood_head.py | 244,173 | 5 | 57 | deform_sampling | https://github.com/open-mmlab/mmdetection.git | [Fix] Avoid invalid bbox after deform_sampling (#7567)
* Avoid invalid bbox after deform_sampling
* replace in-place opertion with torch.where, update docstring
* Update | 79 | 0 | 70,270 | 8 | |
1 | 8 | def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self):
config_dict = default_config("test")
# First test all the error conditions
with self.assertRaises(ConfigError):
HomeServerConfig().parse_config_dict(
{
"session_li... | tests/config/test_registration_config.py | 353 | synapse | {
"docstring": "\n session_lifetime should logically be larger than, or at least as large as,\n all the different token lifetimes.\n Test that the user is faced with configuration errors if they make it\n smaller, as that configuration doesn't make sense.\n ",
"language": "en",
... | 89 | Python | 30 | 4586119f0b0901be64f08655d3aaaef289a51bde | test_registration_config.py | 248,006 | 55 | 185 | test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes | https://github.com/matrix-org/synapse.git | Add missing type hints to config classes. (#12402) | 808 | 0 | 72,044 | 12 | |
3 | 13 | def getlist(self, key, default=__marker):
try:
vals = self._container[key.lower()]
except KeyError:
if default is self.__marker:
return []
return default
else:
return vals[1:]
# Backwards compatibility for httplib
... | .venv/lib/python3.8/site-packages/pip/_vendor/urllib3/_collections.py | 102 | transferlearning | {
"docstring": "Returns a list of all the values for the named field. Returns an\n empty list if the key doesn't exist.",
"language": "en",
"n_whitespaces": 26,
"n_words": 20,
"vocab_size": 16
} | 43 | Python | 29 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | _collections.py | 63,909 | 9 | 49 | getlist | https://github.com/jindongwang/transferlearning.git | upd; format | 148 | 0 | 13,528 | 11 | |
4 | 18 | def _set_train_queue(self):
current_pairlist = self.config.get("exchange", {}).get("pair_whitelist")
if not self.dd.pair_dict:
logger.info('Set fresh train queue from whitelist.')
return deque(current_pairlist)
best_queue = deque()
pair_dict_sorted = so... | freqtrade/freqai/freqai_interface.py | 180 | freqtrade | {
"docstring": "\n Sets train queue from existing train timestamps if they exist\n otherwise it sets the train queue based on the provided whitelist.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 21,
"vocab_size": 17
} | 60 | Python | 49 | eaa43337d2d7c13eeeb8c809d212e047f5935470 | freqai_interface.py | 151,215 | 13 | 105 | _set_train_queue | https://github.com/freqtrade/freqtrade.git | improve train queue system, ensure crash resilience in train queue. | 203 | 0 | 34,978 | 12 | |
4 | 9 | def duplicates_removed(it, already_seen=()):
lst = []
seen = set()
for i in it:
if i in seen or i in already_seen:
continue
lst.append(i)
seen.add(i)
return lst
| pipenv/patched/notpip/_vendor/pygments/util.py | 82 | pipenv | {
"docstring": "\n Returns a list with duplicates removed from the iterable `it`.\n\n Order is preserved.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 13,
"vocab_size": 13
} | 26 | Python | 19 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | util.py | 20,522 | 14 | 49 | duplicates_removed | https://github.com/pypa/pipenv.git | 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... | 73 | 0 | 3,409 | 9 | |
1 | 12 | def test_success_urlencoded(self) -> None:
url = "/_synapse/admin/v1/auth_providers/another-auth-provider/users/a%3Acomplex%40external%2Fid"
channel = self.make_request(
"GET",
url,
access_token=self.admin_user_tok,
)
self.assertEqual(200, c... | tests/rest/admin/test_user.py | 99 | synapse | {
"docstring": "Tests a successful external ID lookup with an url-encoded ID",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | 22 | Python | 20 | 74f60cec92c5aff87d6e74d177e95ec5f1a69f2b | test_user.py | 249,499 | 13 | 61 | test_success_urlencoded | https://github.com/matrix-org/synapse.git | Add an admin API endpoint to find a user based on its external ID in an auth provider. (#13810) | 126 | 0 | 72,954 | 10 | |
1 | 12 | def get_base_context(self) -> MutableMapping[str, Any]:
return {
"data": self.activity.data,
"author": self.activity.user,
"title": self.title,
"project": self.project,
"project_link": self.get_project_link(),
**super().get_base_co... | src/sentry/notifications/notifications/activity/base.py | 102 | sentry | {
"docstring": "The most basic context shared by every notification type.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 19 | Python | 19 | 25469e1e30a717637456d6ab470bdd28864be301 | base.py | 99,100 | 10 | 61 | get_base_context | https://github.com/getsentry/sentry.git | ref(notifications): Remove `get_activity_name()` (#34061) | 106 | 0 | 19,615 | 11 | |
2 | 10 | def tracing_client_interceptor(self) -> Optional['OpenTelemetryClientInterceptor']:
if self.tracing:
from opentelemetry.instrumentation.grpc import (
client_interceptor as grpc_client_interceptor,
)
return grpc_client_interceptor(self.tracer_provider... | jina/serve/instrumentation/__init__.py | 65 | jina | {
"docstring": "\n :returns: a gRPC client interceptor with the global tracing provider.\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 10
} | 19 | Python | 18 | 107631e955b21db8a4ddb3bee02130de3650d032 | __init__.py | 13,242 | 11 | 40 | tracing_client_interceptor | https://github.com/jina-ai/jina.git | feat(instrumentation): add OpenTelemetry tracing and metrics with basic configurations (#5175) | 99 | 0 | 2,578 | 10 | |
1 | 17 | def test_readonly_manytomany_backwards_ref(self):
topping = Topping.objects.create(name="Salami")
pizza = Pizza.objects.create(name="Americano")
pizza.toppings.add(topping)
response = self.client.get(reverse("admin:admin_views_topping_add"))
self.assertEqual(response.sta... | tests/admin_views/tests.py | 106 | django | {
"docstring": "\n Regression test for #16433 - backwards references for related objects\n broke if the related field is read-only due to the help_text attribute\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 22,
"vocab_size": 19
} | 14 | Python | 12 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 207,855 | 6 | 61 | test_readonly_manytomany_backwards_ref | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 56 | 0 | 52,136 | 11 | |
16 | 37 | def transform(self) -> DataFrame | Series:
obj = self.obj
func = self.orig_f
axis = self.axis
args = self.args
kwargs = self.kwargs
is_series = obj.ndim == 1
if obj._get_axis_number(axis) == 1:
assert not is_series
return obj.T.t... | pandas/core/apply.py | 400 | pandas | {
"docstring": "\n Transform a DataFrame or Series.\n\n Returns\n -------\n DataFrame or Series\n Result of applying ``func`` along the given axis of the\n Series or DataFrame.\n\n Raises\n ------\n ValueError\n If the transform functio... | 182 | Python | 115 | 7440fe27eef0aab0f217ca9fb434f1e3ac74836e | apply.py | 167,120 | 51 | 246 | transform | https://github.com/pandas-dev/pandas.git | TYP: setter for index/columns property-like (AxisProperty) (#46565)
Co-authored-by: Matthew Roeschke <emailformattr@gmail.com> | 582 | 0 | 39,941 | 15 | |
9 | 17 | async def acquire(self):
if (not self._locked and (self._waiters is None or
all(w.cancelled() for w in self._waiters))):
self._locked = True
return True
if self._waiters is None:
self._waiters = collections.deque()
fut = self._get_loo... | python3.10.4/Lib/asyncio/locks.py | 203 | XX-Net | {
"docstring": "Acquire a lock.\n\n This method blocks until the lock is unlocked, then sets it to\n locked and returns True.\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 19,
"vocab_size": 19
} | 76 | Python | 56 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | locks.py | 220,550 | 20 | 119 | acquire | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 297 | 0 | 56,049 | 13 | |
35 | 69 | def canonicalize(g, dummies, msym, *v):
from sympy.combinatorics.testutil import canonicalize_naive
if not isinstance(msym, list):
if msym not in (0, 1, None):
raise ValueError('msym must be 0, 1 or None')
num_types = 1
else:
num_types = len(msym)
if not all(... | sympy/combinatorics/tensor_can.py | 980 | sympy | {
"docstring": "\n canonicalize tensor formed by tensors\n\n Parameters\n ==========\n\n g : permutation representing the tensor\n\n dummies : list representing the dummy indices\n it can be a list of dummy indices of the same type\n or a list of lists of dummy indices, one list for each\n ... | 523 | Python | 243 | 7d773eb18daaef3c54f34d1ac6cbc5b83a5bb16c | tensor_can.py | 198,366 | 76 | 638 | canonicalize | https://github.com/sympy/sympy.git | Cleanup loops and ranges | 1,079 | 0 | 48,885 | 17 | |
1 | 7 | def test_set_presence_with_status_msg_none(self) -> None:
user_id = "@test:server"
status_msg = "I'm here!"
# Mark user as online
self._set_presencestate_with_status_msg(
user_id, PresenceState.ONLINE, status_msg
)
# Mark user as online and `status_... | tests/handlers/test_presence.py | 66 | synapse | {
"docstring": "Test that if a user set again the presence manually\n and status is `None`, that `status_msg` is `None`.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 18,
"vocab_size": 16
} | 33 | Python | 24 | 652d1669c5a103b1c20478770c4aaf18849c09a3 | test_presence.py | 250,369 | 10 | 38 | test_set_presence_with_status_msg_none | https://github.com/matrix-org/synapse.git | Add missing type hints to tests.handlers. (#14680)
And do not allow untyped defs in tests.handlers. | 100 | 0 | 73,405 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.