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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 10 | def test_page_with_og(self) -> None:
html = b
parser = OpenGraphParser(html, "text/html; charset=UTF-8")
result = parser.extract_data()
self.assertEqual(result.title, "The Rock")
self.assertEqual(result.description, "The Rock film")
| zerver/tests/test_link_embed.py | 79 | zulip | {
"docstring": "<html>\n <head>\n <meta property=\"og:title\" content=\"The Rock\" />\n <meta property=\"og:type\" content=\"video.movie\" />\n <meta property=\"og:url\" content=\"http://www.imdb.com/title/tt0117500/\" />\n <meta property=\"og:image\" content=\"http://ia.m... | 22 | Python | 19 | 327ff9ea0f5e4712a34d767fee55a549cc1d3f39 | test_link_embed.py | 83,638 | 14 | 46 | test_page_with_og | https://github.com/zulip/zulip.git | preview: Use a dataclass for the embed data.
This is significantly cleaner than passing around `Dict[str, Any]` all
of the time. | 56 | 0 | 17,698 | 9 | |
1 | 4 | def upgrade():
op.create_index('idx_log_event', 'log', ['event'], unique=False)
| airflow/migrations/versions/0109_1de7bc13c950_add_index_for_event_in_log.py | 40 | airflow | {
"docstring": "Apply Add index for ``event`` column in ``log`` table.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 6 | Python | 6 | 5d8cda8c5be42c8daaaa904d29a1011833c0c699 | 0109_1de7bc13c950_add_index_for_event_in_log.py | 48,280 | 2 | 21 | upgrade | https://github.com/apache/airflow.git | Add index for event column in log table (#23625) | 12 | 0 | 9,421 | 9 | |
2 | 6 | def get_fields(self, include_parents=True, include_hidden=False):
if include_parents is False:
include_parents = PROXY_PARENTS
return self._get_fields(
include_parents=include_parents, include_hidden=include_hidden
)
| django/db/models/options.py | 55 | django | {
"docstring": "\n Return a list of fields associated to the model. By default, include\n forward and reverse fields, fields derived from inheritance, but not\n hidden fields. The returned fields can be changed using the parameters:\n\n - include_parents: include fields derived from inheri... | 16 | Python | 15 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | options.py | 205,717 | 6 | 35 | get_fields | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 66 | 0 | 51,174 | 8 | |
1 | 5 | def test_location_present(self):
response = self.get(4)
self.assertContains(response, "The North Pole", 1)
| wagtail/contrib/modeladmin/tests/test_page_modeladmin.py | 42 | wagtail | {
"docstring": "\n The location should appear once, in the field listing\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | 10 | Python | 10 | d10f15e55806c6944827d801cd9c2d53f5da4186 | test_page_modeladmin.py | 73,205 | 3 | 24 | test_location_present | https://github.com/wagtail/wagtail.git | Reformat with black | 31 | 0 | 15,989 | 8 | |
1 | 5 | def _patch_hf_hub_tqdm():
old_tqdm = huggingface_hub.file_download.tqdm
huggingface_hub.file_download.tqdm = tqdm
yield
huggingface_hub.file_download.tqdm = old_tqdm
| src/transformers/utils/hub.py | 48 | transformers | {
"docstring": "\n A context manager to make huggingface hub use the tqdm version of Transformers (which is controlled by some utils)\n in logging.\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 21,
"vocab_size": 21
} | 12 | Python | 7 | 5cd40323684c183c30b34758aea1e877996a7ac9 | hub.py | 32,820 | 5 | 27 | _patch_hf_hub_tqdm | https://github.com/huggingface/transformers.git | Use new huggingface_hub tools for download models (#18438)
* Draft new cached_file
* Initial draft for config and model
* Small fixes
* Fix first batch of tests
* Look in cache when internet is down
* Fix last tests
* Bad black, not fixing all quality errors
* Make diff less
* Implement change ... | 27 | 0 | 5,987 | 8 | |
2 | 16 | def test_failed_execution(self, api, started_job, batch):
jobs = [started_job for _ in range(49)]
batch.execute.side_effect = [batch, batch, None]
update_in_batch(api=api, jobs=jobs)
assert started_job.update_job.call_count == 49
assert len(api.new_batch.return_value) ... | airbyte-integrations/connectors/source-facebook-marketing/unit_tests/test_async_job.py | 111 | airbyte | {
"docstring": "Should execute batch until there are no failed tasks",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 31 | Python | 25 | a3aae8017a0a40ff2006e2567f71dccb04c997a5 | test_async_job.py | 3,777 | 7 | 74 | test_failed_execution | https://github.com/airbytehq/airbyte.git | ๐ ๐ Source FB Marketing: performance and reliability fixes (#9805)
* Facebook Marketing performance improvement
* add comments and little refactoring
* fix integration tests with the new config
* improve job status handling, limit concurrency to 10
* fix campaign jobs, refactor manager
* big refactori... | 80 | 0 | 559 | 10 | |
1 | 45 | async def test_logbook_entity_matches_only_multiple(hass, hass_client, recorder_mock):
await async_setup_component(hass, "logbook", {})
assert await async_setup_component(
hass,
"switch",
{
"switch": {
"platform": "template",
"switches": {... | tests/components/logbook/test_init.py | 680 | core | {
"docstring": "Test the logbook view with a multiple entities and entity_matches_only.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 174 | Python | 100 | 982e314de630de2fe8e379b6f1106ec9fa945335 | test_init.py | 298,435 | 62 | 381 | test_logbook_entity_matches_only_multiple | https://github.com/home-assistant/core.git | Use recorder_mock in tests (#70363)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com> | 684 | 0 | 97,379 | 19 | |
3 | 1 | async def test_gather_is_robust_with_return_types_that_break_equality_checks():
| tests/utilities/test_asyncio.py | 13 | prefect | {
"docstring": "\n Some libraries like pandas override the equality operator and can fail if gather\n performs an __eq__ check with the GatherIncomplete type\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 21,
"vocab_size": 20
} | 3 | Python | 3 | cfe630e97a5942c285b25d3bea5f1a7a47c4d9c5 | test_asyncio.py | 54,599 | 7 | 54 | test_gather_is_robust_with_return_types_that_break_equality_checks | https://github.com/PrefectHQ/prefect.git | Fix issue where gather can fail when a task returns a pandas object | 6 | 0 | 11,107 | 6 | |
1 | 3 | def _valuechoice_staticmethod_helper(orig_func):
orig_func.__doc__ +=
return orig_func
| nni/retiarii/nn/pytorch/api.py | 22 | nni | {
"docstring": "\n Notes\n -----\n This function performs lazy evaluation.\n Only the expression will be recorded when the function is called.\n The real evaluation happens when the inner value choice has determined its final decision.\n If no value choice is contained in the... | 6 | Python | 6 | a36dc07e8d39ec4438fd660c98f6f4551ff5f4a6 | api.py | 111,722 | 9 | 12 | _valuechoice_staticmethod_helper | https://github.com/microsoft/nni.git | Composition of `ValueChoice` (#4435) | 12 | 0 | 24,473 | 7 | |
3 | 9 | def get_buttons_from_dialog(dialog, channel):
buttons = None
if channel == "Follow":
# get follow buttons. This approach will find the follow buttons and
# ignore the Unfollow/Requested buttons.
buttons = dialog.find_elements(
By.XPATH, read_xpath(get_buttons_from_dial... | instapy/unfollow_util.py | 105 | InstaPy | {
"docstring": "Gets buttons from the `Followers` or `Following` dialog boxes",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 47 | Python | 31 | 2a157d452611d37cf50ccb7d56ff1a06e9790ecb | unfollow_util.py | 5,815 | 11 | 61 | get_buttons_from_dialog | https://github.com/InstaPy/InstaPy.git | PR - Fix `extract_text_from_element()`and `find_element*()` to `find_element()` (#6438)
* Updated getUserData() and find_element*
Signed-off-by: elulcao <elulcao@icloud.com>
Thanks @breuerfelix for reviewing, ๐
People in this thread please let me know if something is not OK, IG changed a lot these days. ๐ค @her | 126 | 0 | 838 | 14 | |
1 | 3 | def circumcenter(self):
return self.center
| sympy/geometry/polygon.py | 19 | sympy | {
"docstring": "\n Alias for center.\n\n Examples\n ========\n\n >>> from sympy import RegularPolygon, Point\n >>> rp = RegularPolygon(Point(0, 0), 5, 4)\n >>> rp.circumcenter\n Point2D(0, 0)\n ",
"language": "en",
"n_whitespaces": 79,
"n_words": 22,
"vo... | 4 | Python | 4 | 498015021131af4dbb07eb110e5badaba8250c7b | polygon.py | 196,293 | 2 | 10 | circumcenter | https://github.com/sympy/sympy.git | Updated import locations | 18 | 0 | 47,793 | 6 | |
15 | 18 | def is_maximal_matching(G, matching):
if isinstance(matching, dict):
matching = matching_dict_to_set(matching)
# If the given set is not a matching, then it is not a maximal matching.
edges = set()
nodes = set()
for edge in matching:
if len(edge) != 2:
raise nx.Netwo... | networkx/algorithms/matching.py | 276 | networkx | {
"docstring": "Return True if ``matching`` is a maximal matching of ``G``\n\n A *maximal matching* in a graph is a matching in which adding any\n edge would cause the set to no longer be a valid matching.\n\n Parameters\n ----------\n G : NetworkX graph\n\n matching : dict or set\n A diction... | 169 | Python | 84 | 28b3014d68d2b4e40d3e02219770296a827bd55c | matching.py | 176,371 | 25 | 168 | is_maximal_matching | https://github.com/networkx/networkx.git | Update matching functions for error validation and speed (#4897)
* First steps to update matching functions for #4644
Expand tests
Change API to raise NetworkXError when matching involves nodes not in G
Update is_*_matching to 100+ times faster.
* improve matching_dict_to_set and docs for min_weight_matching
... | 371 | 0 | 41,857 | 13 | |
4 | 8 | def uri(self) -> Optional[str]:
if self._uri:
return self._uri
if self._local_path and Path(self._local_path).exists():
return "file://" + self._local_path
return None
| python/ray/air/checkpoint.py | 74 | ray | {
"docstring": "Return checkpoint URI, if available.\n\n This will return a URI to cloud storage if this checkpoint is\n persisted on cloud, or a local ``file://`` URI if this checkpoint\n is persisted on local disk and available on the current node.\n\n In all other cases, this will retur... | 18 | Python | 14 | 1dede1c296a29332171df87b31d9ba92c26b40f7 | checkpoint.py | 128,028 | 29 | 44 | uri | https://github.com/ray-project/ray.git | [air] Add `Checkpoint.uri` to return checkpoint URI, if available (#28731)
A common ask is to retrieve the URI of a cloud checkpoint, e.g. after training. This PR introduces a property to the `Checkpoint` class that will return a URI if available and reachable from the local node (i.e. cloud storage or locally availab... | 68 | 0 | 28,588 | 11 | |
40 | 14 | def nD(i=None, brute=None, *, n=None, m=None):
from sympy.integrals.integrals import integrate
from sympy.functions.special.polynomials import laguerre
from sympy.abc import x | sympy/functions/combinatorial/numbers.py | 67 | sympy | {
"docstring": "return the number of derangements for: ``n`` unique items, ``i``\n items (as a sequence or multiset), or multiplicities, ``m`` given\n as a sequence or multiset.\n\n Examples\n ========\n\n >>> from sympy.utilities.iterables import generate_derangements as enum\n >>> from sympy.funct... | 18 | Python | 14 | e0dc14eca132f37c5f49369eb4051eae37c9b119 | numbers.py | 197,011 | 67 | 562 | nD | https://github.com/sympy/sympy.git | Refactored import ordering in functions | 30 | 0 | 48,287 | 6 | |
2 | 6 | def _temperature_unit(self) -> str:
if (
weather_option_temperature_unit := self._weather_option_temperature_unit
) is not None:
return weather_option_temperature_unit
return self._default_temperature_unit
| homeassistant/components/weather/__init__.py | 43 | core | {
"docstring": "Return the converted unit of measurement for temperature.\n\n Should not be set by integrations.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 14,
"vocab_size": 14
} | 17 | Python | 15 | 90e1fb6ce2faadb9a35fdbe1774fce7b4456364f | __init__.py | 314,204 | 10 | 26 | _temperature_unit | https://github.com/home-assistant/core.git | Weather unit conversion (#73441)
Co-authored-by: Erik <erik@montnemery.com> | 67 | 0 | 112,812 | 9 | |
1 | 7 | def set_potential_energy(self, scalar):
sympy_deprecation_warning(
,
deprecated_since_version="1.5",
active_deprecations_target="deprecated-set-potential-energy",
)
self.potential_energy = scalar
| sympy/physics/mechanics/particle.py | 43 | sympy | {
"docstring": "\nThe sympy.physics.mechanics.Particle.set_potential_energy()\nmethod is deprecated. Instead use\n\n P.potential_energy = scalar\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 10,
"vocab_size": 10
} | 11 | Python | 11 | 807ed058b5804382971f0045fa1395f087ff12cb | particle.py | 197,090 | 12 | 25 | set_potential_energy | https://github.com/sympy/sympy.git | Update the set_potential_energy() deprecation | 56 | 0 | 48,332 | 9 | |
1 | 3 | def verify_request_params(params, headers):
| tests/sentry/middleware/test_api_gateway.py | 15 | sentry | {
"docstring": "Wrapper for a callback function for responses.add_callback",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 6
} | 3 | Python | 3 | ec6965d597186ae0ecfba786472154f1c3cb7e42 | test_api_gateway.py | 86,320 | 3 | 12 | verify_request_params | https://github.com/getsentry/sentry.git | feat(api-gateway): Unit test helpers (#39424)
These functions will help with the creation of new test cases for the
API gateway | 6 | 0 | 18,100 | 6 | |
5 | 2 | def id(self):
# type: () -> str
| pipenv/patched/notpip/_vendor/distro.py | 14 | pipenv | {
"docstring": "Return the distro ID of the OS distribution, as a string.\n\n For details, see :func:`distro.id`.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 15,
"vocab_size": 14
} | 7 | Python | 7 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | distro.py | 20,041 | 15 | 82 | id | 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... | 21 | 0 | 3,190 | 6 | |
2 | 13 | def test_boolean_constraints(self):
for field in (BooleanField(), BooleanField(null=True)):
with self.subTest(field=field):
field.set_attributes_from_name("is_nice")
self.assertIn('"IS_NICE" IN (0,1)', field.db_check(connection))
@unittest.skipUnless(connec... | tests/backends/oracle/tests.py | 113 | @unittest.skipUnless(connection.vendor == "oracle", "Oracle tests") | django | {
"docstring": "Boolean fields have check constraints on their values.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 19 | Python | 19 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 201,726 | 5 | 51 | test_boolean_constraints | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 73 | 1 | 49,982 | 13 |
2 | 8 | def on_predict_batch_begin(self, batch, logs=None):
if self._should_call_predict_batch_hooks:
self._call_batch_hook(ModeKeys.PREDICT, "begin", batch, logs=logs)
| keras/callbacks.py | 52 | keras | {
"docstring": "Calls the `on_predict_batch_begin` methods of its callbacks.\n\n Args:\n batch: Integer, index of batch within the current epoch.\n logs: Dict, contains the return value of `model.predict_step`,\n it typically returns a dict with a key 'outputs' containing\n ... | 10 | Python | 9 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | callbacks.py | 269,911 | 3 | 33 | on_predict_batch_begin | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 35 | 0 | 80,325 | 10 | |
5 | 31 | def test_version_managing(self, data_handler):
# set up
df = pd.DataFrame([
{'a': 1, 'b': dt.datetime(2020, 1, 1)},
{'a': 2, 'b': dt.datetime(2020, 1, 2)},
{'a': 1, 'b': dt.datetime(2020, 1, 3)},
])
self.set_handler(data_handler, name='pg', tables={'t... | tests/unit/test_project_structure.py | 1,293 | mindsdb | {
"docstring": "\n CREATE PREDICTOR proj.task_model\n from pg (select * from tasks)\n PREDICT a\n using engine='dummy_ml', tag = 'first'\n \n SELECT m.*\n FROM pg.tasks as t\n JOIN proj.task_model as m\n ... | 536 | Python | 173 | 3f1a5c30c2ccbd78b21f1f41b7dfdfca87bb7135 | test_project_structure.py | 117,547 | 130 | 716 | test_version_managing | https://github.com/mindsdb/mindsdb.git | update and delete model version
renaming (predictor->model) | 1,445 | 0 | 26,025 | 13 | |
3 | 18 | def _compute_interactions(self, node):
r
# Note:
# - Case of no interactions is already captured before function call.
# - This is for nodes that are already split and have a
# node.split_info.feature_idx.
allowed_features = set()
interaction_cst_indices = []... | sklearn/ensemble/_hist_gradient_boosting/grower.py | 128 | scikit-learn | {
"docstring": "Compute features allowed by interactions to be inherited by child nodes.\n\n Example: Assume constraints [{0, 1}, {1, 2}].\n 1 <- Both constraint groups could be applied from now on\n / \\\n 1 2 <- Left split still fulfills both constraint groups.\n /... | 56 | Python | 47 | 5ceb8a6a031ddff26a7ede413db1b53edb64166a | grower.py | 261,258 | 37 | 81 | _compute_interactions | https://github.com/scikit-learn/scikit-learn.git | ENH FEA add interaction constraints to HGBT (#21020)
Co-authored-by: Loรฏc Estรจve <loic.esteve@ymail.com> | 193 | 0 | 76,716 | 13 | |
1 | 2 | def groups(self):
return self["groups"]
| packages/python/plotly/plotly/graph_objs/sankey/_node.py | 22 | plotly.py | {
"docstring": "\n Groups of nodes. Each group is defined by an array with the\n indices of the nodes it contains. Multiple groups can be\n specified.\n\n The 'groups' property is an info array that may be specified as:\n * a 2D list where:\n The 'groups[i][j]' property is ... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _node.py | 233,318 | 2 | 11 | groups | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 64,762 | 7 | |
1 | 49 | def test_exec_dataflow_runner(self, gcs_hook, dataflow_hook_mock, beam_hook_mock, persist_link_mock):
dataflow_config = DataflowConfiguration()
self.operator.runner = "DataflowRunner"
self.operator.dataflow_config = dataflow_config
gcs_provide_file = gcs_hook.return_value.provid... | tests/providers/apache/beam/operators/test_beam.py | 416 | airflow | {
"docstring": "Test DataflowHook is created and the right args are passed to\n start_python_dataflow.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 12,
"vocab_size": 12
} | 75 | Python | 66 | 4a5250774be8f48629294785801879277f42cc62 | test_beam.py | 42,750 | 49 | 268 | test_exec_dataflow_runner | https://github.com/apache/airflow.git | Added missing project_id to the wait_for_job (#24020) | 538 | 0 | 7,719 | 12 | |
3 | 19 | def _get_no_faces(self) -> Generator[str, None, None]:
self.output_message = "Frames with no faces"
for frame in tqdm(cast(List[Dict[str, str]], self._items),
desc=self.output_message,
leave=False):
logger.trace(frame) # type:igno... | tools/alignments/jobs.py | 137 | faceswap | {
"docstring": " yield each frame that has no face match in alignments file\n\n Yields\n ------\n str\n The frame name of any frames which have no faces\n ",
"language": "en",
"n_whitespaces": 64,
"n_words": 24,
"vocab_size": 22
} | 34 | Python | 32 | e2a77e7c6e84e81f642cb22f528e25e3f2d2dbc1 | jobs.py | 101,722 | 17 | 86 | _get_no_faces | https://github.com/deepfakes/faceswap.git | Alignments Tool - Typing, Documentation + Re-org | 169 | 0 | 21,126 | 12 | |
12 | 5 | def CopyIcons(dstpath, srcpath):
if isinstance(srcpath, str):
# Just a single string, make it a one-element list.
srcpath = [srcpath]
| PyInstaller/utils/win32/icon.py | 36 | pyinstaller | {
"docstring": "\n Called from building/api.py to handle icons. If the input was by --icon on the command line, srcpath is a single\n string. However, it is possible to modify the spec file adding icon=['foo.ico','bar.ico'] to the EXE() statement.\n In that case, srcpath is a list of strings.\n\n The stri... | 19 | Python | 18 | 3aad9af18641aa2181dd86cececc2aeb8a0dba06 | icon.py | 262,800 | 44 | 376 | CopyIcons | https://github.com/pyinstaller/pyinstaller.git | Icon translation using PIL (#6697)
Convert icons into the correct platform dependent format using PIL/Pillow if installed. | 39 | 0 | 77,378 | 9 | |
5 | 6 | def local_ray_callbacks(callbacks=None):
global_callbacks = callbacks is None
if global_callbacks:
callbacks, RayDaskCallback.ray_active = (RayDaskCallback.ray_active, set())
try:
yield callbacks or ()
finally:
if global_callbacks:
RayDaskCallback.ray_active = ca... | python/ray/util/dask/callbacks.py | 82 | ray | {
"docstring": "\n Allows Dask-Ray callbacks to work with nested schedulers.\n\n Callbacks will only be used by the first started scheduler they encounter.\n This means that only the outermost scheduler will use global callbacks.\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 31,
"vocab_si... | 25 | Python | 18 | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | callbacks.py | 133,122 | 9 | 48 | local_ray_callbacks | https://github.com/ray-project/ray.git | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 72 | 0 | 29,930 | 12 | |
1 | 17 | def test_local_media_retention(self) -> None:
# Advance 31 days (in seconds)
self.reactor.advance(31 * 24 * 60 * 60)
# Check that media has been correctly purged.
# Local media accessed <30 days ago should still exist.
# Remote media should be unaffected.
self._... | tests/rest/media/test_media_retention.py | 158 | synapse | {
"docstring": "\n Tests that local media that have not been accessed recently is purged, while\n cached remote media is unaffected.\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 18,
"vocab_size": 15
} | 59 | Python | 47 | 2fc787c341ff540e5880932f116498ec0ed7a2c2 | test_media_retention.py | 248,468 | 20 | 106 | test_local_media_retention | https://github.com/matrix-org/synapse.git | Add config options for media retention (#12732) | 287 | 0 | 72,296 | 14 | |
4 | 14 | def add_simple_roots(self, root1, root2):
alpha = self.simple_roots()
if root1 > len(alpha) or root2 > len(alpha):
raise ValueError("You've used a root that doesn't exist!")
a1 = alpha[root1]
a2 = alpha[root2]
newroot = [_a1 + _a2 for _a1, _a2 in zip(a1, a2)... | sympy/liealgebras/root_system.py | 110 | sympy | {
"docstring": "Add two simple roots together\n\n The function takes as input two integers, root1 and root2. It then\n uses these integers as keys in the dictionary of simple roots, and gets\n the corresponding simple roots, and then adds them together.\n\n Examples\n ========\n\n ... | 42 | Python | 36 | 7d773eb18daaef3c54f34d1ac6cbc5b83a5bb16c | root_system.py | 198,389 | 8 | 69 | add_simple_roots | https://github.com/sympy/sympy.git | Cleanup loops and ranges | 102 | 0 | 48,901 | 10 | |
6 | 14 | def test_get_release_wheel_url():
# This should be a commit for which wheels have already been built for
# all platforms and python versions at
# `s3://ray-wheels/releases/2.2.0/<commit>/`.
test_commits = {"2.2.0": "b6af0887ee5f2e460202133791ad941a41f15beb"}
for sys_platform in ["darwin", "linu... | python/ray/tests/test_runtime_env.py | 136 | ray | {
"docstring": "Test the code that generates the filenames of the `release` branch wheels.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 10
} | 74 | Python | 53 | 98fef7732852cdb3e9377cd87c1ee1085b894928 | test_runtime_env.py | 137,593 | 9 | 80 | test_get_release_wheel_url | https://github.com/ray-project/ray.git | [runtime env] Support python 3.10 for runtime_env conda (#30970)
Signed-off-by: Archit Kulkarni <architkulkarni@users.noreply.github.com>
conda environments are isolated, so when runtime_env sets up a conda environment it must download the Ray wheel into the conda environment. It must download the wheel that matche... | 193 | 0 | 31,197 | 15 | |
5 | 12 | def prepare_http01_modules(self) -> None:
if self.configurator.conf("handle-modules"):
needed_modules = ["rewrite"]
if self.configurator.version < (2, 4):
needed_modules.append("authz_host")
else:
needed_modules.append("authz_core")
... | certbot-apache/certbot_apache/_internal/http_01.py | 139 | certbot | {
"docstring": "Make sure that we have the needed modules available for http01",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 30 | Python | 26 | 7d9e9a49005de7961e84d2a7c608db57dbab3046 | http_01.py | 186,649 | 11 | 81 | prepare_http01_modules | https://github.com/certbot/certbot.git | Add typing to certbot.apache (#9071)
* Add typing to certbot.apache
Co-authored-by: Adrien Ferrand <ferrand.ad@gmail.com> | 152 | 0 | 45,558 | 14 | |
2 | 9 | def to_reader(self, *args, **kwargs):
if config.PYARROW_VERSION.major < 8:
raise NotImplementedError("`pyarrow>=8.0.0` is required to use this method")
return self.table.to_reader(*args, **kwargs)
| src/datasets/table.py | 65 | datasets | {
"docstring": "\n Convert the Table to a RecordBatchReader.\n\n Note that this method is zero-copy, it merely exposes the same data under a different API.\n\n Args:\n max_chunksize (:obj:`int`, defaults to :obj:`None`)\n Maximum size for RecordBatch chunks. Individual c... | 19 | Python | 19 | 1ea4d091b7a4b83a85b2eeb8df65115d39af3766 | table.py | 105,694 | 4 | 39 | to_reader | https://github.com/huggingface/datasets.git | Fast dataset iter (#5030)
* Fast dataset iter
* Final improvements + some minor fixes
* Update src/datasets/arrow_dataset.py
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
* Address comments
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com> | 51 | 0 | 22,190 | 10 | |
1 | 21 | def test_you_must_be_realm_admin(self) -> None:
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
other_realm = do_create_realm(string_id="other", name="other")
stream = self.make_stream("other_realm_stream", realm=other_realm)
result = self.clie... | zerver/tests/test_subs.py | 182 | zulip | {
"docstring": "\n You must be on the realm to create a stream.\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 10
} | 51 | Python | 37 | 708204290ecebd608a575f76892489a0caad5836 | test_subs.py | 83,893 | 13 | 104 | test_you_must_be_realm_admin | https://github.com/zulip/zulip.git | streams: Capitalize "ID" in invalid stream errors in API.
This commit changes the error message from "Invalid stream id"
to "Invalid stream ID" for cases where invalid stream IDs are
passed to API endpoints to make it consistent with other similar
error messages. | 135 | 0 | 17,744 | 12 | |
11 | 34 | def _async_set_dynamic_options(self) -> None:
if self.entity_description.ufp_options is not None:
return
if self.entity_description.key == _KEY_VIEWER:
options = [
{"id": item.id, "name": item.name}
for item in self.data.api.bootstrap.liv... | homeassistant/components/unifiprotect/select.py | 416 | core | {
"docstring": "Options that do not actually update dynamically.\n\n This is due to possible downstream platforms dependencies on these options.\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 18,
"vocab_size": 18
} | 103 | Python | 60 | a2677983a2924366ea13eab416bf286996a64bdb | select.py | 308,567 | 31 | 252 | _async_set_dynamic_options | https://github.com/home-assistant/core.git | Add UniFi Protect select platform (#63337) | 396 | 0 | 107,315 | 16 | |
1 | 8 | def test_safedata(self):
self.assertIsInstance(
self.encode_decode(mark_safe('<b>Hello Django!</b>')).message,
SafeData,
)
self.assertNotIsInstance(
self.encode_decode('<b>Hello Django!</b>').message,
SafeData,
)
| tests/messages_tests/test_cookie.py | 70 | django | {
"docstring": "\n A message containing SafeData is keeping its safe status when\n retrieved from the message storage.\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 15,
"vocab_size": 14
} | 12 | Python | 10 | efb4478e484ae61c5fc23563d4e9df1f8f49df49 | test_cookie.py | 203,142 | 9 | 41 | test_safedata | https://github.com/django/django.git | Fixed #33458 -- Fixed encoding of messages with empty string as extra_tags. | 91 | 0 | 50,235 | 13 | |
1 | 3 | def test_make_tarball_extended(self):
self.test_make_tarball('ใฎใขใผใซใคใ') # japanese for archive
| python3.10.4/Lib/distutils/tests/test_archive_util.py | 26 | XX-Net | {
"docstring": "\n Mirror test_make_tarball, except filename contains extended\n characters outside the latin charset.\n ",
"language": "en",
"n_whitespaces": 33,
"n_words": 11,
"vocab_size": 11
} | 7 | Python | 7 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | test_archive_util.py | 223,024 | 2 | 12 | test_make_tarball_extended | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 21 | 0 | 56,854 | 8 | |
1 | 7 | def effect_mandelbrot(size, extent, quality):
return Image()._new(core.effect_mandelbrot(size, extent, quality))
| src/PIL/Image.py | 44 | Pillow | {
"docstring": "\n Generate a Mandelbrot set covering the given extent.\n\n :param size: The requested size in pixels, as a 2-tuple:\n (width, height).\n :param extent: The extent to cover, as a 4-tuple:\n (x0, y0, x1, y1).\n :param quality: Quality.\n ",
"language": "en",
"n_whitespace... | 8 | Python | 7 | f77aabf28134d93e35ca2d5622759c856333beb9 | Image.py | 242,898 | 2 | 28 | effect_mandelbrot | https://github.com/python-pillow/Pillow.git | Update Image.py docstrings.
Update Image.py file with a typo in effect_mandelbrot method.
The Typo was in docstrings of the effect_mandelbrot method in Image module of PIL. | 14 | 0 | 69,936 | 9 | |
2 | 5 | def subprocess_runner(self, runner):
prev = self._subprocess_runner
self._subprocess_runner = runner
try:
yield
finally:
self._subprocess_runner = prev
| .venv/lib/python3.8/site-packages/pip/_vendor/pep517/wrappers.py | 50 | transferlearning | {
"docstring": "A context manager for temporarily overriding the default subprocess\n runner.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 10,
"vocab_size": 10
} | 15 | Python | 10 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | wrappers.py | 63,022 | 7 | 28 | subprocess_runner | https://github.com/jindongwang/transferlearning.git | upd; format | 72 | 0 | 13,102 | 10 | |
14 | 2 | def test_recover_start_from_replica_actor_names(serve_instance):
# Test failed to deploy with total of 2 replicas,
# but first constructor call fails. | python/ray/serve/tests/fault_tolerance_tests/test_controller_recovery.py | 15 | ray | {
"docstring": "Test controller is able to recover starting -> running replicas from\n actor names.\n ",
"language": "en",
"n_whitespaces": 19,
"n_words": 13,
"vocab_size": 13
} | 18 | Python | 17 | 09a6e5336ad6ab3c41e4a16e906c778aee2450bc | test_controller_recovery.py | 124,881 | 62 | 343 | test_recover_start_from_replica_actor_names | https://github.com/ray-project/ray.git | [Serve][Part2] Migrate the tests to use deployment graph api (#26507) | 27 | 0 | 27,710 | 6 | |
2 | 9 | def get_profile_context() -> ProfileContext:
profile_ctx = ProfileContext.get()
if not profile_ctx:
raise MissingContextError("No profile context found.")
return profile_ctx
_PROFILE_ENV_LOCK = threading.Lock()
@contextmanager | src/prefect/context.py | 63 | @contextmanager | prefect | {
"docstring": "\n Returns a ProfileContext that contains the combination of user profile \n settings and environment variable settings present when the context was initialized\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 21,
"vocab_size": 19
} | 21 | Python | 19 | e11fd5aa4905c7c27dbdf6ec49442ee107daebac | context.py | 54,856 | 9 | 25 | get_profile_context | https://github.com/PrefectHQ/prefect.git | Bug fix for PrefectHQ/orion#1383, contains test | 38 | 1 | 11,161 | 10 |
1 | 16 | async def test_no_controller_triggers(hass, client, integration):
dev_reg = async_get_dev_reg(hass)
device = dev_reg.async_get_device(
{get_device_id(client.driver, client.driver.controller.nodes[1])}
)
assert device
assert (
await async_get_device_automations(
hass,... | tests/components/zwave_js/test_device_trigger.py | 98 | core | {
"docstring": "Test that we do not get triggers for the controller.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 27 | Python | 22 | 41d5256533ec6ef1c102af0a43c7b7f26b8e06fb | test_device_trigger.py | 297,253 | 12 | 63 | test_no_controller_triggers | https://github.com/home-assistant/core.git | Add via_device support to zwave_js (#83219)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com> | 87 | 0 | 96,222 | 15 | |
2 | 8 | def is_tarfile(name):
try:
t = open(name)
t.close()
return True
except TarError:
return False
bltn_open = open
open = TarFile.open
| pipenv/patched/notpip/_vendor/distlib/_backport/tarfile.py | 60 | pipenv | {
"docstring": "Return True if name points to a tar archive that we\n are able to handle, else return False.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 18,
"vocab_size": 17
} | 19 | Python | 15 | c69d55f7c82d5ae2cce542bcfb98d043ca4836a0 | tarfile.py | 21,410 | 7 | 26 | is_tarfile | https://github.com/pypa/pipenv.git | Vendor in pip 22.1.2 | 54 | 0 | 3,815 | 10 | |
8 | 20 | def fallback_which(command, location=None, allow_global=False, system=False):
from .vendor.pythonfinder import Finder
if not command:
raise ValueError("fallback_which: Must provide a command to search for...")
if not isinstance(command, str):
raise TypeError(f"Provided command must be... | pipenv/core.py | 196 | pipenv | {
"docstring": "\n A fallback implementation of the `which` utility command that relies exclusively on\n searching the path for commands.\n\n :param str command: The command to search for, optional\n :param str location: The search location to prioritize (prepend to path), defaults to None\n :param boo... | 70 | Python | 51 | 9a3b3ce70621af6f9adaa9eeac9cf83fa149319c | core.py | 19,648 | 18 | 118 | fallback_which | https://github.com/pypa/pipenv.git | Issue 4993 Add standard pre commit hooks and apply linting. (#4994)
* Add .pre-commit-config.yaml to the project and exclude tests (for now). This does not include the MyPy linting that pip does but does include everything else. | 156 | 0 | 3,046 | 11 | |
3 | 6 | def suggested_unit_of_measurement(self) -> str | None:
if hasattr(self, "_attr_suggested_unit_of_measurement"):
return self._attr_suggested_unit_of_measurement
if hasattr(self, "entity_description"):
return self.entity_description.suggested_unit_of_measurement
re... | homeassistant/components/sensor/__init__.py | 65 | core | {
"docstring": "Return the unit which should be used for the sensor's state.\n\n This can be used by integrations to override automatic unit conversion rules,\n for example to make a temperature sensor display in ยฐC even if the configured\n unit system prefers ยฐF.\n\n For sensors without a... | 18 | Python | 14 | 6979cd95b0fe85c3ee8eca3dbc9881b8d05591e8 | __init__.py | 289,746 | 22 | 38 | suggested_unit_of_measurement | https://github.com/home-assistant/core.git | Add suggested_unit_of_measurement attribute to sensors (#80638)
* Add suggested_unit_of_measurement attribute to sensors
* Lazy calculation of initial entity options
* Add type alias for entity options
* Small tweak
* Add tests
* Store suggested_unit_of_measurement in its own option key
* Adapt to re... | 68 | 0 | 88,882 | 9 | |
6 | 37 | def test_ppo_exploration_setup(self):
config = copy.deepcopy(ppo.DEFAULT_CONFIG)
config["num_workers"] = 0 # Run locally.
config["env_config"] = {"is_slippery": False, "map_name": "4x4"}
obs = np.array(0)
# Test against all frameworks.
for fw in framework_itera... | rllib/agents/ppo/tests/test_ppo.py | 446 | ray | {
"docstring": "Tests, whether PPO runs with different exploration setups.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 126 | Python | 87 | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | test_ppo.py | 133,802 | 33 | 285 | test_ppo_exploration_setup | https://github.com/ray-project/ray.git | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 629 | 0 | 30,114 | 22 | |
2 | 8 | def pandas_version_info() -> Tuple[int, ...]:
return tuple(int(s) for s in pd.__version__.split("."))
| src/pandas_profiling/utils/compat.py | 52 | ydata-profiling | {
"docstring": "\n Get the Pandas version as a tuple of integers,\n akin to `sys.version_info` for the Python version.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 16,
"vocab_size": 15
} | 11 | Python | 11 | 5c5a710f23d83ba5ff1dc9ab6fc23b28094560fb | compat.py | 191,814 | 6 | 31 | pandas_version_info | https://github.com/ydataai/ydata-profiling.git | feat: add support for Pandas 1.5 (#1076) | 17 | 0 | 46,844 | 11 | |
2 | 10 | def position_cursor(self) -> Control:
if self._shape is not None:
_, height = self._shape
return Control(
ControlType.CARRIAGE_RETURN,
(ControlType.ERASE_IN_LINE, 2),
*(
(
(ControlType.CU... | pipenv/patched/notpip/_vendor/rich/live_render.py | 105 | pipenv | {
"docstring": "Get control codes to move cursor to beginning of live render.\n\n Returns:\n Control: A control instance that may be printed.\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 20,
"vocab_size": 18
} | 33 | Python | 27 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | live_render.py | 20,773 | 20 | 70 | position_cursor | 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... | 250 | 0 | 3,537 | 15 | |
1 | 4 | def _exit_buffer(self) -> None:
self._buffer_index -= 1
self._check_buffer()
| pipenv/patched/notpip/_vendor/rich/console.py | 33 | pipenv | {
"docstring": "Leave buffer context, and render content if required.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 8 | Python | 8 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | console.py | 20,715 | 4 | 18 | _exit_buffer | 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... | 29 | 0 | 3,497 | 7 | |
2 | 6 | def is_multiple_state(state_size):
return (hasattr(state_size, '__len__') and
not isinstance(state_size, tf.TensorShape))
| keras/layers/rnn/rnn_utils.py | 43 | keras | {
"docstring": "Check whether the state_size contains multiple states.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | 9 | Python | 9 | 01c906c4178db5ae03b7eb2d298a052c952a0667 | rnn_utils.py | 268,977 | 3 | 25 | is_multiple_state | https://github.com/keras-team/keras.git | Reorganize RNN layers, cells and wrappers into smaller logically organized files hosted under an `rnn` directory.
PiperOrigin-RevId: 428841673 | 20 | 0 | 79,799 | 11 | |
2 | 7 | def remove(self, event, subscriber):
subs = self._subscribers
if event not in subs:
raise ValueError('No subscribers: %r' % event)
subs[event].remove(subscriber)
| .venv/lib/python3.8/site-packages/pip/_vendor/distlib/util.py | 61 | transferlearning | {
"docstring": "\n Remove a subscriber for an event.\n\n :param event: The name of an event.\n :param subscriber: The subscriber to be removed.\n ",
"language": "en",
"n_whitespaces": 49,
"n_words": 20,
"vocab_size": 15
} | 19 | Python | 19 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | util.py | 62,204 | 5 | 37 | remove | https://github.com/jindongwang/transferlearning.git | upd; format | 58 | 0 | 12,898 | 11 | |
2 | 10 | def _format_ram(self):
retval = []
for name in ("total", "available", "used", "free"):
value = getattr(self, f"_ram_{name}")
value = int(value / (1024 * 1024))
retval.append(f"{name.capitalize()}: {value}MB")
return ", ".join(retval)
| lib/sysinfo.py | 121 | faceswap | {
"docstring": " Format the RAM stats into Megabytes to make it more readable.\n\n Returns\n -------\n str\n The total, available, used and free RAM displayed in Megabytes\n ",
"language": "en",
"n_whitespaces": 64,
"n_words": 24,
"vocab_size": 22
} | 28 | Python | 25 | 48c886b3dce3d3117ad16edaf35c8abd28dc51f5 | sysinfo.py | 102,079 | 7 | 58 | _format_ram | https://github.com/deepfakes/faceswap.git | Allow decoding errors | 89 | 0 | 21,444 | 13 | |
3 | 11 | def get_holiday(holiday_list, month):
holiday_map = frappe._dict()
for d in holiday_list:
if d:
holiday_map.setdefault(
d,
frappe.db.sql(
,
(d, month),
),
)
return holiday_map
@frappe.whitelist() | erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py | 83 | @frappe.whitelist() | erpnext | {
"docstring": "select day(holiday_date), weekly_off from `tabHoliday`\n\t\t\t\twhere parent=%s and month(holiday_date)=%s",
"language": "en",
"n_whitespaces": 7,
"n_words": 9,
"vocab_size": 9
} | 23 | Python | 22 | 494bd9ef78313436f0424b918f200dab8fc7c20b | monthly_attendance_sheet.py | 66,259 | 13 | 47 | get_holiday | https://github.com/frappe/erpnext.git | style: format code with black | 10 | 1 | 14,150 | 14 |
2 | 7 | def __sub__(self, other):
if self._delegate_binop(other):
return NotImplemented
return np.subtract(self, other)
| numpy/ma/core.py | 44 | numpy | {
"docstring": "\n Subtract other from self, and return a new masked array.\n\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 10
} | 10 | Python | 9 | 6d77c591c59b5678f14ae5af2127eebb7d2415bc | core.py | 160,870 | 4 | 27 | __sub__ | https://github.com/numpy/numpy.git | ENH: Adding __array_ufunc__ capability to MaskedArrays.
This enables any ufunc numpy operations that are called on a
MaskedArray to use the masked version of that function automatically
without needing to resort to np.ma.func() calls. | 42 | 0 | 38,770 | 7 | |
1 | 8 | def test_build_in_tf_function(self):
m = metrics.MeanTensor(dtype=tf.float64)
| keras/metrics/base_metric_test.py | 32 | keras | {
"docstring": "Ensure that variables are created correctly in a tf function.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 5 | Python | 5 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | base_metric_test.py | 274,647 | 11 | 117 | test_build_in_tf_function | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 19 | 0 | 81,253 | 10 | |
1 | 3 | def isatty(self) -> bool:
return True
| src/textual/app.py | 19 | textual | {
"docstring": "Pretend to be a terminal.\n\n Returns:\n bool: True if this is a tty.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 13,
"vocab_size": 12
} | 6 | Python | 6 | 0af9fed65969894d604e32a177120f0a03857265 | app.py | 185,685 | 7 | 10 | isatty | https://github.com/Textualize/textual.git | added constant, and docstrings | 20 | 0 | 45,109 | 6 | |
1 | 9 | def is_typeddict(tp):
| pipenv/patched/notpip/_vendor/typing_extensions.py | 26 | """Check if an annotation is a TypedDict class
For example::anFor | pipenv | {
"docstring": "Check if an annotation is a TypedDict class\n\n For example::",
"language": "en",
"n_whitespaces": 16,
"n_words": 10,
"vocab_size": 10
} | 2 | Python | 2 | c69d55f7c82d5ae2cce542bcfb98d043ca4836a0 | typing_extensions.py | 21,607 | 2 | 16 | is_typeddict | https://github.com/pypa/pipenv.git | Vendor in pip 22.1.2 | 9 | 3 | 3,951 | 5 |
1 | 17 | def test_cache_with_asterisk_in_name(self):
config = {
"caches": {
"per_cache_factors": {"*cache_a*": 5, "cache_b": 6, "cache_c": 2}
}
}
self.config._environ = {
"SYNAPSE_CACHE_FACTOR_CACHE_A": "2",
"SYNAPSE_CACHE_FACTOR_C... | tests/config/test_cache.py | 250 | synapse | {
"docstring": "Some caches have asterisks in their name, test that they are set correctly.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 13
} | 49 | Python | 38 | d38d242411b8910dfacde1e61fd3a0ec5cbcaa66 | test_cache.py | 248,242 | 21 | 146 | test_cache_with_asterisk_in_name | https://github.com/matrix-org/synapse.git | Reload cache factors from disk on SIGHUP (#12673) | 220 | 0 | 72,173 | 13 | |
1 | 20 | def test_model_tpu_one_core():
trainer = Trainer(tpu_cores=1, fast_dev_run=True, strategy=TPUSpawnStrategy(debug=True))
# assert training strategy attributes for device setting
assert isinstance(trainer.strategy, TPUSpawnStrategy)
assert not trainer.strategy.on_gpu
assert trainer.strategy.on_tp... | tests/strategies/test_tpu_spawn.py | 135 | lightning | {
"docstring": "Tests if device/debug flag is set correctely when training and after teardown for TPUSpawnStrategy.",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 14
} | 37 | Python | 30 | 650c710efacd633fa283955145342bb64063c883 | test_tpu_spawn.py | 241,590 | 9 | 83 | test_model_tpu_one_core | https://github.com/Lightning-AI/lightning.git | Rename training plugin test files & names to strategy (#11303) | 67 | 0 | 69,613 | 12 | |
1 | 25 | def test_subscriptions_query_count(self) -> None:
user1 = self.example_user("cordelia")
user2 = self.example_user("iago")
new_streams = [
"query_count_stream_1",
"query_count_stream_2",
"query_count_stream_3",
]
# Test creating a publ... | zerver/tests/test_subs.py | 387 | zulip | {
"docstring": "\n Test database query count when creating stream with api/v1/users/me/subscriptions.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | 98 | Python | 59 | b0de5c0f364632feb1e0a662f9be49aaf3412770 | test_subs.py | 84,790 | 39 | 239 | test_subscriptions_query_count | https://github.com/zulip/zulip.git | streams: Set can_remove_subscribers_group while creating streams.
This commit sets can_remove_subscribers_group to admins system
group while creating streams as it will be the default value
of this setting. In further we would provide an option to set
value of this setting to any user group while creating streams
usin... | 519 | 0 | 17,875 | 18 | |
1 | 9 | def test_meta_options_as_defaults(self):
# this plugin relies on the base CMSPlugin and Model classes to
# decide what the app_label and db_table should be
plugin = TestPlugin.model
self.assertEqual(plugin._meta.db_table, 'meta_testpluginmodel')
self.assertEqual(plugin.... | cms/tests/test_plugins.py | 63 | django-cms | {
"docstring": " handling when a CMSPlugin meta options are computed defaults ",
"language": "en",
"n_whitespaces": 10,
"n_words": 9,
"vocab_size": 9
} | 30 | Python | 26 | c1290c9ff89cb00caa5469129fd527e9d82cd820 | test_plugins.py | 82,419 | 4 | 35 | test_meta_options_as_defaults | https://github.com/django-cms/django-cms.git | ci: Added codespell (#7355)
Co-authored-by: Christian Clauss <cclauss@me.com>
* ci: codespell config taken from #7292 | 72 | 0 | 17,389 | 9 | |
8 | 20 | def to_dict(self, field_map={}) -> Dict:
inv_field_map = {v: k for k, v in field_map.items()}
_doc: Dict[str, str] = {}
for k, v in self.__dict__.items():
# Exclude internal fields (Pydantic, ...) fields from the conversion process
if k.startswith("__"):
... | haystack/schema.py | 210 | haystack | {
"docstring": "\n Convert Document to dict. An optional field_map can be supplied to change the names of the keys in the\n resulting dict. This way you can work with standardized Document objects in Haystack, but adjust the format that\n they are serialized / stored in other places (e.g. elastic... | 78 | Python | 55 | 621e1af74c9c7d04b79ca5f5826ddcc06e1237f0 | schema.py | 257,821 | 24 | 130 | to_dict | https://github.com/deepset-ai/haystack.git | refactor: improve support for dataclasses (#3142)
* refactor: improve support for dataclasses
* refactor: refactor class init
* refactor: remove unused import
* refactor: testing 3.7 diffs
* refactor: checking meta where is Optional
* refactor: reverting some changes on 3.7
* refactor: remove unused ... | 232 | 0 | 75,140 | 18 | |
1 | 7 | def _resource_apply_sparse(self, grad, handle, indices, apply_state):
raise NotImplementedError(
"`_resource_apply_sparse` Must be implemented in subclasses."
)
| keras/optimizers/optimizer_v2/optimizer_v2.py | 31 | keras | {
"docstring": "Add ops to apply sparse gradients to the variable `handle`.\n\n Similar to `_apply_sparse`, the `indices` argument to this method has\n been de-duplicated. Optimizers which deal correctly with non-unique\n indices may instead override `_resource_apply_sparse_duplicate_indices`\n ... | 15 | Python | 15 | be73ac1a1e25d9abd4d793cba9707098d7adf231 | optimizer_v2.py | 279,524 | 4 | 19 | _resource_apply_sparse | https://github.com/keras-team/keras.git | Add f-string format and lint with flynt on the whole codebase | 47 | 0 | 83,029 | 8 | |
1 | 2 | def on_shutdown(self) -> None:
| mkdocs/plugins.py | 16 | mkdocs | {
"docstring": "\n The `shutdown` event runs once at the very end of an `mkdocs` invocation, before exiting.\n\n This event is relevant only for support of `mkdocs serve`, otherwise within a\n single build it's undistinguishable from `on_post_build`.\n\n New in MkDocs 1.4.\n\n The p... | 4 | Python | 4 | a56ac6e0513bdea6860ed1fdc3debc10410638cd | plugins.py | 224,971 | 16 | 8 | on_shutdown | https://github.com/mkdocs/mkdocs.git | Add plugin events that persist across builds in `mkdocs serve`
"One-time events" `on_startup(command)`, `on_shutdown`.
Their presence also shows that a plugin *wants* to persist across builds. Otherwise they will be re-created, to not change any existing behavior. | 11 | 0 | 57,435 | 6 | |
6 | 18 | def _build_network_on_replica(model, mode, inputs=None, targets=None):
# Need to do imports here since we run into a circular dependency error.
from keras import models # pylint: disable=g-import-not-at-top
from keras.engine import sequential # pylint: disable=g-import-not-at-top
# We rely on th... | keras/distribute/distributed_training_utils_v1.py | 133 | keras | {
"docstring": "Build an updated model on replicas.\n\n We create a new Keras model while sharing the variables from the old graph.\n Building a new sub-graph is required since the original keras model creates\n placeholders for the input and the output that are not accessible till we\n call iterator.get_... | 122 | Python | 88 | b1105dca17670dcac229271e63d5073fe445b84c | distributed_training_utils_v1.py | 278,045 | 33 | 188 | _build_network_on_replica | https://github.com/keras-team/keras.git | resolve line-too-long in distribute | 228 | 0 | 82,343 | 13 | |
4 | 15 | def _discard_tk_faces(self):
keys = [f"{pnt_x}_{pnt_y}"
for pnt_x, pnt_y in self._objects.visible_grid[:2].T.reshape(-1, 2)]
for key in list(self._tk_faces):
if key not in keys:
del self._tk_faces[key]
logger.trace("keys: %s allocated_faces: %... | tools/manual/faceviewer/viewport.py | 124 | faceswap | {
"docstring": " Remove any :class:`TKFace` objects from the cache that are not currently displayed. ",
"language": "en",
"n_whitespaces": 13,
"n_words": 12,
"vocab_size": 12
} | 28 | Python | 24 | 5e73437be47f2410439a3c6716de96354e6a0c94 | viewport.py | 101,263 | 7 | 74 | _discard_tk_faces | https://github.com/deepfakes/faceswap.git | lib.align updates:
- alignments.py
- Add typed dicts for imported alignments
- Explicitly check for presence of thumb value in alignments dict
- linting
- detected_face.py
- Typing
- Linting
- Legacy support for pre-aligned face
- Update dependencies to new property names | 97 | 0 | 20,683 | 14 | |
1 | 11 | def test_i18n_language_non_english_fallback(self):
with self.settings(LANGUAGE_CODE="fr"), translation.override("none"):
response = self.client.get(reverse("admin:jsi18n"))
self.assertContains(response, "Choisir une heure")
| tests/admin_views/tests.py | 83 | django | {
"docstring": "\n Makes sure that the fallback language is still working properly\n in cases where the selected language cannot be found.\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 19,
"vocab_size": 17
} | 12 | Python | 12 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 207,601 | 4 | 44 | test_i18n_language_non_english_fallback | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 48 | 0 | 52,017 | 13 | |
2 | 10 | def name_scope_only_in_function_or_graph(name):
if not tf.executing_eagerly():
return tf.name_scope(name)
else:
return NullContextmanager()
@keras_export("keras.optimizers.Optimizer", metaclass=abc.ABCMeta) | keras/optimizers/optimizer_v2/optimizer_v2.py | 68 | @keras_export("keras.optimizers.Optimizer", metaclass=abc.ABCMeta) | keras | {
"docstring": "Internal-only entry point for `name_scope*`.\n\n Enters a compat.v1.name_scope only when in a function or graph,\n not when running fully eagerly.\n\n Args:\n name: The name argument that is passed to the op function.\n\n Returns:\n `name_scope*` context manager.\n ",
"langu... | 12 | Python | 11 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | optimizer_v2.py | 275,520 | 5 | 27 | name_scope_only_in_function_or_graph | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 34 | 1 | 81,411 | 10 |
1 | 5 | def name(self) -> PurePosixPath:
return PurePosixPath(_as_posix(self).split("::")[0]).name
| src/datasets/download/streaming_download_manager.py | 46 | datasets | {
"docstring": "Name function for argument of type :obj:`~pathlib.Path` that supports both local paths end remote URLs.\n\n Args:\n path (:obj:`~pathlib.Path`): Calling Path instance.\n\n Returns:\n :obj:`str`\n ",
"language": "en",
"n_whitespaces": 66,
"n_words": 23,
... | 6 | Python | 6 | ab7d3045ac9154e9c1c2602d0869130defdc6dc7 | streaming_download_manager.py | 105,102 | 10 | 26 | name | https://github.com/huggingface/datasets.git | Support DataLoader with num_workers > 0 in streaming mode (#4375)
* make TorchIterableDataset work in parallel
- make it picklable
- paralellize over the shards when num_workers is passed
* start writing some tests
* fix streaming extension and fsspec issues in subprocesses
* fix some tests
* fix more te... | 20 | 0 | 22,070 | 13 | |
8 | 23 | def django_table_names(self, only_existing=False, include_views=True):
tables = set()
for model in self.get_migratable_models():
if not model._meta.managed:
continue
tables.add(model._meta.db_table)
tables.update(
f.m2m_db_tabl... | django/db/backends/base/introspection.py | 186 | django | {
"docstring": "\n Return a list of all table names that have associated Django models and\n are in INSTALLED_APPS.\n\n If only_existing is True, include only the tables in the database.\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 27,
"vocab_size": 25
} | 48 | Python | 31 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | introspection.py | 204,854 | 18 | 117 | django_table_names | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 242 | 0 | 50,932 | 14 | |
2 | 6 | def eulerline(self):
if self.is_equilateral():
return self.orthocenter
return Line(self.orthocenter, self.circumcenter)
| sympy/geometry/polygon.py | 47 | sympy | {
"docstring": "The Euler line of the triangle.\n\n The line which passes through circumcenter, centroid and orthocenter.\n\n Returns\n =======\n\n eulerline : Line (or Point for equilateral triangles in which case all\n centers coincide)\n\n Examples\n ===... | 9 | Python | 8 | 498015021131af4dbb07eb110e5badaba8250c7b | polygon.py | 196,289 | 4 | 28 | eulerline | https://github.com/sympy/sympy.git | Updated import locations | 41 | 0 | 47,789 | 8 | |
2 | 9 | def itermonthdays2(self, year, month):
for i, d in enumerate(self.itermonthdays(year, month), self.firstweekday):
yield d, i % 7
| python3.10.4/Lib/calendar.py | 57 | XX-Net | {
"docstring": "\n Like itermonthdates(), but will yield (day number, weekday number)\n tuples. For days outside the specified month the day number is 0.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 21,
"vocab_size": 20
} | 16 | Python | 16 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | calendar.py | 221,238 | 3 | 37 | itermonthdays2 | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 41 | 0 | 56,285 | 10 | |
4 | 2 | def get_input_shape_and_dtype(layer):
| keras/engine/training_utils.py | 13 | keras | {
"docstring": "Retrieves input shape and input dtype of layer if applicable.\n\n Args:\n layer: Layer (or model) instance.\n\n Returns:\n Tuple (input_shape, input_dtype). Both could be None if the layer\n does not have a defined input shape.\n\n Raises:\n ValueError: in case an empty ... | 2 | Python | 2 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | training_utils.py | 271,837 | 9 | 55 | get_input_shape_and_dtype | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 5 | 0 | 80,858 | 6 | |
2 | 11 | def load_workflow_meta(self) -> Optional[WorkflowMetaData]:
try:
metadata = asyncio_run(self._get(self._key_workflow_metadata(), True))
return WorkflowMetaData(status=WorkflowStatus(metadata["status"]))
except KeyNotFoundError:
return None
| python/ray/workflow/workflow_storage.py | 81 | ray | {
"docstring": "Load the metadata of the current workflow.\n\n Returns:\n The metadata of the current workflow. If it doesn't exist,\n return None.\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 20,
"vocab_size": 14
} | 15 | Python | 14 | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | workflow_storage.py | 133,505 | 12 | 48 | load_workflow_meta | https://github.com/ray-project/ray.git | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 69 | 0 | 30,038 | 14 | |
3 | 11 | def _update_code_co_name(self, code):
if not hasattr(code, "replace"):
# It may not be available on older versions of Python (only
# available for 3.8 onwards).
return code
try:
first_real_line = next(dis.findlinestarts(code))[1]
except St... | IPython/core/interactiveshell.py | 93 | ipython | {
"docstring": "Python 3.10 changed the behaviour so that whenever a code object\n is assembled in the compile(ast) the co_firstlineno would be == 1.\n\n This makes pydevd/debugpy think that all cells invoked are the same\n since it caches information based on (co_firstlineno, co_name, co_filenam... | 40 | Python | 34 | d11e987f174a15f1640f8006c86f58d884c3faa4 | interactiveshell.py | 208,651 | 8 | 54 | _update_code_co_name | https://github.com/ipython/ipython.git | Set co_name for cells run line by line. Fixes https://github.com/ipython/ipykernel/issues/841 | 130 | 0 | 52,437 | 13 | |
4 | 22 | def send_trial(self, parameters, placement_constraint=None):
self.parameters_count += 1
if placement_constraint is None:
placement_constraint = {
'type': 'None',
'gpus': []
}
self._validate_placement_constraint(placement_constraint... | nni/retiarii/integration.py | 233 | nni | {
"docstring": "\n Send parameters to NNI.\n\n Parameters\n ----------\n parameters : Any\n Any payload.\n\n Returns\n -------\n int\n Parameter ID that is assigned to this parameter,\n which will be used for identification in future.\n... | 133 | Python | 108 | d5ed88e4e7f9aa78f06922dce8219a82e3b52682 | integration.py | 111,621 | 28 | 132 | send_trial | https://github.com/microsoft/nni.git | Retiarii serializer user experience improvements (#4437) | 432 | 0 | 24,455 | 16 | |
3 | 14 | async def dry_run(self, empty, context) -> jina_pb2.StatusProto:
from docarray import DocumentArray, Document
from jina.serve.executors import __dry_run_endpoint__
da = DocumentArray([Document()])
try: | jina/serve/runtimes/gateway/grpc/gateway.py | 63 | async def dry_run(self, empty, context) -> jina_pb2.StatusProto:
"""
Process the call requested by having a dry run call to every Executor in the graph
:param empty: The service expects an empty protobuf message
:param context: grpc context
:returns: the response request
... | jina | {
"docstring": "\n Process the call requested by having a dry run call to every Executor in the graph\n\n :param empty: The service expects an empty protobuf message\n :param context: grpc context\n :returns: the response request\n ",
"language": "en",
"n_whitespaces": 69,
"n_... | 20 | Python | 18 | e143ea3092ebae68f8c2cf7f784f86296cae68d7 | gateway.py | 13,668 | 23 | 103 | dry_run | https://github.com/jina-ai/jina.git | refactor: use stream_docs from streamer (#5438) | 55 | 1 | 2,721 | 10 |
4 | 9 | def get_yaxis_transform(self, which='grid'):
if which == 'grid':
return self._yaxis_transform
elif which == 'tick1':
# for cartesian projection, this is bottom spine
return self.spines.left.get_spine_transform()
elif which == 'tick2':
# fo... | lib/matplotlib/axes/_base.py | 109 | matplotlib | {
"docstring": "\n Get the transformation used for drawing y-axis labels, ticks\n and gridlines. The x-direction is in axis coordinates and the\n y-direction is in data coordinates.\n\n .. note::\n\n This transformation is primarily used by the\n `~matplotlib.axis.Ax... | 44 | Python | 29 | bf3a554ccd1299bc260647029811758aeaf577b1 | _base.py | 108,635 | 9 | 57 | get_yaxis_transform | https://github.com/matplotlib/matplotlib.git | Add tests, improve error messages, and use argument checks to simplify code | 145 | 0 | 23,279 | 12 | |
3 | 15 | def get_rfq_containing_supplier(doctype, txt, searchfield, start, page_len, filters):
conditions = ""
if txt:
conditions += "and rfq.name like '%%" + txt + "%%' "
if filters.get("transaction_date"):
conditions += "and rfq.transaction_date = '{0}'".format(filters.get("transaction_date"))
rfq_data = frappe.db.s... | erpnext/buying/doctype/request_for_quotation/request_for_quotation.py | 169 | erpnext | {
"docstring": "\n\t\tselect\n\t\t\tdistinct rfq.name, rfq.transaction_date,\n\t\t\trfq.company\n\t\tfrom\n\t\t\t`tabRequest for Quotation` rfq, `tabRequest for Quotation Supplier` rfq_supplier\n\t\twhere\n\t\t\trfq.name = rfq_supplier.parent\n\t\t\tand rfq_supplier.supplier = %(supplier)s\n\t\t\tand rfq.docstatus = ... | 49 | Python | 38 | 34e4903ed7936c35176d6031a16d1a27654dcb40 | request_for_quotation.py | 69,552 | 30 | 96 | get_rfq_containing_supplier | https://github.com/frappe/erpnext.git | refactor: search queries (#33004)
- guard clauses for readability
- use values or format | 32 | 0 | 15,063 | 13 | |
10 | 29 | async def async_update(self):
# Check if device is disconnected.
if not self._attr_available:
# Try to connect
if await self.aftv.adb_connect(log_errors=self._failed_connect_count == 0):
self._failed_connect_count = 0
self._attr_available ... | homeassistant/components/androidtv/media_player.py | 288 | core | {
"docstring": "Update the device state and, if necessary, re-connect.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 114 | Python | 74 | 0df30782a623204be2941da74ddee5bb110dd03b | media_player.py | 296,246 | 34 | 184 | async_update | https://github.com/home-assistant/core.git | Bump androidtv to 0.0.67 (improve connect attempt logging) (#69721) | 520 | 0 | 95,241 | 14 | |
1 | 9 | def euler_poly(n, x=None, polys=False):
return appell_poly(n, [[1], [1, QQ(-1,2)]], 1, lambda p, i: -p / 2, QQ, x, polys)
@public | sympy/polys/appellseqs.py | 81 | @public | sympy | {
"docstring": "Generates the Euler polynomial of degree `n` in `x`.\n\n Parameters\n ==========\n\n n : int\n Degree of the polynomial.\n x : optional\n polys : bool, optional\n If True, return a Poly, otherwise (default) return an expression.\n ",
"language": "en",
"n_whitespaces... | 20 | Python | 20 | e875bdb804b0285e4a9bd8de0158436e792c03cb | appellseqs.py | 199,618 | 2 | 55 | euler_poly | https://github.com/sympy/sympy.git | Initial definition of Appell sequences | 25 | 1 | 49,296 | 12 |
3 | 9 | def _get_output_folder(self) -> str:
if self._is_video and self._type == "frames":
return os.path.dirname(self._source_dir)
return self._source_dir
| tools/alignments/jobs.py | 58 | faceswap | {
"docstring": " Return output folder. Needs to be in the root if input is a video and processing\n frames\n\n Returns\n -------\n str\n Full path to the output folder\n ",
"language": "en",
"n_whitespaces": 73,
"n_words": 26,
"vocab_size": 23
} | 14 | Python | 13 | e2a77e7c6e84e81f642cb22f528e25e3f2d2dbc1 | jobs.py | 101,716 | 12 | 34 | _get_output_folder | https://github.com/deepfakes/faceswap.git | Alignments Tool - Typing, Documentation + Re-org | 46 | 0 | 21,120 | 10 | |
4 | 21 | def update_cached_response(self, request, response):
cache_url = self.cache_url(request.url)
cached_response = self.serializer.loads(request, self.cache.get(cache_url))
if not cached_response:
# we didn't have a cached response
return response
# Lets u... | pipenv/patched/notpip/_vendor/cachecontrol/controller.py | 172 | pipenv | {
"docstring": "On a 304 we will get a new set of headers that we want to\n update our cached value with, assuming we have one.\n\n This should only ever be called when we've sent an ETag and\n gotten a 304 as the response.\n ",
"language": "en",
"n_whitespaces": 70,
"n_words": 42,
... | 120 | Python | 79 | c69d55f7c82d5ae2cce542bcfb98d043ca4836a0 | controller.py | 21,319 | 16 | 103 | update_cached_response | https://github.com/pypa/pipenv.git | Vendor in pip 22.1.2 | 342 | 0 | 3,761 | 13 | |
5 | 13 | def remote(self, *args, **kwargs):
# Delayed import to avoid a cyclic import
from ray.util.client.common import remote_decorator
if len(args) == 1 and len(kwargs) == 0 and callable(args[0]):
# This is the case where the decorator is just @ray.remote.
return remo... | python/ray/util/client/api.py | 162 | ray | {
"docstring": "remote is the hook stub passed on to replace `ray.remote`.\n\n This sets up remote functions or actors, as the decorator,\n but does not execute them.\n\n Args:\n args: opaque arguments\n kwargs: opaque keyword arguments\n ",
"language": "en",
"n_w... | 113 | Python | 81 | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | api.py | 132,910 | 16 | 93 | remote | https://github.com/ray-project/ray.git | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | 285 | 0 | 29,866 | 11 | |
2 | 23 | def process_struct(fileobj):
(key_id,) = struct.unpack("Q", fileobj.read(8))
(country_code,) = struct.unpack("2s", fileobj.read(2))
(recognized,) = struct.unpack("b", fileobj.read(1))
(timestamp,) = struct.unpack("I", fileobj.read(4))
(n_strokes,) = struct.unpack("H", fileobj.read(2))
drawi... | datasets/quickdraw/quickdraw.py | 365 | datasets | {
"docstring": "\n Process a struct from a binary file object.\n\n The code for this function is borrowed from the following link:\n https://github.com/googlecreativelab/quickdraw-dataset/blob/f0f3beef0fc86393b3771cdf1fc94828b76bc89b/examples/binary_file_parser.py#L19\n ",
"language": "en",
"n_whitesp... | 63 | Python | 49 | 1c1eaf96d5ef4623e36c9124d49e88ab476dd655 | quickdraw.py | 105,091 | 20 | 220 | process_struct | https://github.com/huggingface/datasets.git | Add QuickDraw dataset (#3592)
* Add QuickDraw dataset
* Style
* Add infos file, dummy data, improve script
* Add info and dummy data
* Test readme
* Finish readme
* Delete generate_dummy.py
* Remove whitespace | 163 | 0 | 22,068 | 13 | |
2 | 9 | def convert_x_to_bbox(x, score=None):
w = np.sqrt(x[2] * x[3])
h = x[2] / w
if (score == None):
return np.array(
[x[0] - w / 2., x[1] - h / 2., x[0] + w / 2.,
x[1] + h / 2.]).reshape((1, 4))
else:
score = np.array([score])
return np.array([
... | deploy/pptracking/python/mot/tracker/ocsort_tracker.py | 233 | PaddleDetection | {
"docstring": "\n Takes a bounding box in the centre form [x,y,s,r] and returns it in the form\n [x1,y1,x2,y2] where x1,y1 is the top left and x2,y2 is the bottom right\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 28,
"vocab_size": 21
} | 69 | Python | 31 | c84153a355d9855fe55cf51d203b8b24e7d884e5 | ocsort_tracker.py | 211,029 | 12 | 167 | convert_x_to_bbox | https://github.com/PaddlePaddle/PaddleDetection.git | [MOT] Add OC_SORT tracker (#6272)
* add ocsort tracker
* add ocsort deploy
* merge develop
* fix ocsort tracker codes
* fix doc, test=document_fix
* fix doc, test=document_fix | 146 | 0 | 53,004 | 15 | |
1 | 4 | def multiply(inputs, **kwargs):
return Multiply(**kwargs)(inputs)
| keras/layers/merging/multiply.py | 32 | keras | {
"docstring": "Functional interface to the `Multiply` layer.\n\n Example:\n\n >>> x1 = np.arange(3.0)\n >>> x2 = np.arange(3.0)\n >>> tf.keras.layers.multiply([x1, x2])\n <tf.Tensor: shape=(3,), dtype=float32, numpy=array([0., 1., 4.], ...)>\n\n Usage in a functional model:\n\n >>> input1 = tf.k... | 5 | Python | 5 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | multiply.py | 272,694 | 2 | 18 | multiply | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 11 | 0 | 81,038 | 9 | |
1 | 4 | def export_model(self):
return self.tuner.get_best_model()
| autokeras/auto_model.py | 26 | autokeras | {
"docstring": "Export the best Keras Model.\n\n # Returns\n keras.Model instance. The best model found during the search, loaded\n with trained weights.\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 20,
"vocab_size": 18
} | 4 | Python | 4 | b97d27d2e916025f65fed751d54c089d4d4bd022 | auto_model.py | 175,928 | 2 | 14 | export_model | https://github.com/keras-team/autokeras.git | clean up imports | 18 | 0 | 41,662 | 8 | |
4 | 23 | def async_remove_legacy_device_serial_numbers(self) -> None:
_LOGGER.debug(
"Removing legacy serial numbers from device registry entries for pairing %s",
self.unique_id,
)
device_registry = dr.async_get(self.hass)
for accessory in self.entity_map.accesso... | homeassistant/components/homekit_controller/connection.py | 160 | core | {
"docstring": "Migrate remove legacy serial numbers from devices.\n\n We no longer use serial numbers as device identifiers\n since they are not reliable, and the HomeKit spec\n does not require them to be stable.\n ",
"language": "en",
"n_whitespaces": 60,
"n_words": 32,
"vocab_s... | 53 | Python | 41 | f23b1750e85f07091eb896a0b12b8f95e5646338 | connection.py | 288,840 | 27 | 93 | async_remove_legacy_device_serial_numbers | https://github.com/home-assistant/core.git | Migrate HomeKit Controller to use stable identifiers (#80064) | 300 | 0 | 87,989 | 13 | |
1 | 15 | def test_print_args(self):
args_list = [
'tests/tests.csv',
'-is', ','
]
args = self.parser.parse_args(args_list)
with captured_output() as (out, err):
_print_args(args)
output = out.getvalue()
expected_output =
self.a... | tests/driver_tests.py | 115 | tpot | {
"docstring": "Assert that _print_args prints correct values for all parameters in default settings.\nTPOT settings:\nCHECKPOINT_FOLDER = None\nCONFIG_FILE = None\nCROSSOVER_RATE = 0.1\nEARLY_STOP = None\nGENERATIONS = 100\nINPUT_FILE = tests/tests.csv... | 25 | Python | 22 | 388616b6247ca4ea8de4e2f340d6206aee523541 | driver_tests.py | 181,601 | 38 | 64 | test_print_args | https://github.com/EpistasisLab/tpot.git | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 115 | 0 | 43,390 | 10 | |
3 | 29 | def crash_log():
original_traceback = traceback.format_exc().encode("utf-8")
path = os.path.dirname(os.path.realpath(sys.argv[0]))
filename = os.path.join(path, datetime.now().strftime("crash_report.%Y.%m.%d.%H%M%S%f.log"))
freeze_log = [line.encode("utf-8") for line in _DEBUG_BUFFER]
try:
... | lib/logger.py | 249 | faceswap | {
"docstring": " On a crash, write out the contents of :func:`_DEBUG_BUFFER` containing the last 100 lines\n of debug messages to a crash report in the root Faceswap folder.\n\n Returns\n -------\n str\n The filename of the file that contains the crash report\n ",
"language": "en",
"n_whites... | 64 | Python | 55 | afec52309326304f4323029039e49bfcf928ef43 | logger.py | 100,731 | 15 | 127 | crash_log | https://github.com/deepfakes/faceswap.git | Bugfixes:
- Stats graph - Handle NaNs in data
- logger - de-elevate matplotlib font messages | 145 | 0 | 20,186 | 15 | |
6 | 27 | def remap_palette(self, dest_map, source_palette=None):
from . import ImagePalette
if self.mode not in ("L", "P"):
raise ValueError("illegal image mode")
if source_palette is None:
if self.mode == "P":
self.load()
source_palette ... | src/PIL/Image.py | 425 | Pillow | {
"docstring": "\n Rewrites the image to reorder the palette.\n\n :param dest_map: A list of indexes into the original palette.\n e.g. ``[1,0]`` would swap a two item palette, and ``list(range(256))``\n is the identity transform.\n :param source_palette: Bytes or None.\n ... | 299 | Python | 177 | 46a80d144a16836af304a7aaa8e620962d91ac23 | Image.py | 242,978 | 27 | 231 | remap_palette | https://github.com/python-pillow/Pillow.git | Update transparency when remapping the palette | 680 | 0 | 69,947 | 16 | |
1 | 4 | def decode(self, buffer):
raise NotImplementedError()
| src/PIL/ImageFile.py | 22 | Pillow | {
"docstring": "\n Override to perform the decoding process.\n\n :param buffer: A bytes object with the data to be decoded.\n :returns: A tuple of ``(bytes consumed, errcode)``.\n If finished with decoding return 0 for the bytes consumed.\n Err codes are from :data:`.ImageFi... | 5 | Python | 5 | a0e1fde1eddf45f26653e2ff6080d31e177adbec | ImageFile.py | 242,437 | 2 | 12 | decode | https://github.com/python-pillow/Pillow.git | Added PyEncoder | 19 | 0 | 69,859 | 7 | |
1 | 3 | def DeveloperAPI(obj):
_mark_annotated(obj)
return obj
| rllib/utils/annotations.py | 23 | ray | {
"docstring": "Decorator for documenting developer APIs.\n\n Developer APIs are classes and methods explicitly exposed to developers\n for the purposes of building custom algorithms or advanced training\n strategies on top of RLlib internals. You can generally expect these APIs\n to be stable sans minor ... | 5 | Python | 5 | 55d039af320caaab7fe11d404585bd402e66d393 | annotations.py | 139,970 | 3 | 12 | DeveloperAPI | https://github.com/ray-project/ray.git | Annotate datasources and add API annotation check script (#24999)
Why are these changes needed?
Add API stability annotations for datasource classes, and add a linter to check all data classes have appropriate annotations. | 14 | 0 | 31,815 | 7 | |
4 | 21 | def upsample_2d(x, k=None, factor=2, gain=1):
r
assert isinstance(factor, int) and factor >= 1
if k is None:
k = [1] * factor
k = np.asarray(k, dtype=np.float32)
if k.ndim == 1:
k = np.outer(k, k)
k /= np.sum(k)
k = k * (gain * (factor**2))
p = k.shape[0] - factor
r... | modules/image/text_to_image/stable_diffusion/diffusers/models/resnet.py | 209 | PaddleHub | {
"docstring": "Upsample2D a batch of 2D images with the given filter.\n\n Args:\n Accepts a batch of 2D images of the shape `[N, C, H, W]` or `[N, H, W, C]` and upsamples each image with the given\n filter. The filter is normalized so that if the input pixels are constant, they will be scaled by the specifi... | 65 | Python | 45 | a6790a651a12eb391060e533868bf0ba197f6f7e | resnet.py | 50,724 | 27 | 130 | upsample_2d | https://github.com/PaddlePaddle/PaddleHub.git | Add stable diffusion module | 105 | 0 | 10,204 | 14 | |
2 | 4 | def revert(self):
if self._backup:
self.set_state(self._backup)
self._backup = None
| mitmproxy/flow.py | 42 | mitmproxy | {
"docstring": "\n Revert to the last backed up state.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | 8 | Python | 8 | b3587b52b25077f68116b9852b041d33e7fc6601 | flow.py | 251,362 | 4 | 24 | revert | https://github.com/mitmproxy/mitmproxy.git | make it black! | 44 | 0 | 73,697 | 10 | |
5 | 17 | def homogeneity_completeness_v_measure(labels_true, labels_pred, *, beta=1.0):
labels_true, labels_pred = check_clusterings(labels_true, labels_pred)
if len(labels_true) == 0:
return 1.0, 1.0, 1.0
entropy_C = entropy(labels_true)
entropy_K = entropy(labels_pred)
contingency = conting... | sklearn/metrics/cluster/_supervised.py | 205 | scikit-learn | {
"docstring": "Compute the homogeneity and completeness and V-Measure scores at once.\n\n Those metrics are based on normalized conditional entropy measures of\n the clustering labeling to evaluate given the knowledge of a Ground\n Truth class labels of the same samples.\n\n A clustering result satisfies... | 83 | Python | 48 | 1ac8ea14847cad8bec5ac49a01013beef4361f79 | _supervised.py | 260,492 | 20 | 151 | homogeneity_completeness_v_measure | https://github.com/scikit-learn/scikit-learn.git | DOC Ensure homogeneity_completeness_v_measure passes numpydoc validation (#23942) | 191 | 0 | 76,288 | 15 | |
3 | 8 | def leaf_symbols(self) -> Iterable[Symbol]:
for arg in self.arguments:
if isinstance(arg, SymbolicExpression):
yield from arg.leaf_symbols()
| nni/mutable/symbol.py | 54 | nni | {
"docstring": "\n Return a generator of all leaf symbols.\n\n Useful for when you want to inspect when the symbols come from.\n No deduplication even if the symbols has duplicates.\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 27,
"vocab_size": 24
} | 14 | Python | 14 | 8f454f3bf29e2c3cd0d359231a46edd8ee768d42 | symbol.py | 113,538 | 10 | 33 | leaf_symbols | https://github.com/microsoft/nni.git | Mutable V3 (Stage 2) - Symbolic execution engine (#5195) | 54 | 0 | 24,940 | 12 | |
2 | 8 | def get_existing_payment_request_amount(ref_dt, ref_dn):
existing_payment_request_amount = frappe.db.sql(
,
(ref_dt, ref_dn),
)
return flt(existing_payment_request_amount[0][0]) if existing_payment_request_amount else 0
| erpnext/accounts/doctype/payment_request/payment_request.py | 62 | erpnext | {
"docstring": "\n\tGet the existing payment request which are unpaid or partially paid for payment channel other than Phone\n\tand get the summation of existing paid payment request for Phone payment channel.\n\t\n\t\tselect sum(grand_total)\n\t\tfrom `tabPayment Request`\n\t\twhere\n\t\t\treference_doctype = %s\n\t... | 16 | Python | 15 | 494bd9ef78313436f0424b918f200dab8fc7c20b | payment_request.py | 64,926 | 16 | 40 | get_existing_payment_request_amount | https://github.com/frappe/erpnext.git | style: format code with black | 10 | 0 | 13,755 | 10 | |
2 | 24 | def argsort(self, axis=0, kind="quicksort", order=None) -> Series:
values = self._values
mask = isna(values)
if mask.any():
result = np.full(len(self), -1, dtype=np.intp)
notmask = ~mask
result[notmask] = np.argsort(values[notmask], kind=kind)
... | pandas/core/series.py | 203 | pandas | {
"docstring": "\n Return the integer indices that would sort the Series values.\n\n Override ndarray.argsort. Argsorts the value, omitting NA/null values,\n and places the result in the same locations as the non-NA values.\n\n Parameters\n ----------\n axis : {0 or 'index'}\... | 41 | Python | 32 | 244f747bb63f45c1c439193f0672c6162853b168 | series.py | 166,613 | 37 | 131 | argsort | https://github.com/pandas-dev/pandas.git | make series axis parameter docs consistent (#47109)
* make series docs consistent
add series unused param info to DF docs
* fix trailing whitespace
* fix docs build
* add unused
* add or update docs for all series methods
* small fix
* fix line length
* fix param order
* fix param order
*... | 134 | 0 | 39,842 | 12 | |
1 | 27 | async def test_get_image_disabled(hass):
patch_key, entity_id, config_entry = _setup(CONFIG_ANDROIDTV_DEFAULT)
config_entry.add_to_hass(hass)
hass.config_entries.async_update_entry(
config_entry, options={CONF_SCREENCAP: False}
)
with patchers.patch_connect(True)[patch_key], patchers.p... | tests/components/androidtv/test_media_player.py | 218 | core | {
"docstring": "Test that the screencap option can disable entity_picture.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 49 | Python | 38 | d989e4373d576c403790c9a7e5eb7a29d08e3c47 | test_media_player.py | 317,428 | 19 | 130 | test_get_image_disabled | https://github.com/home-assistant/core.git | Remove websocket_api send_big_result (#75452) | 130 | 0 | 115,995 | 11 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.