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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
176,400 | 40 | 16 | 31 | 173 | 18 | 0 | 57 | 117 | _add_edge_keys | Fix missing backticks (#5381)
* Fix missing backticks
* one more backticks | https://github.com/networkx/networkx.git | def _add_edge_keys(G, betweenness, weight=None):
r
_weight = _weight_function(G, weight)
edge_bc = dict.fromkeys(G.edges, 0.0)
for u, v in betweenness:
d = G[u][v]
wt = _weight(u, v, d)
keys = [k for k in d if _weight(u, v, {k: d[k]}) == wt]
bc = betweenness[(u, v)] / le... | 122 | betweenness.py | Python | networkx/algorithms/centrality/betweenness.py | 0ce72858168a8ece6b55f695677f4be80f144aff | networkx | 5 | |
130,235 | 21 | 12 | 7 | 72 | 10 | 0 | 23 | 60 | get_other_nodes | [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 get_other_nodes(cluster, exclude_head=False):
return [
node
for node in cluster.list_all_nodes()
if node._raylet_socket_name != ray.worker._global_node._raylet_socket_name
and (exclude_head is False or node.head is False)
]
| 46 | test_utils.py | Python | python/ray/_private/test_utils.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 5 | |
118,639 | 41 | 14 | 22 | 276 | 24 | 0 | 60 | 353 | test_multiple_connections | Rename and refactor `Report` machinery (#4141)
This refactor renames (almost) everything related to the outdated "report" concept with more precise concepts that we use throughout our code, primarily "script run", "session", and "app". | https://github.com/streamlit/streamlit.git | def test_multiple_connections(self):
with patch(
"streamlit.server.server.LocalSourcesWatcher"
), self._patch_app_session():
yield self.start_server_loop()
self.assertFalse(self.server.browser_is_connected)
# Open a websocket connection
... | 166 | server_test.py | Python | lib/tests/streamlit/server_test.py | 704eab3478cf69847825b23dabf15813a8ac9fa2 | streamlit | 1 | |
43,677 | 6 | 6 | 3 | 28 | 3 | 0 | 6 | 20 | leaves | Map and Partial DAG authoring interface for Dynamic Task Mapping (#19965)
* Make DAGNode a proper Abstract Base Class
* Prevent mapping an already mapped Task/TaskGroup
Also prevent calls like .partial(...).partial(...). It is uncertain
whether these kinds of repeated partial/map calls have utility, so let's
disable... | https://github.com/apache/airflow.git | def leaves(self) -> List["MappedOperator"]:
return [self]
| 15 | baseoperator.py | Python | airflow/models/baseoperator.py | e9226139c2727a4754d734f19ec625c4d23028b3 | airflow | 1 | |
215,150 | 16 | 13 | 5 | 117 | 15 | 1 | 16 | 42 | free_port | adding functional tests for use_etag parameter in file.managed state | https://github.com/saltstack/salt.git | def free_port():
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s:
s.bind(("", 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
return s.getsockname()[1]
@pytest.fixture(autouse=True, scope="session") | @pytest.fixture(autouse=True, scope="session") | 57 | test_file.py | Python | tests/pytests/functional/states/test_file.py | e535e1cbc2a56154fc77efa26957e1c076125911 | salt | 1 |
271,440 | 4 | 7 | 2 | 22 | 3 | 0 | 4 | 18 | shape | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def shape(self):
return self._type_spec.shape
| 12 | keras_tensor.py | Python | keras/engine/keras_tensor.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 | |
69,313 | 73 | 20 | 41 | 446 | 21 | 0 | 150 | 110 | get_conditions | fix: typo in sales_register's filter mode_of_payment (#32371)
* fix: typo in sales_register's filter mode_of_payment | https://github.com/frappe/erpnext.git | def get_conditions(filters):
conditions = ""
accounting_dimensions = get_accounting_dimensions(as_list=False) or []
accounting_dimensions_list = [d.fieldname for d in accounting_dimensions]
if filters.get("company"):
conditions += " and company=%(company)s"
if filters.get("customer") and "customer" not in acc... | 213 | sales_register.py | Python | erpnext/accounts/report/sales_register/sales_register.py | 62c5b286906a594e5ea58e3412e3d5fb4eb5add7 | erpnext | 13 | |
259,467 | 38 | 12 | 5 | 139 | 23 | 1 | 44 | 98 | _assert_predictor_equal | MNT Update to black 22.3.0 to resolve click error (#22983)
* MNT Update to black 22.3.0 to resolve click error
* STY Update for new black version | https://github.com/scikit-learn/scikit-learn.git | def _assert_predictor_equal(gb_1, gb_2, X):
# Check identical nodes for each tree
for pred_ith_1, pred_ith_2 in zip(gb_1._predictors, gb_2._predictors):
for predictor_1, predictor_2 in zip(pred_ith_1, pred_ith_2):
assert_array_equal(predictor_1.nodes, predictor_2.nodes)
# Check ide... | @pytest.mark.parametrize(
"GradientBoosting, X, y",
[
(HistGradientBoostingClassifier, X_classification, y_classification),
(HistGradientBoostingRegressor, X_regression, y_regression),
],
) | 64 | test_warm_start.py | Python | sklearn/ensemble/_hist_gradient_boosting/tests/test_warm_start.py | d4aad64b1eb2e42e76f49db2ccfbe4b4660d092b | scikit-learn | 3 |
267,881 | 43 | 14 | 24 | 176 | 19 | 0 | 51 | 260 | _setup_dynamic | ansible-test - Use more native type hints. (#78435)
* ansible-test - Use more native type hints.
Simple search and replace to switch from comments to native type hints for return types of functions with no arguments.
* ansible-test - Use more native type hints.
Conversion of simple single-line function annota... | https://github.com/ansible/ansible.git | def _setup_dynamic(self) -> None:
port = 8443
ports = [
port,
]
cmd = ['start', 'master', '--listen', 'https://0.0.0.0:%d' % port]
descriptor = run_support_container(
self.args,
self.platform,
self.image,
sel... | 110 | openshift.py | Python | test/lib/ansible_test/_internal/commands/integration/cloud/openshift.py | 3eb0485dd92c88cc92152d3656d94492db44b183 | ansible | 3 | |
287,676 | 54 | 10 | 44 | 287 | 18 | 0 | 106 | 305 | test_switching_adapters_based_on_zero_rssi | Handle default RSSI values from bleak in bluetooth (#78908) | https://github.com/home-assistant/core.git | async def test_switching_adapters_based_on_zero_rssi(hass, enable_bluetooth):
address = "44:44:33:11:23:45"
switchbot_device_no_rssi = BLEDevice(address, "wohand_poor_signal", rssi=0)
switchbot_adv_no_rssi = AdvertisementData(
local_name="wohand_no_rssi", service_uuids=[]
)
inject_adv... | 180 | test_manager.py | Python | tests/components/bluetooth/test_manager.py | 5c294550e8c96d636ff22f4206c23de05b13bdb2 | core | 1 | |
294,075 | 13 | 10 | 7 | 73 | 9 | 0 | 17 | 67 | entity_picture | Add update platform to the Supervisor integration (#68475) | https://github.com/home-assistant/core.git | def entity_picture(self) -> str | None:
if not self.available:
return None
if self.coordinator.data[DATA_KEY_ADDONS][self._addon_slug][ATTR_ICON]:
return f"/api/hassio/addons/{self._addon_slug}/icon"
return None
| 41 | update.py | Python | homeassistant/components/hassio/update.py | d17f8e9ed6cd8b4e3e44e404b639fd58d595a3ac | core | 3 | |
337,974 | 15 | 13 | 8 | 94 | 14 | 0 | 17 | 44 | test_load_states_by_epoch | Speed up main CI (#571)
* Speed up ci by reducing training epochs | https://github.com/huggingface/accelerate.git | def test_load_states_by_epoch(self):
testargs = f.split()
output = run_command(self._launch_args + testargs, return_stdout=True)
self.assertNotIn("epoch 0:", output)
self.assertIn("epoch 1:", output)
| 43 | test_examples.py | Python | tests/test_examples.py | 7a49418e51a460fbd5229e065041d1ff0749e3c8 | accelerate | 1 | |
215,142 | 23 | 12 | 10 | 119 | 10 | 0 | 32 | 94 | wait_until | Fix the check in the hetzner cloud show_instance function to be an action. | https://github.com/saltstack/salt.git | def wait_until(name, state, timeout=300):
start_time = time.time()
node = show_instance(name, call="action")
while True:
if node["state"] == state:
return True
time.sleep(1)
if time.time() - start_time > timeout:
return False
node = show_instance(... | 71 | hetzner.py | Python | salt/cloud/clouds/hetzner.py | 4b878dfc1c12034ac1deacaa9ebb1401971ce38c | salt | 4 | |
291,738 | 15 | 11 | 10 | 83 | 9 | 0 | 19 | 73 | test_track_task_functions | Upgrade pytest-aiohttp (#82475)
* Upgrade pytest-aiohttp
* Make sure executors, tasks and timers are closed
Some test will trigger warnings on garbage collect, these warnings
spills over into next test.
Some test trigger tasks that raise errors on shutdown, these spill
over into next test.
This is to mim... | https://github.com/home-assistant/core.git | async def test_track_task_functions(event_loop):
hass = ha.HomeAssistant()
try:
assert hass._track_task
hass.async_stop_track_tasks()
assert not hass._track_task
hass.async_track_tasks()
assert hass._track_task
finally:
await hass.async_stop()
| 46 | test_core.py | Python | tests/test_core.py | c576a68d336bc91fd82c299d9b3e5dfdc1c14960 | core | 2 | |
296,853 | 31 | 10 | 5 | 75 | 9 | 0 | 31 | 85 | handle_template_exception | Refactor history_stats to minimize database access (part 2) (#70255) | https://github.com/home-assistant/core.git | def handle_template_exception(ex, field):
if ex.args and ex.args[0].startswith("UndefinedError: 'None' has no attribute"):
# Common during HA startup - so just a warning
_LOGGER.warning(ex)
return
_LOGGER.error("Error parsing template for field %s", field, ex... | 44 | helpers.py | Python | homeassistant/components/history_stats/helpers.py | 73a368c24246b081cdb98923ca3180937d436c3b | core | 3 | |
169,036 | 4 | 6 | 8 | 16 | 3 | 0 | 4 | 11 | _get_column_format_based_on_dtypes | TYP: Autotyping (#48191)
* annotate-magics
* annotate-imprecise-magics
* none-return
* scalar-return
* pyi files
* ignore vendored file
* manual changes
* ignore pyright in pickle_compat (these errors would be legit if the current __new__ methods were called but I think these pickle tests call old... | https://github.com/pandas-dev/pandas.git | def _get_column_format_based_on_dtypes(self) -> str:
| 31 | latex.py | Python | pandas/io/formats/latex.py | 54347fe684e0f7844bf407b1fb958a5269646825 | pandas | 1 | |
246,115 | 20 | 12 | 268 | 72 | 7 | 0 | 25 | 123 | generate_config_section | Add a config flag to inhibit `M_USER_IN_USE` during registration (#11743)
This is mostly motivated by the tchap use case, where usernames are automatically generated from the user's email address (in a way that allows figuring out the email address from the username). Therefore, it's an issue if we respond to requests... | https://github.com/matrix-org/synapse.git | def generate_config_section(self, generate_secrets=False, **kwargs):
if generate_secrets:
registration_shared_secret = 'registration_shared_secret: "%s"' % (
random_string_with_symbols(50),
)
else:
registration_shared_secret = "#registration_shared_sec... | 39 | registration.py | Python | synapse/config/registration.py | 95b3f952fa43e51feae166fa1678761c5e32d900 | synapse | 2 | |
258,534 | 29 | 13 | 13 | 152 | 25 | 0 | 36 | 83 | test_graph_feature_names_out | ENH Adds get_feature_names_out to neighbors module (#22212)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> | https://github.com/scikit-learn/scikit-learn.git | def test_graph_feature_names_out(Klass):
n_samples_fit = 20
n_features = 10
rng = np.random.RandomState(42)
X = rng.randn(n_samples_fit, n_features)
est = Klass().fit(X)
names_out = est.get_feature_names_out()
class_name_lower = Klass.__name__.lower()
expected_names_out = np.arra... | 89 | test_graph.py | Python | sklearn/neighbors/tests/test_graph.py | 330881a21ca48c543cc8a67aa0d4e4c1dc1001ab | scikit-learn | 2 | |
107,233 | 4 | 8 | 2 | 27 | 3 | 0 | 4 | 18 | verts | Jointly track x and y in PolygonSelector.
It's easier to track them in a single list.
Also init _selection_artist and _polygon_handles with empty arrays, as
there's no reason to pretend that they start with 0, 0. On the other
hand, _xys does need to start as a non-empty array as the last point
gets updated as being ... | https://github.com/matplotlib/matplotlib.git | def verts(self):
return self._xys[:-1]
| 15 | widgets.py | Python | lib/matplotlib/widgets.py | 7f4eb87ef290ef9911d2febb7e8c60fcd5c3266e | matplotlib | 1 | |
130,249 | 25 | 12 | 7 | 109 | 15 | 0 | 27 | 84 | match_entries | [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_entries(self, entries, separators=None):
if not util._is_iterable(entries):
raise TypeError("entries:{!r} is not an iterable.".format(entries))
entry_map = util._normalize_entries(entries, separators=separators)
match_paths = util.match_files(self.patterns, iterke... | 68 | pathspec.py | Python | python/ray/_private/thirdparty/pathspec/pathspec.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 3 | |
209,841 | 38 | 8 | 21 | 111 | 15 | 0 | 58 | 152 | get_service_status | [Hinty] Core typing: windows (#3684)
* Core typing: windows
Co-authored-by: Pierre <pierre@droids-corp.org> | https://github.com/secdev/scapy.git | def get_service_status(service):
# type: (str) -> Dict[str, int]
SERVICE_QUERY_STATUS = 0x0004
schSCManager = OpenSCManagerW(
None, # Local machine
None, # SERVICES_ACTIVE_DATABASE
SERVICE_QUERY_STATUS
)
service = OpenServiceW(
schSCManager,
service,
... | 56 | structures.py | Python | scapy/arch/windows/structures.py | a2b7a28faff1db058dd22ce097a268e0ad5d1d33 | scapy | 1 | |
153,096 | 13 | 8 | 4 | 38 | 5 | 0 | 13 | 27 | inplace_applyier_builder | FIX-#3197: do not pass lambdas to the backend in GroupBy (#3373)
Signed-off-by: Dmitry Chigarev <dmitry.chigarev@intel.com> | https://github.com/modin-project/modin.git | def inplace_applyier_builder(cls, key, func=None):
inplace_args = [] if func is None else [func]
| 28 | groupby.py | Python | modin/core/dataframe/algebra/default2pandas/groupby.py | 1e65a4afd191cf61ba05b80545d23f9b88962f41 | modin | 2 | |
179,428 | 46 | 15 | 25 | 245 | 24 | 0 | 67 | 322 | preprocess | Svelte migration (WIP) (#448)
* first migration commit
* style comment
* first mvp working with calculator
* ali components
* carousel
* more changes
* changes
* add examples
* examples support
* more changes
* interpretation
* interpretation
* submission state
* first migration ... | https://github.com/gradio-app/gradio.git | def preprocess(self, x):
if x is None:
return x
file_name, file_data, is_example = (
x["name"],
x["data"],
x.get("is_example", False),
)
if is_example:
file = processing_utils.create_tmp_copy_of_file(file_name)
... | 152 | inputs.py | Python | gradio/inputs.py | d6b1247e2198acf7b30f9e90a4c4c3b94bc72107 | gradio | 5 | |
215,950 | 42 | 15 | 17 | 198 | 20 | 0 | 52 | 211 | _get_disk_size | Update to latest ``pyupgrade`` hook. Stop skipping it on CI.
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com> | https://github.com/saltstack/salt.git | def _get_disk_size(self, device):
out = __salt__["cmd.run_all"]("df {}".format(device))
if out["retcode"]:
msg = "Disk size info error: {}".format(out["stderr"])
log.error(msg)
raise SIException(msg)
devpath, blocks, used, available, used_p, mountpoi... | 117 | query.py | Python | salt/modules/inspectlib/query.py | f2a783643de61cac1ff3288b40241e5ce6e1ddc8 | salt | 4 | |
87,074 | 24 | 13 | 12 | 116 | 10 | 0 | 26 | 158 | test_sessions_metrics_with_metrics_only_field | fix(sessions): Handle edge case in case of wrong duplexer dispatch to `SessionsReleaseHealthBackend` [TET-481] (#40243) | https://github.com/getsentry/sentry.git | def test_sessions_metrics_with_metrics_only_field(self):
response = self.do_request(
{
"organization_slug": [self.organization1],
"project": [self.project1.id],
"field": ["crash_free_rate(session)"],
"groupBy": [],
... | 66 | test_metrics_sessions_v2.py | Python | tests/sentry/release_health/test_metrics_sessions_v2.py | 89d7aaa5a23f4d4ff962ad12c3be23651ace5c29 | sentry | 1 | |
208,027 | 61 | 20 | 20 | 185 | 18 | 0 | 84 | 432 | find_module | Minor refactors, found by static analysis (#7587)
* Remove deprecated methods in `celery.local.Proxy`
* Collapse conditionals for readability
* Remove unused parameter `uuid`
* Remove unused import `ClusterOptions`
* Remove dangerous mutable default argument
Continues work from #5478
* Remove always ... | https://github.com/celery/celery.git | def find_module(module, path=None, imp=None):
if imp is None:
imp = import_module
with cwd_in_path():
try:
return imp(module)
except ImportError:
# Raise a more specific error if the problem is that one of the
# dot-separated segments of the modul... | 105 | imports.py | Python | celery/utils/imports.py | 59263b0409e3f02dc16ca8a3bd1e42b5a3eba36d | celery | 7 | |
58,910 | 18 | 12 | 14 | 126 | 14 | 0 | 21 | 81 | _generate_code_example | Adds default code example for blocks (#6755)
* Adds method to generate a default code example for block subclasses
* Adds test for code example to block standard test suite
* Updates test case where no example is configured
* Addresses review comments | https://github.com/PrefectHQ/prefect.git | def _generate_code_example(cls) -> str:
qualified_name = to_qualified_name(cls)
module_str = ".".join(qualified_name.split(".")[:-1])
class_name = cls.__name__
block_variable_name = f'{cls.get_block_type_slug().replace("-", "_")}_block'
return dedent(
f
... | 47 | core.py | Python | src/prefect/blocks/core.py | d68e5c0d8f0e29810b9b75ed554a4c549fa18f2c | prefect | 1 | |
188,928 | 53 | 14 | 54 | 334 | 33 | 0 | 87 | 251 | generate_css | Automated upgrade of code to python 3.7+
Done by https://github.com/asottile/pyupgrade
Consists mainly of moving string formatting to f-strings and removing
encoding declarations | https://github.com/kovidgoyal/calibre.git | def generate_css(self, dest_dir, docx, notes_nopb, nosupsub):
ef = self.fonts.embed_fonts(dest_dir, docx)
s =
if not notes_nopb:
s +=
s = s +
if nosupsub:
s = s +
body_color = ''
if self.body_color.lower() not in ('currentcolor', '... | 184 | styles.py | Python | src/calibre/ebooks/docx/styles.py | eb78a761a99ac20a6364f85e12059fec6517d890 | calibre | 7 | |
133,418 | 52 | 12 | 9 | 90 | 8 | 0 | 64 | 195 | get_serialization_context | [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 get_serialization_context(self, job_id=None):
# This function needs to be protected by a lock, because it will be
# called by`register_class_for_serialization`, as well as the import
# thread, from different threads. Also, this function will recursively
# call itself, so we ... | 53 | worker.py | Python | python/ray/worker.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 3 | |
294,222 | 99 | 13 | 65 | 648 | 47 | 0 | 155 | 493 | test_sync_request | Exclude hidden entities from google_assistant (#68554) | https://github.com/home-assistant/core.git | async def test_sync_request(hass_fixture, assistant_client, auth_header):
entity_registry = mock_registry(hass_fixture)
entity_entry1 = entity_registry.async_get_or_create(
"switch",
"test",
"switch_config_id",
suggested_object_id="config_switch",
entity_category="... | 382 | test_google_assistant.py | Python | tests/components/google_assistant/test_google_assistant.py | dc0c3a4d2dde52c4bb485e8b9758d517e1141703 | core | 5 | |
68,771 | 82 | 26 | 29 | 500 | 40 | 0 | 110 | 80 | get_valuation_rate | chore: `get_valuation_rate` sider fixes
- Use qb instead of db.sql
- Don't use `args` as argument for function
- Cleaner variable names | https://github.com/frappe/erpnext.git | def get_valuation_rate(data):
from frappe.query_builder.functions import Sum
item_code, company = data.get("item_code"), data.get("company")
valuation_rate = 0.0
bin_table = frappe.qb.DocType("Bin")
wh_table = frappe.qb.DocType("Warehouse")
item_valuation = (
frappe.qb.from_(bin_table)
.join(wh_table)
.... | 311 | bom.py | Python | erpnext/manufacturing/doctype/bom/bom.py | 7e41d84a116f2acd03984c98ec4eaa8e50ddc1d3 | erpnext | 5 | |
246,344 | 34 | 7 | 3 | 39 | 4 | 0 | 40 | 96 | test_push_unread_count_message_count | Prevent duplicate push notifications for room reads (#11835) | https://github.com/matrix-org/synapse.git | def test_push_unread_count_message_count(self):
# Carry out common push count tests and setup
self._test_push_unread_count()
# Carry out our option-value specific test
#
# We're counting every unread message, so there should now be 3 since the
# last read receip... | 19 | test_http.py | Python | tests/push/test_http.py | 40771773909cb03d9296e3f0505e4e32372f10aa | synapse | 1 | |
5,889 | 37 | 11 | 19 | 173 | 13 | 0 | 50 | 151 | run_experiment_with_visualization | Use tempfile to automatically garbage collect data and modeling artifacts in ludwig integration tests. (#1642)
* Use tmpdir to automatically garbage collect data and modeling artifacts in ludwig integration tests. | https://github.com/ludwig-ai/ludwig.git | def run_experiment_with_visualization(input_features, output_features, dataset):
output_directory = os.path.dirname(dataset)
config = {
"input_features": input_features,
"output_features": output_features,
"combiner": {"type": "concat", "fc_size": 14},
"training": {"epochs":... | 101 | test_visualization.py | Python | tests/integration_tests/test_visualization.py | 4fb8f63181f5153b4f6778c6ef8dad61022c4f3f | ludwig | 1 | |
292,953 | 30 | 12 | 18 | 194 | 21 | 0 | 42 | 136 | _mock_powerwall_with_fixtures | Add sensor to expose Powerwall backup reserve percentage (#66393) | https://github.com/home-assistant/core.git | async def _mock_powerwall_with_fixtures(hass):
meters = await _async_load_json_fixture(hass, "meters.json")
sitemaster = await _async_load_json_fixture(hass, "sitemaster.json")
site_info = await _async_load_json_fixture(hass, "site_info.json")
status = await _async_load_json_fixture(hass, "status.j... | 123 | mocks.py | Python | tests/components/powerwall/mocks.py | d077c3b8d106e7e102a5a58a8a07ed381ff06567 | core | 1 | |
1,078 | 31 | 14 | 16 | 137 | 16 | 1 | 38 | 192 | to_local_object_without_private_data_child | Renamed entities -> data subject, NDEPT -> phi tensor | https://github.com/OpenMined/PySyft.git | def to_local_object_without_private_data_child(self) -> PhiTensor:
# relative
from ..tensor import Tensor
public_shape = getattr(self, "public_shape", None)
public_dtype = getattr(self, "public_dtype", None)
return Tensor(
child=PhiTensor(
ch... | @serializable(capnp_bytes=True) | 79 | phi_tensor.py | Python | packages/syft/src/syft/core/tensor/autodp/phi_tensor.py | 44fa2242416c7131fef4f00db19c5ca36af031dc | PySyft | 1 |
130,326 | 96 | 18 | 65 | 577 | 41 | 0 | 189 | 1,269 | terminate_node | [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 terminate_node(self, node_id):
resource_group = self.provider_config["resource_group"]
try:
# get metadata for node
metadata = self._get_node(node_id)
except KeyError:
# node no longer exists
return
if self.cache_stopped_node... | 337 | node_provider.py | Python | python/ray/autoscaler/_private/_azure/node_provider.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 11 | |
299,235 | 19 | 11 | 6 | 79 | 12 | 0 | 19 | 69 | async_added_to_hass | Restore ONVIF sensors (#70393)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com> | https://github.com/home-assistant/core.git | async def async_added_to_hass(self):
self.async_on_remove(
self.device.events.async_add_listener(self.async_write_ha_state)
)
if (last_state := await self.async_get_last_state()) is not None:
self._attr_is_on = last_state.state == STATE_ON
| 47 | binary_sensor.py | Python | homeassistant/components/onvif/binary_sensor.py | 29a2df3dfcf3b5d1fb6cf20b413e024eb0ebf597 | core | 2 | |
110,576 | 11 | 8 | 3 | 54 | 9 | 0 | 11 | 32 | get_extent | Reparametrize offsetbox calculations in terms of bboxes.
Passing a single bbox instead of (xdescent, ydescent, width, height)
separately is easier to follow (see e.g. the changes in VPacker and
HPacker, which no longer have to repeatedly pack/unpack whd_list), and
avoids having to figure out e.g. the sign of the desce... | https://github.com/matplotlib/matplotlib.git | def get_extent(self, renderer):
bbox = self.get_bbox(renderer)
return bbox.width, bbox.height, -bbox.x0, -bbox.y0
| 34 | offsetbox.py | Python | lib/matplotlib/offsetbox.py | de2192589f8ea50c9dc90be87b649399ff623feb | matplotlib | 1 | |
100,972 | 30 | 13 | 12 | 186 | 12 | 0 | 46 | 162 | _output_startup_info | Training: Add setting option to save optimizer weights | https://github.com/deepfakes/faceswap.git | def _output_startup_info(self):
logger.debug("Launching Monitor")
logger.info("===================================================")
logger.info(" Starting")
if self._args.preview:
logger.info(" Using live preview")
if sys.stdout.isatty():
logge... | 103 | train.py | Python | scripts/train.py | 06468c97d475c0125375e77aad3f4fc1a87e8fe6 | faceswap | 8 | |
290,581 | 32 | 13 | 14 | 132 | 19 | 1 | 41 | 154 | async_cluster_exists | Fix ZHA configuration APIs (#81874)
* Fix ZHA configuration loading and saving issues
* add tests | https://github.com/home-assistant/core.git | def async_cluster_exists(hass, cluster_id, skip_coordinator=True):
zha_gateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
zha_devices = zha_gateway.devices.values()
for zha_device in zha_devices:
if skip_coordinator and zha_device.is_coordinator:
continue
clusters_by_endpoint =... | @callback | 82 | helpers.py | Python | homeassistant/components/zha/core/helpers.py | ebffe0f33b61e87c348bb7c99714c1d551623f9c | core | 7 |
134,156 | 12 | 11 | 7 | 64 | 12 | 0 | 12 | 49 | _resize_image | Benchmarking Ray Data bulk ingest as input file size changes. (#29296)
This PR adds a benchmark which takes work from https://github.com/anyscale/air-benchmarks and makes it run as a release test.
Full metrics are stored in Databricks.
Signed-off-by: Cade Daniel <cade@anyscale.com> | https://github.com/ray-project/ray.git | def _resize_image(image, height, width):
return tf.compat.v1.image.resize(
image,
[height, width],
method=tf.image.ResizeMethod.BILINEAR,
align_corners=False,
)
| 44 | tf_utils.py | Python | release/air_tests/air_benchmarks/mlperf-train/tf_utils.py | 02f911ce78137cb63ecb685a8ef8e56dcb60062c | ray | 1 | |
286,857 | 12 | 11 | 11 | 71 | 12 | 1 | 14 | 25 | get_all_holiday_exchange_short_names | Addition of exchange holiday functionality under stocks/th (#3486)
* Addition of exchange holiday calendars using PandasMarketCalendar
* website update for holidays functionality
* Disable pylint too many attributes
* Changes to not show index for dataframe and include metavar
* Setting of default value fo... | https://github.com/OpenBB-finance/OpenBBTerminal.git | def get_all_holiday_exchange_short_names() -> pd.DataFrame:
exchange_short_names = mcal.calendar_registry.get_calendar_names()
df = pd.DataFrame(exchange_short_names, columns=["short_name"])
return df
@log_start_end(log=logger) | @log_start_end(log=logger) | 34 | pandas_market_cal_model.py | Python | openbb_terminal/stocks/tradinghours/pandas_market_cal_model.py | 7e4a657333c8b7bb1ebdcb7a4c8f06e8dc0d66f6 | OpenBBTerminal | 1 |
125,579 | 4 | 8 | 48 | 32 | 5 | 2 | 4 | 11 | test_local_clusters | [core] ray.init defaults to an existing Ray instance if there is one (#26678)
ray.init() will currently start a new Ray instance even if one is already existing, which is very confusing if you are a new user trying to go from local development to a cluster. This PR changes it so that, when no address is specified, we ... | https://github.com/ray-project/ray.git | def test_local_clusters():
driver_template = | """
import ray
info = ray.client({address}).namespace("").@ray.remote | 173 | test_client_builder.py | Python | python/ray/tests/test_client_builder.py | 55a0f7bb2db941d8c6ff93f55e4b3193f404ddf0 | ray | 1 |
268,682 | 6 | 6 | 3 | 19 | 3 | 0 | 6 | 20 | usable | ansible-test - Improve container management. (#78550)
See changelogs/fragments/ansible-test-container-management.yml for details. | https://github.com/ansible/ansible.git | def usable(cls) -> bool:
return False
| 10 | runme.py | Python | test/integration/targets/ansible-test-container/runme.py | cda16cc5e9aa8703fb4e1ac0a0be6b631d9076cc | ansible | 1 | |
191,407 | 34 | 9 | 7 | 76 | 7 | 0 | 43 | 67 | test_document_lookups_too_many | Harrison/add react chain (#24)
from https://arxiv.org/abs/2210.03629
still need to think if docstore abstraction makes sense | https://github.com/hwchase17/langchain.git | def test_document_lookups_too_many() -> None:
page = Document(page_content=_PAGE_CONTENT)
# Start with lookup on "framework".
output = page.lookup("framework")
assert output == "(Result 1/1) It is a really cool framework."
# Now try again, should be exhausted.
output = page.lookup("framew... | 39 | test_document.py | Python | tests/unit_tests/docstore/test_document.py | ce7b14b84381c766ae42a0f71953b2a56c024dbb | langchain | 1 | |
289,001 | 21 | 11 | 10 | 106 | 14 | 0 | 26 | 101 | async_added_to_hass | Adjust distance unit check in gdacs (#80235)
* Adjust length unit check in gdacs
* Use system compare
* Use is not ==
* Apply suggestion
Co-authored-by: Erik Montnemery <erik@montnemery.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com> | https://github.com/home-assistant/core.git | async def async_added_to_hass(self) -> None:
if self.hass.config.units is IMPERIAL_SYSTEM:
self._attr_unit_of_measurement = LENGTH_MILES
self._remove_signal_delete = async_dispatcher_connect(
self.hass, f"gdacs_delete_{self._external_id}", self._delete_callback
)... | 58 | geo_location.py | Python | homeassistant/components/gdacs/geo_location.py | 689dcb02dd46dd849593b9bafb4ed1844977fbe4 | core | 2 | |
104,414 | 6 | 7 | 2 | 28 | 5 | 0 | 6 | 20 | slice | Update docs to new frontend/UI (#3690)
* WIP: update docs to new UI
* make style
* Rm unused
* inject_arrow_table_documentation __annotations__
* hasattr(arrow_table_method, "__annotations__")
* Update task_template.rst
* Codeblock PT-TF-SPLIT
* Convert loading scripts
* Convert docs to mdx
... | https://github.com/huggingface/datasets.git | def slice(self, *args, **kwargs):
raise NotImplementedError()
| 16 | table.py | Python | src/datasets/table.py | e35be138148333078284b942ccc9ed7b1d826f97 | datasets | 1 | |
60,298 | 30 | 9 | 9 | 156 | 21 | 0 | 35 | 98 | test_crop_of_crop | Balanced joint maximum mean discrepancy for deep transfer learning | https://github.com/jindongwang/transferlearning.git | def test_crop_of_crop(self):
n = coord_net_spec()
offset = random.randint(0, 10)
ax, a, b = coord_map_from_to(n.deconv, n.data)
n.crop = L.Crop(n.deconv, n.data, axis=2, offset=offset)
ax_crop, a_crop, b_crop = coord_map_from_to(n.crop, n.data)
self.assertEquals(... | 103 | test_coord_map.py | Python | code/deep/BJMMD/caffe/python/caffe/test/test_coord_map.py | cc4d0564756ca067516f71718a3d135996525909 | transferlearning | 1 | |
259,222 | 137 | 12 | 64 | 854 | 33 | 0 | 346 | 772 | test_ohe_infrequent_multiple_categories | ENH Adds infrequent categories to OneHotEncoder (#16018)
* ENH Completely adds infrequent categories
* STY Linting
* STY Linting
* DOC Improves wording
* DOC Lint
* BUG Fixes
* CLN Address comments
* CLN Address comments
* DOC Uses math to description float min_frequency
* DOC Adds comment r... | https://github.com/scikit-learn/scikit-learn.git | def test_ohe_infrequent_multiple_categories():
X = np.c_[
[0, 1, 3, 3, 3, 3, 2, 0, 3],
[0, 0, 5, 1, 1, 10, 5, 5, 0],
[1, 0, 1, 0, 1, 0, 1, 0, 1],
]
ohe = OneHotEncoder(
categories="auto", max_categories=3, handle_unknown="infrequent_if_exist"
)
# X[:, 0] 1 and ... | 632 | test_encoders.py | Python | sklearn/preprocessing/tests/test_encoders.py | 7f0006c8aad1a09621ad19c3db19c3ff0555a183 | scikit-learn | 2 | |
247,884 | 31 | 12 | 15 | 133 | 19 | 0 | 39 | 184 | get_success_or_raise | Remove redundant `get_success` calls in test code (#12346)
There are a bunch of places we call get_success on an immediate value, which is unnecessary. Let's rip them out, and remove the redundant functionality in get_success and friends. | https://github.com/matrix-org/synapse.git | def get_success_or_raise(self, d, by=0.0):
deferred: Deferred[TV] = ensureDeferred(d)
results: list = []
deferred.addBoth(results.append)
self.pump(by=by)
if not results:
self.fail(
"Success result expected on {!r}, found no result instead"... | 83 | unittest.py | Python | tests/unittest.py | 33ebee47e4e96a2b6fdf72091769e59034dc550f | synapse | 3 | |
88,592 | 35 | 14 | 14 | 146 | 16 | 0 | 39 | 172 | test_no_configs | ref(stacktrace_link): Add more than one code mapping in the tests (#41409)
Include more than one code mapping in the setup code. Cleaning up a bit how we tag the transactions.
This makes the PR for WOR-2395 a little easier to read. | https://github.com/getsentry/sentry.git | def test_no_configs(self):
# new project that has no configurations set up for it
project = self.create_project(
name="bloop",
organization=self.organization,
teams=[self.create_team(organization=self.organization)],
)
response = self.get_suc... | 90 | test_project_stacktrace_link.py | Python | tests/sentry/api/endpoints/test_project_stacktrace_link.py | 2e0d2c856eb17a842c67d88363bed92c99578c20 | sentry | 1 | |
135,598 | 2 | 6 | 9 | 13 | 2 | 0 | 2 | 5 | test_single_worker_failure | [Train] Immediately fail on any worker failure (#29927)
Signed-off-by: Amog Kamsetty amogkamsetty@yahoo.com
Follow up to #28314
#28314 did not cover all the cases. In particular, if one worker fails, but the other workers are hanging, then our shutdown logic will also hang since it's waiting for the actors to fi... | https://github.com/ray-project/ray.git | def test_single_worker_failure(ray_start_4_cpus):
| 42 | test_torch_trainer.py | Python | python/ray/train/tests/test_torch_trainer.py | 152a8b900d2a0d3c462ed37a44916c26540826c5 | ray | 1 | |
275,523 | 9 | 8 | 2 | 32 | 4 | 0 | 9 | 23 | _call_if_callable | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _call_if_callable(self, param):
return param() if callable(param) else param
| 19 | optimizer_v2.py | Python | keras/optimizers/optimizer_v2/optimizer_v2.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 2 | |
265,388 | 48 | 15 | 16 | 264 | 19 | 0 | 67 | 203 | _clean_side | #9102: Enable creating terminations in conjunction with cables via REST API | https://github.com/netbox-community/netbox.git | def _clean_side(self, side):
assert side in 'ab', f"Invalid side designation: {side}"
device = self.cleaned_data.get(f'side_{side}_device')
content_type = self.cleaned_data.get(f'side_{side}_type')
name = self.cleaned_data.get(f'side_{side}_name')
if not device or not c... | 127 | bulk_import.py | Python | netbox/dcim/forms/bulk_import.py | 0b86326435fe6ea07ef376a81ff6fb592906fafc | netbox | 6 | |
322,894 | 9 | 12 | 5 | 64 | 6 | 0 | 10 | 53 | string_position | Add NLP model interpretation (#1752)
* upload NLP interpretation
* fix problems and relocate project
* remove abandoned picture
* remove abandoned picture
* fix dead link in README
* fix dead link in README
* fix code style problems
* fix CR round 1
* remove .gitkeep files
* fix code style
... | https://github.com/PaddlePaddle/PaddleNLP.git | def string_position(self, id_):
if self.bow:
return self.string_start[self.positions[id_]]
else:
return self.string_start[[self.positions[id_]]]
| 41 | lime_text.py | Python | examples/model_interpretation/task/senti/LIME/lime_text.py | 93cae49c0c572b5c1ac972759140fbe924b0374d | PaddleNLP | 2 | |
101,420 | 63 | 16 | 14 | 184 | 19 | 0 | 80 | 331 | update_config | Bugfix: convert - Gif Writer
- Fix non-launch error on Gif Writer
- convert plugins - linting
- convert/fs_media/preview/queue_manager - typing
- Change convert items from dict to Dataclass | https://github.com/deepfakes/faceswap.git | def update_config(self) -> None:
for section, items in self.tk_vars.items():
for item, value in items.items():
try:
new_value = str(value.get())
except tk.TclError as err:
# When manually filling in text fields, blank v... | 113 | preview.py | Python | tools/preview/preview.py | 1022651eb8a7741014f5d2ec7cbfe882120dfa5f | faceswap | 5 | |
132,867 | 20 | 9 | 8 | 66 | 9 | 0 | 22 | 79 | all_trials_are_terminated | [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 all_trials_are_terminated(self) -> bool:
if not self._snapshot:
return False
last_snapshot = self._snapshot[-1]
return all(
last_snapshot[trial_id] == Trial.TERMINATED for trial_id in last_snapshot
)
| 41 | mock.py | Python | python/ray/tune/utils/mock.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 3 | |
133,003 | 26 | 12 | 9 | 109 | 19 | 0 | 30 | 104 | _generate_nccl_uid | [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 _generate_nccl_uid(self, key):
group_uid = nccl_util.get_nccl_unique_id()
store_name = get_store_name(key)
# Avoid a potential circular dependency in ray/actor.py
from ray.util.collective.util import NCCLUniqueIDStore
store = NCCLUniqueIDStore.options(name=store_nam... | 67 | nccl_collective_group.py | Python | python/ray/util/collective/collective_group/nccl_collective_group.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 1 | |
176,134 | 8 | 9 | 10 | 30 | 3 | 0 | 8 | 43 | test_edgeql_functions_contains_05 | Fix builtin polymorphic USING SQL functions with object arguments (#3319)
We actually don't have a lot of these (most use USING SQL EXPRESSION).
Fix is simple: don't try to pass the type to polymorphic arguments.
Fixes #3318. | https://github.com/edgedb/edgedb.git | async def test_edgeql_functions_contains_05(self):
await self.assert_query_result(
r,
[True],
)
| 18 | test_edgeql_functions.py | Python | tests/test_edgeql_functions.py | 529247861f25dc9f55672f250473d6a7f0148e4e | edgedb | 1 | |
275,773 | 22 | 11 | 7 | 99 | 12 | 1 | 25 | 65 | _remove_long_seq | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def _remove_long_seq(maxlen, seq, label):
new_seq, new_label = [], []
for x, y in zip(seq, label):
if len(x) < maxlen:
new_seq.append(x)
new_label.append(y)
return new_seq, new_label
@keras_export("keras.preprocessing.sequence.TimeseriesGenerator") | @keras_export("keras.preprocessing.sequence.TimeseriesGenerator") | 55 | sequence.py | Python | keras/preprocessing/sequence.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 3 |
260,720 | 110 | 14 | 44 | 345 | 26 | 0 | 186 | 761 | fit | MAINT Parameters validation for `SimpleImputer` (#24109)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: jeremie du boisberranger <jeremiedbb@yahoo.fr> | https://github.com/scikit-learn/scikit-learn.git | def fit(self, X, y=None):
self._validate_params()
if self.verbose != "deprecated":
warnings.warn(
"The 'verbose' parameter was deprecated in version "
"1.1 and will be removed in 1.3. A warning will "
"always be raised upon the removal... | 198 | _base.py | Python | sklearn/impute/_base.py | 593524d33bc79507eea07b54229f312d48e0a95f | scikit-learn | 9 | |
118,726 | 15 | 10 | 6 | 81 | 11 | 0 | 15 | 61 | test_just_disabled | Add disabled to select_slider + tests + snapshots (#4314) | https://github.com/streamlit/streamlit.git | def test_just_disabled(self):
st.select_slider(
"the label", options=["red", "orange", "yellow"], disabled=True
)
c = self.get_delta_from_queue().new_element.slider
self.assertEqual(c.disabled, True)
| 47 | select_slider_test.py | Python | lib/tests/streamlit/select_slider_test.py | 8795e0c41c546880368c8bb9513b0f2ae9220e99 | streamlit | 1 | |
31,896 | 46 | 22 | 16 | 203 | 17 | 0 | 61 | 173 | assert_tensors_close | Add MVP model (#17787)
* Add MVP model
* Update README
* Remove useless module
* Update docs
* Fix bugs in tokenizer
* Remove useless test
* Remove useless module
* Update vocab
* Remove specifying
* Remove specifying
* Add #Copied ... statement
* Update paper link
* Remove useless ... | https://github.com/huggingface/transformers.git | def assert_tensors_close(a, b, atol=1e-12, prefix=""):
if a is None and b is None:
return True
try:
if torch.allclose(a, b, atol=atol):
return True
raise
except Exception:
pct_different = (torch.gt((a - b).abs(), atol)).float().mean().item()
if a.nume... | 117 | test_modeling_mvp.py | Python | tests/models/mvp/test_modeling_mvp.py | 3cff4cc58730409c68f8afa2f3b9c61efa0e85c6 | transformers | 7 | |
154,295 | 19 | 11 | 9 | 91 | 9 | 0 | 25 | 112 | copy | PERF-#4842: `copy` should not trigger any previous computations (#4843)
Signed-off-by: Myachev <anatoly.myachev@intel.com> | https://github.com/modin-project/modin.git | def copy(self):
return self.__constructor__(
self._partitions,
self._index_cache.copy() if self._index_cache is not None else None,
self._columns_cache.copy() if self._columns_cache is not None else None,
self._row_lengths_cache,
self._column_... | 62 | dataframe.py | Python | modin/core/dataframe/pandas/dataframe/dataframe.py | 3ca5005696a9a9cb7cce7d8986e34d6987aa8074 | modin | 3 | |
168,200 | 84 | 14 | 28 | 300 | 31 | 0 | 121 | 420 | remove_categories | PERF cache find_stack_level (#48023)
cache stacklevel | https://github.com/pandas-dev/pandas.git | def remove_categories(self, removals, inplace=no_default):
if inplace is not no_default:
warn(
"The `inplace` parameter in pandas.Categorical."
"remove_categories is deprecated and will be removed in "
"a future version. Removing unused catego... | 181 | categorical.py | Python | pandas/core/arrays/categorical.py | 2f8d0a36703e81e4dca52ca9fe4f58c910c1b304 | pandas | 11 | |
259,787 | 143 | 15 | 64 | 556 | 51 | 0 | 200 | 981 | fit | ENH Add sparse input support to OPTICS (#22965)
Co-authored-by: huntzhan <huntzhan.dev@gmail.com>
Co-authored-by: Clickedbigfoot <clickedbigfoot@gmail.com>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> | https://github.com/scikit-learn/scikit-learn.git | def fit(self, X, y=None):
dtype = bool if self.metric in PAIRWISE_BOOLEAN_FUNCTIONS else float
if dtype == bool and X.dtype != bool:
msg = (
"Data will be converted to boolean for"
f" metric {self.metric}, to avoid this warning,"
" you... | 352 | _optics.py | Python | sklearn/cluster/_optics.py | af5b6a100357852f4c3040ff2cb06cb8691023e9 | scikit-learn | 11 | |
181,811 | 26 | 10 | 7 | 72 | 8 | 0 | 27 | 92 | predict | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | https://github.com/EpistasisLab/tpot.git | def predict(self, features):
if not self.fitted_pipeline_:
raise RuntimeError(
"A pipeline has not yet been optimized. Please call fit() first."
)
features = self._check_dataset(features, target=None, sample_weight=None)
return self.fitted_pipel... | 44 | base.py | Python | tpot/base.py | 388616b6247ca4ea8de4e2f340d6206aee523541 | tpot | 2 | |
8,245 | 168 | 17 | 42 | 464 | 55 | 0 | 292 | 782 | explain | Explanation API and feature importance for GBM (#2564)
* add docstring for explain_ig
* solidify Explainer API
* add gbm explainer
* add dataclasses for typed explanations
* add GBM feature importance
* remove unused imports
* add tests
* fix test
* extract explanation into file
* rename bas... | https://github.com/ludwig-ai/ludwig.git | def explain(self) -> Tuple[List[Explanation], List[float]]:
self.model.model.to(DEVICE)
# Convert input data into embedding tensors from the output of the model encoders.
inputs_encoded = get_input_tensors(self.model, self.inputs_df)
sample_encoded = get_input_tensors(self.mode... | 289 | captum.py | Python | ludwig/explain/captum.py | 1caede3a2da4ec71cb8650c7e45120c26948a5b9 | ludwig | 9 | |
48,314 | 46 | 10 | 19 | 187 | 31 | 0 | 52 | 209 | test_mark_success_no_kill | AIP45 Remove dag parsing in airflow run local (#21877) | https://github.com/apache/airflow.git | def test_mark_success_no_kill(self, caplog, get_test_dag, session):
dag = get_test_dag('test_mark_state')
dr = dag.create_dagrun(
state=State.RUNNING,
execution_date=DEFAULT_DATE,
run_type=DagRunType.SCHEDULED,
session=session,
)
t... | 115 | test_local_task_job.py | Python | tests/jobs/test_local_task_job.py | 3138604b264878f27505223bd14c7814eacc1e57 | airflow | 1 | |
124,673 | 15 | 12 | 6 | 79 | 14 | 1 | 16 | 61 | reconfigure | [Serve] [AIR] Adding reconfigure method to model deployment (#26026) | https://github.com/ray-project/ray.git | def reconfigure(self, config):
from ray.air.checkpoint import Checkpoint
predictor_cls = _load_predictor_cls(config["predictor_cls"])
self.model = predictor_cls.from_checkpoint(
Checkpoint.from_dict(config["checkpoint"])
)
@serve.deployment | @serve.deployment | 43 | air_integrations.py | Python | python/ray/serve/air_integrations.py | 980a59477de62ed8b3441a1fd5f8fb9e18df0f14 | ray | 1 |
60,285 | 75 | 14 | 22 | 326 | 26 | 0 | 114 | 269 | _Net_backward | Balanced joint maximum mean discrepancy for deep transfer learning | https://github.com/jindongwang/transferlearning.git | def _Net_backward(self, diffs=None, start=None, end=None, **kwargs):
if diffs is None:
diffs = []
if start is not None:
start_ind = list(self._layer_names).index(start)
else:
start_ind = len(self.layers) - 1
if end is not None:
end_ind = list(self._layer_names).ind... | 205 | pycaffe.py | Python | code/deep/BJMMD/caffe/python/caffe/pycaffe.py | cc4d0564756ca067516f71718a3d135996525909 | transferlearning | 9 | |
269,306 | 6 | 8 | 2 | 50 | 8 | 1 | 6 | 10 | selu | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | https://github.com/keras-team/keras.git | def selu(x):
return tf.nn.selu(x)
@keras_export("keras.activations.softplus")
@tf.__internal__.dispatch.add_dispatch_support | @keras_export("keras.activations.softplus")
@tf.__internal__.dispatch.add_dispatch_support | 15 | activations.py | Python | keras/activations.py | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | keras | 1 |
247,973 | 29 | 12 | 21 | 139 | 10 | 0 | 41 | 226 | test_get_global | Add Module API for reading and writing global account data. (#12391) | https://github.com/matrix-org/synapse.git | def test_get_global(self) -> None:
self.get_success(
self._store.add_account_data_for_user(
self.user_id, "test.data", {"wombat": True}
)
)
# Getting existent account data works as expected.
self.assertEqual(
self.get_success(... | 82 | test_account_data_manager.py | Python | tests/module_api/test_account_data_manager.py | 85ca963c1add5ca12f59238a50dfc63df4846bb7 | synapse | 1 | |
105,895 | 16 | 12 | 7 | 52 | 6 | 0 | 17 | 51 | require_spacy | Make torch.Tensor and spacy models cacheable (#5191)
* Make torch.Tensor and spacy models cacheable
* Use newest models
* Address comments
* Small optim | https://github.com/huggingface/datasets.git | def require_spacy(test_case):
try:
import spacy # noqa F401
except ImportError:
return unittest.skip("test requires spacy")(test_case)
else:
return test_case
| 27 | utils.py | Python | tests/utils.py | 0d9c12ad5155c6d505e70813a07c0aecd7120405 | datasets | 2 | |
290,582 | 14 | 11 | 11 | 61 | 9 | 1 | 14 | 94 | required_platform_only | Fix ZHA configuration APIs (#81874)
* Fix ZHA configuration loading and saving issues
* add tests | https://github.com/home-assistant/core.git | def required_platform_only():
with patch(
"homeassistant.components.zha.PLATFORMS",
(
Platform.ALARM_CONTROL_PANEL,
Platform.SELECT,
Platform.SENSOR,
Platform.SWITCH,
),
):
yield
@pytest.fixture | @pytest.fixture | 32 | test_api.py | Python | tests/components/zha/test_api.py | ebffe0f33b61e87c348bb7c99714c1d551623f9c | core | 1 |
111,341 | 9 | 13 | 4 | 56 | 9 | 0 | 9 | 34 | _require_patterns | Add SpanRuler component (#9880)
* Add SpanRuler component
Add a `SpanRuler` component similar to `EntityRuler` that saves a list
of matched spans to `Doc.spans[spans_key]`. The matches from the token
and phrase matchers are deduplicated and sorted before assignment but
are not otherwise filtered.
* Update spa... | https://github.com/explosion/spaCy.git | def _require_patterns(self) -> None:
if len(self) == 0:
warnings.warn(Warnings.W036.format(name=self.name))
| 33 | span_ruler.py | Python | spacy/pipeline/span_ruler.py | a322d6d5f2f85c2da6cded4fcd6143d41b5a9e96 | spaCy | 2 | |
153,617 | 27 | 12 | 5 | 118 | 13 | 0 | 35 | 71 | at_time | DOCS-#3099: Fix `BasePandasDataSet` docstrings warnings (#4333)
Co-authored-by: Yaroslav Igoshev <Poolliver868@mail.ru>
Signed-off-by: Alexander Myskov <alexander.myskov@intel.com> | https://github.com/modin-project/modin.git | def at_time(self, time, asof=False, axis=None): # noqa: PR01, RT01, D200
axis = self._get_axis_number(axis)
idx = self.index if axis == 0 else self.columns
indexer = pandas.Series(index=idx).at_time(time, asof=asof).index
return self.loc[indexer] if axis == 0 else self.loc[:, i... | 78 | base.py | Python | modin/pandas/base.py | 605efa618e7994681f57b11d04d417f353ef8d50 | modin | 3 | |
118,727 | 57 | 13 | 14 | 153 | 20 | 0 | 63 | 208 | bokeh_chart | Replace static apps with live Cloud apps (#4317)
Co-authored-by: kajarenc <kajarenc@gmail.com> | https://github.com/streamlit/streamlit.git | def bokeh_chart(self, figure, use_container_width=False):
import bokeh
if bokeh.__version__ != ST_BOKEH_VERSION:
raise StreamlitAPIException(
f"Streamlit only supports Bokeh version {ST_BOKEH_VERSION}, "
f"but you have version {bokeh.__version__} ins... | 84 | bokeh_chart.py | Python | lib/streamlit/elements/bokeh_chart.py | 72703b38029f9358a0ec7ca5ed875a6b438ece19 | streamlit | 2 | |
304,164 | 36 | 13 | 15 | 193 | 23 | 0 | 47 | 204 | async_step_user | Add Landis+Gyr Heat Meter integration (#73363)
* Add Landis+Gyr Heat Meter integration
* Add contant for better sensor config
* Add test for init
* Refactor some of the PR suggestions in config_flow
* Apply small fix
* Correct total_increasing to total
* Add test for restore state
* Add MWh entity... | https://github.com/home-assistant/core.git | async def async_step_user(self, user_input=None):
errors = {}
if user_input is not None:
if user_input[CONF_DEVICE] == CONF_MANUAL_PATH:
return await self.async_step_setup_serial_manual_path()
dev_path = await self.hass.async_add_executor_job(
... | 117 | config_flow.py | Python | homeassistant/components/landisgyr_heat_meter/config_flow.py | 7a497c1e6e5a0d44b9418a754470ca9dd35e9719 | core | 4 | |
130,352 | 26 | 11 | 11 | 114 | 15 | 0 | 29 | 114 | create_v_switch | [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 create_v_switch(self, vpc_id, zone_id, cidr_block):
request = CreateVSwitchRequest()
request.set_ZoneId(zone_id)
request.set_VpcId(vpc_id)
request.set_CidrBlock(cidr_block)
response = self._send_request(request)
if response is not None:
return res... | 68 | utils.py | Python | python/ray/autoscaler/_private/aliyun/utils.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 2 | |
299,744 | 27 | 9 | 8 | 88 | 12 | 1 | 31 | 88 | test_select_source_firetv | Review AndroidTV tests for media player entity (#71168) | https://github.com/home-assistant/core.git | async def test_select_source_firetv(hass, source, expected_arg, method_patch):
conf_apps = {
"com.app.test1": "TEST 1",
"com.app.test3": None,
}
await _test_select_source(
hass, CONFIG_FIRETV_DEFAULT, conf_apps, source, expected_arg, method_patch
)
@pytest.mark.parametrize... | @pytest.mark.parametrize(
"config",
[
CONFIG_ANDROIDTV_DEFAULT,
CONFIG_FIRETV_DEFAULT,
],
) | 39 | test_media_player.py | Python | tests/components/androidtv/test_media_player.py | ea456893f94c7dc88b0cc28f92dadf240fbb1fe7 | core | 1 |
224,037 | 15 | 10 | 4 | 68 | 9 | 0 | 18 | 53 | _set_active | Remove spaces at the ends of docstrings, normalize quotes | https://github.com/mkdocs/mkdocs.git | def _set_active(self, value):
self.__active = bool(value)
if self.parent is not None:
self.parent.active = bool(value)
active = property(_get_active, _set_active)
| 34 | nav.py | Python | mkdocs/structure/nav.py | e7f07cc82ab2be920ab426ba07456d8b2592714d | mkdocs | 2 | |
304,335 | 31 | 11 | 10 | 98 | 9 | 0 | 31 | 130 | _filter_entries | Type feedreader strictly (#76707)
* Type feedreader strictly
* Run hassfest | https://github.com/home-assistant/core.git | def _filter_entries(self) -> None:
assert self._feed is not None
if len(self._feed.entries) > self._max_entries:
_LOGGER.debug(
"Processing only the first %s entries in feed %s",
self._max_entries,
self._url,
)
... | 62 | __init__.py | Python | homeassistant/components/feedreader/__init__.py | d0986c765083fd7d597f03ea4679245417d8a6f8 | core | 2 | |
127,695 | 9 | 8 | 4 | 39 | 5 | 0 | 10 | 38 | job_id | [core/docs] Update worker docstring (#28495)
Co-authored-by: Philipp Moritz <pcmoritz@gmail.com> | https://github.com/ray-project/ray.git | def job_id(self):
job_id = self.worker.current_job_id
assert not job_id.is_nil()
return job_id
| 22 | runtime_context.py | Python | python/ray/runtime_context.py | 8ffe435173aee0f313f786e7301d05f608b6d5be | ray | 1 | |
262,764 | 69 | 18 | 18 | 183 | 11 | 0 | 108 | 303 | binary_to_target_arch | building: macOS: limit binaries' architecture validation to extensions
As demonstrated by scipy 1.8.0, the multi-arch universal2 extensions
may have their individual arch slices linked against distinct
single-arch thin shared libraries.
Such thin shared libraries will fail the current strict architecture
validation, ... | https://github.com/pyinstaller/pyinstaller.git | def binary_to_target_arch(filename, target_arch, display_name=None):
if not display_name:
display_name = filename # Same as input file
# Check the binary
is_fat, archs = get_binary_architectures(filename)
if target_arch == 'universal2':
if not is_fat:
raise Incompatible... | 91 | osx.py | Python | PyInstaller/utils/osx.py | b401095d572789211857fbc47a021d7f712e555a | pyinstaller | 7 | |
248,551 | 135 | 15 | 125 | 890 | 25 | 0 | 337 | 1,750 | test_join_rules_msc3083_restricted | EventAuthTestCase: build events for the right room version
In practice, when we run the auth rules, all of the events have the right room
version. Let's stop building Room V1 events for these tests and use the right
version. | https://github.com/matrix-org/synapse.git | def test_join_rules_msc3083_restricted(self) -> None:
creator = "@creator:example.com"
pleb = "@joiner:example.com"
auth_events = {
("m.room.create", ""): _create_event(RoomVersions.V8, creator),
("m.room.member", creator): _join_event(RoomVersions.V8, creator),... | 548 | test_event_auth.py | Python | tests/test_event_auth.py | 2959184a42398277ff916206235b844a8f7be5d7 | synapse | 1 | |
246,359 | 70 | 17 | 48 | 234 | 18 | 0 | 127 | 443 | return_expanded | Fix bug in `StateFilter.return_expanded()` and add some tests. (#12016) | https://github.com/matrix-org/synapse.git | def return_expanded(self) -> "StateFilter":
if self.is_full():
# If we're going to return everything then there's nothing to do
return self
if not self.has_wildcards():
# If there are no wild cards, there's nothing to do
return self
if ... | 141 | state.py | Python | synapse/storage/state.py | eb609c65d0794dd49efcd924bdc8743fd4253a93 | synapse | 10 | |
255,151 | 17 | 12 | 11 | 99 | 15 | 0 | 21 | 75 | tests | Use Python type annotations rather than comments (#3962)
* These have been supported since Python 3.5.
ONNX doesn't support Python < 3.6, so we can use the annotations.
Diffs generated by https://pypi.org/project/com2ann/.
Signed-off-by: Gary Miguel <garymiguel@microsoft.com>
* Remove MYPY conditional logi... | https://github.com/onnx/onnx.git | def tests(self) -> Type[unittest.TestCase]:
tests = self._get_test_case('OnnxBackendTest')
for items_map in sorted(self._filtered_test_items.values()):
for name, item in sorted(items_map.items()):
setattr(tests, name, item.func)
return tests
| 61 | __init__.py | Python | onnx/backend/test/runner/__init__.py | 83fa57c74edfd13ddac9548b8a12f9e3e2ed05bd | onnx | 3 | |
133,619 | 7 | 8 | 16 | 30 | 3 | 0 | 8 | 17 | test_ssh_sync | [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 test_ssh_sync():
experiment_name = "cloud_ssh_sync"
indicator_file = f"/tmp/{experiment_name}_indicator"
| 70 | run_cloud_test.py | Python | release/tune_tests/cloud_tests/workloads/run_cloud_test.py | 7f1bacc7dc9caf6d0ec042e39499bbf1d9a7d065 | ray | 2 | |
293,767 | 24 | 11 | 9 | 115 | 12 | 0 | 27 | 66 | test_from_event_to_db_state_attributes | Separate attrs into another table (reduces database size) (#68224) | https://github.com/home-assistant/core.git | def test_from_event_to_db_state_attributes():
attrs = {"this_attr": True}
state = ha.State("sensor.temperature", "18", attrs)
event = ha.Event(
EVENT_STATE_CHANGED,
{"entity_id": "sensor.temperature", "old_state": None, "new_state": state},
context=state.context,
)
asser... | 66 | test_models.py | Python | tests/components/recorder/test_models.py | 9215702388eef03c7c3ed9f756ea0db533d5beec | core | 1 | |
101,983 | 26 | 12 | 13 | 122 | 13 | 0 | 32 | 164 | destroy_widgets | GUI - Preview updates
- Training preview. Embed preview pop-out window
- Bugfix - convert/extract previews | https://github.com/deepfakes/faceswap.git | def destroy_widgets(self) -> None:
if self._is_standalone:
return
for widget in self._gui_mapped:
if widget.winfo_ismapped():
logger.debug("Removing widget: %s", widget)
widget.pack_forget()
widget.destroy()
... | 73 | preview_tk.py | Python | lib/training/preview_tk.py | 2e8ef5e3c8f2df0f1cca9b342baa8aaa6f620650 | faceswap | 5 | |
281,251 | 6 | 6 | 3 | 25 | 4 | 0 | 6 | 20 | custom_reset | Baseclass (#1141)
* A working decorator
* Basic intro
* Added more
* Refactor
* Refactor
* Cleaned code
* Simplified function (thanks Chavi)
* Small change
* Updating tests : fix issue with mock
* Updating tests : fix remaining mocks after merging
* Updating tests : black
* Cleaned up
... | https://github.com/OpenBB-finance/OpenBBTerminal.git | def custom_reset(self) -> List[str]:
return []
| 14 | parent_classes.py | Python | gamestonk_terminal/parent_classes.py | 006b3570b795215a17c64841110b649b03db9a98 | OpenBBTerminal | 1 | |
147,859 | 5 | 11 | 15 | 77 | 26 | 5 | 5 | 12 | options | [core] Simplify options handling [Part 1] (#23127)
* handle options
* update doc
* fix serve | https://github.com/ray-project/ray.git | def options(self, args=None, kwargs=None, **actor_options):
| """overrides the actor instantiation parameters.
The arguments are thethose that can be:obj:`ray.remote`.
Examples:
.. code-block::
. | 86 | actor.py | Python | python/ray/actor.py | d7ef546352c78f5080938a41432b8de4c0c81ff0 | ray | 2 |
260,356 | 18 | 10 | 8 | 87 | 13 | 0 | 23 | 83 | transform | MAINT Use _validate_params in SparsePCA and MiniBatchSparsePCA (#23710)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: jeremiedbb <jeremiedbb@yahoo.fr> | https://github.com/scikit-learn/scikit-learn.git | def transform(self, X):
check_is_fitted(self)
X = self._validate_data(X, reset=False)
X = X - self.mean_
U = ridge_regression(
self.components_.T, X.T, self.ridge_alpha, solver="cholesky"
)
return U
| 55 | _sparse_pca.py | Python | sklearn/decomposition/_sparse_pca.py | db6123fe40400828918037f3fae949bfcc4d9d05 | scikit-learn | 1 | |
191,406 | 29 | 9 | 9 | 103 | 13 | 0 | 37 | 61 | test_predict_until_observation_repeat | Harrison/add react chain (#24)
from https://arxiv.org/abs/2210.03629
still need to think if docstore abstraction makes sense | https://github.com/hwchase17/langchain.git | def test_predict_until_observation_repeat() -> None:
outputs = ["foo", " search[foo]"]
fake_llm = FakeListLLM(outputs)
fake_llm_chain = LLMChain(llm=fake_llm, prompt=_FAKE_PROMPT)
ret_text, action, directive = predict_until_observation(fake_llm_chain, "", 1)
assert ret_text == "foo\nAction 1: s... | 58 | test_react.py | Python | tests/unit_tests/chains/test_react.py | ce7b14b84381c766ae42a0f71953b2a56c024dbb | langchain | 1 | |
157,004 | 15 | 12 | 3 | 87 | 10 | 1 | 15 | 27 | _emulate | Filter out `numeric_only` warnings from `pandas` (#9496)
* Initial checkpoint
* test-upstream
* Pass method name [test-upstream]
* Groupby [test-upstream]
* Cleanup [test-upstream]
* More specific warning catching [test-upstream]
* Remove stray breakpoint [test-upstream]
* Fix categorical tests [t... | https://github.com/dask/dask.git | def _emulate(func, *args, udf=False, **kwargs):
with raise_on_meta_error(funcname(func), udf=udf), check_numeric_only_deprecation():
return func(*_extract_meta(args, True), **_extract_meta(kwargs, True))
@insert_meta_param_description | @insert_meta_param_description | 52 | core.py | Python | dask/dataframe/core.py | 1a8533fddb7de0c9981acee0c33408e7205f8c7a | dask | 1 |
292,209 | 79 | 12 | 35 | 367 | 26 | 0 | 123 | 300 | test_cleanup_trigger | 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> | https://github.com/home-assistant/core.git | async def test_cleanup_trigger(hass, hass_ws_client, device_reg, entity_reg, mqtt_mock):
assert await async_setup_component(hass, "config", {})
ws_client = await hass_ws_client(hass)
config = {
"automation_type": "trigger",
"topic": "test-topic",
"type": "foo",
"subtype... | 207 | test_device_trigger.py | Python | tests/components/mqtt/test_device_trigger.py | ba6d1976dff8df2aa32726ff2acbf0ba61e5c550 | core | 1 | |
150,089 | 64 | 16 | 16 | 182 | 16 | 0 | 78 | 266 | load_historic_predictions_from_disk | start collecting indefinite history of predictions. Allow user to generate statistics on these predictions. Direct FreqAI to save these to disk and reload them if available. | https://github.com/freqtrade/freqtrade.git | def load_historic_predictions_from_disk(self):
exists = Path(self.full_path / str("historic_predictions.json")).resolve().exists()
if exists:
with open(self.full_path / str("historic_predictions.json"), "r") as fp:
self.pair_dict = json.load(fp)
logger.in... | 90 | data_drawer.py | Python | freqtrade/freqai/data_drawer.py | 8ce6b183180e69411d4b44b51489451b31475f35 | freqtrade | 3 | |
281,543 | 19 | 9 | 32 | 93 | 11 | 0 | 26 | 61 | 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):
is_foreign_start = "" if not self.suffix else "[unvl]"
is_foreign_end = "" if not self.suffix else "[/unvl]"
help_text = f
console.print(text=help_text, menu="Stocks - Fundamental Analysis")
| 42 | fa_controller.py | Python | gamestonk_terminal/stocks/fundamental_analysis/fa_controller.py | 82747072c511beb1b2672846ae2ee4aec53eb562 | OpenBBTerminal | 3 | |
162,356 | 6 | 5 | 15 | 28 | 11 | 1 | 6 | 13 | _entries | [PRX] Add Extractors (#2245)
Closes #2144, https://github.com/ytdl-org/youtube-dl/issues/15948
Authored by: coletdjnz | https://github.com/yt-dlp/yt-dlp.git | def _entries(self, item_id, endpoint, entry_func, query=None):
| """
Extract entries from paginated list API | 106 | prx.py | Python | yt_dlp/extractor/prx.py | 85fee2215295b099d34350d9a9ff42c086e3aef2 | yt-dlp | 6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.