id int64 20 338k | vocab_size int64 2 671 | ast_levels int64 4 32 | nloc int64 1 451 | n_ast_nodes int64 12 5.6k | n_identifiers int64 1 186 | n_ast_errors int64 0 10 | n_words int64 2 2.17k | n_whitespaces int64 2 13.8k | fun_name stringlengths 2 73 | commit_message stringlengths 51 15.3k | url stringlengths 31 59 | code stringlengths 51 31k | ast_errors stringlengths 0 1.46k | token_counts int64 6 3.32k | file_name stringlengths 5 56 | language stringclasses 1
value | path stringlengths 7 134 | commit_id stringlengths 40 40 | repo stringlengths 3 28 | complexity int64 1 153 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
177,558 | 34 | 10 | 5 | 61 | 11 | 0 | 37 | 106 | _get_storage_by_url | fix: DEV-1476: Resolving performance for project storages (#1910)
* Fix: DEV-1476: Resolving performance for project storages
* Rewrite cache
* Remove cache completely | https://github.com/heartexlabs/label-studio.git | def _get_storage_by_url(self, url, storage_objects):
from io_storages.models import get_storage_classes
for storage_object in storage_objects:
# check url is string because task can have int, float, dict, list
# and 'can_resolve_url' will fail
if isinstance(... | 38 | models.py | Python | label_studio/tasks/models.py | 6293c3226e3713bdae678603d6c1300e09c41448 | label-studio | 4 | |
108,942 | 8 | 12 | 5 | 59 | 8 | 0 | 8 | 71 | _on_leave | Make it easier to improve UI event metadata.
Currently, UI events (MouseEvent, KeyEvent, etc.) are generated by
letting the GUI-specific backends massage the native event objects into
a list of args/kwargs and then call
`FigureCanvasBase.motion_notify_event`/`.key_press_event`/etc. This
makes it a bit tricky to impro... | https://github.com/matplotlib/matplotlib.git | def _on_leave(self, event):
event.Skip()
LocationEvent("figure_leave_event", self,
*self._mpl_coords(event),
guiEvent=event)._process()
| 35 | backend_wx.py | Python | lib/matplotlib/backends/backend_wx.py | 4e21912d2938b0e8812c4d1f7cd902c080062ff2 | matplotlib | 1 | |
337,616 | 10 | 12 | 2 | 45 | 7 | 0 | 10 | 16 | require_cpu | Fix debug_launcher issues (#413)
* change to require_cpu only | https://github.com/huggingface/accelerate.git | def require_cpu(test_case):
return unittest.skipUnless(not torch.cuda.is_available(), "test requires only a CPU")(test_case)
| 25 | testing.py | Python | src/accelerate/test_utils/testing.py | 3b51d6e9ad8a3916e519eb27ed85ec70f6f862fc | accelerate | 1 | |
189,393 | 18 | 13 | 5 | 98 | 13 | 0 | 22 | 69 | set_color_by_t2g | Update `Text` to use new ManimPango color setting (#2341)
* Find indexes in stripped text, not original text
* Add regression test
* Only run the test in linux environement
* Rewrite text2settings in Text to set text color via pango
* Make gradient in Text use pango coloring
* Bump manimpango to newest ... | https://github.com/ManimCommunity/manim.git | def set_color_by_t2g(self, t2g=None):
t2g = t2g if t2g else self.t2g
for word, gradient in list(t2g.items()):
for start, end in self.find_indexes(word, self.text):
self.chars[start:end].set_color_by_gradient(*gradient)
| 63 | text_mobject.py | Python | manim/mobject/svg/text_mobject.py | 540dc70d2fd7a2f759a6da158303ef81a1ae53f8 | manim | 4 | |
130,250 | 25 | 12 | 7 | 109 | 14 | 0 | 27 | 84 | match_files | [CI] Format Python code with Black (#21975)
See #21316 and #21311 for the motivation behind these changes. | https://github.com/ray-project/ray.git | def match_files(self, files, separators=None):
if not util._is_iterable(files):
raise TypeError("files:{!r} is not an iterable.".format(files))
file_map = util.normalize_files(files, separators=separators)
matched_files = util.match_files(self.patterns, iterkeys(file_map))
... | 68 | pathspec.py | Python | python/ray/_private/thirdparty/pathspec/pathspec.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 3 | |
81,824 | 64 | 12 | 22 | 197 | 15 | 0 | 102 | 278 | check_related | DRY edits to access classes for new prompts
Remove if-not-data conditional from WFJTnode.can_change
these are cannonical for can_add, but this looks like a bug
Change JTaccess.can_unattach to call same method in super()
previously called can_attach, which is problematic
Better consolidate launch config m2m relat... | https://github.com/ansible/awx.git | def check_related(self, field, Model, data, role_field='admin_role', obj=None, mandatory=False):
new = None
changed = True
if data and 'reference_obj' in data:
# Use reference object's related fields, if given
new = getattr(data['reference_obj'], field)
e... | 161 | access.py | Python | awx/main/access.py | 34e8087aeef0de19642e7dd9cd076adcdf5fbe9c | awx | 20 | |
247,387 | 14 | 9 | 12 | 59 | 6 | 0 | 14 | 64 | test_unknown_invalid | Add type hints to `tests/rest` (#12146)
* Add type hints to `tests/rest`
* newsfile
* change import from `SigningKey` | https://github.com/matrix-org/synapse.git | def test_unknown_invalid(self) -> None:
encodings = _get_html_media_encodings(
b,
'text/html; charset="invalid"',
)
self.assertEqual(list(encodings), ["utf-8", "cp1252"])
| 33 | test_html_preview.py | Python | tests/rest/media/v1/test_html_preview.py | 7e91107be1a4287873266e588a3c5b415279f4c8 | synapse | 1 | |
241,621 | 6 | 6 | 3 | 19 | 3 | 0 | 6 | 20 | creates_processes_externally | Modify LSFEnvironment to use more reliable environment variable (#10825)
Co-authored-by: thomas chaton <thomas@grid.ai>
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: Adrian Wälchli <aedu.waelchli@gmail.com>
Co-authored-by: Jirka Borovec <Borda@users.noreply.github.com> | https://github.com/Lightning-AI/lightning.git | def creates_processes_externally(self) -> bool:
return True
| 10 | lsf_environment.py | Python | pytorch_lightning/plugins/environments/lsf_environment.py | dbf1acd5a553ffc1546734be164cc89cef2b741d | lightning | 1 | |
145,828 | 2 | 6 | 60 | 13 | 2 | 0 | 2 | 9 | test_timeslices_partially_overlapping_experiences | [RLlib] Issue 22625: `MultiAgentBatch.timeslices()` does not behave as expected. (#22657) | https://github.com/ray-project/ray.git | def test_timeslices_partially_overlapping_experiences(self):
| 254 | test_multi_agent_batch.py | Python | rllib/policy/tests/test_multi_agent_batch.py | c0ade5f0b7cfc9aeba46cde7af3b36068a6420df | ray | 3 | |
250,614 | 12 | 11 | 43 | 63 | 15 | 0 | 14 | 26 | test_http_client_aborts | reintroduce `Flow.live`
We previously relied on the state of `Flow.reply` to check if a flow can be killed,
but this doesn't work anymore with `Flow.reply` being removed. Instead, we now
reintroduce the `Flow.live` attribute, which signals if we are on a live connection.
Killing still is not ideal (see comment in `Flo... | https://github.com/mitmproxy/mitmproxy.git | def test_http_client_aborts(tctx, stream):
server = Placeholder(Server)
flow = Placeholder(HTTPFlow)
playbook = Playbook(http.HttpLayer(tctx, HTTPMode.regular), hooks=True)
| 191 | test_http.py | Python | test/mitmproxy/proxy/layers/http/test_http.py | 372a632161dee642d81542069507826e34466ba1 | mitmproxy | 3 | |
109,257 | 18 | 7 | 2 | 84 | 8 | 0 | 25 | 54 | get_yaxis | Add discouraged admonitions
The [*Discouraged*] prefix in the summary line is added in analogy to
the [*Deprecated*] prefix we add automatically. We do this so that
these "labels" are prominently visible also in summary overviews of
the functions in the docs.
Since we rarely discourage whole functions, for now I just... | https://github.com/matplotlib/matplotlib.git | def get_yaxis(self):
return self.yaxis
get_xgridlines = _axis_method_wrapper("xaxis", "get_gridlines")
get_xticklines = _axis_method_wrapper("xaxis", "get_ticklines")
get_ygridlines = _axis_method_wrapper("yaxis", "get_gridlines")
get_yticklines = _axis_method_wrapper("yaxis", "get_tic... | 10 | _base.py | Python | lib/matplotlib/axes/_base.py | 5af97515b3823b2efa1961253a11e2d77df88637 | matplotlib | 1 | |
13,348 | 52 | 10 | 37 | 162 | 15 | 0 | 68 | 217 | mixin_scalable_deployment_parser | refactor: remove unnecessary parser args (#5328)
* refactor: refactor deployment mixin and remove polling and shards for gateway
* chore: rename executor to pod and move native and array type to worker args
* refactor: make exit-on-exceptions just a worker arg
* style: fix overload and cli autocomplete
* c... | https://github.com/jina-ai/jina.git | def mixin_scalable_deployment_parser(parser):
gp = mixin_base_deployment_parser(parser, title='Scalable Deployment')
gp.add_argument(
'--polling',
type=str,
default=PollingType.ANY.name,
help=,
)
gp.add_argument(
'--shards',
type=int,
defaul... | 97 | base.py | Python | jina/parsers/orchestrate/base.py | bd8003508da0b35713361484f5801ebc818bd0c3 | jina | 1 | |
271,620 | 11 | 8 | 39 | 41 | 4 | 0 | 13 | 38 | make_train_function | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def make_train_function(self, force=False):
if self.train_function is not None and not force:
return self.train_function
| 204 | training.py | Python | keras/engine/training.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 10 | |
274,931 | 4 | 7 | 2 | 22 | 3 | 0 | 4 | 18 | dtype | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def dtype(self):
return self._variable.dtype
| 12 | autocast_variable.py | Python | keras/mixed_precision/autocast_variable.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 | |
171,304 | 37 | 12 | 17 | 169 | 15 | 0 | 59 | 244 | __new__ | STYLE enable pylint's redefined-outer-name (#49671)
* fix warning for pandas/core/dtypes/cast.py, pandas/core/dtypes/dtypes.py, pandas/core/indexes/base.py
* fix warning for pandas/core/dtypes/cast.py, pandas/core/dtypes/dtypes.py, pandas/core/indexes/base.py
* fix warning for pandas/core/dtypes/cast.py, pandas/... | https://github.com/pandas-dev/pandas.git | def __new__(cls, freq=None):
if isinstance(freq, PeriodDtype):
return freq
elif freq is None:
# empty constructor for pickle compat
# -10_000 corresponds to PeriodDtypeCode.UNDEFINED
u = PeriodDtypeBase.__new__(cls, -10_000)
u._freq =... | 106 | dtypes.py | Python | pandas/core/dtypes/dtypes.py | c7010a7adec1c47a4642fa068544699fc8e1ea6a | pandas | 5 | |
100,733 | 55 | 11 | 9 | 134 | 7 | 0 | 79 | 231 | _rewrite_warnings | Bugfixes:
- Stats graph - Handle NaNs in data
- logger - de-elevate matplotlib font messages | https://github.com/deepfakes/faceswap.git | def _rewrite_warnings(cls, record):
if record.levelno == 30 and record.funcName == "warn" and record.module == "ag_logging":
# TF 2.3 in Conda is imported with the wrong gast(0.4 when 0.3.3 should be used). This
# causes warnings in autograph. They don't appear to impact perform... | 74 | logger.py | Python | lib/logger.py | afec52309326304f4323029039e49bfcf928ef43 | faceswap | 7 | |
163,113 | 22 | 11 | 51 | 53 | 6 | 0 | 24 | 97 | get_loc | BUG: Index.get_loc always raise InvalidIndexError on listlike (#45181) | https://github.com/pandas-dev/pandas.git | def get_loc(self, key, method=None):
if method is not None:
raise NotImplementedError(
"only the default get_loc method is "
"currently supported for MultiIndex"
)
self._check_indexing_error(key)
| 324 | multi.py | Python | pandas/core/indexes/multi.py | 46ddb8ef882940fa3da58813e0b7a2df1061031e | pandas | 15 | |
225,597 | 77 | 15 | 22 | 422 | 32 | 1 | 145 | 242 | bbox_rotate | Implement Ellipse Method For Bounding Box Rotation (#1203)
* implement ellipse method
* black formatting
* fix serialization and update docs
* apply reviews | https://github.com/albumentations-team/albumentations.git | def bbox_rotate(bbox, angle, method, rows, cols):
x_min, y_min, x_max, y_max = bbox[:4]
scale = cols / float(rows)
if method == "largest_box":
x = np.array([x_min, x_max, x_max, x_min]) - 0.5
y = np.array([y_min, y_min, y_max, y_max]) - 0.5
elif method == "ellipse":
w = (x_m... | @angle_2pi_range | 280 | functional.py | Python | albumentations/augmentations/geometric/functional.py | a3a8fd99b564663e26a741c6d59013f2f213c799 | albumentations | 3 |
68,215 | 26 | 11 | 12 | 105 | 9 | 0 | 32 | 24 | get_message | feat: add colors for attendance status to lessen the cognitive load
- legend with colors and full form for status abbreviations | https://github.com/frappe/erpnext.git | def get_message() -> str:
message = ''
colors = ['green', 'red', 'orange', 'green', '#318AD8', '', '']
count = 0
for status, abbr in status_map.items():
message += f
count += 1
return message
| 49 | monthly_attendance_sheet.py | Python | erpnext/hr/report/monthly_attendance_sheet/monthly_attendance_sheet.py | 865204a541651c284979a824576cdfcc4d789056 | erpnext | 2 | |
270,970 | 27 | 10 | 7 | 117 | 12 | 0 | 50 | 121 | get_losses_for | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def get_losses_for(self, inputs):
if inputs is None:
# Requesting unconditional losses.
return [l for l in self.losses if l._unconditional_loss]
# Requesting input-conditional losses.
losses = [l for l in self.losses if not l._unconditional_loss]
inputs ... | 75 | base_layer_v1.py | Python | keras/engine/base_layer_v1.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 8 | |
209,501 | 70 | 9 | 6 | 132 | 26 | 0 | 103 | 101 | GetIcmpStatistics | E275 - Missing whitespace after keyword (#3711)
Co-authored-by: Alexander Aring <alex.aring@gmail.com>
Co-authored-by: Anmol Sarma <me@anmolsarma.in>
Co-authored-by: antoine.torre <torreantoine1@gmail.com>
Co-authored-by: Antoine Vacher <devel@tigre-bleu.net>
Co-authored-by: Arnaud Ebalard <arno@natisbad.org>
Co-... | https://github.com/secdev/scapy.git | def GetIcmpStatistics():
statistics = MIB_ICMP()
_GetIcmpStatistics(byref(statistics))
results = _struct_to_dict(statistics)
del statistics
return results
##############################
##### Adapters Addresses #####
##############################
# Our GetAdaptersAddresses implementation is... | 27 | structures.py | Python | scapy/arch/windows/structures.py | 08b1f9d67c8e716fd44036a027bdc90dcb9fcfdf | scapy | 1 | |
292,459 | 50 | 14 | 34 | 241 | 33 | 1 | 68 | 366 | upnp_factory_mock | Add dlna_dms integration to support DLNA Digital Media Servers (#66437) | https://github.com/home-assistant/core.git | def upnp_factory_mock() -> Iterable[Mock]:
with patch(
"homeassistant.components.dlna_dms.dms.UpnpFactory",
autospec=True,
spec_set=True,
) as upnp_factory:
upnp_device = create_autospec(UpnpDevice, instance=True)
upnp_device.name = MOCK_DEVICE_NAME
upnp_devi... | @pytest.fixture | 143 | conftest.py | Python | tests/components/dlna_dms/conftest.py | b19bf9b147f4321e89d1f7f01e68337f2102f460 | core | 1 |
211,430 | 27 | 9 | 9 | 114 | 16 | 0 | 36 | 126 | forward | pose3d metro modeling (#6612)
* pose3d metro modeling
* delete extra comments | https://github.com/PaddlePaddle/PaddleDetection.git | def forward(self, pred3d, pred2d, inputs):
gt_3d_joints = inputs['joints_3d']
gt_2d_joints = inputs['joints_2d']
has_3d_joints = inputs['has_3d_joints']
has_2d_joints = inputs['has_2d_joints']
loss_3d = mpjpe(pred3d, gt_3d_joints, has_3d_joints)
loss_2d = keypoi... | 72 | pose3d_loss.py | Python | ppdet/modeling/losses/pose3d_loss.py | d4e34fe165c09db65fd00113708be1b711ac957c | PaddleDetection | 1 | |
337,064 | 61 | 11 | 24 | 261 | 37 | 0 | 81 | 291 | test_stable_diffusion_fp16 | [img2img, inpainting] fix fp16 inference (#769)
* handle dtype in vae and image2image pipeline
* fix inpaint in fp16
* dtype should be handled in add_noise
* style
* address review comments
* add simple fast tests to check fp16
* fix test name
* put mask in fp16 | https://github.com/huggingface/diffusers.git | def test_stable_diffusion_fp16(self):
unet = self.dummy_cond_unet
scheduler = PNDMScheduler(skip_prk_steps=True)
vae = self.dummy_vae
bert = self.dummy_text_encoder
tokenizer = CLIPTokenizer.from_pretrained("hf-internal-testing/tiny-random-clip")
# put models in... | 165 | test_pipelines.py | Python | tests/test_pipelines.py | 92d70863663662669ee3c376909be1f876e00965 | diffusers | 1 | |
209,387 | 17 | 9 | 7 | 56 | 3 | 0 | 23 | 58 | dce_rpc_endianess | Add SPDX License identifiers (#3655)
* Add SPDX License identifiers
* Relicense `ldp.py` with author consent
See https://github.com/secdev/scapy/issues/3478
* Apply guedou suggestions
* Relicense someim under GPL2
* DCE/RPC licensing | https://github.com/secdev/scapy.git | def dce_rpc_endianess(pkt):
if pkt.endianness == 0: # big endian
return ">"
elif pkt.endianness == 1: # little endian
return "<"
else:
return "!"
| 28 | dce_rpc.py | Python | scapy/contrib/dce_rpc.py | 9420c2229bf5330c2cc580f114f63f920a68db10 | scapy | 3 | |
128,581 | 11 | 14 | 24 | 67 | 10 | 0 | 12 | 55 | get_results | [tune] Add Tuner.get_results() to retrieve results after restore (#29083)
At the moment, we need to call `tuner.fit()` to retrieve results. This PR adds a method `Tuner.get_results()` that will return the results again after fitting. It can also be used after restoring a run to get results without calling `fit()` (and... | https://github.com/ray-project/ray.git | def get_results(self) -> ResultGrid:
if not self._is_ray_client:
return self._local_tuner.get_results()
else:
return ray.get(self._remote_tuner.fit.remote())
| 39 | tuner.py | Python | python/ray/tune/tuner.py | b510640f15a0fa4782b83ec2ea0749386b615b15 | ray | 2 | |
276,451 | 12 | 9 | 4 | 42 | 8 | 0 | 12 | 44 | _get_tensors | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _get_tensors(self, sess, tensor_list):
return [
sess.graph.get_tensor_by_name(tensor.name) for tensor in tensor_list
]
| 27 | graph_util_test.py | Python | keras/tests/graph_util_test.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 2 | |
46,559 | 44 | 16 | 16 | 207 | 27 | 0 | 51 | 135 | pool_import_helper | More explicit messages for pools and exceptions (#22569) | https://github.com/apache/airflow.git | def pool_import_helper(filepath):
api_client = get_current_api_client()
with open(filepath) as poolfile:
data = poolfile.read()
try:
pools_json = json.loads(data)
except JSONDecodeError as e:
raise SystemExit(f"Invalid json file: {e}")
pools = []
failed = []
for... | 120 | pool_command.py | Python | airflow/cli/commands/pool_command.py | 7418720ce173ca5d0c5f5197c168e43258af8cc3 | airflow | 5 | |
314,848 | 26 | 10 | 10 | 98 | 16 | 0 | 28 | 71 | test_dont_fire_on_unknown_module | Add tests for LCN sensor and binary_sensor platforms (#67263) | https://github.com/home-assistant/core.git | async def test_dont_fire_on_unknown_module(hass, lcn_connection):
inp = ModStatusAccessControl(
LcnAddr(0, 10, False), # unknown module
periphery=AccessControlPeriphery.FINGERPRINT,
code="aabbcc",
)
events = async_capture_events(hass, LCN_FINGERPRINT)
await lcn_connection.... | 60 | test_events.py | Python | tests/components/lcn/test_events.py | b7b8feda0ffb7487954545c96c50e7f64e2195bc | core | 1 | |
310,210 | 22 | 10 | 13 | 101 | 13 | 0 | 28 | 81 | extra_state_attributes | Remove vera from mypy ignore list (#64474)
* Remove vera from mypy ignore list
* Fix pylint | https://github.com/home-assistant/core.git | def extra_state_attributes(self) -> dict[str, Any] | None:
data = super().extra_state_attributes or {}
last_user = self.vera_device.get_last_user_alert()
if last_user is not None:
data[ATTR_LAST_USER_NAME] = last_user[1]
data[ATTR_LOW_BATTERY] = self.vera_device.ge... | 63 | lock.py | Python | homeassistant/components/vera/lock.py | 03bf2cdd56eb9a0a9ed56d7afb700d5f7d9cf75e | core | 3 | |
33,645 | 68 | 12 | 24 | 337 | 36 | 0 | 84 | 284 | loss_labels | Add Deformable DETR (#17281)
* First draft
* More improvements
* Improve model, add custom CUDA code
* Import torch before
* Add script that imports custom layer
* Add everything in new ops directory
* Import custom layer in modeling file
* Fix ARCHIVE_MAP typo
* Creating the custom kernel on t... | https://github.com/huggingface/transformers.git | def loss_labels(self, outputs, targets, indices, num_boxes, log=True):
if "logits" not in outputs:
raise ValueError("No logits were found in the outputs")
source_logits = outputs["logits"]
idx = self._get_source_permutation_idx(indices)
target_classes_o = torch.cat... | 226 | modeling_deformable_detr.py | Python | src/transformers/models/deformable_detr/modeling_deformable_detr.py | 59407bbeb31fff8340938768051c9daabd38d7a7 | transformers | 3 | |
22,665 | 18 | 11 | 5 | 61 | 6 | 0 | 19 | 62 | component | refactor: clean code
Signed-off-by: slowy07 <slowy.arfy@gmail.com> | https://github.com/geekcomputers/Python.git | def component(self, i):
if i < len(self.__components) and i >= 0:
return self.__components[i]
else:
raise Exception("index out of range")
| 36 | lib.py | Python | linear-algebra-python/src/lib.py | f0af0c43340763724f139fa68aa1e5a9ffe458b4 | Python | 3 | |
260,557 | 82 | 13 | 28 | 334 | 28 | 0 | 103 | 367 | fit | MAINT add parameter_constraints for MultiOutputClassifier and MultiOutputRegressor (#23902)
Co-authored-by: jeremiedbb <jeremiedbb@yahoo.fr> | https://github.com/scikit-learn/scikit-learn.git | def fit(self, X, y, sample_weight=None, **fit_params):
self._validate_params()
if not hasattr(self.estimator, "fit"):
raise ValueError("The base estimator should implement a fit method")
y = self._validate_data(X="no_validation", y=y, multi_output=True)
if is_clas... | 209 | multioutput.py | Python | sklearn/multioutput.py | d942600e1f1979c431c24f59933a95155789f324 | scikit-learn | 9 | |
181,911 | 13 | 10 | 6 | 74 | 12 | 0 | 16 | 34 | mutate_random_individual | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | https://github.com/EpistasisLab/tpot.git | def mutate_random_individual(population, toolbox):
idx = np.random.randint(0,len(population))
ind = population[idx]
ind, = toolbox.mutate(ind)
del ind.fitness.values
return ind
| 46 | gp_deap.py | Python | tpot/gp_deap.py | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot | 1 | |
224,172 | 32 | 11 | 21 | 232 | 21 | 0 | 42 | 181 | test_nav_no_title | Some manual changes ahead of formatting code with Black | https://github.com/mkdocs/mkdocs.git | def test_nav_no_title(self):
nav_cfg = [
'index.md',
{'About': 'about.md'},
]
expected = dedent(
)
cfg = load_config(nav=nav_cfg, site_url='http://example.com/')
fs = [
File(nav_cfg[0], cfg['docs_dir'], cfg['site_dir'], cfg... | 142 | nav_tests.py | Python | mkdocs/tests/structure/nav_tests.py | 372384d8102ddb4be6360f44d1bfddb8b45435a4 | mkdocs | 1 | |
60,276 | 4 | 7 | 2 | 21 | 2 | 0 | 4 | 18 | to_proto | Balanced joint maximum mean discrepancy for deep transfer learning | https://github.com/jindongwang/transferlearning.git | def to_proto(self):
return to_proto(self)
| 11 | net_spec.py | Python | code/deep/BJMMD/caffe/python/caffe/net_spec.py | cc4d0564756ca067516f71718a3d135996525909 | transferlearning | 1 | |
168,314 | 8 | 10 | 3 | 45 | 8 | 0 | 8 | 29 | get | DOC/TST: Clarify Series.str.get supports passing hashable label (#47918)
* gh 47911
* pre-commit issue
* add test and fix doc
* modified comment
* pep 8
* add more elements | https://github.com/pandas-dev/pandas.git | def get(self, i):
result = self._data.array._str_get(i)
return self._wrap_result(result)
| 27 | accessor.py | Python | pandas/core/strings/accessor.py | d5b4b33f1034b0fb0aa8a76cefe620794e28e851 | pandas | 1 | |
296,122 | 6 | 7 | 3 | 25 | 4 | 0 | 6 | 20 | is_connected | Add missing type declaration to AsusWrt Scanner Entity (#69773) | https://github.com/home-assistant/core.git | def is_connected(self) -> bool:
return self._device.is_connected
| 14 | device_tracker.py | Python | homeassistant/components/asuswrt/device_tracker.py | bc2ba8e1c8c988ae24f6961ce64187782f5ba32d | core | 1 | |
261,022 | 84 | 12 | 16 | 185 | 17 | 0 | 113 | 219 | get_namespace | ENH Adds Array API support to LinearDiscriminantAnalysis (#22554)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Julien Jerphanion <git@jjerphan.xyz> | https://github.com/scikit-learn/scikit-learn.git | def get_namespace(*arrays):
# `arrays` contains one or more arrays, or possibly Python scalars (accepting
# those is a matter of taste, but doesn't seem unreasonable).
# Returns a tuple: (array_namespace, is_array_api)
if not get_config()["array_api_dispatch"]:
return _NumPyApiWrapper(), F... | 107 | _array_api.py | Python | sklearn/utils/_array_api.py | 2710a9e7eefd2088ce35fd2fb6651d5f97e5ef8b | scikit-learn | 8 | |
268,938 | 113 | 16 | 32 | 479 | 22 | 1 | 178 | 316 | array_to_img | Copy image utils from keras_preprocessing directly into core keras
This is not new code, we are just moving these utilities directly
into keras from keras-preprocessing.
For the library code, just fixed linting errors.
For the test code, had to do more major changes to port from pytest, but
hopefully any errors have ... | https://github.com/keras-team/keras.git | def array_to_img(x, data_format=None, scale=True, dtype=None):
if data_format is None:
data_format = backend.image_data_format()
if dtype is None:
dtype = backend.floatx()
if pil_image is None:
raise ImportError('Could not import PIL.Image. '
'The use of `array_to_img` requir... | @keras_export('keras.utils.img_to_array',
'keras.preprocessing.image.img_to_array') | 264 | image.py | Python | keras/preprocessing/image.py | 373ad97c72ed1ac4b6898e85b2cfd7b016e4b469 | keras | 13 |
276,040 | 34 | 11 | 21 | 177 | 23 | 0 | 50 | 225 | _infer_inputs | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _infer_inputs(self, layer_node_id, convert_to_shapes=False):
call_fn_id = self._search_for_child_node(
layer_node_id, ["call_and_return_all_conditional_losses"]
)
if call_fn_id is None:
return None
concrete_functions = self._proto.nodes[
... | 113 | load.py | Python | keras/saving/saved_model/load.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 4 | |
289,389 | 20 | 10 | 73 | 90 | 11 | 0 | 34 | 83 | test_measure_from_end_going_backwards | Ensure recorder test fixture is setup before hass fixture (#80528)
* Ensure recorder test fixture is setup before hass fixture
* Adjust more tests | https://github.com/home-assistant/core.git | async def test_measure_from_end_going_backwards(recorder_mock, hass):
start_time = dt_util.utcnow() - timedelta(minutes=60)
t0 = start_time + timedelta(minutes=20)
t1 = t0 + timedelta(minutes=10)
t2 = t1 + timedelta(minutes=10)
# Start t0 t1 t2 End
# |--20min--|--2... | 393 | test_sensor.py | Python | tests/components/history_stats/test_sensor.py | 31a787558fd312331b55e5c2c4b33341fc3601fc | core | 2 | |
268,596 | 32 | 15 | 6 | 111 | 12 | 0 | 36 | 72 | _gen_candidate_chars | fix password lookup's use of f=v settings (#76551)
update tests | https://github.com/ansible/ansible.git | def _gen_candidate_chars(characters):
chars = []
for chars_spec in characters:
# getattr from string expands things like "ascii_letters" and "digits"
# into a set of characters.
chars.append(to_text(getattr(string, to_native(chars_spec), chars_spec), errors='strict'))
chars = u'... | 67 | password.py | Python | lib/ansible/plugins/lookup/password.py | 5d253a13807e884b7ce0b6b57a963a45e2f0322c | ansible | 2 | |
245,934 | 54 | 11 | 20 | 256 | 26 | 1 | 76 | 166 | quality_focal_loss_tensor_target | [Feat]: adjust FocalLoss and QualityFocalLoss to allow different kinds of targets (#9481)
* Adjust FocalLoss and QualityFocalLoss for MMYOLO
* Adjust FocalLoss and QualityFocalLoss to fit MMYOLO
* Adjust FocalLoss and QualityFocalLoss to fit MMYOLO
* add comment
* Add docstring
* refine docstring
* a... | https://github.com/open-mmlab/mmdetection.git | def quality_focal_loss_tensor_target(pred, target, beta=2.0, activated=False):
# pred and target should be of the same size
assert pred.size() == target.size()
if activated:
pred_sigmoid = pred
loss_function = F.binary_cross_entropy
else:
pred_sigmoid = pred.sigmoid()
... | @weighted_loss | 161 | gfocal_loss.py | Python | mmdet/models/losses/gfocal_loss.py | 380d936098c051a639ed8403667d95a595145c2a | mmdetection | 2 |
291,850 | 4 | 6 | 2 | 16 | 3 | 0 | 4 | 18 | supported_options | Add dialect support to google_translate (#81768)
* Add TLD option support to google_translate
* Fix tests for added TLD option in google_translate
* Add Language to TLD mapping, Make tld configurable in google_translate
* Move const to dedicated file in google_translate | https://github.com/home-assistant/core.git | def supported_options(self):
return SUPPORT_OPTIONS
| 8 | tts.py | Python | homeassistant/components/google_translate/tts.py | 5533368171525f00beb7b2355f49c5b774408996 | core | 1 | |
34,566 | 26 | 11 | 7 | 101 | 8 | 0 | 28 | 68 | maybe_append_new_line | [DocTests Speech] Add doc tests for all speech models (#15031)
* fix_torch_device_generate_test
* remove @
* doc tests
* up
* up
* fix doctests
* adapt files
* finish refactor
* up
* save intermediate
* add more logic
* new change
* improve
* next try
* next try
* next try
... | https://github.com/huggingface/transformers.git | def maybe_append_new_line(code):
lines = code.split("\n")
if lines[0] in ["py", "python"]:
# add new line before last line being ```
last_line = lines[-1]
lines.pop()
lines.append("\n" + last_line)
return "\n".join(lines)
| 53 | prepare_for_doc_test.py | Python | utils/prepare_for_doc_test.py | 9f831bdeaf965acca6c6097dfffb1364f4416c17 | transformers | 2 | |
153,887 | 14 | 11 | 4 | 55 | 8 | 0 | 14 | 46 | add_to_apply_calls | REFACTOR-#4530: Standardize access to physical data in partitions (#4563)
Signed-off-by: Alexey Prutskov <lehaprutskov@gmail.com> | https://github.com/modin-project/modin.git | def add_to_apply_calls(self, func, *args, **kwargs):
return PandasOnRayDataframePartition(
self._data, call_queue=self.call_queue + [(func, args, kwargs)]
)
| 37 | partition.py | Python | modin/core/execution/ray/implementations/pandas_on_ray/partitioning/partition.py | 4ec7f6347903f9133c65ebc5b6e0e15553b98577 | modin | 1 | |
290,592 | 29 | 12 | 62 | 215 | 15 | 0 | 46 | 202 | test_remote_scanner | Move bluetooth remote scanner implementation into a base class (#82012) | https://github.com/home-assistant/core.git | async def test_remote_scanner(hass):
manager = _get_manager()
switchbot_device = BLEDevice(
"44:44:33:11:23:45",
"wohand",
{},
rssi=-100,
)
switchbot_device_adv = generate_advertisement_data(
local_name="wohand",
service_uuids=["050a021a-0000-1000-80... | 337 | test_models.py | Python | tests/components/bluetooth/test_models.py | f584efa0c24df19ef1f805ecf95a95cecec5ff99 | core | 1 | |
20,526 | 45 | 10 | 3 | 84 | 14 | 0 | 51 | 128 | with_class | 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... | https://github.com/pypa/pipenv.git | def with_class(classname, namespace=""):
<div>
Some text
<div class="grid">1 4 0 1 0</div>
<div class="graph">1,3 2,3 1,1</div>
<div>this <div> has no class</div>
</div>
classattr = "{}:class".format(namespace) if namespace... | 32 | actions.py | Python | pipenv/patched/notpip/_vendor/pyparsing/actions.py | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | pipenv | 2 | |
1,721 | 13 | 10 | 6 | 56 | 8 | 0 | 18 | 67 | predict | fix pooling layers
add notebooks for model training | https://github.com/OpenMined/PySyft.git | def predict(self, X):
x_next = X
for layer in self.layers[:]:
x_next = layer.forward(x_next)
y_pred = x_next
return y_pred
| 34 | model.py | Python | packages/syft/src/syft/core/tensor/nn/model.py | f9c115a133e58935de7905dd8a19b6b0d6490500 | PySyft | 2 | |
190,823 | 113 | 14 | 25 | 348 | 25 | 0 | 164 | 532 | getSubRectangles | Reformat of files using black
These files were not properly formatted. | https://github.com/thumbor/thumbor.git | def getSubRectangles(self, ims):
# Check image count
if len(ims) < 2:
return ims, [(0, 0) for i in ims]
# We need numpy
if np is None:
raise RuntimeError("Need Numpy to calculate sub-rectangles. ")
# Prepare
ims2 = [ims[0]]
xy =... | 215 | pil.py | Python | thumbor/engines/extensions/pil.py | 3c745ef193e9af9244cc406734e67815377472ed | thumbor | 8 | |
244,171 | 5 | 6 | 27 | 19 | 5 | 0 | 5 | 8 | split_coco | [Feature] Support splitting COCO data for Semi-supervised object detection. (#7431)
* Split COCO data for Semi-supervised object detection.
* import mmcv and use f-string
* add a parser out_dir to set the path of semi-annos
* Support multiprocessing
* use mmcv.track_parallel_progress
* fix
* rename s... | https://github.com/open-mmlab/mmdetection.git | def split_coco(data_root, out_dir, percent, fold):
| 214 | split_coco.py | Python | tools/misc/split_coco.py | 04db930cec2bb1bf628456ac57ec1aa396204b1b | mmdetection | 5 | |
22,785 | 27 | 16 | 5 | 122 | 10 | 0 | 36 | 75 | expand_block | refactor: clean code
Signed-off-by: slowy07 <slowy.arfy@gmail.com> | https://github.com/geekcomputers/Python.git | def expand_block(self, block):
w = list(struct.unpack(">16L", block)) + [0] * 64
for i in range(16, 80):
w[i] = self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]), 1)
return w
| 80 | sha1.py | Python | sha1.py | f0af0c43340763724f139fa68aa1e5a9ffe458b4 | Python | 2 | |
309,481 | 6 | 6 | 12 | 19 | 4 | 0 | 6 | 20 | speed_count | Bump pytradfri to 8.0.1 and fix fan preset mode "Auto" bug (#63920)
* Move util functions
* Fix errors
* Revert changes
* Fix tests
* Use self.async_set_percentage()
* Fix calculation functions and associated tests
* Handle case of 0
* Update tests/components/tradfri/test_util.py
Co-authored-by... | https://github.com/home-assistant/core.git | def speed_count(self) -> int:
return ATTR_MAX_FAN_STEPS
| 10 | fan.py | Python | homeassistant/components/tradfri/fan.py | b52a8ba37a5e5e05b80beddff06b116371941d86 | core | 1 | |
181,816 | 26 | 8 | 7 | 55 | 7 | 0 | 29 | 83 | _combine_individual_stats | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | https://github.com/EpistasisLab/tpot.git | 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... | 32 | base.py | Python | tpot/base.py | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot | 1 | |
200,290 | 9 | 11 | 4 | 54 | 6 | 0 | 9 | 29 | raise_on_deprecated | runtests.py: Undo auto-formatting, re-add changes to blacklist for scipy, numpy | https://github.com/sympy/sympy.git | def raise_on_deprecated():
with warnings.catch_warnings():
warnings.filterwarnings('error', '.*', DeprecationWarning, module='sympy.*')
yield
| 27 | runtests.py | Python | sympy/testing/runtests.py | 6d2bbf80752549276a968fd4af78231c569d55c5 | sympy | 1 | |
142,835 | 4 | 6 | 2 | 19 | 3 | 0 | 4 | 18 | get_live_trials | [tune/structure] Introduce execution package (#26015)
Execution-specific packages are moved to tune.execution.
Co-authored-by: Xiaowei Jiang <xwjiang2010@gmail.com> | https://github.com/ray-project/ray.git | def get_live_trials(self):
return self._live_trials
| 10 | trial_runner.py | Python | python/ray/tune/execution/trial_runner.py | 0959f44b6fc217a4f2766ed46a721eb79b067b2c | ray | 1 | |
96,980 | 26 | 11 | 13 | 75 | 12 | 0 | 27 | 62 | is_guessed_to_be_created_on_project_creation | ref(types): Add types to conditions and filters (#32393) | https://github.com/getsentry/sentry.git | def is_guessed_to_be_created_on_project_creation(self) -> bool:
# TODO(mgaeta): Bug: Rule is optional.
delta = abs(self.rule.date_added - self.project.date_added)
guess: bool = delta.total_seconds() < 30 and self.rule.label == DEFAULT_RULE_LABEL
return guess
| 45 | event_frequency.py | Python | src/sentry/rules/conditions/event_frequency.py | 654c6627307359956c6d44f83791d6b177841363 | sentry | 2 | |
248,089 | 16 | 12 | 12 | 140 | 6 | 0 | 18 | 93 | test_check_push_rules_actions | Add a module API to allow modules to edit push rule actions (#12406)
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | https://github.com/matrix-org/synapse.git | def test_check_push_rules_actions(self) -> None:
with self.assertRaises(InvalidRuleException):
self.module_api.check_push_rule_actions(["foo"])
with self.assertRaises(InvalidRuleException):
self.module_api.check_push_rule_actions({"foo": "bar"})
self.module_api... | 74 | test_api.py | Python | tests/module_api/test_api.py | 5ef673de4f0bf991402ee29235741a91a7cc9b02 | synapse | 1 | |
43,887 | 53 | 17 | 31 | 292 | 32 | 0 | 83 | 452 | on_task_instance_state_session_flush | Add Listener Plugin API that tracks TaskInstance state changes (#20443)
This adds new Plugin API - "listeners". It enables plugin authors to write
[pluggy hook implementation][1] that will be called on certain formalized extension
points. To differentiate between current Airflow extension points, like
plugins, and ... | https://github.com/apache/airflow.git | def on_task_instance_state_session_flush(session, flush_context):
logger = logging.getLogger(__name__)
if not get_listener_manager().has_listeners:
return
for state in flush_context.states:
if isinstance(state.object, TaskInstance) and session.is_modified(
state.object, incl... | 190 | events.py | Python | airflow/listeners/events.py | dba00ce6a32b7f50153887c6974f62985ca8023f | airflow | 10 | |
277,101 | 8 | 11 | 5 | 49 | 9 | 0 | 8 | 21 | sync_to_numpy_or_python_type | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def sync_to_numpy_or_python_type(tensors):
if isinstance(tensors, tf.distribute.experimental.coordinator.RemoteValue):
tensors = tensors.fetch()
| 42 | tf_utils.py | Python | keras/utils/tf_utils.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 2 | |
43,650 | 23 | 14 | 6 | 83 | 9 | 0 | 25 | 102 | cancel_triggers | Rename `to_delete` to `to_cancel` in TriggerRunner (#20658)
The queue's purpose is to track triggers that need to be canceled. The language `to_delete` was a bit confusing because for one it does not actually delete them but cancel them. The deletion work is actually in `cleanup_finished_triggers`. It seems that thi... | https://github.com/apache/airflow.git | async def cancel_triggers(self):
while self.to_cancel:
trigger_id = self.to_cancel.popleft()
if trigger_id in self.triggers:
# We only delete if it did not exit already
self.triggers[trigger_id]["task"].cancel()
await asyncio.sleep(0)
| 47 | triggerer_job.py | Python | airflow/jobs/triggerer_job.py | c20ad79b40ea2b213f6dca221221c6dbd55bd08f | airflow | 3 | |
166,980 | 5 | 6 | 21 | 27 | 4 | 0 | 5 | 8 | parametrize_fixture_doc | TYP: pandas/_testing (#47037)
* TYP: bunch of type annotations
* change not needed | https://github.com/pandas-dev/pandas.git | def parametrize_fixture_doc(*args) -> Callable[[F], F]:
| 20 | _test_decorators.py | Python | pandas/util/_test_decorators.py | c9c6685c51ead26bbbb9a0dd565e82967cd839e8 | pandas | 1 | |
102,175 | 10 | 8 | 8 | 47 | 6 | 0 | 11 | 32 | test_empty_backend | Revert "Revert D32498569: allow external backend codegen to toggle whether to generate out= and inplace kernels" (#69950)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69950
This reverts commit f6cad53443704dfe5a20cc62bee14d91e3bffcaa.
Test Plan: Imported from OSS
Reviewed By: albanD
Diff... | https://github.com/pytorch/pytorch.git | def test_empty_backend(self) -> None:
yaml_str =
output_error = self.get_errors_from_gen_backend_stubs(yaml_str)
self.assertExpectedInline(output_error, )
| 26 | test_gen_backend_stubs.py | Python | tools/test/test_gen_backend_stubs.py | bb5b4cceb6f737448eaaa6817cd773b6f4b0e77d | pytorch | 1 | |
270,204 | 25 | 12 | 9 | 84 | 10 | 0 | 29 | 84 | normalize_cluster_spec | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def normalize_cluster_spec(cluster_spec):
if isinstance(cluster_spec, (dict, cluster_pb2.ClusterDef)):
return tf.train.ClusterSpec(cluster_spec)
elif not isinstance(cluster_spec, tf.train.ClusterSpec):
raise ValueError(
"`cluster_spec' should be dict or a `tf.train.ClusterSpec` ... | 50 | distribute_coordinator_utils.py | Python | keras/distribute/distribute_coordinator_utils.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 3 | |
295,908 | 10 | 8 | 7 | 41 | 7 | 0 | 13 | 27 | available_tones | Add EntityFeature enum to Siren (#69585)
Co-authored-by: Franck Nijhof <frenck@frenck.nl> | https://github.com/home-assistant/core.git | def available_tones(self) -> list[int | str] | dict[int, str] | None:
return self._attr_available_tones
| 26 | __init__.py | Python | homeassistant/components/siren/__init__.py | a61ac3ddc6d65522dfa1eb599adf73420a9267dc | core | 1 | |
126,954 | 56 | 14 | 23 | 257 | 37 | 0 | 67 | 330 | test_ddpg_compilation | [RLlib] Move learning_starts logic from buffers into `training_step()`. (#26032) | https://github.com/ray-project/ray.git | def test_ddpg_compilation(self):
config = (
ddpg.DDPGConfig()
.training(num_steps_sampled_before_learning_starts=0)
.rollouts(num_rollout_workers=0, num_envs_per_worker=2)
)
explore = config.exploration_config.update({"random_timesteps": 100})
... | 153 | test_ddpg.py | Python | rllib/algorithms/ddpg/tests/test_ddpg.py | 0dceddb912ed92286032b5563dd2e541a8a7031f | ray | 4 | |
297,996 | 75 | 16 | 37 | 382 | 49 | 0 | 111 | 521 | async_step_user | Add blebox discovery/zeroconf (#83837)
Co-authored-by: J. Nick Koston <nick@koston.org> | https://github.com/home-assistant/core.git | async def async_step_user(self, user_input=None):
hass = self.hass
schema = create_schema(user_input)
if user_input is None:
return self.async_show_form(
step_id="user",
data_schema=schema,
errors={},
descripti... | 241 | config_flow.py | Python | homeassistant/components/blebox/config_flow.py | c737378ee14c12f988118dc9d23f1fc0b1da8ea1 | core | 7 | |
167,373 | 61 | 18 | 26 | 240 | 21 | 0 | 96 | 488 | update_info | TYP: some return annotations in pytables.py (#47512) | https://github.com/pandas-dev/pandas.git | def update_info(self, info) -> None:
for key in self._info_fields:
value = getattr(self, key, None)
idx = info.setdefault(self.name, {})
existing_value = idx.get(key)
if key in idx and value is not None and existing_value != value:
# fre... | 141 | pytables.py | Python | pandas/io/pytables.py | 7d2f9b8d59908fbf57c6453bc41891efbfe981a6 | pandas | 8 | |
176,408 | 4 | 7 | 2 | 21 | 3 | 0 | 4 | 18 | out_degree | Updated MultiDiGraph documentation to include more examples of actually (#5387)
using parallel edges, and fixed references to things like G[u, v] where
G[u, v, k] is required for a MultiDigraph. Have not made parallel
changes in MultiGraph which should maybe also be made?
Docs tests pass on my end; no code outsid... | https://github.com/networkx/networkx.git | def out_degree(self):
return OutMultiDegreeView(self)
| 11 | multidigraph.py | Python | networkx/classes/multidigraph.py | 4d4cf1efd44326a858af33711cb0c631abc5105a | networkx | 1 | |
264,675 | 6 | 8 | 2 | 31 | 4 | 0 | 6 | 12 | get_auth_backend_display | Closes #9123: Improve appearance of SSO login providers | https://github.com/netbox-community/netbox.git | def get_auth_backend_display(name):
return AUTH_BACKEND_ATTRS.get(name, (name, None))
| 19 | authentication.py | Python | netbox/netbox/authentication.py | d6df6b444f1bcc1b77b1b6ae6e726f3024e0abd4 | netbox | 1 | |
45,743 | 24 | 10 | 9 | 101 | 10 | 0 | 30 | 94 | unmap | More explicit mapped argument validation (#21933)
* More explicit mapped argument validation
Instead of always using MagicMock to validate mapped arguments, this
implements a more sophisticated protocol that allows an operator to
implement a 'validate_mapped_arguments' to provide custom validation
logic. If an o... | https://github.com/apache/airflow.git | def unmap(self) -> "BaseOperator":
dag = self.dag
if not dag:
raise RuntimeError("Cannot unmap a task without a DAG")
dag._remove_task(self.task_id)
if isinstance(self.operator_class, str):
raise RuntimeError("Cannot unmap a deserialized operator")
... | 57 | mappedoperator.py | Python | airflow/models/mappedoperator.py | b65e52205a7045eb08d471289b85abda587442b7 | airflow | 3 | |
154,520 | 26 | 11 | 12 | 150 | 17 | 0 | 39 | 143 | apply | REFACTOR-#5009: use RayWrapper.materialize instead of ray.get (#5010)
Signed-off-by: Myachev <anatoly.myachev@intel.com> | https://github.com/modin-project/modin.git | def apply(self, first, other, func, **kwargs):
df1 = self.cudf_dataframe_dict[first]
if not other:
result = func(df1, **kwargs)
return self.store_new_df(result)
if not isinstance(other, int):
assert isinstance(other, ray.ObjectRef)
df2 = R... | 97 | gpu_manager.py | Python | modin/core/execution/ray/implementations/cudf_on_ray/partitioning/gpu_manager.py | 1dc16415333bf2428ee2b1f4d31ff94e66b9a0a6 | modin | 3 | |
270,593 | 10 | 8 | 2 | 60 | 11 | 1 | 10 | 21 | get_default_mesh | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def get_default_mesh(self):
return self._default_mesh
LayoutMap.get.__doc__ = LayoutMap.__getitem__.__doc__
@keras_export("keras.dtensor.experimental.layout_map_scope", v1=[])
@contextlib.contextmanager | @keras_export("keras.dtensor.experimental.layout_map_scope", v1=[])
@contextlib.contextmanager | 10 | layout_map.py | Python | keras/dtensor/layout_map.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 |
308,560 | 51 | 13 | 27 | 261 | 18 | 0 | 77 | 246 | test_local_push_only | Allow mobile app registrations only supporting websocket push (#63208) | https://github.com/home-assistant/core.git | async def test_local_push_only(hass, hass_ws_client, setup_websocket_channel_only_push):
with pytest.raises(HomeAssistantError) as e_info:
assert await hass.services.async_call(
"notify",
"mobile_app_websocket_push_name",
{"message": "Not connected"},
blo... | 143 | test_notify.py | Python | tests/components/mobile_app/test_notify.py | ad8af5fc7a52a66a584bc31c535f100fb7c71919 | core | 1 | |
241,648 | 50 | 16 | 11 | 303 | 25 | 1 | 63 | 220 | test_error_raised_with_float_limited_eval_batches | Deprecate `TrainerDataLoadingMixin` and move logic to `DataConnector` (#11282)
Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
Co-authored-by: Aki Nitta <nitta@akihironitta.com>
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com> | https://github.com/Lightning-AI/lightning.git | def test_error_raised_with_float_limited_eval_batches():
model = BoringModel()
dl_size = len(model.val_dataloader())
limit_val_batches = 1 / (dl_size + 2)
trainer = Trainer(limit_val_batches=limit_val_batches)
trainer._data_connector.attach_data(model)
with pytest.raises(
Misconfigu... | @pytest.mark.parametrize(
"val_dl",
[
DataLoader(dataset=RandomDataset(32, 64), shuffle=True),
CombinedLoader(DataLoader(dataset=RandomDataset(32, 64), shuffle=True)),
CombinedLoader(
[DataLoader(dataset=RandomDataset(32, 64)), DataLoader(dataset=RandomDataset(32, 64), shuffl... | 71 | test_data_loading.py | Python | tests/trainer/test_data_loading.py | 5b59c951e28ddc8bb884f044b1f46fb54c23a8b8 | lightning | 1 |
8,060 | 23 | 11 | 6 | 99 | 15 | 0 | 30 | 45 | _get_dataset_configs | Config-first Datasets API (ludwig.datasets refactor) (#2479)
* Adds README and stub for reading dataset configs.
* Adds __init__.py for configs, moves circular import into function scope in ludwig/datasets/__init__.py
* Print config files in datasets folder.
* First pass at automatic archive extraction.
* ... | https://github.com/ludwig-ai/ludwig.git | def _get_dataset_configs() -> Dict[str, DatasetConfig]:
import importlib.resources
config_files = [f for f in importlib.resources.contents(configs) if f.endswith(".yaml")]
config_objects = [load_dataset_config(f) for f in config_files]
return {c.name: c for c in config_objects}
| 63 | __init__.py | Python | ludwig/datasets/__init__.py | e4fc06f986e03919d9aef3ab55c05fee5a6b9d3a | ludwig | 5 | |
291,214 | 18 | 11 | 5 | 64 | 9 | 0 | 20 | 52 | sound_mode_list | Bump to Arcam 1.0.1 and make strictly typed (#82487)
* Make arcam_fmj strictly typed
* Add test for invalid UDN | https://github.com/home-assistant/core.git | def sound_mode_list(self) -> list[str] | None:
if (values := self._state.get_decode_modes()) is None:
return None
return [x.name for x in values]
| 40 | media_player.py | Python | homeassistant/components/arcam_fmj/media_player.py | a55fb445b0ed4efd625227b4f13a01a0f469c358 | core | 3 | |
288,186 | 17 | 9 | 7 | 74 | 9 | 0 | 19 | 65 | wait_for_ble_connections_free | Wait for disconnect when we are out of connection ble slots in esphome (#79246) | https://github.com/home-assistant/core.git | async def wait_for_ble_connections_free(self) -> int:
if self.ble_connections_free > 0:
return self.ble_connections_free
fut: asyncio.Future[int] = asyncio.Future()
self._ble_connection_free_futures.append(fut)
return await fut
| 44 | entry_data.py | Python | homeassistant/components/esphome/entry_data.py | 0b5289f7483dde5911f4a268233fea2ce3b417ff | core | 2 | |
110,032 | 11 | 13 | 4 | 77 | 11 | 0 | 11 | 64 | update_from_data_y | Remove unnecessary np.{,as}array / astype calls.
Quite often numpy will call asarray for us, saving us the need to call
asarray explicitly.
When we do call asarray (or array) ourselves, a dtype can directly be
passed in, rather than immediately calling astype immediately after.
Passing the dtype makes it unnecessary ... | https://github.com/matplotlib/matplotlib.git | def update_from_data_y(self, y, ignore=None):
y = np.ravel(y)
self.update_from_data_xy(np.column_stack([np.ones(y.size), y]),
ignore=ignore, updatex=False)
| 50 | transforms.py | Python | lib/matplotlib/transforms.py | 1068a6faa19767724437461bcfb88c6852ec435c | matplotlib | 1 | |
87,234 | 5 | 7 | 2 | 28 | 3 | 0 | 5 | 11 | generate_cache_key_for_observed_release | feat(ds): Implements release boosting functionality for ds [TET-496] (#40403)
Sets releases that should be boosted with ds into the cache when a
transaction is observed in the event manager. The logic is as follows
once a transaction from a release that wasn't observed in the previous
24 hours is received, a cache ... | https://github.com/getsentry/sentry.git | def generate_cache_key_for_observed_release(project_id, release_id):
return f"ds::p:{project_id}:r:{release_id}"
| 11 | latest_release_booster.py | Python | src/sentry/dynamic_sampling/latest_release_booster.py | 0fc7bab05d499d4df4faea2d11f49d2be8214776 | sentry | 1 | |
101,208 | 79 | 13 | 15 | 213 | 22 | 0 | 98 | 301 | _update_file_format | 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 | https://github.com/deepfakes/faceswap.git | def _update_file_format(self, folder, filename):
logger.info("Reformatting legacy alignments file...")
old_location = os.path.join(str(folder), filename)
new_location = f"{os.path.splitext(old_location)[0]}.{self._serializer.file_extension}"
if os.path.exists(old_location):
... | 109 | alignments.py | Python | lib/align/alignments.py | 5e73437be47f2410439a3c6716de96354e6a0c94 | faceswap | 3 | |
297,977 | 16 | 9 | 6 | 47 | 6 | 0 | 16 | 66 | async_sync | String formatting and max line length - Part 5 (#84501)
Co-authored-by: jjlawren <jjlawren@users.noreply.github.com> | https://github.com/home-assistant/core.git | async def async_sync(self, other_player):
_LOGGER.warning(
"Service squeezebox.sync is deprecated; use media_player.join_players"
" instead"
)
await self.async_join_players([other_player])
| 24 | media_player.py | Python | homeassistant/components/squeezebox/media_player.py | f39f3b612a8c1a12504f2f1d54fb1c9872216d12 | core | 1 | |
10,842 | 38 | 12 | 8 | 59 | 10 | 0 | 48 | 134 | get_worker_host | refactor: rename pod to deployment (#4230)
* refactor: rename pod to deployment
* style: fix overload and cli autocomplete
* fix: undo daemon mistake
* refactor: leftover cleanup
* fix: more test fixes
* fix: more fixes
* fix: more fixes
* fix: more fixes
* fix: more tests
* fix: fix more te... | https://github.com/jina-ai/jina.git | def get_worker_host(pod_args, pod, head_pod):
# Check if the current pod and head are both containerized on the same host
# If so __docker_host__ needs to be advertised as the worker's address to the head
worker_host = (
__docker_host__
if Deployment._is_containe... | 37 | __init__.py | Python | jina/orchestrate/deployments/__init__.py | 13edc16d806fb5d77a6849551178ccc75937f25f | jina | 3 | |
175,178 | 105 | 12 | 37 | 278 | 28 | 0 | 142 | 549 | test_co_positions_artificial_instructions | bpo-46202: Remove opcode POP_EXCEPT_AND_RERAISE (GH-30302)
* bpo-46202: remove opcode POP_EXCEPT_AND_RERAISE
* do not assume that an exception group is truthy | https://github.com/python/cpython.git | def test_co_positions_artificial_instructions(self):
import dis
namespace = {}
exec(textwrap.dedent(), namespace)
exc = namespace['exc']
traceback = exc.__traceback__
code = traceback.tb_frame.f_code
artificial_instructions = []
for instr, positions in ... | 169 | test_code.py | Python | Lib/test/test_code.py | a94461d7189d7f1147ab304a332c8684263dc17e | cpython | 4 | |
281,540 | 8 | 9 | 31 | 40 | 7 | 0 | 8 | 30 | print_help | Terminal Wide Rich (#1161)
* My idea for how we handle Rich moving forward
* remove independent consoles
* FIxed pylint issues
* add a few vars
* Switched print to console
* More transitions
* Changed more prints
* Replaced all prints
* Fixing tabulate
* Finished replace tabulate
* Finish... | https://github.com/OpenBB-finance/OpenBBTerminal.git | def print_help(self):
help_text =
console.print(text=help_text, menu="Stocks - Discovery")
| 21 | disc_controller.py | Python | gamestonk_terminal/stocks/discovery/disc_controller.py | 82747072c511beb1b2672846ae2ee4aec53eb562 | OpenBBTerminal | 1 | |
142,459 | 35 | 10 | 7 | 81 | 9 | 0 | 38 | 107 | task_id | [api] Annotate as public / move ray-core APIs to _private and add enforcement rule (#25695)
Enable checking of the ray core module, excluding serve, workflows, and tune, in ./ci/lint/check_api_annotations.py. This required moving many files to ray._private and associated fixes. | https://github.com/ray-project/ray.git | def task_id(self):
# only worker mode has actor_id
assert (
self.worker.mode == ray._private.worker.WORKER_MODE
), f"This method is only available when the process is a\
worker. Current mode: {self.worker.mode}"
task_id = self.worker.current_task_id
... | 43 | runtime_context.py | Python | python/ray/runtime_context.py | 43aa2299e6623c8f8c7c4a1b80133459d0aa68b0 | ray | 2 | |
203,277 | 61 | 12 | 17 | 156 | 13 | 0 | 70 | 250 | test_body_after_POST_multipart_form_data | Refs #33476 -- Refactored problematic code before reformatting by Black.
In these cases Black produces unexpected results, e.g.
def make_random_password(
self,
length=10,
allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789',
):
or
cursor.execute("""
SELECT ...
""",
... | https://github.com/django/django.git | def test_body_after_POST_multipart_form_data(self):
# Because multipart is used for large amounts of data i.e. file uploads,
# we don't want the data held in memory twice, and we don't want to
# silence the error by setting body = '' either.
payload = FakePayload("\r\n".join([
... | 80 | tests.py | Python | tests/requests/tests.py | c5cd8783825b5f6384417dac5f3889b4210b7d08 | django | 1 | |
297,694 | 26 | 13 | 12 | 165 | 12 | 0 | 37 | 150 | update | Use UnitOfTemperature in integrations (e-h) (#84305) | https://github.com/home-assistant/core.git | def update(self) -> None:
self.hddtemp.update()
if self.hddtemp.data and self.disk in self.hddtemp.data:
self._details = self.hddtemp.data[self.disk].split("|")
self._attr_native_value = self._details[2]
if self._details is not None and self._details[3] == "... | 101 | sensor.py | Python | homeassistant/components/hddtemp/sensor.py | 9580c4f1ec5e45e5090d927792feea4ecf7c96e7 | core | 5 | |
269,419 | 32 | 14 | 11 | 145 | 14 | 1 | 43 | 131 | stack3 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def stack3(x, filters, blocks, stride1=2, groups=32, name=None):
x = block3(x, filters, stride=stride1, groups=groups, name=name + "_block1")
for i in range(2, blocks + 1):
x = block3(
x,
filters,
groups=groups,
conv_shortcut=False,
name=n... | @keras_export(
"keras.applications.resnet50.ResNet50",
"keras.applications.resnet.ResNet50",
"keras.applications.ResNet50",
) | 86 | resnet.py | Python | keras/applications/resnet.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 2 |
308,886 | 4 | 6 | 2 | 16 | 2 | 0 | 4 | 11 | async_update_group_state | Simplify groups (#63477)
* Simplify group
* Rename async_update to async_update_group_state and mark it as callback
* Simplify _async_start | https://github.com/home-assistant/core.git | def async_update_group_state(self) -> None:
| 8 | __init__.py | Python | homeassistant/components/group/__init__.py | 8bf8709d9928b714e70d32a383ba4e1a2849d353 | core | 1 | |
268,806 | 43 | 8 | 7 | 78 | 9 | 0 | 56 | 123 | add_locals | Simplify AnsibleJ2Vars by using ChainMap for vars (#78713)
Co-authored-by: Matt Martz <matt@sivel.net> | https://github.com/ansible/ansible.git | def add_locals(self, locals):
if locals is None:
return self
current_locals = self.maps[0]
current_globals = self.maps[2]
# prior to version 2.9, locals contained all of the vars and not just the current
# local vars so this was not necessary for locals to ... | 49 | vars.py | Python | lib/ansible/template/vars.py | 60f76436c144a08aa6b74bfefd559ac0188202f6 | ansible | 2 | |
104,587 | 36 | 12 | 24 | 131 | 17 | 0 | 42 | 63 | _parse_and_clean_wikicode | Improve Wikipedia Loading Script (#3435)
* Improve Wikipedia Loading Script (#3400)
* More structured approach to detecting redirects
* Remove redundant template filter code (covered by strip_code)
* Add language-specific lists of additional media namespace aliases for filtering
* Add language-specific lists of ca... | https://github.com/huggingface/datasets.git | def _parse_and_clean_wikicode(raw_content, parser, language):
wikicode = parser.parse(raw_content)
# Filters for magic words that are parser instructions -- e.g., __NOTOC__
re_rm_magic = re.compile("__[A-Z]*__", flags=re.UNICODE)
# Filters for file/image links.
media_prefixes = "|".join(["Fil... | 236 | wikipedia.py | Python | datasets/wikipedia/wikipedia.py | 7e30308f49f8c85dc7a2ab5aafbff04b5d2f38e2 | datasets | 6 | |
275,541 | 18 | 15 | 12 | 110 | 15 | 0 | 20 | 188 | iterations | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def iterations(self):
if self._iterations is None:
with self._distribution_strategy_scope():
self._iterations = self.add_weight(
"iter",
shape=[],
dtype=tf.int64,
trainable=False,
... | 68 | optimizer_v2.py | Python | keras/optimizers/optimizer_v2/optimizer_v2.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 2 | |
319,942 | 108 | 20 | 43 | 463 | 56 | 0 | 141 | 662 | update_document_archive_file | Implements a better re-do of OCR by making the document archiver function common. Actually creates updated file now | https://github.com/paperless-ngx/paperless-ngx.git | def update_document_archive_file(document_id):
document = Document.objects.get(id=document_id)
mime_type = document.mime_type
parser_class: Type[DocumentParser] = get_parser_class_for_mime_type(mime_type)
if not parser_class:
logger.error(
f"No parser found for mime type {mim... | 266 | tasks.py | Python | src/documents/tasks.py | ab761e837c4be4974f699c8c97560a4291a8d298 | paperless-ngx | 5 | |
181,659 | 8 | 9 | 6 | 38 | 6 | 0 | 8 | 38 | test_sparse1_with_non_sparse_components | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | https://github.com/EpistasisLab/tpot.git | def test_sparse1_with_non_sparse_components():
fit_then_transform(
sparse1_paratial_1h.todense(),
sparse1,
categorical_features=[True, False]
)
| 23 | one_hot_encoder_tests.py | Python | tests/one_hot_encoder_tests.py | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot | 1 | |
267,386 | 20 | 11 | 3 | 56 | 8 | 0 | 22 | 35 | get_generic_type | ansible-test - Code cleanup.
This helps prepare for a future pylint upgrade. | https://github.com/ansible/ansible.git | def get_generic_type(base_type, generic_base_type): # type: (t.Type, t.Type[TValue]) -> t.Optional[t.Type[TValue]]
# noinspection PyUnresolvedReferences
type_arg = t.get_args(base_type.__orig_bases__[0])[0]
return None if isinstance(type_arg, generic_base_type) else type_arg
| 35 | util.py | Python | test/lib/ansible_test/_internal/util.py | 86779cc90376ea70bafa7044b12ce5132409fd63 | ansible | 2 | |
166,227 | 4 | 8 | 2 | 23 | 3 | 0 | 4 | 18 | __dlpack__ | ENH: Implement DataFrame interchange protocol (#46141) | https://github.com/pandas-dev/pandas.git | def __dlpack__(self):
raise NotImplementedError("__dlpack__")
| 11 | dataframe_protocol.py | Python | pandas/core/exchange/dataframe_protocol.py | 90140f055892a46f473bd26affab88a7f171e394 | pandas | 1 | |
82,287 | 46 | 15 | 22 | 232 | 21 | 0 | 71 | 314 | for_page | Enabled isort workflow (#7200)
* Ran isort
* Enabled isort workflow
Co-authored-by: Vinit Kumar <mail@vinitkumar.me> | https://github.com/django-cms/django-cms.git | def for_page(self, page):
# permissions should be managed on the draft page only
from cms.models import (
ACCESS_CHILDREN, ACCESS_DESCENDANTS, ACCESS_PAGE,
ACCESS_PAGE_AND_CHILDREN, ACCESS_PAGE_AND_DESCENDANTS,
)
page = page.get_draft_object()
p... | 143 | managers.py | Python | cms/models/managers.py | a3110e1ff24085373898c7d2a85f628abeb8518d | django-cms | 2 | |
20,773 | 27 | 15 | 20 | 105 | 10 | 0 | 33 | 250 | position_cursor | 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... | https://github.com/pypa/pipenv.git | 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... | 70 | live_render.py | Python | pipenv/patched/notpip/_vendor/rich/live_render.py | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | pipenv | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.