complexity int64 1 139 | fun_name stringlengths 1 80 | code stringlengths 101 62.2k | commit_id stringlengths 40 40 | ast_errors stringlengths 0 3.11k | ast_levels int64 6 36 | file_name stringlengths 5 79 | n_ast_nodes int64 17 19.2k | commit_message stringlengths 3 15.3k | d_id int64 12 121k | n_ast_errors int64 0 9 | n_whitespaces int64 4 10.8k | token_counts int64 5 3.06k | vocab_size int64 4 1.11k | id int64 20 338k | n_words int64 4 4.82k | repo stringlengths 3 22 | n_identifiers int64 2 176 | path stringlengths 7 134 | language stringclasses 1
value | nloc int64 1 413 | documentation dict | url stringlengths 31 59 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | test_cyclic | def test_cyclic(self):
one = '<li>Cyclic one: <a href="%s">I am recursive</a>' % (
reverse("admin:admin_views_cyclicone_change", args=(self.cy1.pk,)),
)
two = '<li>Cyclic two: <a href="%s">I am recursive too</a>' % (
reverse("admin:admin_views_cyclictwo_change", ... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 14 | tests.py | 151 | Refs #33476 -- Reformatted code with Black. | 52,132 | 0 | 137 | 94 | 29 | 207,849 | 41 | django | 13 | tests/admin_views/tests.py | Python | 12 | {
"docstring": "\n Cyclic relationships should still cause each object to only be\n listed once.\n ",
"language": "en",
"n_whitespaces": 34,
"n_words": 12,
"vocab_size": 12
} | https://github.com/django/django.git | |
1 | test_center_head_loss | def test_center_head_loss(self):
s = 256
img_metas = [{'batch_input_shape': (s, s, 3)}]
test_cfg = dict(topK=100, max_per_img=100)
centernet_head = CenterNetHead(
num_classes=4, in_channels=1, feat_channels=4, test_cfg=test_cfg)
feat = [torch.rand(1, 1, s, s... | 96aa909c19dbe753852ac6dba13bbbc35329b99f | 10 | test_centernet_head.py | 457 | [Refactor] CenterNet | 70,506 | 0 | 532 | 295 | 101 | 244,739 | 183 | mmdetection | 34 | tests/test_models/test_dense_heads/test_centernet_head.py | Python | 33 | {
"docstring": "Tests center head loss when truth is empty and non-empty.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/open-mmlab/mmdetection.git | |
1 | parsebytes | def parsebytes(self, text, headersonly=False):
text = text.decode('ASCII', errors='surrogateescape')
return self.parser.parsestr(text, headersonly)
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 10 | parser.py | 58 | add python 3.10.4 for windows | 57,101 | 0 | 32 | 35 | 11 | 223,843 | 11 | XX-Net | 8 | python3.10.4/Lib/email/parser.py | Python | 3 | {
"docstring": "Create a message structure from a byte string.\n\n Returns the root of the message structure. Optional headersonly is a\n flag specifying whether to stop parsing after reading the headers or\n not. The default is False, meaning it parses the entire contents of\n the file.... | https://github.com/XX-net/XX-Net.git | |
3 | shuffle | def shuffle(self) -> "SampleBatch":
# Shuffling the data when we have `seq_lens` defined is probably
# a bad idea!
if self.get(SampleBatch.SEQ_LENS) is not None:
raise ValueError(
"SampleBatch.shuffle not possible when your data has "
"`seq_l... | de9e143938d2e551e973496e167297dcd166b3c8 | 11 | sample_batch.py | 151 | [RLlib] Issue 23907: SampleBatch.shuffle does not flush intercepted_values dict (which it should). (#24005) | 34,200 | 0 | 256 | 86 | 75 | 148,185 | 99 | ray | 19 | rllib/policy/sample_batch.py | Python | 26 | {
"docstring": "Shuffles the rows of this batch in-place.\n\n Returns:\n This very (now shuffled) SampleBatch.\n\n Raises:\n ValueError: If self[SampleBatch.SEQ_LENS] is defined.\n\n Examples:\n >>> from ray.rllib.policy.sample_batch import SampleBatch\n ... | https://github.com/ray-project/ray.git | |
1 | frucht_graph | def frucht_graph(create_using=None):
G = cycle_graph(7, create_using)
G.add_edges_from(
[
[0, 7],
[1, 7],
[2, 8],
[3, 9],
[4, 9],
[5, 10],
[6, 10],
[7, 11],
[8, 11],
[8, 9],
... | dec723f072eb997a497a159dbe8674cd39999ee9 | 9 | small.py | 130 | Docstrings for the small.py module (#5240)
* added description for the first 5 small graphs
* modified descriptions based on comment and added description for two more functions
* added doctrings to all the functions
* Minor touchups.
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> | 41,743 | 0 | 191 | 96 | 29 | 176,173 | 38 | networkx | 6 | networkx/generators/small.py | Python | 19 | {
"docstring": "\n Returns the Frucht Graph.\n\n The Frucht Graph is the smallest cubical graph whose\n automorphism group consists only of the identity element [1]_.\n It has 12 nodes and 18 edges and no nontrivial symmetries.\n It is planar and Hamiltonian [2]_.\n\n Parameters\n ----------\n ... | https://github.com/networkx/networkx.git | |
1 | managed | def managed(self): # type: () -> bool
return t.cast(bool, self._get_cloud_config(self._MANAGED))
| a06fa496d3f837cca3c437ab6e9858525633d147 | 10 | __init__.py | 38 | 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... | 78,553 | 0 | 25 | 22 | 10 | 266,742 | 10 | ansible | 7 | test/lib/ansible_test/_internal/commands/integration/cloud/__init__.py | Python | 2 | {
"docstring": "True if resources are managed by ansible-test, otherwise False.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/ansible/ansible.git | |
1 | _combine_individual_stats | def _combine_individual_stats(self, operator_count, cv_score, individual_stats):
stats = deepcopy(
individual_stats
) # Deepcopy, since the string reference to predecessor should be cloned
stats["operator_count"] = operator_count
stats["internal_cv_score"] = cv_scor... | 388616b6247ca4ea8de4e2f340d6206aee523541 | 8 | base.py | 55 | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 43,600 | 0 | 83 | 32 | 26 | 181,816 | 29 | tpot | 7 | tpot/base.py | Python | 7 | {
"docstring": "Combine the stats with operator count and cv score and preprare to be written to _evaluated_individuals\n\n Parameters\n ----------\n operator_count: int\n number of components in the pipeline\n cv_score: float\n internal cross validation score\n ... | https://github.com/EpistasisLab/tpot.git | |
7 | __arrow_array__ | def __arrow_array__(self, type=None):
import pyarrow
from pandas.core.arrays.arrow._arrow_utils import ArrowIntervalType
try:
subtype = pyarrow.from_numpy_dtype(self.dtype.subtype)
except TypeError as err:
raise TypeError(
f"Conversion t... | 41e423fd09df5817dcfa11f3aea111a5b1a2f98a | 19 | interval.py | 450 | REF: Create pandas/core/arrays/arrow (#46591) | 39,734 | 0 | 711 | 249 | 106 | 165,894 | 149 | pandas | 40 | pandas/core/arrays/interval.py | Python | 42 | {
"docstring": "\n Convert myself into a pyarrow Array.\n \n Return an %(return_type)s of tuples of the form (left, right).\n\n Parameters\n ----------\n na_tuple : bool, default True\n Returns NA as a tuple if True, ``(nan, nan)``, or just as the NA\n v... | https://github.com/pandas-dev/pandas.git | |
14 | getopt | def getopt(self, args=None, object=None):
if args is None:
args = sys.argv[1:]
if object is None:
object = OptionDummy()
created_object = True
else:
created_object = False
self._grok_option_table()
short_opts = ' '.join(s... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 14 | fancy_getopt.py | 437 | add python 3.10.4 for windows | 56,808 | 0 | 660 | 269 | 101 | 222,919 | 171 | XX-Net | 31 | python3.10.4/Lib/distutils/fancy_getopt.py | Python | 40 | {
"docstring": "Parse command-line options in args. Store as attributes on object.\n\n If 'args' is None or not supplied, uses 'sys.argv[1:]'. If\n 'object' is None or not supplied, creates a new OptionDummy\n object, stores option values there, and returns a tuple (args,\n object). If '... | https://github.com/XX-net/XX-Net.git | |
14 | split_code_in_indented_blocks | def split_code_in_indented_blocks(code, indent_level="", start_prompt=None, end_prompt=None):
# Let's split the code into lines and move to start_index.
index = 0
lines = code.split("\n")
if start_prompt is not None:
while not lines[index].startswith(start_prompt):
index += 1
... | 4261c3aadfc23ee5b123b80ab7d8680a013acb66 | 17 | custom_init_isort.py | 478 | Make style | 120,784 | 0 | 445 | 284 | 80 | 335,484 | 153 | diffusers | 15 | utils/custom_init_isort.py | Python | 32 | {
"docstring": "\n Split `code` into its indented blocks, starting at `indent_level`. If provided, begins splitting after\n `start_prompt` and stops at `end_prompt` (but returns what's before `start_prompt` as a first block and what's\n after `end_prompt` as a last block, so `code` is always the same as join... | https://github.com/huggingface/diffusers.git | |
2 | test_find_next_time_expression_tenth_second_pattern_does_not_drift_entering_dst | def test_find_next_time_expression_tenth_second_pattern_does_not_drift_entering_dst():
tz = dt_util.get_time_zone("America/Chicago")
dt_util.set_default_time_zone(tz)
tenth_second_pattern = (None, None, "10")
# Entering DST, clocks go forward
test_time = datetime(2021, 3, 15, 2, 30, 0, tzinfo=t... | 4e9bc9eaffd464f192d187a01771a86699b2f932 | 14 | test_dt.py | 236 | Small cleanups to find_next_time_expression and addition of tests (#71845) | 99,552 | 0 | 214 | 159 | 55 | 300,692 | 82 | core | 26 | tests/util/test_dt.py | Python | 23 | {
"docstring": "Test finding next time expression tenth second pattern does not drift entering dst.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 13
} | https://github.com/home-assistant/core.git | |
1 | groundtruths | def groundtruths(self) -> 'DocumentArray':
return DocumentArray(self._content.groundtruths)
| 933415bfa1f9eb89f935037014dfed816eb9815d | 9 | data.py | 36 | feat: star routing (#3900)
* feat(proto): adjust proto for star routing (#3844)
* feat(proto): adjust proto for star routing
* feat(proto): generate proto files
* feat(grpc): refactor grpclet interface (#3846)
* feat: refactor connection pool for star routing (#3872)
* feat(k8s): add more labels to k8s ... | 1,803 | 0 | 32 | 17 | 6 | 9,954 | 6 | jina | 4 | jina/types/request/data.py | Python | 5 | {
"docstring": "Get the :class: `DocumentArray` with sequence `data.docs` as content.\n\n .. # noqa: DAR201\n :class:`DataRequest` is one of the **primitive data type** in Jina.\n\n It offers a Pythonic interface to allow users access and manipulate\n :class:`jina.jina_pb2.DataRequestProto` object... | https://github.com/jina-ai/jina.git | |
3 | sharey | def sharey(self, other):
_api.check_isinstance(_AxesBase, other=other)
if self._sharey is not None and other is not self._sharey:
raise ValueError("y-axis is already shared")
self._shared_axes["y"].join(self, other)
self._sharey = other
self.yaxis.major = oth... | f156db08eee54d285ab0fb4e031e48d078ba6aa3 | 10 | _base.py | 188 | DOC: More cleanup axes -> Axes | 22,766 | 0 | 133 | 118 | 39 | 107,477 | 50 | matplotlib | 21 | lib/matplotlib/axes/_base.py | Python | 11 | {
"docstring": "\n Share the y-axis with *other*.\n\n This is equivalent to passing ``sharey=other`` when constructing the\n Axes, and cannot be used if the y-axis is already being shared with\n another Axes.\n ",
"language": "en",
"n_whitespaces": 65,
"n_words": 29,
"vocab_... | https://github.com/matplotlib/matplotlib.git | |
11 | clean_text | def clean_text(start_token, end_token, doc_tokens, doc_bytes, ignore_final_whitespace=True):
text = ""
for index in range(start_token, end_token):
token = doc_tokens[index]
if token["html_token"]:
continue
text += token["token"]
# Add a single space between two t... | a59bca366174d9c692fa19750c24d65f47660ef7 | 14 | nq_to_squad.py | 250 | Apply black formatting (#2115)
* Testing black on ui/
* Applying black on docstores
* Add latest docstring and tutorial changes
* Create a single GH action for Black and docs to reduce commit noise to the minimum, slightly refactor the OpenAPI action too
* Remove comments
* Relax constraints on pydoc-ma... | 74,866 | 0 | 559 | 144 | 107 | 256,314 | 175 | haystack | 18 | test/benchmarks/nq_to_squad.py | Python | 23 | {
"docstring": "Remove HTML tags from a text span and reconstruct proper spacing.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | https://github.com/deepset-ai/haystack.git | |
3 | test_simple_q_compilation | def test_simple_q_compilation(self):
# Run locally and with compression
config = (
simple_q.SimpleQConfig()
.rollouts(num_rollout_workers=0, compress_observations=True)
.training(num_steps_sampled_before_learning_starts=0)
)
num_iterations = ... | 0dceddb912ed92286032b5563dd2e541a8a7031f | 13 | test_simple_q.py | 180 | [RLlib] Move learning_starts logic from buffers into `training_step()`. (#26032) | 28,323 | 0 | 241 | 109 | 40 | 126,972 | 47 | ray | 31 | rllib/algorithms/simple_q/tests/test_simple_q.py | Python | 17 | {
"docstring": "Test whether SimpleQ can be built on all frameworks.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/ray-project/ray.git | |
1 | load_config | def load_config(file_path):
_, ext = os.path.splitext(file_path)
assert ext in ['.yml', '.yaml'], "only support yaml files for now"
config = yaml.load(open(file_path, 'rb'), Loader=yaml.Loader)
return config
| a323fce66dd68a881cf599526185b52ab5df356b | 11 | program.py | 84 | vqa code integrated into ppocr training system | 4,491 | 0 | 39 | 49 | 21 | 22,954 | 24 | PaddleOCR | 12 | tools/program.py | Python | 5 | {
"docstring": "\n Load config from yml/yaml file.\n Args:\n file_path (str): Path of the config file to be loaded.\n Returns: global config\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 19,
"vocab_size": 17
} | https://github.com/PaddlePaddle/PaddleOCR.git | |
4 | _get_spaces_from_remote_worker | def _get_spaces_from_remote_worker(self):
# Get ID of the first remote worker.
worker_id = next(iter(self.__worker_manager.actors().keys()))
# Try to figure out spaces from the first remote worker.
remote_spaces = self.foreach_worker(
lambda worker: worker.foreach_p... | e707ce4fb3717e3c05118c57f503dfbd03552ca9 | 15 | worker_set.py | 286 | [RLlib] Refactor `WorkerSet` on top of `FaultTolerantActorManager`. (#29938)
Signed-off-by: Jun Gong <jungong@anyscale.com> | 30,791 | 0 | 496 | 177 | 94 | 136,000 | 137 | ray | 27 | rllib/evaluation/worker_set.py | Python | 32 | {
"docstring": "Infer observation and action spaces from a remote worker.\n\n Returns:\n A dict mapping from policy ids to spaces.\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 18,
"vocab_size": 17
} | https://github.com/ray-project/ray.git | |
1 | test_performance_frozen_clock | def test_performance_frozen_clock(self) -> None:
past_stats = [
(self.hs.get_clock().time(), resource.getrusage(resource.RUSAGE_SELF))
]
stats: JsonDict = {}
self.get_success(phone_stats_home(self.hs, stats, past_stats))
self.assertEqual(stats["cpu_average"],... | d666fc02fab7421efb39a33800a83791f88bf9b2 | 13 | test_phone_home.py | 107 | Add type hints to some tests files (#12371) | 71,999 | 0 | 72 | 66 | 18 | 247,931 | 19 | synapse | 14 | tests/test_phone_home.py | Python | 10 | {
"docstring": "\n If time doesn't move, don't error out.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | https://github.com/matrix-org/synapse.git | |
4 | get_trades | def get_trades(trade_filter=None) -> Query:
if not Trade.use_db:
raise NotImplementedError('`Trade.get_trades()` not supported in backtesting mode.')
if trade_filter is not None:
if not isinstance(trade_filter, list):
trade_filter = [trade_filter]
... | b58e811b1486ae62e835cbea3e40cf88128243a0 | 11 | trade_model.py | 96 | Move trade/order Models to their own class | 34,484 | 0 | 118 | 57 | 24 | 149,690 | 31 | freqtrade | 10 | freqtrade/persistence/trade_model.py | Python | 18 | {
"docstring": "\n Helper function to query Trades using filters.\n NOTE: Not supported in Backtesting.\n :param trade_filter: Optional filter to apply to trades\n Can be either a Filter object, or a List of filters\n e.g. `(trade_filter=[Tr... | https://github.com/freqtrade/freqtrade.git | |
1 | load_data | def load_data(path="boston_housing.npz", test_split=0.2, seed=113):
assert 0 <= test_split < 1
origin_folder = (
"https://storage.googleapis.com/tensorflow/tf-keras-datasets/"
)
path = get_file(
path,
origin=origin_folder + "boston_housing.npz",
file_hash=( # noqa: ... | be73ac1a1e25d9abd4d793cba9707098d7adf231 | 15 | boston_housing.py | 354 | Add f-string format and lint with flynt on the whole codebase | 82,968 | 0 | 202 | 221 | 63 | 279,394 | 90 | keras | 27 | keras/datasets/boston_housing.py | Python | 25 | {
"docstring": "Loads the Boston Housing dataset.\n\n This is a dataset taken from the StatLib library which is maintained at\n Carnegie Mellon University.\n\n **WARNING:** This dataset has an ethical problem: the authors of this\n dataset included a variable, \"B\", that may appear to assume that racial\... | https://github.com/keras-team/keras.git | |
1 | test_androidtv_select_source_overridden_app_name | async def test_androidtv_select_source_overridden_app_name(hass):
# Evidence that the default YouTube app ID will be overridden
conf_apps = {
"com.youtube.test": "YouTube",
}
assert "YouTube" in ANDROIDTV_APPS.values()
assert "com.youtube.test" not in ANDROIDTV_APPS
await _test_sele... | ea456893f94c7dc88b0cc28f92dadf240fbb1fe7 | @pytest.mark.parametrize(
["source", "expected_arg", "method_patch"],
[
("com.app.test1", "com.app.test1", patchers.PATCH_LAUNCH_APP),
("TEST 1", "com.app.test1", patchers.PATCH_LAUNCH_APP),
("com.app.test2", "com.app.test2", patchers.PATCH_LAUNCH_APP),
("com.app.test3", "com.app... | 9 | test_media_player.py | 243 | Review AndroidTV tests for media player entity (#71168) | 98,649 | 1 | 207 | 45 | 55 | 299,745 | 71 | core | 13 | tests/components/androidtv/test_media_player.py | Python | 14 | {
"docstring": "Test that when an app name is overridden via the `apps` configuration parameter, the app is launched correctly.",
"language": "en",
"n_whitespaces": 17,
"n_words": 18,
"vocab_size": 15
} | https://github.com/home-assistant/core.git |
2 | to_row_dict | def to_row_dict(self, item):
row_dict = OrderedDict(
(field, item.get_data().get(field)) for field in self.list_export
)
return row_dict
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 13 | views.py | 56 | Reformat with black | 15,939 | 0 | 54 | 35 | 14 | 73,068 | 15 | wagtail | 9 | wagtail/contrib/forms/views.py | Python | 5 | {
"docstring": "Orders the submission dictionary for spreadsheet writing",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 7
} | https://github.com/wagtail/wagtail.git | |
1 | _get_multi_faces | def _get_multi_faces(self) -> Union[Generator[str, None, None],
Generator[Tuple[str, int], None, None]]:
process_type = getattr(self, f"_get_multi_faces_{self._type}")
for item in process_type():
yield item
| e2a77e7c6e84e81f642cb22f528e25e3f2d2dbc1 | 11 | jobs.py | 80 | Alignments Tool - Typing, Documentation + Re-org | 21,125 | 0 | 91 | 31 | 18 | 101,721 | 20 | faceswap | 11 | tools/alignments/jobs.py | Python | 2 | {
"docstring": " yield each frame or face that has multiple faces matched in alignments file\n\n Yields\n ------\n str or tuple\n The frame name of any frames which have multiple faces and potentially the face id\n ",
"language": "en",
"n_whitespaces": 73,
"n_words": 33,
... | https://github.com/deepfakes/faceswap.git | |
1 | group_members | def group_members(self) -> list[str] | None:
return self.speaker.sonos_group_entities
| 6151306e3d8f0bc774145280276a1801613f8aa7 | 7 | media_player.py | 32 | Use standard attribute for Sonos group members (#70924) | 98,271 | 0 | 22 | 19 | 8 | 299,337 | 8 | core | 6 | homeassistant/components/sonos/media_player.py | Python | 3 | {
"docstring": "List of entity_ids which are currently grouped together.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/home-assistant/core.git | |
1 | losses | def losses(self, vv):
with tf.compat.v1.variable_scope("losses"):
obj = self.free_energy(vv) - self.free_energy(self.v_k)
return obj
| dbf7ed08d36b4c77e5455c2c3ba165d6308aeaaf | 12 | rbm.py | 68 | update loss function documentation | 7,088 | 0 | 44 | 39 | 11 | 39,033 | 12 | recommenders | 10 | recommenders/models/rbm/rbm.py | Python | 4 | {
"docstring": "Calculate contrastive divergence, which is the difference between\n the free energy clamped on the data (v) and the model Free energy (v_k).\n\n Args:\n vv (tf.Tensor, float32): empirical input\n\n Returns:\n obj: contrastive divergence\n ",
"languag... | https://github.com/microsoft/recommenders.git | |
4 | update_positions | def update_positions(self, renderer):
x, y = self.xybox
if isinstance(self.boxcoords, tuple):
xcoord, ycoord = self.boxcoords
x1, y1 = self._get_xy(renderer, x, y, xcoord)
x2, y2 = self._get_xy(renderer, x, y, ycoord)
ox0, oy0 = x1, y2
el... | 924d7c7f9900d8839e66616791121237101e7b57 | 14 | offsetbox.py | 418 | Cleanup AnnotationBbox.
Inline _update_position_xybox into update_positions. Avoid unpacking
x,y pairs where unnecessary. Don't bother copying arrowprops, as we
don't actually modify it. Reuse mutation scale for both patch and
arrow. Clarify the doc for frameon. Various small extra cleanups. | 22,838 | 0 | 501 | 264 | 113 | 107,623 | 169 | matplotlib | 49 | lib/matplotlib/offsetbox.py | Python | 26 | {
"docstring": "\n Update pixel positions for the annotated point, the text and the arrow.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 10
} | https://github.com/matplotlib/matplotlib.git | |
1 | test_events_service_call | async def test_events_service_call(hass):
mock_session = MockAioSession()
with async_patch(
"homeassistant.components.aws.AioSession", return_value=mock_session
):
await async_setup_component(
hass,
"aws",
{
"aws": {
... | dbfca8def81b6aac9b4bd0a494c96a0b15f1a82c | 18 | test_init.py | 328 | Add support for EventBridge to aws integration (#77573)
* Added EventBridge support to aws integration
* Added type hints for all aws notification services + Added unit tests for EventBridge AWS integration
* Increase line coverage for unit tests for aws integration. | 88,945 | 0 | 568 | 173 | 65 | 289,810 | 82 | core | 17 | tests/components/aws/test_init.py | Python | 46 | {
"docstring": "Test events service (EventBridge) call works as expected.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/home-assistant/core.git | |
5 | _consume_incoming | async def _consume_incoming(self) -> None:
while True:
message_json = await self.incoming_queue.get()
if message_json is None:
self.incoming_queue.task_done()
break
type = message_json["type"]
if type == "client_log":
... | a72e347ed99333a090377ee438eaf63477cbf98b | 16 | service.py | 299 | Seperate server and client handling logic into classes for devtools | 44,000 | 0 | 506 | 170 | 49 | 182,900 | 67 | textual | 27 | src/textual/devtools/service.py | Python | 32 | {
"docstring": "Consume messages from the incoming (client -> server) Queue, and print\n the corresponding renderables to the console for each message.\n ",
"language": "en",
"n_whitespaces": 34,
"n_words": 20,
"vocab_size": 18
} | https://github.com/Textualize/textual.git | |
6 | resolve | def resolve(self, root_reqs, check_supported_wheels):
# type: (List[InstallRequirement], bool) -> RequirementSet
requirement_set = RequirementSet(check_supported_wheels=check_supported_wheels)
for req in root_reqs:
if req.constraint:
check_invalid_constraint_... | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 13 | resolver.py | 163 | upd; format | 12,406 | 0 | 295 | 97 | 71 | 61,064 | 88 | transferlearning | 20 | .venv/lib/python3.8/site-packages/pip/_internal/resolution/legacy/resolver.py | Python | 17 | {
"docstring": "Resolve what operations need to be done\n\n As a side-effect of this method, the packages (and their dependencies)\n are downloaded, unpacked and prepared for installation. This\n preparation is done by ``pip.operations.prepare``.\n\n Once PyPI has static dependency metadat... | https://github.com/jindongwang/transferlearning.git | |
1 | test_convert_outgoing_payload | async def test_convert_outgoing_payload(hass):
command_template = mqtt.MqttCommandTemplate(None, hass=hass)
assert command_template.async_render(b"\xde\xad\xbe\xef") == b"\xde\xad\xbe\xef"
assert (
command_template.async_render("b'\\xde\\xad\\xbe\\xef'")
== "b'\\xde\\xad\\xbe\\xef'"
... | 457ce195dd9758cc7916d0cf1786948a10ef8135 | 10 | test_init.py | 129 | Add mqtt entity attributes command templates (#61937)
* Add entity variables to MqttCommandTemplate
* missing command template update
* make hass and entity conditional parameters
* Add encoding support for publishing
* Revert "Add encoding support for publishing"
This reverts commit b69b9c60ececdab1d35... | 107,239 | 0 | 67 | 71 | 22 | 308,485 | 29 | core | 6 | tests/components/mqtt/test_init.py | Python | 10 | {
"docstring": "Test the converting of outgoing MQTT payloads without template.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/home-assistant/core.git | |
2 | test_sessions_metrics_equal_num_keys | def test_sessions_metrics_equal_num_keys(self):
interval_days_int = 1
interval_days = f"{interval_days_int}d"
groupbyes = _session_groupby_powerset()
for groupby in groupbyes:
with patch(
"sentry.api.endpoints.organization_sessions.release_health",
... | 4d9743df1cadba2b3dd8055f05c76e6e5fae3c4d | 14 | test_metrics_sessions_v2.py | 172 | fix(metrics): Fix flaky test [TET-387] (#39742)
This PR aims at fixing the flakiness reproduced
[here](https://sentry.io/organizations/sentry/issues/3070580114/?project=2423079&query=is:unresolved+test_sessions_metrics_equal_num_keys&statsPeriod=14d). | 18,144 | 0 | 302 | 101 | 41 | 86,663 | 54 | sentry | 20 | tests/sentry/release_health/test_metrics_sessions_v2.py | Python | 21 | {
"docstring": "\n Tests whether the number of keys in the metrics implementation of\n sessions data is the same as in the sessions implementation.\n\n ",
"language": "en",
"n_whitespaces": 43,
"n_words": 21,
"vocab_size": 15
} | https://github.com/getsentry/sentry.git | |
2 | stop_gradient | def stop_gradient(variables):
if isinstance(variables, (list, tuple)):
return map(tf.stop_gradient, variables)
return tf.stop_gradient(variables)
# CONTROL FLOW
@keras_export("keras.backend.rnn")
@tf.__internal__.dispatch.add_dispatch_support | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | @keras_export("keras.backend.rnn")
@tf.__internal__.dispatch.add_dispatch_support | 10 | backend.py | 78 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,112 | 1 | 29 | 34 | 15 | 269,479 | 16 | keras | 11 | keras/backend.py | Python | 4 | {
"docstring": "Returns `variables` but with zero gradient w.r.t. every other variable.\n\n Args:\n variables: Tensor or list of tensors to consider constant with respect\n to any other variable.\n\n\n Returns:\n A single tensor or a list of tensors (depending on the passed argument)\n ... | https://github.com/keras-team/keras.git |
1 | test_max_pos | def test_max_pos(self) -> None:
cache = StreamChangeCache("#test", 1)
cache.entity_has_changed("user@foo.com", 2)
cache.entity_has_changed("bar@baz.net", 3)
cache.entity_has_changed("user@elsewhere.org", 4)
# Known entities will return the point where they were changed... | acea4d7a2ff61b5beda420b54a8451088060a8cd | 10 | test_stream_change_cache.py | 162 | Add missing types to tests.util. (#14597)
Removes files under tests.util from the ignored by list, then
fully types all tests/util/*.py files. | 73,230 | 0 | 119 | 92 | 33 | 250,016 | 42 | synapse | 7 | tests/util/test_stream_change_cache.py | Python | 14 | {
"docstring": "\n StreamChangeCache.get_max_pos_of_last_change will return the most\n recent point where the entity could have changed. If the entity is not\n known, the stream start is provided instead.\n ",
"language": "en",
"n_whitespaces": 55,
"n_words": 25,
"vocab_size": 20
... | https://github.com/matrix-org/synapse.git | |
1 | test_simple_animation_reverse | def test_simple_animation_reverse():
# Thing that may be animated
animatable = AnimateTest()
# Fake wall-clock time
time = 100.0
# Object that does the animation
animation = SimpleAnimation(
animatable,
"foo",
time,
3.0,
start_value=50.0,
e... | 8be6ea91f6e8a8d24d385975f1a5a7714cf27894 | 11 | test_animator.py | 162 | fix and test for animator | 43,809 | 0 | 180 | 127 | 47 | 182,371 | 76 | textual | 12 | tests/test_animator.py | Python | 21 | {
"docstring": "Test an animation from one float to another, where the end value is less than the start.",
"language": "en",
"n_whitespaces": 16,
"n_words": 17,
"vocab_size": 16
} | https://github.com/Textualize/textual.git | |
6 | before_task_publish_handler | def before_task_publish_handler(sender=None, headers=None, body=None, **kwargs):
if "task" not in headers or headers["task"] != "documents.tasks.consume_file":
# Assumption: this is only ever a v2 message
return
try:
task_args = body[0]
task_kwargs = body[1]
task_f... | 97d6503fefc5737028637c39a2c1f33dd1e12904 | @task_prerun.connect | 13 | handlers.py | 258 | Switches task serialization over to pickle format | 117,208 | 1 | 347 | 149 | 89 | 320,534 | 112 | paperless-ngx | 33 | src/documents/signals/handlers.py | Python | 24 | {
"docstring": "\n Creates the PaperlessTask object in a pending state. This is sent before\n the task reaches the broker, but before it begins executing on a worker.\n\n https://docs.celeryq.dev/en/stable/userguide/signals.html#before-task-publish\n\n https://docs.celeryq.dev/en/stable/internals/protoco... | https://github.com/paperless-ngx/paperless-ngx.git |
1 | test_dataframe_format_with_index | def test_dataframe_format_with_index():
pytest.importorskip("jinja2")
df = pd.DataFrame(
{
"A": [1, 2, 3, 4, 5, 6, 7, 8],
"B": list("ABCDEFGH"),
"C": pd.Categorical(list("AAABBBCC")),
},
index=list("ABCDEFGH"),
)
ddf = dd.from_pandas(df, 3)
... | ddcb841903f8f180aa359bd8db0054aa3b5964e3 | 15 | test_format.py | 259 | Change repr methods to avoid Layer materialization (#9289)
* change task count to layer count in DataFrame and Array reprs
* add test
* address doctest failure
* simplify test
* support pluralization
* use 'graph layers' instead of 'layers' to be more explicit | 36,771 | 0 | 453 | 145 | 70 | 156,780 | 100 | dask | 20 | dask/dataframe/tests/test_format.py | Python | 79 | {
"docstring": "<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>A</th>\n <th>B</th>\n <th>C</th>\n </tr>\n <tr>\n <th>npartitions=3</th>\n <th></th>\n <th></th>\n <th></th>\n </tr>\n </thead>\n <tbody>\n ... | https://github.com/dask/dask.git | |
4 | is_path | def is_path(G, path):
for node, nbr in nx.utils.pairwise(path):
if (node not in G) or (nbr not in G[node]):
return False
return True
| d8b07498dfcd9fb2ce1c83ccf190ab24209234e8 | 11 | function.py | 68 | Minor docstring touchups and test refactor for `is_path` (#5967)
* Touch up docstring.
* Condense conditional.
* Minor refactor of ispath test - parametrize and rm redundant.
* Add release note.
* Update networkx/classes/function.py
Co-authored-by: Dan Schult <dschult@colgate.edu>
Co-authored-by: Dan... | 42,315 | 0 | 49 | 44 | 18 | 177,249 | 22 | networkx | 8 | networkx/classes/function.py | Python | 5 | {
"docstring": "Returns whether or not the specified path exists.\n\n For it to return True, every node on the path must exist and\n each consecutive pair must be connected via one or more edges.\n\n Parameters\n ----------\n G : graph\n A NetworkX graph.\n\n path : list\n A list of no... | https://github.com/networkx/networkx.git | |
7 | evaluate | def evaluate(self, eval_features, return_realism=False, return_neighbors=False):
num_eval_images = eval_features.shape[0]
num_ref_images = self.D.shape[0]
distance_batch = np.zeros([self.row_batch_size, num_ref_images], dtype=np.float16)
batch_predictions = np.zeros([num_eval_im... | 7375ee364e0df2a417f92593e09557f1b2a3575a | 14 | precision_recall.py | 499 | initialize ostec | 1,623 | 0 | 485 | 336 | 118 | 9,466 | 185 | insightface | 38 | reconstruction/ostec/external/stylegan2/metrics/precision_recall.py | Python | 25 | {
"docstring": "Evaluate if new feature vectors are in the estimated manifold.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/deepinsight/insightface.git | |
1 | test_processors | def test_processors(self):
from djangocms_text_ckeditor.cms_plugins import TextPlugin
from cms.plugin_pool import plugin_pool
instance = CMSPlugin.objects.all()[0].get_plugin_instance()[0]
load_from_string = self.load_template_from_string
| a3110e1ff24085373898c7d2a85f628abeb8518d | 13 | test_rendering.py | 69 | Enabled isort workflow (#7200)
* Ran isort
* Enabled isort workflow
Co-authored-by: Vinit Kumar <mail@vinitkumar.me> | 17,345 | 0 | 51 | 169 | 13 | 82,298 | 16 | django-cms | 14 | cms/tests/test_rendering.py | Python | 27 | {
"docstring": "\n Tests that plugin processors and plugin context processors can be defined\n in settings and are working and that extra plugin context processors can be\n passed to PluginContext.\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 27,
"vocab_size": 17
} | https://github.com/django-cms/django-cms.git | |
5 | __aenter__ | async def __aenter__(self):
if self._closed:
# httpx.AsyncClient does not allow reuse so we will not either.
raise RuntimeError(
"The client cannot be started again after closing. "
"Retrieve a new client with `get_client()` instead."
... | 05b92d7c7f6cf21c5d6033df7242c331fc66b92e | 14 | client.py | 145 | Disable lifespan management during logging | 11,152 | 0 | 294 | 80 | 65 | 54,803 | 95 | prefect | 12 | src/prefect/client.py | Python | 16 | {
"docstring": "\n Start the client.\n\n If the client is already started, this will raise an exception.\n\n If the client is already closed, this will raise an exception. Use a new client\n instance instead.\n ",
"language": "en",
"n_whitespaces": 67,
"n_words": 31,
"vocab_... | https://github.com/PrefectHQ/prefect.git | |
3 | _start_profiler | def _start_profiler(self, logdir):
if self._profiler_started:
return
try:
tf.profiler.experimental.start(logdir=logdir)
self._profiler_started = True
except tf.errors.AlreadyExistsError as e:
# Profiler errors should not be fatal.
... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 11 | callbacks.py | 89 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,363 | 0 | 111 | 52 | 28 | 269,967 | 28 | keras | 14 | keras/callbacks.py | Python | 8 | {
"docstring": "Starts the profiler if currently inactive.\n\n Args:\n logdir: Directory where profiler results will be saved.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 15,
"vocab_size": 14
} | https://github.com/keras-team/keras.git | |
1 | test_export_pipeline_3 | def test_export_pipeline_3():
pipeline_string = (
'DecisionTreeClassifier(SelectPercentile(input_matrix, SelectPercentile__percentile=20),'
'DecisionTreeClassifier__criterion=gini, DecisionTreeClassifier__max_depth=8,'
'DecisionTreeClassifier__min_samples_leaf=5, DecisionTreeClassifier... | 388616b6247ca4ea8de4e2f340d6206aee523541 | 9 | export_tests.py | 79 | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 43,405 | 0 | 64 | 44 | 20 | 181,617 | 24 | tpot | 11 | tests/export_tests.py | Python | 29 | {
"docstring": "Assert that exported_pipeline() generated a compile source file as expected given a fixed simple pipeline with a preprocessor.import numpy as np\nimport pandas as pd\nfrom sklearn.feature_selection import SelectPercentile, f_classif\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.p... | https://github.com/EpistasisLab/tpot.git | |
3 | _experimental_indices | def _experimental_indices(self) -> List[int]:
retval = [idx for idx, device in enumerate(self._all_devices)
if device not in self._supported_indices]
return retval
| bdbbad4d310fb606b6f412aa81e9f57ccd994e97 | 11 | amd.py | 57 | Refactor lib.gpu_stats (#1218)
* inital gpu_stats refactor
* Add dummy CPU Backend
* Update Sphinx documentation | 20,011 | 0 | 57 | 36 | 16 | 100,547 | 19 | faceswap | 10 | lib/gpu_stats/amd.py | Python | 6 | {
"docstring": " list: The indices corresponding to :attr:`_ids` of GPU devices marked as\n \"experimental\". ",
"language": "en",
"n_whitespaces": 20,
"n_words": 12,
"vocab_size": 12
} | https://github.com/deepfakes/faceswap.git | |
7 | loglog | def loglog(self, *args, **kwargs):
dx = {k: v for k, v in kwargs.items()
if k in ['base', 'subs', 'nonpositive',
'basex', 'subsx', 'nonposx']}
self.set_xscale('log', **dx)
dy = {k: v for k, v in kwargs.items()
if k in ['base', 'subs', '... | 383de519505964ed879c40b23ef36e90c17ebe0d | 13 | _axes.py | 222 | [Doc] fix more spelling and grammar | 24,058 | 0 | 194 | 132 | 41 | 110,319 | 68 | matplotlib | 12 | lib/matplotlib/axes/_axes.py | Python | 11 | {
"docstring": "\n Make a plot with log scaling on both the x- and y-axis.\n\n Call signatures::\n\n loglog([x], y, [fmt], data=None, **kwargs)\n loglog([x], y, [fmt], [x2], y2, [fmt2], ..., **kwargs)\n\n This is just a thin wrapper around `.plot` which additionally changes\... | https://github.com/matplotlib/matplotlib.git | |
1 | moebius_kantor_graph | def moebius_kantor_graph(create_using=None):
G = LCF_graph(16, [5, -5], 8, create_using)
G.name = "Moebius-Kantor Graph"
return G
| dec723f072eb997a497a159dbe8674cd39999ee9 | 10 | small.py | 52 | Docstrings for the small.py module (#5240)
* added description for the first 5 small graphs
* modified descriptions based on comment and added description for two more functions
* added doctrings to all the functions
* Minor touchups.
Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> | 41,735 | 0 | 27 | 32 | 13 | 176,165 | 15 | networkx | 5 | networkx/generators/small.py | Python | 4 | {
"docstring": "\n Returns the Moebius-Kantor graph.\n\n The Möbius-Kantor graph is the cubic symmetric graph on 16 nodes.\n Its LCF notation is [5,-5]^8, and it is isomorphic to the generalized\n Petersen graph [1]_.\n\n Parameters\n ----------\n create_using : NetworkX graph constructor, option... | https://github.com/networkx/networkx.git | |
1 | test_real_query | def test_real_query(user_api_client, product, channel_USD):
product_attr = product.product_type.product_attributes.first()
category = product.category
attr_value = product_attr.values.first()
query =
variables = {
"categoryId": graphene.Node.to_global_id("Category", category.id),
"s... | 6e1f00a685069da8d0704216ceca1fc2c2177840 | 15 | test_graphql.py | 204 | Make GraphQL list items non-nullable (#9391)
* Add NonNullList type
* Fix types.common imports
* Adjust tests
* Explicit types.common imports
* Fix tests
* Use NonNullList in filter inputs | 4,970 | 0 | 120 | 110 | 38 | 26,365 | 43 | saleor | 21 | saleor/graphql/core/tests/test_graphql.py | Python | 146 | {
"docstring": "\n query Root($categoryId: ID!, $sortBy: ProductOrder, $first: Int,\n $attributesFilter: [AttributeInput!], $channel: String) {\n\n category(id: $categoryId) {\n ...CategoryPageFragmentQuery\n __typename\n }\n products(first: $first, sortBy: $so... | https://github.com/saleor/saleor.git | |
2 | format | def format(self, tokensource, outfile):
if self.encoding:
# wrap the outfile in a StreamWriter
outfile = codecs.lookup(self.encoding)[3](outfile)
return self.format_unencoded(tokensource, outfile)
| f3166e673fe8d40277b804d35d77dcdb760fc3b3 | 13 | formatter.py | 64 | check point progress on only bringing in pip==22.0.4 (#4966)
* vendor in pip==22.0.4
* updating vendor packaging version
* update pipdeptree to fix pipenv graph with new version of pip.
* Vendoring of pip-shims 0.7.0
* Vendoring of requirementslib 1.6.3
* Update pip index safety restrictions patch for p... | 3,310 | 0 | 62 | 40 | 18 | 20,286 | 19 | pipenv | 8 | pipenv/patched/notpip/_vendor/pygments/formatter.py | Python | 4 | {
"docstring": "\n Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``\n tuples and write it into ``outfile``.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 13,
"vocab_size": 13
} | https://github.com/pypa/pipenv.git | |
6 | _get_layer_inputs | def _get_layer_inputs(self, layer):
if (
isinstance(layer.call, tf.__internal__.function.Function)
and layer.call.input_signature is not None
):
return layer.call.input_signature, {}
elif isinstance(layer, training_lib.Model):
return savin... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 12 | save_impl.py | 117 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81,569 | 0 | 142 | 104 | 25 | 276,121 | 33 | keras | 16 | keras/saving/saved_model/save_impl.py | Python | 19 | {
"docstring": "Inspects layer object and returns the inferred input signature.\n\n Args:\n layer: Layer object.\n\n Returns:\n List of possibly nested TensorSpecs of the layer call function inputs in\n the form of `(args, kwargs)`\n ",
"language": "en",
"n_whitespa... | https://github.com/keras-team/keras.git | |
1 | test_lookup_cache | def test_lookup_cache(self):
# At this point, a lookup for a ContentType should hit the DB
with self.assertNumQueries(1):
ContentType.objects.get_for_model(ContentType)
# A second hit, though, won't hit the DB, nor will a lookup by ID
# or natural key
with s... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | test_models.py | 263 | Refs #33476 -- Reformatted code with Black. | 50,069 | 0 | 284 | 142 | 48 | 202,324 | 95 | django | 11 | tests/contenttypes_tests/test_models.py | Python | 17 | {
"docstring": "\n The content type cache (see ContentTypeManager) works correctly.\n Lookups for a particular content type -- by model, ID, or natural key\n -- should hit the database only on the first lookup.\n ",
"language": "en",
"n_whitespaces": 60,
"n_words": 31,
"vocab_size"... | https://github.com/django/django.git | |
12 | prepare | def prepare(self):
super().prepare()
try:
if self.config["verify_env"]:
confd = self.config.get("default_include")
if confd:
# If 'default_include' is specified in config, then use it
if "*" in confd:
... | 25c2ae356bcf684cbe20f776e1ffcab0f8aeb80c | 20 | daemons.py | 599 | Address docs and hard coded strings | 53,991 | 0 | 1,155 | 348 | 148 | 215,494 | 227 | salt | 40 | salt/cli/daemons.py | Python | 54 | {
"docstring": "\n Run the preparation sequence required to start a salt minion.\n\n If sub-classed, don't **ever** forget to run:\n\n super(YourSubClass, self).prepare()\n ",
"language": "en",
"n_whitespaces": 52,
"n_words": 19,
"vocab_size": 18
} | https://github.com/saltstack/salt.git | |
1 | test_cleanup_device_mqtt | async def test_cleanup_device_mqtt(hass, device_reg, entity_reg, mqtt_mock):
data = (
'{ "device":{"identifiers":["0AFFD2"]},'
' "state_topic": "foobar/sensor",'
' "unique_id": "unique" }'
)
async_fire_mqtt_message(hass, "homeassistant/sensor/bla/config", data)
await hass... | ba6d1976dff8df2aa32726ff2acbf0ba61e5c550 | 11 | test_discovery.py | 280 | Improve MQTT device removal (#66766)
* Improve MQTT device removal
* Update homeassistant/components/mqtt/mixins.py
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
* Adjust tests
* Improve test coverage
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> | 91,310 | 0 | 213 | 157 | 52 | 292,210 | 112 | core | 17 | tests/components/mqtt/test_discovery.py | Python | 25 | {
"docstring": "Test discvered device is cleaned up when removed through MQTT.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/home-assistant/core.git | |
1 | set_params | def set_params(self, **kwargs):
self._set_params("transformer_list", **kwargs)
return self
| b849ce8d17fce0ff7569a9d49b7264d0f54d37d3 | 8 | pipeline.py | 36 | DOC fix typo inside Pipeline docstring (#24730) | 76,788 | 0 | 28 | 20 | 7 | 261,378 | 7 | scikit-learn | 4 | sklearn/pipeline.py | Python | 3 | {
"docstring": "Set the parameters of this estimator.\n\n Valid parameter keys can be listed with ``get_params()``. Note that\n you can directly set the parameters of the estimators contained in\n `transformer_list`.\n\n Parameters\n ----------\n **kwargs : dict\n ... | https://github.com/scikit-learn/scikit-learn.git | |
2 | _convert_to_boolean | def _convert_to_boolean(self, value):
if value.lower() not in self.BOOLEAN_STATES:
raise ValueError('Not a boolean: %s' % value)
return self.BOOLEAN_STATES[value.lower()]
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 11 | configparser.py | 64 | add python 3.10.4 for windows | 56,464 | 0 | 49 | 38 | 17 | 221,663 | 17 | XX-Net | 6 | python3.10.4/Lib/configparser.py | Python | 4 | {
"docstring": "Return a boolean value translating from other types if necessary.\n ",
"language": "en",
"n_whitespaces": 17,
"n_words": 10,
"vocab_size": 10
} | https://github.com/XX-net/XX-Net.git | |
1 | test_unignore_create_entry | async def test_unignore_create_entry(hass, manager):
async_setup_entry = AsyncMock(return_value=True)
mock_integration(hass, MockModule("comp", async_setup_entry=async_setup_entry))
mock_entity_platform(hass, "config_flow.comp", None)
| 7cd68381f1d4f58930ffd631dfbfc7159d459832 | 10 | test_config_entries.py | 63 | Search/replace RESULT_TYPE_* by FlowResultType enum (#74642) | 115,027 | 0 | 25 | 244 | 13 | 316,449 | 13 | core | 9 | tests/test_config_entries.py | Python | 29 | {
"docstring": "Test that we can ignore flows that are in progress and have a unique ID, then rediscover them.",
"language": "en",
"n_whitespaces": 17,
"n_words": 18,
"vocab_size": 17
} | https://github.com/home-assistant/core.git | |
1 | test_rst_then_close | def test_rst_then_close(tctx):
playbook, cff = start_h3_client(tctx)
flow = tutils.Placeholder(HTTPFlow)
server = tutils.Placeholder(connection.Server)
err = tutils.Placeholder(str)
assert (
playbook
# request client
>> cff.receive_headers(example_request_headers, end_s... | f23a1887bb76501f6dbb57573847767e7c1538f1 | 22 | test_http3.py | 314 | [quic] fix h3 double-close issue | 74,056 | 0 | 317 | 212 | 51 | 253,303 | 78 | mitmproxy | 40 | test/mitmproxy/proxy/layers/http/test_http3.py | Python | 32 | {
"docstring": "\n Test that we properly handle the case of a client that first causes protocol errors and then disconnects.\n\n This is slightly different to H2, as QUIC will close the connection immediately.\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 31,
"vocab_size": 29
} | https://github.com/mitmproxy/mitmproxy.git | |
2 | test_simple | def test_simple(self):
code_owner_1 = self.create_codeowners(
self.project_1, self.code_mapping_1, raw=self.data_1["raw"]
)
code_owner_2 = self.create_codeowners(
self.project_2, self.code_mapping_2, raw=self.data_2["raw"]
)
response = self.get_su... | 5efa5eeb57ae6ddf740256e08ce3b9ff4ec98eaa | 13 | test_organization_codeowners_associations.py | 274 | feat(codeowners): Add endpoint to view code owner associations per organization (#31030)
See API-2186
So the earlier version of this PR just had the endpoint return the entire serialized ProjectCodeOwners for an organization. While that works, the intention behind this feature is to read and use the associations, s... | 19,207 | 0 | 215 | 175 | 36 | 95,412 | 52 | sentry | 26 | tests/sentry/api/endpoints/test_organization_codeowners_associations.py | Python | 17 | {
"docstring": "\n Tests that all the ProjectCodeOwners are serialized in the response\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 9
} | https://github.com/getsentry/sentry.git | |
1 | test_memory_2 | def test_memory_2():
cachedir = mkdtemp()
tpot_obj = TPOTClassifier(
random_state=42,
population_size=1,
offspring_size=2,
generations=1,
config_dict='TPOT light',
memory=cachedir,
verbosity=0
)
tpot_obj._setup_memory()
rmtree(cachedir)
... | 388616b6247ca4ea8de4e2f340d6206aee523541 | 10 | tpot_tests.py | 104 | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 43,503 | 0 | 99 | 66 | 23 | 181,716 | 26 | tpot | 18 | tests/tpot_tests.py | Python | 15 | {
"docstring": "Assert that the TPOT _setup_memory function runs normally with a valid path.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | https://github.com/EpistasisLab/tpot.git | |
1 | get_environment_client | def get_environment_client(self) -> EnvironmentsClient:
return EnvironmentsClient(
credentials=self._get_credentials(),
client_info=self.client_info,
client_options=self.client_options,
)
| 05a883b35e34853ec9326bd579551a8e161d6cdc | 10 | cloud_composer.py | 51 | Google Cloud Composer opearators (#21251) | 8,337 | 0 | 64 | 32 | 10 | 44,661 | 10 | airflow | 7 | airflow/providers/google/cloud/hooks/cloud_composer.py | Python | 7 | {
"docstring": "Retrieves client library object that allow access Environments service.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/apache/airflow.git | |
2 | update_metrics | def update_metrics(self, targets, predictions):
for of_name, of_obj in self.output_features.items():
of_obj.update_metrics(targets[of_name], predictions[of_name])
eval_loss, additional_losses = self.eval_loss(targets, predictions)
self.eval_loss_metric.update(eval_loss)
... | aa0c63bf2ed825eb3ca8eff8a002d5ccbe395173 | 10 | base.py | 101 | feat: Added model type GBM (LightGBM tree learner), as an alternative to ECD (#2027) | 1,143 | 0 | 64 | 65 | 18 | 7,165 | 18 | ludwig | 13 | ludwig/models/base.py | Python | 6 | {
"docstring": "Updates the model's metrics given targets and predictions.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/ludwig-ai/ludwig.git | |
4 | get_arc_center | def get_arc_center(self, warning=True):
# First two anchors and handles
a1, h1, h2, a2 = self.points[:4]
if np.all(a1 == a2):
# For a1 and a2 to lie at the same point arc radius
# must be zero. Thus arc_center will also lie at
# that point.
... | e040bcacd38378386749db18aeba575b93f4ebca | 13 | arc.py | 187 | Improved structure of the :mod:`.mobject` module (#2476)
* group graphing and update its references
* group text and update its references
* group opengl and update its references
* group three_d and update its references
* group geometry and update (most) references
* move some chaning.py + updater fil... | 46,157 | 0 | 287 | 116 | 73 | 189,657 | 100 | manim | 25 | manim/mobject/geometry/arc.py | Python | 15 | {
"docstring": "\n Looks at the normals to the first two\n anchors, and finds their intersection points\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 14,
"vocab_size": 13
} | https://github.com/ManimCommunity/manim.git | |
1 | forward | def forward(self, hidden_states):
# We "pool" the model by simply taking the hidden state corresponding
# to the first token.
first_token_tensor = hidden_states[:, 0]
pooled_output = self.dense(first_token_tensor)
pooled_output = self.activation(pooled_output)
return pool... | 1ac698744c4dbdf1495d303246d08ffacdf4f5b8 | @add_start_docstrings(
"""
YOLOS Model (consisting of a ViT encoder) with object detection heads on top, for tasks such as COCO detection.
""",
YOLOS_START_DOCSTRING,
) | 8 | modeling_yolos.py | 68 | Add YOLOS (#16848)
* First draft
* Add YolosForObjectDetection
* Make forward pass work
* Add mid position embeddings
* Add interpolation of position encodings
* Add expected values
* Add YOLOS to tests
* Add integration test
* Support tiny model as well
* Support all models in conversion sc... | 6,846 | 1 | 81 | 33 | 29 | 37,643 | 36 | transformers | 9 | src/transformers/models/yolos/modeling_yolos.py | Python | 5 | {
"docstring": "\n YOLOS Model (consisting of a ViT encoder) with object detection heads on top, for tasks such as COCO detection.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 19,
"vocab_size": 19
} | https://github.com/huggingface/transformers.git |
1 | test_enabled_requires_valid_sub | def test_enabled_requires_valid_sub(hass, mock_expired_cloud_login, cloud_prefs):
assert cloud_prefs.alexa_enabled
assert hass.data["cloud"].is_logged_in
assert hass.data["cloud"].subscription_expired
config = alexa_config.CloudAlexaConfig(
hass, ALEXA_SCHEMA({}), "mock-user-id", cloud_pre... | 537dfbca18830a90a7f89d291f519948a3d977e8 | 11 | test_alexa_config.py | 100 | Rename cloud's AlexaConfig to CloudAlexaConfig (#64065)
* Rename cloud's AlexaConfig to CloudAlexaConfig
* Tweak | 108,191 | 0 | 50 | 62 | 19 | 309,493 | 22 | core | 13 | tests/components/cloud/test_alexa_config.py | Python | 8 | {
"docstring": "Test that alexa config enabled requires a valid Cloud sub.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/home-assistant/core.git | |
3 | predict_snli | def predict_snli(net, vocab, premise, hypothesis):
premise = np.array(vocab[premise], ctx=d2l.try_gpu())
hypothesis = np.array(vocab[hypothesis], ctx=d2l.try_gpu())
label = np.argmax(net([premise.reshape((1, -1)),
hypothesis.reshape((1, -1))]), axis=1)
return 'entailment'... | b64b41d8c1ac23c43f7a4e3f9f6339d6f0012ab2 | 15 | mxnet.py | 183 | [PaddlePaddle] Merge master into Paddle branch (#1186)
* change 15.2 title in chinese version (#1109)
change title ’15.2. 情感分析:使用递归神经网络‘ to ’15.2. 情感分析:使用循环神经网络‘
* 修改部分语义表述 (#1105)
* Update r0.17.5 (#1120)
* Bump versions in installation
* 94行typo: (“bert.mall”)->(“bert.small”) (#1129)
* line 313: "b... | 37,391 | 0 | 97 | 104 | 31 | 158,223 | 40 | d2l-zh | 15 | d2l/mxnet.py | Python | 7 | {
"docstring": "Predict the logical relationship between the premise and hypothesis.\n\n Defined in :numref:`sec_natural-language-inference-attention`",
"language": "en",
"n_whitespaces": 14,
"n_words": 12,
"vocab_size": 11
} | https://github.com/d2l-ai/d2l-zh.git | |
1 | fit | def fit(self, X, y=None):
self._validate_params()
self._fit_transform(X)
return self
| ceeda362402bfc978bcc93d02481fe28e21a07ad | 7 | _locally_linear.py | 42 | MAINT Use _validate_params in LocallyLinearEmbedding (#23938)
Co-authored-by: jeremiedbb <jeremiedbb@yahoo.fr> | 76,332 | 0 | 36 | 25 | 8 | 260,545 | 8 | scikit-learn | 6 | sklearn/manifold/_locally_linear.py | Python | 4 | {
"docstring": "Compute the embedding vectors for data X.\n\n Parameters\n ----------\n X : array-like of shape (n_samples, n_features)\n Training set.\n\n y : Ignored\n Not used, present here for API consistency by convention.\n\n Returns\n -------\n ... | https://github.com/scikit-learn/scikit-learn.git | |
4 | _customize_site | def _customize_site(self) -> None:
if not LEGACY_VIRTUALENV or self._venv_type == "venv":
# Enable user site (before system).
contents = textwrap.dedent(
f
).strip()
else:
contents = ""
if self._sitecustomize is not None:
... | 83c85e94b70aa5b3211ef3cc592d8cd8619beb15 | 15 | venv.py | 154 | Fix legacy virtualenv setup in tests | 41,545 | 0 | 171 | 81 | 43 | 175,018 | 53 | pip | 18 | tests/lib/venv.py | Python | 32 | {
"docstring": "\n import os, site, sys\n if not os.environ.get('PYTHONNOUSERSITE', False):\n site.ENABLE_USER_SITE = {self._user_site_packages}\n # First, drop system-sites related paths.\n original_sys_path = sys.path[:]\n ... | https://github.com/pypa/pip.git | |
1 | test_bitbucket2_on_push_commits_multiple_committers_with_others | def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None:
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n"
expected_message = f
self.check_webhook(
"push_multiple... | 4e4689949438735622bdf669f05d218c671e7e01 | 9 | tests.py | 52 | webhooks: Pick a more reasonable length for short sha.
7 characters are not enough for large projects, so we change
it to reasonably longer. As an example, The Linux kernel needs
at least 11 characters of sha in its shortened form to identify
a revision. We pick 11 so it should work for most of the projects.
Signed-o... | 17,927 | 0 | 56 | 24 | 16 | 85,091 | 18 | zulip | 6 | zerver/webhooks/bitbucket2/tests.py | Python | 6 | {
"docstring": "Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by Tomasz (4), James (3), Brendon (2) and others (1).\\n\\n{commit_info*9}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d19636... | https://github.com/zulip/zulip.git | |
1 | line_collection_2d_to_3d | def line_collection_2d_to_3d(col, zs=0, zdir='z'):
segments3d = _paths_to_3d_segments(col.get_paths(), zs, zdir)
col.__class__ = Line3DCollection
col.set_segments(segments3d)
| df6f95703b60348e01603f98a439b133da2938a0 | 10 | art3d.py | 64 | Improve mpl_toolkit documentation | 23,823 | 0 | 25 | 39 | 12 | 109,916 | 13 | matplotlib | 10 | lib/mpl_toolkits/mplot3d/art3d.py | Python | 4 | {
"docstring": "Convert a `.LineCollection` to a `.Line3DCollection` object.",
"language": "en",
"n_whitespaces": 6,
"n_words": 7,
"vocab_size": 6
} | https://github.com/matplotlib/matplotlib.git | |
5 | register_serializer | def register_serializer(format, serializer_module, serializers=None):
if serializers is None and not _serializers:
_load_serializers()
try:
module = importlib.import_module(serializer_module)
except ImportError as exc:
bad_serializer = BadSerializer(exc)
module = type(... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 14 | __init__.py | 140 | Refs #33476 -- Reformatted code with Black. | 50,863 | 0 | 187 | 84 | 35 | 204,735 | 46 | django | 14 | django/core/serializers/__init__.py | Python | 19 | {
"docstring": "Register a new serializer.\n\n ``serializer_module`` should be the fully qualified module name\n for the serializer.\n\n If ``serializers`` is provided, the registration will be added\n to the provided dictionary.\n\n If ``serializers`` is not provided, the registration will be made\n ... | https://github.com/django/django.git | |
4 | close | def close(self) -> None:
if self._buf is not None:
self._buf.release()
self._buf = None
if self._mmap is not None:
self._mmap.close()
if self._fd >= 0:
os.close(self._fd)
self._fd = -1
| fd0262413e84c02f93d15eca1f87e1ba74cbe34e | 10 | shm.py | 106 | Access to POSIX shared memory from Python | 21,617 | 0 | 110 | 64 | 18 | 103,211 | 27 | kitty | 7 | kitty/shm.py | Python | 11 | {
"docstring": "Closes access to the shared memory from this instance but does\n not destroy the shared memory block.",
"language": "en",
"n_whitespaces": 23,
"n_words": 17,
"vocab_size": 14
} | https://github.com/kovidgoyal/kitty.git | |
6 | require_libsndfile_with_opus | def require_libsndfile_with_opus(test_case):
if (sys.platform != "linux" and find_spec("soundfile")) or (sys.platform == "linux" and find_library("sndfile")):
import soundfile
# soundfile library is needed to be installed to check libsndfile version
if version.parse(soundfile.__libsnd... | b55c590809381d7822ad76c2bebbb06e895393fa | 14 | utils.py | 134 | process .opus files (for Multilingual Spoken Words) (#3666)
* check version of libsndfile explicitly (instead of catching an error)
* fix version of libsndfile
* add test for opus decoding
* add decorator to pass tests that require libsndfile>=1.0.30 | 21,816 | 0 | 127 | 73 | 41 | 104,318 | 50 | datasets | 13 | tests/utils.py | Python | 10 | {
"docstring": "\n Decorator marking a test that requires libsndfile>=1.0.30 (version that is required for opus decoding).\n\n These tests are skipped when libsndfile is <1.0.30.\n\n ",
"language": "en",
"n_whitespaces": 32,
"n_words": 22,
"vocab_size": 20
} | https://github.com/huggingface/datasets.git | |
6 | _replace_child_layer_functions | def _replace_child_layer_functions(layer, serialization_cache):
# pylint: disable=protected-access
original_fns = {}
| 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 7 | save_impl.py | 23 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81,571 | 0 | 18 | 106 | 9 | 276,127 | 9 | keras | 4 | keras/saving/saved_model/save_impl.py | Python | 22 | {
"docstring": "Replaces functions in the children layers with wrapped tf.functions.\n\n This step allows functions from parent layers to reference the wrapped\n functions from their children layers instead of retracing the ops.\n\n This function also resets all losses stored in the layer. These are stored i... | https://github.com/keras-team/keras.git | |
1 | _parallel_scaling | def _parallel_scaling(self) -> Dict[int, float]:
retval = {0: 1.0,
1: 1.0,
2: 0.7,
3: 0.55,
4: 0.5,
5: 0.4}
logger.trace(retval) # type: ignore
return retval
| 13cfb3f39e72e9ca181f173b7b3db2a048db0d08 | 8 | pipeline.py | 72 | extract: Add batch processing mode | 20,871 | 0 | 139 | 60 | 23 | 101,458 | 25 | faceswap | 8 | plugins/extract/pipeline.py | Python | 22 | {
"docstring": " dict: key is number of parallel plugins being loaded, value is the scaling factor that\n the total base vram for those plugins should be scaled by\n\n Notes\n -----\n VRAM for parallel plugins does not stack in a linear manner. Calculating the precise\n scaling for ... | https://github.com/deepfakes/faceswap.git | |
3 | hass | def hass(hass_fixture_setup, loop, load_registries, hass_storage, request):
hass_fixture_setup.append(True)
orig_tz = dt_util.DEFAULT_TIME_ZONE
| 31a787558fd312331b55e5c2c4b33341fc3601fc | 7 | conftest.py | 39 | Ensure recorder test fixture is setup before hass fixture (#80528)
* Ensure recorder test fixture is setup before hass fixture
* Adjust more tests | 88,632 | 0 | 19 | 111 | 10 | 289,490 | 10 | core | 10 | tests/conftest.py | Python | 19 | {
"docstring": "Fixture to provide a test instance of Home Assistant.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/home-assistant/core.git | |
12 | change_aliases | def change_aliases(self, change_map):
# If keys and values of change_map were to intersect, an alias might be
# updated twice (e.g. T4 -> T5, T5 -> T6, so also T4 -> T6) depending
# on their order in change_map.
assert set(change_map).isdisjoint(change_map.values())
# 1... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 13 | query.py | 385 | Refs #33476 -- Reformatted code with Black. | 51,257 | 0 | 527 | 246 | 113 | 205,875 | 167 | django | 31 | django/db/models/sql/query.py | Python | 29 | {
"docstring": "\n Change the aliases in change_map (which maps old-alias -> new-alias),\n relabelling any references to them in select columns and the where\n clause.\n ",
"language": "en",
"n_whitespaces": 51,
"n_words": 22,
"vocab_size": 20
} | https://github.com/django/django.git | |
1 | test_update_from_select | def test_update_from_select(self, mock_handler):
self.set_handler(mock_handler, name='pg', tables={'tasks': self.df})
# --- use predictor ---
self.set_predictor(self.task_predictor)
sql =
ret = self.command_executor.execute_command(
parse_sql(sql, dialect='mindsdb'... | 8f9cbb01af1f68c55227cebf4e749b86a2c525ca | 15 | test_executor.py | 157 | unit tests for:
- create table
- insert into | 25,858 | 0 | 135 | 94 | 44 | 116,874 | 54 | mindsdb | 20 | tests/unit/test_executor.py | Python | 26 | {
"docstring": "\n update \n pg.table2 \n set\n a1 = df.a,\n c1 = df.c\n from \n (\n SELECT model.a as a, model.b as b, model.p as c\n FROM ... | https://github.com/mindsdb/mindsdb.git | |
2 | _compile_weights_loss_and_weighted_metrics | def _compile_weights_loss_and_weighted_metrics(self, sample_weights=None):
with backend.get_graph().as_default():
if sample_weights is not None:
self._update_sample_weight_modes(sample_weights)
self._prepare_sample_weights(sample_weights)
masks = sel... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 12 | training_v1.py | 154 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,923 | 0 | 348 | 93 | 50 | 271,987 | 61 | keras | 19 | keras/engine/training_v1.py | Python | 15 | {
"docstring": "Compiles the model loss and weighted metric sub-graphs.\n\n This may be used to set graph tensors as sample weights (instead of creating\n placeholders). This functionality is necessary for\n `tf.keras.estimator.model_to_estimator`, which calls Keras models in a v1\n graph,... | https://github.com/keras-team/keras.git | |
1 | get_mop_query | def get_mop_query(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql(
,
{"parent": filters.get("parent"), "start": start, "page_len": page_len, "txt": "%%%s%%" % txt},
)
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs | 494bd9ef78313436f0424b918f200dab8fc7c20b | @frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs | 12 | payment_order.py | 99 | style: format code with black | 13,751 | 1 | 16 | 50 | 21 | 64,915 | 23 | erpnext | 13 | erpnext/accounts/doctype/payment_order/payment_order.py | Python | 7 | {
"docstring": " select mode_of_payment from `tabPayment Order Reference`\n\t\twhere parent = %(parent)s and mode_of_payment like %(txt)s\n\t\tlimit %(start)s, %(page_len)s",
"language": "en",
"n_whitespaces": 15,
"n_words": 17,
"vocab_size": 16
} | https://github.com/frappe/erpnext.git |
4 | reset_page_edit_handler_cache | def reset_page_edit_handler_cache(**kwargs):
if kwargs["setting"] == "WAGTAILADMIN_COMMENTS_ENABLED":
set_default_page_edit_handlers(Page)
for model in apps.get_models():
if issubclass(model, Page):
model.get_edit_handler.cache_clear()
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 14 | edit_handlers.py | 76 | Reformat with black | 15,624 | 0 | 61 | 43 | 14 | 71,107 | 15 | wagtail | 10 | wagtail/admin/edit_handlers.py | Python | 6 | {
"docstring": "\n Clear page edit handler cache when global WAGTAILADMIN_COMMENTS_ENABLED settings are changed\n ",
"language": "en",
"n_whitespaces": 18,
"n_words": 11,
"vocab_size": 11
} | https://github.com/wagtail/wagtail.git | |
1 | test_comment | def test_comment(self) -> None:
html = b
tree = decode_body(html, "http://example.com/test.html")
og = parse_html_to_open_graph(tree, "http://example.com/test.html")
self.assertEqual(og, {"og:title": "Foo", "og:description": "Some text."})
| 7e91107be1a4287873266e588a3c5b415279f4c8 | 10 | test_html_preview.py | 78 | Add type hints to `tests/rest` (#12146)
* Add type hints to `tests/rest`
* newsfile
* change import from `SigningKey` | 71,639 | 0 | 48 | 43 | 18 | 247,381 | 21 | synapse | 8 | tests/rest/media/v1/test_html_preview.py | Python | 13 | {
"docstring": "\n <html>\n <head><title>Foo</title></head>\n <body>\n <!-- HTML comment -->\n Some text.\n </body>\n </html>\n ",
"language": "en",
"n_whitespaces": 68,
"n_words": 11,
"vocab_size": 11
} | https://github.com/matrix-org/synapse.git | |
18 | _process_packet | def _process_packet(self, pkt):
# type: (Packet) -> Optional[Packet]
if self.app:
# Special mode: Application layer. Use on top of TCP
pay_class = pkt.__class__
if not hasattr(pay_class, "tcp_reassemble"):
# Being on top of TCP, we have no way... | ca10c5cf00425d0178998ec0b006cbb65ddbfb54 | 12 | sessions.py | 675 | [MS-RPCE] and [MS-SMB] major update (#3683)
* Various fixes regarding DCE/RPC build
* DCE/RPC sessions
* Cleanup unused code
* Add missing GSS_WRAP algo names
* Add find_dcerpc_interface
* Split SMB client and server
* Missing StrFixedLenFieldUtf16
* Remove unfinished smbserver feature
* Friend... | 52,769 | 0 | 1,171 | 405 | 189 | 209,763 | 360 | scapy | 46 | scapy/sessions.py | Python | 61 | {
"docstring": "Process each packet: matches the TCP seq/ack numbers\n to follow the TCP streams, and orders the fragments.\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 17,
"vocab_size": 14
} | https://github.com/secdev/scapy.git | |
1 | test_sequential_bad_outputs | def test_sequential_bad_outputs() -> None:
chain_1 = FakeChain(input_variables=["foo"], output_variables=["bar"])
chain_2 = FakeChain(input_variables=["bar"], output_variables=["baz"])
with pytest.raises(ValueError):
# "test" is not present as an output variable.
SequentialChain(
... | 4a4dfbfbed5ca271fc74f61a0b3387314dda8703 | 12 | test_sequential.py | 123 | Harrison/sequential chains (#168)
add support for basic sequential chains | 46,657 | 0 | 95 | 70 | 28 | 191,532 | 29 | langchain | 11 | tests/unit_tests/chains/test_sequential.py | Python | 10 | {
"docstring": "Test error is raised when bad outputs are specified.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/hwchase17/langchain.git | |
1 | test_run_cleanup_skip_archive | def test_run_cleanup_skip_archive(self, cleanup_table_mock, kwargs, should_skip):
run_cleanup(
clean_before_timestamp=None,
table_names=['log'],
dry_run=None,
verbose=None,
confirm=False,
**kwargs,
)
assert cleanup_... | 95bd6b71cc9f5da377e272707f7b68000d980939 | 10 | test_db_cleanup.py | 78 | Don't rely on current ORM structure for db clean command (#23574)
For command DB clean, by not relying on the ORM models, we will be able to use the command even when the metadatabase is not yet upgraded to the version of Airflow you have installed.
Additionally we archive all rows before deletion. | 7,871 | 0 | 111 | 52 | 17 | 43,210 | 17 | airflow | 12 | tests/utils/test_db_cleanup.py | Python | 10 | {
"docstring": "test that delete confirmation input is called when appropriate",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/apache/airflow.git | |
2 | for_each_shape | def for_each_shape(self, fn, selector=None, row=None, col=None, secondary_y=None):
for obj in self._select_annotations_like(
prop="shapes",
selector=selector,
row=row,
col=col,
secondary_y=secondary_y,
):
fn(obj)
r... | 43e3a4011080911901176aab919c0ecf5046ddd3 | 9 | _figure.py | 86 | switch to black .22 | 58,414 | 0 | 114 | 59 | 20 | 226,741 | 20 | plotly.py | 10 | packages/python/plotly/plotly/graph_objs/_figure.py | Python | 10 | {
"docstring": "\n Apply a function to all shapes that satisfy the specified selection\n criteria\n\n Parameters\n ----------\n fn:\n Function that inputs a single shape object.\n selector: dict, function, int, str or None (default None)\n Dict to use as... | https://github.com/plotly/plotly.py.git | |
3 | load_drawer_from_disk | def load_drawer_from_disk(self):
exists = self.pair_dictionary_path.is_file()
if exists:
with open(self.pair_dictionary_path, "r") as fp:
self.pair_dict = json.load(fp)
elif not self.follow_mode:
logger.info("Could not find existing datadrawer, st... | 76b33359a939e8db89b55f268e9d650f78c51bf3 | 14 | data_drawer.py | 121 | add an optional metric tracker to collect train timings, inference timings, and cpu load data | 35,018 | 0 | 167 | 62 | 39 | 151,471 | 43 | freqtrade | 15 | freqtrade/freqai/data_drawer.py | Python | 12 | {
"docstring": "\n Locate and load a previously saved data drawer full of all pair model metadata in\n present model folder.\n Load any existing metric tracker that may be present.\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 27,
"vocab_size": 26
} | https://github.com/freqtrade/freqtrade.git | |
3 | _var_key | def _var_key(var):
# pylint: disable=protected-access
# Get the distributed variable if it exists.
if hasattr(var, "_distributed_container"):
var = var._distributed_container()
if getattr(var, "_in_graph_mode", False):
return var._shared_name
return var._unique_id
| 75d70a610dffe927d89ceb400d79bb7f9027b26e | 10 | optimizer_v2.py | 69 | Support checkpointing ShardedVariables in optimizer slot variables.
PiperOrigin-RevId: 429577423 | 79,831 | 0 | 39 | 39 | 23 | 269,013 | 27 | keras | 7 | keras/optimizers/optimizer_v2/optimizer_v2.py | Python | 6 | {
"docstring": "Key for representing a primary variable, for looking up slots.\n\n In graph mode the name is derived from the var shared name.\n In eager mode the name is derived from the var unique id.\n If distribution strategy exists, get the primary variable first.\n\n Args:\n var: the variable.\n\n Retur... | https://github.com/keras-team/keras.git | |
3 | process_dataframe | def process_dataframe(self) -> dict[int | str, dict[str, Any]]:
df = self.frame
if self.index:
df = df.reset_index()
if self.na_rep is not None:
df = df.fillna(self.na_rep)
return df.to_dict(orient="index")
| 9dfb454dbe5f183b1508a9571ee97938c9cb0db9 | 11 | xml.py | 103 | REF: Deduplicate to_xml code (#45132) | 39,359 | 0 | 83 | 64 | 21 | 163,017 | 26 | pandas | 14 | pandas/io/formats/xml.py | Python | 13 | {
"docstring": "\n Adjust Data Frame to fit xml output.\n\n This method will adjust underlying data frame for xml output,\n including optionally replacing missing values and including indexes.\n ",
"language": "en",
"n_whitespaces": 54,
"n_words": 25,
"vocab_size": 23
} | https://github.com/pandas-dev/pandas.git | |
2 | xresnet101 | def xresnet101(pretrained=False, **kwargs):
model = XResNet(Bottleneck, [3, 4, 23, 3], **kwargs)
if pretrained: model.load_state_dict(model_zoo.load_url(model_urls['xresnet101']))
return model
| 4fc3616712edb19179b17dd270ad6cf63abf99c2 | 13 | xresnet2.py | 77 | Upgrading to support latest Pytorch version | 46,356 | 0 | 28 | 49 | 15 | 190,597 | 16 | DeOldify | 10 | fastai/vision/models/xresnet2.py | Python | 4 | {
"docstring": "Constructs a XResNet-101 model.\n\n Args:\n pretrained (bool): If True, returns a model pre-trained on ImageNet\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 15,
"vocab_size": 14
} | https://github.com/jantic/DeOldify.git | |
1 | test_check_complete_II | def test_check_complete_II(value, expected):
cc = ipt2.TransformerManager().check_complete
assert cc(value) == expected
@pytest.mark.parametrize(
"value, expected",
[
(")", ("invalid", None)),
("]", ("invalid", None)),
("}", ("invalid", None)),
(")(", ("invalid", N... | cb6563dcd85783ea0a687fbe227c4782a8a7cadf | @pytest.mark.parametrize(
"value, expected",
[
(")", ("invalid", None)),
("]", ("invalid", None)),
("}", ("invalid", None)),
(")(", ("invalid", None)),
("][", ("invalid", None)),
("}{", ("invalid", None)),
("]()(", ("invalid", None)),
("())(", ("in... | 10 | test_inputtransformer2.py | 223 | Fix and test for "async with does not allow new lines".
Use the opportunity to add a test, and parametrise a few other, plus set
the correct stacklevel.
Closes #12975 | 52,326 | 1 | 132 | 24 | 28 | 208,444 | 46 | ipython | 10 | IPython/core/tests/test_inputtransformer2.py | Python | 3 | {
"docstring": "\n Test that multiple line strings are properly handled.\n\n Separate test function for convenience\n\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 13,
"vocab_size": 13
} | https://github.com/ipython/ipython.git |
6 | async_inference_detector | async def async_inference_detector(model, imgs):
if not isinstance(imgs, (list, tuple)):
imgs = [imgs]
cfg = model.cfg
if isinstance(imgs[0], np.ndarray):
cfg = cfg.copy()
# set loading pipeline type
cfg.data.test.pipeline[0].type = 'LoadImageFromWebcam'
cfg.data.... | 2631e2879acf0bd20a64dfdd7039f37a8e6afbf6 | 17 | inference.py | 314 | Support Datasampler | 70,325 | 0 | 298 | 193 | 80 | 244,324 | 113 | mmdetection | 32 | mmdet/apis/inference.py | Python | 24 | {
"docstring": "Async inference image(s) with the detector.\n\n Args:\n model (nn.Module): The loaded detector.\n img (str | ndarray): Either image files or loaded images.\n\n Returns:\n Awaitable detection results.\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 26,
"voca... | https://github.com/open-mmlab/mmdetection.git | |
5 | upgrade | def upgrade():
conn = op.get_bind()
update_flow_run_state_name_in_batches =
result = conn.execute(sa.text(update_flow_run_state_name_in_batches))
while True:
if result.rowcount <= 0:
break
update_task_run_state_name_in_batches =
result = conn.execute(sa.text(update... | fc9f253912945e088e48cc723af383e6a9f46faf | 10 | 2022_04_21_095519_14dc68cc5853_backfill_state_name.py | 116 | Add run.state_name columns | 11,142 | 0 | 91 | 66 | 17 | 54,788 | 29 | prefect | 11 | src/prefect/orion/database/migrations/versions/postgresql/2022_04_21_095519_14dc68cc5853_backfill_state_name.py | Python | 26 | {
"docstring": "\n Backfills state_name column for task_run and flow_run tables.\n\n This is a data only migration that can be run as many\n times as desired.\n \n WITH null_flow_run_state_name_cte as (SELECT id from flow_run where state_name is null limit 500)\n UPDATE flow_run\n SET... | https://github.com/PrefectHQ/prefect.git | |
1 | get_default_rl_module_class | def get_default_rl_module_class(self) -> Union[Type["RLModule"], str]:
raise NotImplementedError
| f9ec2d1ae2e14e1f1ed38d315dfd643f600dc397 | 7 | algorithm_config.py | 31 | [RLlib] Make RLModule initialization easy (#31069)
1. Moved the `_enable_rl_module_api` signature into `rl_module()` api of the algorithmConfig.
2. Added the ability for the user to override the entire RLModule from algorithmConfig by
simply changing the class.
3. updated marl_module: we now have only one MARLModul... | 31,158 | 0 | 21 | 18 | 7 | 137,403 | 7 | ray | 6 | rllib/algorithms/algorithm_config.py | Python | 11 | {
"docstring": "Returns the RLModule class to use for this algorithm.\n\n Override this method in the sub-class to return the RLModule class type given\n the input framework.\n\n Returns:\n The RLModule class to use for this algorithm either as a class type or as\n a string ... | https://github.com/ray-project/ray.git | |
1 | is_spotify_media_type | def is_spotify_media_type(media_content_type):
return media_content_type.startswith(MEDIA_PLAYER_PREFIX)
| a371f8f7882bd1c7de5e344aa23f7d6b1967ce66 | 7 | __init__.py | 24 | Allow browsing the Spotify media player in Sonos (#64921) | 109,737 | 0 | 10 | 13 | 4 | 311,067 | 4 | core | 4 | homeassistant/components/spotify/__init__.py | Python | 2 | {
"docstring": "Return whether the media_content_type is a valid Spotify media_id.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/home-assistant/core.git | |
3 | _window_closed | def _window_closed(self) -> bool:
retval = any(cv2.getWindowProperty(win, cv2.WND_PROP_VISIBLE) < 1 for win in self._windows)
if retval:
logger.debug("Window closed detected")
return retval
| 7da2cc3dd266aabebf41a31384cc2e0e7e5af6e5 | 12 | preview_cv.py | 70 | Training - Use custom preview pop-out | 20,955 | 0 | 60 | 42 | 20 | 101,545 | 21 | faceswap | 12 | lib/training/preview_cv.py | Python | 6 | {
"docstring": " bool: ``True`` if any window has been closed otherwise ``False`` ",
"language": "en",
"n_whitespaces": 11,
"n_words": 10,
"vocab_size": 10
} | https://github.com/deepfakes/faceswap.git | |
8 | eval | def eval(cls, *_args):
if not _args:
return Undefined
if len(_args) == 1 and _args[0][-1] == True:
return _args[0][0]
newargs = _piecewise_collapse_arguments(_args)
# some conditions may have been redundant
missing = len(newargs) != len(_args)
... | fc7b460a21e340d4104e67c86d973765c9b4071b | 12 | piecewise.py | 169 | Refactor Piecewise simplifcation/evaluation | 49,272 | 0 | 204 | 102 | 52 | 199,448 | 76 | sympy | 15 | sympy/functions/elementary/piecewise.py | Python | 15 | {
"docstring": "Either return a modified version of the args or, if no\n modifications were made, return None.\n\n Modifications that are made here:\n\n 1. relationals are made canonical\n 2. any False conditions are dropped\n 3. any repeat of a previous condition is ignored\n ... | https://github.com/sympy/sympy.git | |
5 | _populate_vhost_names_v2 | def _populate_vhost_names_v2(self, vhost):
servername_match = vhost.node.find_directives("ServerName", exclude=False)
serveralias_match = vhost.node.find_directives("ServerAlias", exclude=False)
servername = None
if servername_match:
servername = servername_match[-... | eeca208c8f57304590ac1af80b496e61021aaa45 | 14 | configurator.py | 139 | Various clean-ups in certbot-apache. Use f-strings. (#9132)
* Various clean-ups in certbot-apache. Use f-strings.
* Smaller tweaks | 45,474 | 0 | 143 | 86 | 24 | 186,378 | 34 | certbot | 16 | certbot-apache/certbot_apache/_internal/configurator.py | Python | 11 | {
"docstring": "Helper function that populates the VirtualHost names.\n :param host: In progress vhost whose names will be added\n :type host: :class:`~certbot_apache.obj.VirtualHost`\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 20,
"vocab_size": 19
} | https://github.com/certbot/certbot.git | |
3 | get_resource_path | def get_resource_path(self, relative_path):
r = self.get_distinfo_resource('RESOURCES')
with contextlib.closing(r.as_stream()) as stream:
with CSVReader(stream=stream) as resources_reader:
for relative, destination in resources_reader:
if relative... | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 13 | database.py | 113 | upd; format | 12,790 | 0 | 156 | 62 | 32 | 61,975 | 38 | transferlearning | 14 | .venv/lib/python3.8/site-packages/pip/_vendor/distlib/database.py | Python | 9 | {
"docstring": "\n NOTE: This API may change in the future.\n\n Return the absolute path to a resource file with the given relative\n path.\n\n :param relative_path: The path, relative to .dist-info, of the resource\n of interest.\n :return: The absolute... | https://github.com/jindongwang/transferlearning.git | |
4 | get_training_or_validation_split | def get_training_or_validation_split(samples, labels, validation_split, subset):
if not validation_split:
return samples, labels
num_val_samples = int(validation_split * len(samples))
if subset == "training":
print(f"Using {len(samples) - num_val_samples} files for training.")
... | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 14 | dataset_utils.py | 184 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81,744 | 0 | 171 | 96 | 49 | 276,811 | 65 | keras | 10 | keras/utils/dataset_utils.py | Python | 18 | {
"docstring": "Potentially restict samples & labels to a training or validation split.\n\n Args:\n samples: List of elements.\n labels: List of corresponding labels.\n validation_split: Float, fraction of data to reserve for validation.\n subset: Subset of the data to return.\n Either \... | https://github.com/keras-team/keras.git | |
6 | get_employees | def get_employees(filters):
holiday_filter = [
["holiday_date", ">=", filters.from_date],
["holiday_date", "<=", filters.to_date],
]
if filters.holiday_list:
holiday_filter.append(["parent", "=", filters.holiday_list])
holidays = frappe.get_all(
"Holiday", fields=["holiday_date", "description"], filters=ho... | 494bd9ef78313436f0424b918f200dab8fc7c20b | 18 | employees_working_on_a_holiday.py | 308 | style: format code with black | 14,147 | 0 | 47 | 185 | 58 | 66,253 | 77 | erpnext | 25 | erpnext/hr/report/employees_working_on_a_holiday/employees_working_on_a_holiday.py | Python | 35 | {
"docstring": " and (employee in (select employee from tabEmployee where holiday_list = %(holidays)s))select\n\t\t\t\temployee, employee_name, attendance_date, status\n\t\t\tfrom tabAttendance\n\t\t\twhere %s",
"language": "en",
"n_whitespaces": 16,
"n_words": 19,
"vocab_size": 17
} | https://github.com/frappe/erpnext.git | |
1 | test_django_date_trunc | def test_django_date_trunc(self):
updated = datetime.datetime(2010, 2, 20)
SchoolClass.objects.create(year=2009, last_updated=updated)
years = SchoolClass.objects.dates("last_updated", "year")
self.assertEqual(list(years), [datetime.date(2010, 1, 1)])
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 10 | tests.py | 105 | Refs #33476 -- Reformatted code with Black. | 50,004 | 0 | 52 | 66 | 16 | 201,823 | 17 | django | 14 | tests/backends/tests.py | Python | 5 | {
"docstring": "\n Test the custom ``django_date_trunc method``, in particular against\n fields which clash with strings passed to it (e.g. 'year') (#12818).\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 19,
"vocab_size": 19
} | https://github.com/django/django.git | |
3 | get_tests_dir | def get_tests_dir(append_path=None):
# this function caller's __file__
caller__file__ = inspect.stack()[1][1]
tests_dir = os.path.abspath(os.path.dirname(caller__file__))
while not tests_dir.endswith("tests"):
tests_dir = os.path.dirname(tests_dir)
if append_path:
return os.pa... | 29c10a41d04f855c433a6cde7797b325651417d2 | 11 | testing_utils.py | 138 | [Test refactor 1/5] Per-folder tests reorganization (#15725)
* Per-folder tests reorganization
Co-authored-by: sgugger <sylvain.gugger@gmail.com>
Co-authored-by: Stas Bekman <stas@stason.org> | 6,452 | 0 | 158 | 75 | 95 | 35,453 | 129 | transformers | 12 | src/transformers/testing_utils.py | Python | 9 | {
"docstring": "\n Args:\n append_path: optional path to append to the tests dir path\n\n Return:\n The full path to the `tests` dir, so that the tests can be invoked from anywhere. Optionally `append_path` is\n joined after the `tests` dir the former is provided.\n\n ",
"language": "e... | https://github.com/huggingface/transformers.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.