Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
SolarEdgeConfigFlow.async_step_import | (self, user_input=None) | Import a config entry. | Import a config entry. | async def async_step_import(self, user_input=None):
"""Import a config entry."""
if self._site_in_configuration_exists(user_input[CONF_SITE_ID]):
return self.async_abort(reason="site_exists")
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"_site_in_configuration_exists",
"(",
"user_input",
"[",
"CONF_SITE_ID",
"]",
")",
":",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
"... | [
93,
4
] | [
97,
53
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up OwnTracks based off an entry. | Set up OwnTracks based off an entry. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up OwnTracks based off an entry."""
# Restore previously loaded devices
dev_reg = await device_registry.async_get_registry(hass)
dev_ids = {
identifier[1]
for device in dev_reg.devices.values()
for identifier in... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"# Restore previously loaded devices",
"dev_reg",
"=",
"await",
"device_registry",
".",
"async_get_registry",
"(",
"hass",
")",
"dev_ids",
"=",
"{",
"identifier",
"[... | [
20,
0
] | [
53,
15
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.__init__ | (self, dev_id, data=None) | Set up OwnTracks entity. | Set up OwnTracks entity. | def __init__(self, dev_id, data=None):
"""Set up OwnTracks entity."""
self._dev_id = dev_id
self._data = data or {}
self.entity_id = f"{DOMAIN}.{dev_id}" | [
"def",
"__init__",
"(",
"self",
",",
"dev_id",
",",
"data",
"=",
"None",
")",
":",
"self",
".",
"_dev_id",
"=",
"dev_id",
"self",
".",
"_data",
"=",
"data",
"or",
"{",
"}",
"self",
".",
"entity_id",
"=",
"f\"{DOMAIN}.{dev_id}\""
] | [
59,
4
] | [
63,
45
] | python | en | ['en', 'zu', 'en'] | True |
OwnTracksEntity.unique_id | (self) | Return the unique ID. | Return the unique ID. | def unique_id(self):
"""Return the unique ID."""
return self._dev_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_dev_id"
] | [
66,
4
] | [
68,
27
] | python | en | ['en', 'la', 'en'] | True |
OwnTracksEntity.battery_level | (self) | Return the battery level of the device. | Return the battery level of the device. | def battery_level(self):
"""Return the battery level of the device."""
return self._data.get("battery") | [
"def",
"battery_level",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"\"battery\"",
")"
] | [
71,
4
] | [
73,
40
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.device_state_attributes | (self) | Return device specific attributes. | Return device specific attributes. | def device_state_attributes(self):
"""Return device specific attributes."""
return self._data.get("attributes") | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"\"attributes\"",
")"
] | [
76,
4
] | [
78,
43
] | python | en | ['fr', 'it', 'en'] | False |
OwnTracksEntity.location_accuracy | (self) | Return the gps accuracy of the device. | Return the gps accuracy of the device. | def location_accuracy(self):
"""Return the gps accuracy of the device."""
return self._data.get("gps_accuracy") | [
"def",
"location_accuracy",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"\"gps_accuracy\"",
")"
] | [
81,
4
] | [
83,
45
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.latitude | (self) | Return latitude value of the device. | Return latitude value of the device. | def latitude(self):
"""Return latitude value of the device."""
# Check with "get" instead of "in" because value can be None
if self._data.get("gps"):
return self._data["gps"][0]
return None | [
"def",
"latitude",
"(",
"self",
")",
":",
"# Check with \"get\" instead of \"in\" because value can be None",
"if",
"self",
".",
"_data",
".",
"get",
"(",
"\"gps\"",
")",
":",
"return",
"self",
".",
"_data",
"[",
"\"gps\"",
"]",
"[",
"0",
"]",
"return",
"None"... | [
86,
4
] | [
92,
19
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.longitude | (self) | Return longitude value of the device. | Return longitude value of the device. | def longitude(self):
"""Return longitude value of the device."""
# Check with "get" instead of "in" because value can be None
if self._data.get("gps"):
return self._data["gps"][1]
return None | [
"def",
"longitude",
"(",
"self",
")",
":",
"# Check with \"get\" instead of \"in\" because value can be None",
"if",
"self",
".",
"_data",
".",
"get",
"(",
"\"gps\"",
")",
":",
"return",
"self",
".",
"_data",
"[",
"\"gps\"",
"]",
"[",
"1",
"]",
"return",
"None... | [
95,
4
] | [
101,
19
] | python | en | ['en', 'zu', 'en'] | True |
OwnTracksEntity.location_name | (self) | Return a location name for the current location of the device. | Return a location name for the current location of the device. | def location_name(self):
"""Return a location name for the current location of the device."""
return self._data.get("location_name") | [
"def",
"location_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"\"location_name\"",
")"
] | [
104,
4
] | [
106,
46
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._data.get("host_name") | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"\"host_name\"",
")"
] | [
109,
4
] | [
111,
42
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.source_type | (self) | Return the source type, eg gps or router, of the device. | Return the source type, eg gps or router, of the device. | def source_type(self):
"""Return the source type, eg gps or router, of the device."""
return self._data.get("source_type", SOURCE_TYPE_GPS) | [
"def",
"source_type",
"(",
"self",
")",
":",
"return",
"self",
".",
"_data",
".",
"get",
"(",
"\"source_type\"",
",",
"SOURCE_TYPE_GPS",
")"
] | [
114,
4
] | [
116,
61
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {"name": self.name, "identifiers": {(OT_DOMAIN, self._dev_id)}} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"identifiers\"",
":",
"{",
"(",
"OT_DOMAIN",
",",
"self",
".",
"_dev_id",
")",
"}",
"}"
] | [
119,
4
] | [
121,
78
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.async_added_to_hass | (self) | Call when entity about to be added to Home Assistant. | Call when entity about to be added to Home Assistant. | async def async_added_to_hass(self):
"""Call when entity about to be added to Home Assistant."""
await super().async_added_to_hass()
# Don't restore if we got set up with data.
if self._data:
return
state = await self.async_get_last_state()
if state is None... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"# Don't restore if we got set up with data.",
"if",
"self",
".",
"_data",
":",
"return",
"state",
"=",
"await",
"self",
".",
"async_g... | [
123,
4
] | [
143,
9
] | python | en | ['en', 'en', 'en'] | True |
OwnTracksEntity.update_data | (self, data) | Mark the device as seen. | Mark the device as seen. | def update_data(self, data):
"""Mark the device as seen."""
self._data = data
if self.hass:
self.async_write_ha_state() | [
"def",
"update_data",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"if",
"self",
".",
"hass",
":",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
146,
4
] | [
150,
39
] | python | en | ['en', 'en', 'en'] | True |
test_sma_config | (hass) | Test new config. | Test new config. | async def test_sma_config(hass):
"""Test new config."""
sensors = ["current_consumption"]
with assert_setup_component(1):
assert await async_setup_component(
hass, DOMAIN, {DOMAIN: dict(BASE_CFG, sensors=sensors)}
)
await hass.async_block_till_done()
state = hass.st... | [
"async",
"def",
"test_sma_config",
"(",
"hass",
")",
":",
"sensors",
"=",
"[",
"\"current_consumption\"",
"]",
"with",
"assert_setup_component",
"(",
"1",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"DOMAIN",
":"... | [
15,
0
] | [
31,
16
] | python | en | ['en', 'en', 'en'] | True |
test_manually_configured_platform | (hass) | Test that we do not set up an access point. | Test that we do not set up an access point. | async def test_manually_configured_platform(hass):
"""Test that we do not set up an access point."""
assert await async_setup_component(
hass, LIGHT_DOMAIN, {LIGHT_DOMAIN: {"platform": HMIPC_DOMAIN}}
)
assert not hass.data.get(HMIPC_DOMAIN) | [
"async",
"def",
"test_manually_configured_platform",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LIGHT_DOMAIN",
",",
"{",
"LIGHT_DOMAIN",
":",
"{",
"\"platform\"",
":",
"HMIPC_DOMAIN",
"}",
"}",
")",
"assert",
"not",
"ha... | [
19,
0
] | [
24,
42
] | python | en | ['en', 'en', 'en'] | True |
test_hmip_light | (hass, default_mock_hap_factory) | Test HomematicipLight. | Test HomematicipLight. | async def test_hmip_light(hass, default_mock_hap_factory):
"""Test HomematicipLight."""
entity_id = "light.treppe_ch"
entity_name = "Treppe CH"
device_model = "HmIP-BSL"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Treppe"]
)
ha_state, hmip_device = g... | [
"async",
"def",
"test_hmip_light",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"light.treppe_ch\"",
"entity_name",
"=",
"\"Treppe CH\"",
"device_model",
"=",
"\"HmIP-BSL\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".",
"asyn... | [
27,
0
] | [
63,
37
] | python | en | ['es', 'sv', 'en'] | False |
test_hmip_notification_light | (hass, default_mock_hap_factory) | Test HomematicipNotificationLight. | Test HomematicipNotificationLight. | async def test_hmip_notification_light(hass, default_mock_hap_factory):
"""Test HomematicipNotificationLight."""
entity_id = "light.alarm_status"
entity_name = "Alarm Status"
device_model = "HmIP-BSL"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=["Treppe"]
)... | [
"async",
"def",
"test_hmip_notification_light",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"light.alarm_status\"",
"entity_name",
"=",
"\"Alarm Status\"",
"device_model",
"=",
"\"HmIP-BSL\"",
"mock_hap",
"=",
"await",
"default_mock_hap_facto... | [
66,
0
] | [
154,
55
] | python | en | ['es', 'lb', 'en'] | False |
test_hmip_dimmer | (hass, default_mock_hap_factory) | Test HomematicipDimmer. | Test HomematicipDimmer. | async def test_hmip_dimmer(hass, default_mock_hap_factory):
"""Test HomematicipDimmer."""
entity_id = "light.schlafzimmerlicht"
entity_name = "Schlafzimmerlicht"
device_model = "HmIP-BDT"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_s... | [
"async",
"def",
"test_hmip_dimmer",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"light.schlafzimmerlicht\"",
"entity_name",
"=",
"\"Schlafzimmerlicht\"",
"device_model",
"=",
"\"HmIP-BDT\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory... | [
157,
0
] | [
206,
55
] | python | en | ['es', 'no', 'en'] | False |
test_hmip_light_measuring | (hass, default_mock_hap_factory) | Test HomematicipLightMeasuring. | Test HomematicipLightMeasuring. | async def test_hmip_light_measuring(hass, default_mock_hap_factory):
"""Test HomematicipLightMeasuring."""
entity_id = "light.flur_oben"
entity_name = "Flur oben"
device_model = "HmIP-BSM"
mock_hap = await default_mock_hap_factory.async_get_mock_hap(
test_devices=[entity_name]
)
ha_... | [
"async",
"def",
"test_hmip_light_measuring",
"(",
"hass",
",",
"default_mock_hap_factory",
")",
":",
"entity_id",
"=",
"\"light.flur_oben\"",
"entity_name",
"=",
"\"Flur oben\"",
"device_model",
"=",
"\"HmIP-BSM\"",
"mock_hap",
"=",
"await",
"default_mock_hap_factory",
".... | [
209,
0
] | [
246,
38
] | python | en | ['en', 'ky', 'en'] | False |
test_new_users_available | (hass, entry, mock_websocket, setup_plex_server) | Test setting up when new users available on Plex server. | Test setting up when new users available on Plex server. | async def test_new_users_available(hass, entry, mock_websocket, setup_plex_server):
"""Test setting up when new users available on Plex server."""
MONITORED_USERS = {"Owner": {"enabled": True}}
OPTIONS_WITH_USERS = copy.deepcopy(DEFAULT_OPTIONS)
OPTIONS_WITH_USERS[MP_DOMAIN][CONF_MONITORED_USERS] = MONI... | [
"async",
"def",
"test_new_users_available",
"(",
"hass",
",",
"entry",
",",
"mock_websocket",
",",
"setup_plex_server",
")",
":",
"MONITORED_USERS",
"=",
"{",
"\"Owner\"",
":",
"{",
"\"enabled\"",
":",
"True",
"}",
"}",
"OPTIONS_WITH_USERS",
"=",
"copy",
".",
... | [
45,
0
] | [
66,
62
] | python | en | ['en', 'en', 'en'] | True |
test_new_ignored_users_available | (
hass, caplog, entry, mock_websocket, setup_plex_server
) | Test setting up when new users available on Plex server but are ignored. | Test setting up when new users available on Plex server but are ignored. | async def test_new_ignored_users_available(
hass, caplog, entry, mock_websocket, setup_plex_server
):
"""Test setting up when new users available on Plex server but are ignored."""
MONITORED_USERS = {"Owner": {"enabled": True}}
OPTIONS_WITH_USERS = copy.deepcopy(DEFAULT_OPTIONS)
OPTIONS_WITH_USERS[M... | [
"async",
"def",
"test_new_ignored_users_available",
"(",
"hass",
",",
"caplog",
",",
"entry",
",",
"mock_websocket",
",",
"setup_plex_server",
")",
":",
"MONITORED_USERS",
"=",
"{",
"\"Owner\"",
":",
"{",
"\"enabled\"",
":",
"True",
"}",
"}",
"OPTIONS_WITH_USERS",... | [
69,
0
] | [
103,
62
] | python | en | ['en', 'en', 'en'] | True |
test_network_error_during_refresh | (
hass, caplog, mock_plex_server, mock_websocket
) | Test network failures during refreshes. | Test network failures during refreshes. | async def test_network_error_during_refresh(
hass, caplog, mock_plex_server, mock_websocket
):
"""Test network failures during refreshes."""
server_id = mock_plex_server.machineIdentifier
loaded_server = hass.data[DOMAIN][SERVERS][server_id]
trigger_plex_update(mock_websocket)
await hass.async_... | [
"async",
"def",
"test_network_error_during_refresh",
"(",
"hass",
",",
"caplog",
",",
"mock_plex_server",
",",
"mock_websocket",
")",
":",
"server_id",
"=",
"mock_plex_server",
".",
"machineIdentifier",
"loaded_server",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
... | [
106,
0
] | [
125,
5
] | python | en | ['fr', 'en', 'en'] | True |
test_gdm_client_failure | (hass, mock_websocket, setup_plex_server) | Test connection failure to a GDM discovered client. | Test connection failure to a GDM discovered client. | async def test_gdm_client_failure(hass, mock_websocket, setup_plex_server):
"""Test connection failure to a GDM discovered client."""
mock_plex_server = await setup_plex_server(disable_gdm=False)
with patch(
"homeassistant.components.plex.server.PlexClient", side_effect=ConnectionError
):
... | [
"async",
"def",
"test_gdm_client_failure",
"(",
"hass",
",",
"mock_websocket",
",",
"setup_plex_server",
")",
":",
"mock_plex_server",
"=",
"await",
"setup_plex_server",
"(",
"disable_gdm",
"=",
"False",
")",
"with",
"patch",
"(",
"\"homeassistant.components.plex.server... | [
128,
0
] | [
143,
42
] | python | en | ['en', 'en', 'en'] | True |
test_mark_sessions_idle | (hass, mock_plex_server, mock_websocket) | Test marking media_players as idle when sessions end. | Test marking media_players as idle when sessions end. | async def test_mark_sessions_idle(hass, mock_plex_server, mock_websocket):
"""Test marking media_players as idle when sessions end."""
server_id = mock_plex_server.machineIdentifier
loaded_server = hass.data[DOMAIN][SERVERS][server_id]
trigger_plex_update(mock_websocket)
await hass.async_block_till... | [
"async",
"def",
"test_mark_sessions_idle",
"(",
"hass",
",",
"mock_plex_server",
",",
"mock_websocket",
")",
":",
"server_id",
"=",
"mock_plex_server",
".",
"machineIdentifier",
"loaded_server",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"SERVERS",
"]",
... | [
146,
0
] | [
164,
30
] | python | en | ['en', 'en', 'en'] | True |
test_ignore_plex_web_client | (hass, entry, mock_websocket) | Test option to ignore Plex Web clients. | Test option to ignore Plex Web clients. | async def test_ignore_plex_web_client(hass, entry, mock_websocket):
"""Test option to ignore Plex Web clients."""
OPTIONS = copy.deepcopy(DEFAULT_OPTIONS)
OPTIONS[MP_DOMAIN][CONF_IGNORE_PLEX_WEB_CLIENTS] = True
entry.options = OPTIONS
mock_plex_server = MockPlexServer(config_entry=entry)
with ... | [
"async",
"def",
"test_ignore_plex_web_client",
"(",
"hass",
",",
"entry",
",",
"mock_websocket",
")",
":",
"OPTIONS",
"=",
"copy",
".",
"deepcopy",
"(",
"DEFAULT_OPTIONS",
")",
"OPTIONS",
"[",
"MP_DOMAIN",
"]",
"[",
"CONF_IGNORE_PLEX_WEB_CLIENTS",
"]",
"=",
"Tru... | [
167,
0
] | [
190,
54
] | python | en | ['en', 'fr', 'en'] | True |
test_media_lookups | (hass, mock_plex_server, mock_websocket) | Test media lookups to Plex server. | Test media lookups to Plex server. | async def test_media_lookups(hass, mock_plex_server, mock_websocket):
"""Test media lookups to Plex server."""
server_id = mock_plex_server.machineIdentifier
loaded_server = hass.data[DOMAIN][SERVERS][server_id]
# Plex Key searches
trigger_plex_update(mock_websocket)
await hass.async_block_till... | [
"async",
"def",
"test_media_lookups",
"(",
"hass",
",",
"mock_plex_server",
",",
"mock_websocket",
")",
":",
"server_id",
"=",
"mock_plex_server",
".",
"machineIdentifier",
"loaded_server",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"SERVERS",
"]",
"[",
... | [
193,
0
] | [
440,
17
] | python | en | ['en', 'et', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up Homekit lock. | Set up Homekit lock. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up Homekit lock."""
hkid = config_entry.data["AccessoryPairingID"]
conn = hass.data[KNOWN_DEVICES][hkid]
@callback
def async_add_service(service):
if service.short_type != ServicesTypes.LOCK_MECHANISM:
r... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"hkid",
"=",
"config_entry",
".",
"data",
"[",
"\"AccessoryPairingID\"",
"]",
"conn",
"=",
"hass",
".",
"data",
"[",
"KNOWN_DEVICES",
"]",
"[",
"hkid",
... | [
17,
0
] | [
30,
40
] | python | en | ['en', 'ky', 'en'] | True |
HomeKitLock.get_characteristic_types | (self) | Define the homekit characteristics the entity cares about. | Define the homekit characteristics the entity cares about. | def get_characteristic_types(self):
"""Define the homekit characteristics the entity cares about."""
return [
CharacteristicsTypes.LOCK_MECHANISM_CURRENT_STATE,
CharacteristicsTypes.LOCK_MECHANISM_TARGET_STATE,
CharacteristicsTypes.BATTERY_LEVEL,
] | [
"def",
"get_characteristic_types",
"(",
"self",
")",
":",
"return",
"[",
"CharacteristicsTypes",
".",
"LOCK_MECHANISM_CURRENT_STATE",
",",
"CharacteristicsTypes",
".",
"LOCK_MECHANISM_TARGET_STATE",
",",
"CharacteristicsTypes",
".",
"BATTERY_LEVEL",
",",
"]"
] | [
36,
4
] | [
42,
9
] | python | en | ['en', 'en', 'en'] | True |
HomeKitLock.is_locked | (self) | Return true if device is locked. | Return true if device is locked. | def is_locked(self):
"""Return true if device is locked."""
value = self.service.value(CharacteristicsTypes.LOCK_MECHANISM_CURRENT_STATE)
return CURRENT_STATE_MAP[value] == STATE_LOCKED | [
"def",
"is_locked",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"service",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"LOCK_MECHANISM_CURRENT_STATE",
")",
"return",
"CURRENT_STATE_MAP",
"[",
"value",
"]",
"==",
"STATE_LOCKED"
] | [
45,
4
] | [
48,
55
] | python | en | ['en', 'fy', 'en'] | True |
HomeKitLock.async_lock | (self, **kwargs) | Lock the device. | Lock the device. | async def async_lock(self, **kwargs):
"""Lock the device."""
await self._set_lock_state(STATE_LOCKED) | [
"async",
"def",
"async_lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_set_lock_state",
"(",
"STATE_LOCKED",
")"
] | [
50,
4
] | [
52,
48
] | python | en | ['en', 'en', 'en'] | True |
HomeKitLock.async_unlock | (self, **kwargs) | Unlock the device. | Unlock the device. | async def async_unlock(self, **kwargs):
"""Unlock the device."""
await self._set_lock_state(STATE_UNLOCKED) | [
"async",
"def",
"async_unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_set_lock_state",
"(",
"STATE_UNLOCKED",
")"
] | [
54,
4
] | [
56,
50
] | python | en | ['en', 'zh', 'en'] | True |
HomeKitLock._set_lock_state | (self, state) | Send state command. | Send state command. | async def _set_lock_state(self, state):
"""Send state command."""
await self.async_put_characteristics(
{CharacteristicsTypes.LOCK_MECHANISM_TARGET_STATE: TARGET_STATE_MAP[state]}
) | [
"async",
"def",
"_set_lock_state",
"(",
"self",
",",
"state",
")",
":",
"await",
"self",
".",
"async_put_characteristics",
"(",
"{",
"CharacteristicsTypes",
".",
"LOCK_MECHANISM_TARGET_STATE",
":",
"TARGET_STATE_MAP",
"[",
"state",
"]",
"}",
")"
] | [
58,
4
] | [
62,
9
] | python | en | ['en', 'en', 'en'] | True |
HomeKitLock.device_state_attributes | (self) | Return the optional state attributes. | Return the optional state attributes. | def device_state_attributes(self):
"""Return the optional state attributes."""
attributes = {}
battery_level = self.service.value(CharacteristicsTypes.BATTERY_LEVEL)
if battery_level:
attributes[ATTR_BATTERY_LEVEL] = battery_level
return attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attributes",
"=",
"{",
"}",
"battery_level",
"=",
"self",
".",
"service",
".",
"value",
"(",
"CharacteristicsTypes",
".",
"BATTERY_LEVEL",
")",
"if",
"battery_level",
":",
"attributes",
"[",
"ATTR_BATTERY... | [
65,
4
] | [
73,
25
] | python | en | ['en', 'en', 'en'] | True |
get_service | (hass, config, discovery_info=None) | Get the syslog notification service. | Get the syslog notification service. | def get_service(hass, config, discovery_info=None):
"""Get the syslog notification service."""
facility = getattr(syslog, SYSLOG_FACILITY[config.get(CONF_FACILITY)])
option = getattr(syslog, SYSLOG_OPTION[config.get(CONF_OPTION)])
priority = getattr(syslog, SYSLOG_PRIORITY[config.get(CONF_PRIORITY)])
... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"facility",
"=",
"getattr",
"(",
"syslog",
",",
"SYSLOG_FACILITY",
"[",
"config",
".",
"get",
"(",
"CONF_FACILITY",
")",
"]",
")",
"option",
"=",
"getattr",
"... | [
65,
0
] | [
72,
64
] | python | en | ['en', 'en', 'en'] | True |
SyslogNotificationService.__init__ | (self, facility, option, priority) | Initialize the service. | Initialize the service. | def __init__(self, facility, option, priority):
"""Initialize the service."""
self._facility = facility
self._option = option
self._priority = priority | [
"def",
"__init__",
"(",
"self",
",",
"facility",
",",
"option",
",",
"priority",
")",
":",
"self",
".",
"_facility",
"=",
"facility",
"self",
".",
"_option",
"=",
"option",
"self",
".",
"_priority",
"=",
"priority"
] | [
78,
4
] | [
82,
33
] | python | en | ['en', 'en', 'en'] | True |
SyslogNotificationService.send_message | (self, message="", **kwargs) | Send a message to a user. | Send a message to a user. | def send_message(self, message="", **kwargs):
"""Send a message to a user."""
title = kwargs.get(ATTR_TITLE, ATTR_TITLE_DEFAULT)
syslog.openlog(title, self._option, self._facility)
syslog.syslog(self._priority, message)
syslog.closelog() | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"title",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TITLE",
",",
"ATTR_TITLE_DEFAULT",
")",
"syslog",
".",
"openlog",
"(",
"title",
",",
"self",
".",
"_optio... | [
84,
4
] | [
91,
25
] | python | en | ['en', 'en', 'en'] | True |
test_json_encoder | (hass) | Test the JSON Encoder. | Test the JSON Encoder. | def test_json_encoder(hass):
"""Test the JSON Encoder."""
ha_json_enc = JSONEncoder()
state = core.State("test.test", "hello")
assert ha_json_enc.default(state) == state.as_dict()
# Default method raises TypeError if non HA object
with pytest.raises(TypeError):
ha_json_enc.default(1)
... | [
"def",
"test_json_encoder",
"(",
"hass",
")",
":",
"ha_json_enc",
"=",
"JSONEncoder",
"(",
")",
"state",
"=",
"core",
".",
"State",
"(",
"\"test.test\"",
",",
"\"hello\"",
")",
"assert",
"ha_json_enc",
".",
"default",
"(",
"state",
")",
"==",
"state",
".",... | [
8,
0
] | [
20,
54
] | python | en | ['en', 'da', 'en'] | True |
create_temperature_sensor_service | (accessory) | Define temperature characteristics. | Define temperature characteristics. | def create_temperature_sensor_service(accessory):
"""Define temperature characteristics."""
service = accessory.add_service(ServicesTypes.TEMPERATURE_SENSOR)
cur_state = service.add_char(CharacteristicsTypes.TEMPERATURE_CURRENT)
cur_state.value = 0 | [
"def",
"create_temperature_sensor_service",
"(",
"accessory",
")",
":",
"service",
"=",
"accessory",
".",
"add_service",
"(",
"ServicesTypes",
".",
"TEMPERATURE_SENSOR",
")",
"cur_state",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"TEMPERATURE_... | [
22,
0
] | [
27,
23
] | python | en | ['en', 'ca', 'en'] | True |
create_humidity_sensor_service | (accessory) | Define humidity characteristics. | Define humidity characteristics. | def create_humidity_sensor_service(accessory):
"""Define humidity characteristics."""
service = accessory.add_service(ServicesTypes.HUMIDITY_SENSOR)
cur_state = service.add_char(CharacteristicsTypes.RELATIVE_HUMIDITY_CURRENT)
cur_state.value = 0 | [
"def",
"create_humidity_sensor_service",
"(",
"accessory",
")",
":",
"service",
"=",
"accessory",
".",
"add_service",
"(",
"ServicesTypes",
".",
"HUMIDITY_SENSOR",
")",
"cur_state",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"RELATIVE_HUMIDITY_... | [
30,
0
] | [
35,
23
] | python | en | ['en', 'sw', 'en'] | True |
create_light_level_sensor_service | (accessory) | Define light level characteristics. | Define light level characteristics. | def create_light_level_sensor_service(accessory):
"""Define light level characteristics."""
service = accessory.add_service(ServicesTypes.LIGHT_SENSOR)
cur_state = service.add_char(CharacteristicsTypes.LIGHT_LEVEL_CURRENT)
cur_state.value = 0 | [
"def",
"create_light_level_sensor_service",
"(",
"accessory",
")",
":",
"service",
"=",
"accessory",
".",
"add_service",
"(",
"ServicesTypes",
".",
"LIGHT_SENSOR",
")",
"cur_state",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"LIGHT_LEVEL_CURREN... | [
38,
0
] | [
43,
23
] | python | bg | ['es', 'bg', 'en'] | False |
create_carbon_dioxide_level_sensor_service | (accessory) | Define carbon dioxide level characteristics. | Define carbon dioxide level characteristics. | def create_carbon_dioxide_level_sensor_service(accessory):
"""Define carbon dioxide level characteristics."""
service = accessory.add_service(ServicesTypes.CARBON_DIOXIDE_SENSOR)
cur_state = service.add_char(CharacteristicsTypes.CARBON_DIOXIDE_LEVEL)
cur_state.value = 0 | [
"def",
"create_carbon_dioxide_level_sensor_service",
"(",
"accessory",
")",
":",
"service",
"=",
"accessory",
".",
"add_service",
"(",
"ServicesTypes",
".",
"CARBON_DIOXIDE_SENSOR",
")",
"cur_state",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"... | [
46,
0
] | [
51,
23
] | python | fr | ['fr', 'fr', 'en'] | True |
create_battery_level_sensor | (accessory) | Define battery level characteristics. | Define battery level characteristics. | def create_battery_level_sensor(accessory):
"""Define battery level characteristics."""
service = accessory.add_service(ServicesTypes.BATTERY_SERVICE)
cur_state = service.add_char(CharacteristicsTypes.BATTERY_LEVEL)
cur_state.value = 100
low_battery = service.add_char(CharacteristicsTypes.STATUS_L... | [
"def",
"create_battery_level_sensor",
"(",
"accessory",
")",
":",
"service",
"=",
"accessory",
".",
"add_service",
"(",
"ServicesTypes",
".",
"BATTERY_SERVICE",
")",
"cur_state",
"=",
"service",
".",
"add_char",
"(",
"CharacteristicsTypes",
".",
"BATTERY_LEVEL",
")"... | [
54,
0
] | [
67,
18
] | python | en | ['en', 'bg', 'en'] | True |
test_temperature_sensor_read_state | (hass, utcnow) | Test reading the state of a HomeKit temperature sensor accessory. | Test reading the state of a HomeKit temperature sensor accessory. | async def test_temperature_sensor_read_state(hass, utcnow):
"""Test reading the state of a HomeKit temperature sensor accessory."""
helper = await setup_test_component(
hass, create_temperature_sensor_service, suffix="temperature"
)
helper.characteristics[TEMPERATURE].value = 10
state = awa... | [
"async",
"def",
"test_temperature_sensor_read_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_temperature_sensor_service",
",",
"suffix",
"=",
"\"temperature\"",
")",
"helper",
".",
"characteristi... | [
70,
0
] | [
84,
71
] | python | en | ['en', 'en', 'en'] | True |
test_humidity_sensor_read_state | (hass, utcnow) | Test reading the state of a HomeKit humidity sensor accessory. | Test reading the state of a HomeKit humidity sensor accessory. | async def test_humidity_sensor_read_state(hass, utcnow):
"""Test reading the state of a HomeKit humidity sensor accessory."""
helper = await setup_test_component(
hass, create_humidity_sensor_service, suffix="humidity"
)
helper.characteristics[HUMIDITY].value = 10
state = await helper.poll_... | [
"async",
"def",
"test_humidity_sensor_read_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_humidity_sensor_service",
",",
"suffix",
"=",
"\"humidity\"",
")",
"helper",
".",
"characteristics",
"[... | [
87,
0
] | [
101,
68
] | python | en | ['en', 'en', 'en'] | True |
test_light_level_sensor_read_state | (hass, utcnow) | Test reading the state of a HomeKit temperature sensor accessory. | Test reading the state of a HomeKit temperature sensor accessory. | async def test_light_level_sensor_read_state(hass, utcnow):
"""Test reading the state of a HomeKit temperature sensor accessory."""
helper = await setup_test_component(
hass, create_light_level_sensor_service, suffix="light_level"
)
helper.characteristics[LIGHT_LEVEL].value = 10
state = awa... | [
"async",
"def",
"test_light_level_sensor_read_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_light_level_sensor_service",
",",
"suffix",
"=",
"\"light_level\"",
")",
"helper",
".",
"characteristi... | [
104,
0
] | [
118,
71
] | python | en | ['en', 'en', 'en'] | True |
test_carbon_dioxide_level_sensor_read_state | (hass, utcnow) | Test reading the state of a HomeKit carbon dioxide sensor accessory. | Test reading the state of a HomeKit carbon dioxide sensor accessory. | async def test_carbon_dioxide_level_sensor_read_state(hass, utcnow):
"""Test reading the state of a HomeKit carbon dioxide sensor accessory."""
helper = await setup_test_component(
hass, create_carbon_dioxide_level_sensor_service, suffix="co2"
)
helper.characteristics[CARBON_DIOXIDE_LEVEL].valu... | [
"async",
"def",
"test_carbon_dioxide_level_sensor_read_state",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_carbon_dioxide_level_sensor_service",
",",
"suffix",
"=",
"\"co2\"",
")",
"helper",
".",
"cha... | [
121,
0
] | [
133,
30
] | python | en | ['en', 'en', 'en'] | True |
test_battery_level_sensor | (hass, utcnow) | Test reading the state of a HomeKit battery level sensor. | Test reading the state of a HomeKit battery level sensor. | async def test_battery_level_sensor(hass, utcnow):
"""Test reading the state of a HomeKit battery level sensor."""
helper = await setup_test_component(
hass, create_battery_level_sensor, suffix="battery"
)
helper.characteristics[BATTERY_LEVEL].value = 100
state = await helper.poll_and_get_s... | [
"async",
"def",
"test_battery_level_sensor",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_battery_level_sensor",
",",
"suffix",
"=",
"\"battery\"",
")",
"helper",
".",
"characteristics",
"[",
"BATT... | [
136,
0
] | [
152,
67
] | python | en | ['en', 'en', 'en'] | True |
test_battery_charging | (hass, utcnow) | Test reading the state of a HomeKit battery's charging state. | Test reading the state of a HomeKit battery's charging state. | async def test_battery_charging(hass, utcnow):
"""Test reading the state of a HomeKit battery's charging state."""
helper = await setup_test_component(
hass, create_battery_level_sensor, suffix="battery"
)
helper.characteristics[BATTERY_LEVEL].value = 0
helper.characteristics[CHARGING_STATE... | [
"async",
"def",
"test_battery_charging",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_battery_level_sensor",
",",
"suffix",
"=",
"\"battery\"",
")",
"helper",
".",
"characteristics",
"[",
"BATTERY_... | [
155,
0
] | [
168,
64
] | python | en | ['en', 'en', 'en'] | True |
test_battery_low | (hass, utcnow) | Test reading the state of a HomeKit battery's low state. | Test reading the state of a HomeKit battery's low state. | async def test_battery_low(hass, utcnow):
"""Test reading the state of a HomeKit battery's low state."""
helper = await setup_test_component(
hass, create_battery_level_sensor, suffix="battery"
)
helper.characteristics[LO_BATT].value = 0
helper.characteristics[BATTERY_LEVEL].value = 1
s... | [
"async",
"def",
"test_battery_low",
"(",
"hass",
",",
"utcnow",
")",
":",
"helper",
"=",
"await",
"setup_test_component",
"(",
"hass",
",",
"create_battery_level_sensor",
",",
"suffix",
"=",
"\"battery\"",
")",
"helper",
".",
"characteristics",
"[",
"LO_BATT",
"... | [
171,
0
] | [
184,
58
] | python | en | ['en', 'en', 'en'] | True |
load_smt_fixture | (name) | Return a dict of the json fixture. | Return a dict of the json fixture. | def load_smt_fixture(name):
"""Return a dict of the json fixture."""
json_fixture = load_fixture(Path() / DOMAIN / f"{name}.json")
return json.loads(json_fixture) | [
"def",
"load_smt_fixture",
"(",
"name",
")",
":",
"json_fixture",
"=",
"load_fixture",
"(",
"Path",
"(",
")",
"/",
"DOMAIN",
"/",
"f\"{name}.json\"",
")",
"return",
"json",
".",
"loads",
"(",
"json_fixture",
")"
] | [
28,
0
] | [
31,
35
] | python | en | ['en', 'en', 'en'] | True |
setup_integration | (hass, config_entry, aioclient_mock, **kwargs) | Initialize the Smart Meter Texas integration for testing. | Initialize the Smart Meter Texas integration for testing. | async def setup_integration(hass, config_entry, aioclient_mock, **kwargs):
"""Initialize the Smart Meter Texas integration for testing."""
mock_connection(aioclient_mock, **kwargs)
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done() | [
"async",
"def",
"setup_integration",
"(",
"hass",
",",
"config_entry",
",",
"aioclient_mock",
",",
"*",
"*",
"kwargs",
")",
":",
"mock_connection",
"(",
"aioclient_mock",
",",
"*",
"*",
"kwargs",
")",
"await",
"hass",
".",
"config_entries",
".",
"async_setup",... | [
34,
0
] | [
38,
38
] | python | en | ['en', 'en', 'en'] | True |
refresh_data | (hass, config_entry, aioclient_mock) | Request a DataUpdateCoordinator refresh. | Request a DataUpdateCoordinator refresh. | async def refresh_data(hass, config_entry, aioclient_mock):
"""Request a DataUpdateCoordinator refresh."""
mock_connection(aioclient_mock)
await async_setup_component(hass, HA_DOMAIN, {})
await hass.services.async_call(
HA_DOMAIN,
SERVICE_UPDATE_ENTITY,
{ATTR_ENTITY_ID: TEST_ENTI... | [
"async",
"def",
"refresh_data",
"(",
"hass",
",",
"config_entry",
",",
"aioclient_mock",
")",
":",
"mock_connection",
"(",
"aioclient_mock",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"HA_DOMAIN",
",",
"{",
"}",
")",
"await",
"hass",
".",
"servic... | [
41,
0
] | [
51,
38
] | python | en | ['en', 'de', 'en'] | True |
mock_connection | (
aioclient_mock, auth_fail=False, auth_timeout=False, bad_reading=False
) | Mock all calls to the API. | Mock all calls to the API. | def mock_connection(
aioclient_mock, auth_fail=False, auth_timeout=False, bad_reading=False
):
"""Mock all calls to the API."""
aioclient_mock.get(BASE_URL)
auth_endpoint = f"{BASE_ENDPOINT}{AUTH_ENDPOINT}"
if not auth_fail and not auth_timeout:
aioclient_mock.post(
auth_endpoin... | [
"def",
"mock_connection",
"(",
"aioclient_mock",
",",
"auth_fail",
"=",
"False",
",",
"auth_timeout",
"=",
"False",
",",
"bad_reading",
"=",
"False",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"BASE_URL",
")",
"auth_endpoint",
"=",
"f\"{BASE_ENDPOINT}{AUTH_ENDPO... | [
54,
0
] | [
89,
9
] | python | en | ['en', 'en', 'en'] | True |
mock_config_entry | (hass) | Return a mock config entry. | Return a mock config entry. | def mock_config_entry(hass):
"""Return a mock config entry."""
config_entry = MockConfigEntry(
domain=DOMAIN,
unique_id="user123",
data={"username": "user123", "password": "password123"},
)
config_entry.add_to_hass(hass)
return config_entry | [
"def",
"mock_config_entry",
"(",
"hass",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"\"user123\"",
",",
"data",
"=",
"{",
"\"username\"",
":",
"\"user123\"",
",",
"\"password\"",
":",
"\"password123\"",... | [
93,
0
] | [
102,
23
] | python | en | ['en', 'cy', 'en'] | True |
DN3ataset.__init__ | (self) |
Base class for that specifies the interface for DN3 datasets.
|
Base class for that specifies the interface for DN3 datasets.
| def __init__(self):
"""
Base class for that specifies the interface for DN3 datasets.
"""
self._transforms = list()
self._safe_mode = False
self._mutli_proc_start = None
self._mutli_proc_end = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"_transforms",
"=",
"list",
"(",
")",
"self",
".",
"_safe_mode",
"=",
"False",
"self",
".",
"_mutli_proc_start",
"=",
"None",
"self",
".",
"_mutli_proc_end",
"=",
"None"
] | [
21,
4
] | [
28,
35
] | python | en | ['en', 'error', 'th'] | False |
DN3ataset.sfreq | (self) |
Returns
-------
sampling_frequency: float, list
The sampling frequencies employed by the dataset.
|
Returns
-------
sampling_frequency: float, list
The sampling frequencies employed by the dataset.
| def sfreq(self):
"""
Returns
-------
sampling_frequency: float, list
The sampling frequencies employed by the dataset.
"""
raise NotImplementedError | [
"def",
"sfreq",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
37,
4
] | [
44,
33
] | python | en | ['en', 'error', 'th'] | False |
DN3ataset.channels | (self) |
Returns
-------
channels: list
The channel sets used by the dataset.
|
Returns
-------
channels: list
The channel sets used by the dataset.
| def channels(self):
"""
Returns
-------
channels: list
The channel sets used by the dataset.
"""
raise NotImplementedError | [
"def",
"channels",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
47,
4
] | [
54,
33
] | python | en | ['en', 'error', 'th'] | False |
DN3ataset.sequence_length | (self) |
Returns
-------
sequence_length: int, list
The length of each instance in number of samples
|
Returns
-------
sequence_length: int, list
The length of each instance in number of samples
| def sequence_length(self):
"""
Returns
-------
sequence_length: int, list
The length of each instance in number of samples
"""
raise NotImplementedError | [
"def",
"sequence_length",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
57,
4
] | [
64,
33
] | python | en | ['en', 'error', 'th'] | False |
DN3ataset.clone | (self) |
A copy of this object to allow the repetition of recordings, thinkers, etc. that load data from
the same memory/files but have their own tracking of ids.
Returns
-------
cloned : DN3ataset
New copy of this object.
|
A copy of this object to allow the repetition of recordings, thinkers, etc. that load data from
the same memory/files but have their own tracking of ids. | def clone(self):
"""
A copy of this object to allow the repetition of recordings, thinkers, etc. that load data from
the same memory/files but have their own tracking of ids.
Returns
-------
cloned : DN3ataset
New copy of this object.
"""
... | [
"def",
"clone",
"(",
"self",
")",
":",
"return",
"copy",
".",
"deepcopy",
"(",
"self",
")"
] | [
66,
4
] | [
76,
34
] | python | en | ['en', 'error', 'th'] | False |
DN3ataset.add_transform | (self, transform) |
Add a transformation that is applied to every fetched item in the dataset
Parameters
----------
transform : BaseTransform
For each item retrieved by __getitem__, transform is called to modify that item.
|
Add a transformation that is applied to every fetched item in the dataset | def add_transform(self, transform):
"""
Add a transformation that is applied to every fetched item in the dataset
Parameters
----------
transform : BaseTransform
For each item retrieved by __getitem__, transform is called to modify that item.
"""
... | [
"def",
"add_transform",
"(",
"self",
",",
"transform",
")",
":",
"if",
"isinstance",
"(",
"transform",
",",
"InstanceTransform",
")",
":",
"self",
".",
"_transforms",
".",
"append",
"(",
"transform",
")"
] | [
78,
4
] | [
88,
46
] | python | en | ['en', 'error', 'th'] | False |
DN3ataset.clear_transforms | (self) |
Remove all added transforms from dataset.
|
Remove all added transforms from dataset.
| def clear_transforms(self):
"""
Remove all added transforms from dataset.
"""
self._transforms = list() | [
"def",
"clear_transforms",
"(",
"self",
")",
":",
"self",
".",
"_transforms",
"=",
"list",
"(",
")"
] | [
109,
4
] | [
113,
33
] | python | en | ['en', 'error', 'th'] | False |
DN3ataset.preprocess | (self, preprocessor: Preprocessor, apply_transform=True) |
Applies a preprocessor to the dataset
Parameters
----------
preprocessor : Preprocessor
A preprocessor to be applied
apply_transform : bool
Whether to apply the transform to this dataset (and all members e.g thinkers or sessions)... |
Applies a preprocessor to the dataset | def preprocess(self, preprocessor: Preprocessor, apply_transform=True):
"""
Applies a preprocessor to the dataset
Parameters
----------
preprocessor : Preprocessor
A preprocessor to be applied
apply_transform : bool
Whethe... | [
"def",
"preprocess",
"(",
"self",
",",
"preprocessor",
":",
"Preprocessor",
",",
"apply_transform",
"=",
"True",
")",
":",
"raise",
"NotImplementedError"
] | [
115,
4
] | [
133,
33
] | python | en | ['en', 'error', 'th'] | False |
DN3ataset.to_numpy | (self, batch_size=64, batch_transforms: list = None, num_workers=4, **dataloader_kwargs) |
Commits the dataset to numpy-formatted arrays. Useful for saving dataset to disk, or preparing for tools that
expect numpy-formatted data rather than iteratable.
Notes
-----
A pytorch :any:`DataLoader` is used to fetch the data to conveniently leverage multiprocessing, and natu... |
Commits the dataset to numpy-formatted arrays. Useful for saving dataset to disk, or preparing for tools that
expect numpy-formatted data rather than iteratable. | def to_numpy(self, batch_size=64, batch_transforms: list = None, num_workers=4, **dataloader_kwargs):
"""
Commits the dataset to numpy-formatted arrays. Useful for saving dataset to disk, or preparing for tools that
expect numpy-formatted data rather than iteratable.
Notes
-----... | [
"def",
"to_numpy",
"(",
"self",
",",
"batch_size",
"=",
"64",
",",
"batch_transforms",
":",
"list",
"=",
"None",
",",
"num_workers",
"=",
"4",
",",
"*",
"*",
"dataloader_kwargs",
")",
":",
"dataloader_kwargs",
".",
"setdefault",
"(",
"'batch_size'",
",",
"... | [
135,
4
] | [
180,
21
] | python | en | ['en', 'error', 'th'] | False |
RawTorchRecording.__init__ | (self, raw: mne.io.Raw, tlen, session_id=0, person_id=0, stride=1, ch_ind_picks=None, decimate=1,
bad_spans=None, **kwargs) |
Interface for bridging mne Raw instances as PyTorch compatible "Dataset".
Parameters
----------
raw : mne.io.Raw
Raw data, data does not need to be preloaded.
tlen : float
Length of each retrieved portion of the recording.
session_id : (int, ... |
Interface for bridging mne Raw instances as PyTorch compatible "Dataset". | def __init__(self, raw: mne.io.Raw, tlen, session_id=0, person_id=0, stride=1, ch_ind_picks=None, decimate=1,
bad_spans=None, **kwargs):
"""
Interface for bridging mne Raw instances as PyTorch compatible "Dataset".
Parameters
----------
raw : mne.io.Raw
... | [
"def",
"__init__",
"(",
"self",
",",
"raw",
":",
"mne",
".",
"io",
".",
"Raw",
",",
"tlen",
",",
"session_id",
"=",
"0",
",",
"person_id",
"=",
"0",
",",
"stride",
"=",
"1",
",",
"ch_ind_picks",
"=",
"None",
",",
"decimate",
"=",
"1",
",",
"bad_s... | [
244,
4
] | [
310,
37
] | python | en | ['en', 'error', 'th'] | False |
EpochTorchRecording.__init__ | (self, epochs: mne.Epochs, session_id=0, person_id=0, force_label=None, cached=False,
ch_ind_picks=None, event_mapping=None, skip_epochs=None) |
Wraps :any:`mne.Epochs` instances so that they conform to the :any:`Recording` API.
Parameters
----------
epochs
session_id
person_id
force_label : bool, Optional
Whether to force the labels provided by the epoch instance. By default (False... |
Wraps :any:`mne.Epochs` instances so that they conform to the :any:`Recording` API. | def __init__(self, epochs: mne.Epochs, session_id=0, person_id=0, force_label=None, cached=False,
ch_ind_picks=None, event_mapping=None, skip_epochs=None):
"""
Wraps :any:`mne.Epochs` instances so that they conform to the :any:`Recording` API.
Parameters
----------
... | [
"def",
"__init__",
"(",
"self",
",",
"epochs",
":",
"mne",
".",
"Epochs",
",",
"session_id",
"=",
"0",
",",
"person_id",
"=",
"0",
",",
"force_label",
"=",
"None",
",",
"cached",
"=",
"False",
",",
"ch_ind_picks",
"=",
"None",
",",
"event_mapping",
"="... | [
350,
4
] | [
385,
78
] | python | en | ['en', 'error', 'th'] | False |
EpochTorchRecording.event_mapping | (self) |
Maps the labels returned by this to the events as recorded in the original annotations or stim channel.
Returns
-------
mapping : dict
Keys are the class labels used by this object, values are the original event signifier.
|
Maps the labels returned by this to the events as recorded in the original annotations or stim channel. | def event_mapping(self):
"""
Maps the labels returned by this to the events as recorded in the original annotations or stim channel.
Returns
-------
mapping : dict
Keys are the class labels used by this object, values are the original event signifier.
"... | [
"def",
"event_mapping",
"(",
"self",
")",
":",
"return",
"self",
".",
"epoch_codes_to_class_labels"
] | [
417,
4
] | [
426,
47
] | python | en | ['en', 'error', 'th'] | False |
Thinker.__init__ | (self, sessions, person_id="auto", return_session_id=False, return_trial_id=False,
propagate_kwargs=False) |
Collects multiple recordings of the same person, intended to be of the same task, at different times or
conditions.
Parameters
----------
sessions : Iterable, dict
Either a sequence of recordings, or a mapping of session_ids to recordings. If the former, the
... |
Collects multiple recordings of the same person, intended to be of the same task, at different times or
conditions. | def __init__(self, sessions, person_id="auto", return_session_id=False, return_trial_id=False,
propagate_kwargs=False):
"""
Collects multiple recordings of the same person, intended to be of the same task, at different times or
conditions.
Parameters
----------
... | [
"def",
"__init__",
"(",
"self",
",",
"sessions",
",",
"person_id",
"=",
"\"auto\"",
",",
"return_session_id",
"=",
"False",
",",
"return_trial_id",
"=",
"False",
",",
"propagate_kwargs",
"=",
"False",
")",
":",
"DN3ataset",
".",
"__init__",
"(",
"self",
")",... | [
438,
4
] | [
477,
46
] | python | en | ['en', 'error', 'th'] | False |
Thinker.split | (self, training_sess_ids=None, validation_sess_ids=None, testing_sess_ids=None, test_frac=0.25,
validation_frac=0.25) |
Split the thinker's data into training, validation and testing sets.
Parameters
----------
test_frac : float
Proportion of the total data to use for testing, this is overridden by `testing_sess_ids`.
validation_frac : float
Proporti... |
Split the thinker's data into training, validation and testing sets. | def split(self, training_sess_ids=None, validation_sess_ids=None, testing_sess_ids=None, test_frac=0.25,
validation_frac=0.25):
"""
Split the thinker's data into training, validation and testing sets.
Parameters
----------
test_frac : float
Prop... | [
"def",
"split",
"(",
"self",
",",
"training_sess_ids",
"=",
"None",
",",
"validation_sess_ids",
"=",
"None",
",",
"testing_sess_ids",
"=",
"None",
",",
"test_frac",
"=",
"0.25",
",",
"validation_frac",
"=",
"0.25",
")",
":",
"training_sess_ids",
"=",
"set",
... | [
560,
4
] | [
618,
44
] | python | en | ['en', 'error', 'th'] | False |
Thinker.preprocess | (self, preprocessor: Preprocessor, apply_transform=True, sessions=None) |
Applies a preprocessor to the dataset
Parameters
----------
preprocessor : Preprocessor
A preprocessor to be applied
sessions : (None, Iterable)
If specified (default is None), the sessions to use for preprocessing calculation
a... |
Applies a preprocessor to the dataset | def preprocess(self, preprocessor: Preprocessor, apply_transform=True, sessions=None):
"""
Applies a preprocessor to the dataset
Parameters
----------
preprocessor : Preprocessor
A preprocessor to be applied
sessions : (None, Iterable)
... | [
"def",
"preprocess",
"(",
"self",
",",
"preprocessor",
":",
"Preprocessor",
",",
"apply_transform",
"=",
"True",
",",
"sessions",
"=",
"None",
")",
":",
"sessions",
"=",
"list",
"(",
"self",
".",
"sessions",
".",
"values",
"(",
")",
")",
"if",
"sessions"... | [
620,
4
] | [
646,
27
] | python | en | ['en', 'error', 'th'] | False |
Thinker.get_targets | (self) |
Collect all the targets (i.e. labels) that this Thinker's data is annotated with.
Returns
-------
targets: np.ndarray
A numpy-formatted array of all the targets/label for this thinker.
|
Collect all the targets (i.e. labels) that this Thinker's data is annotated with. | def get_targets(self):
"""
Collect all the targets (i.e. labels) that this Thinker's data is annotated with.
Returns
-------
targets: np.ndarray
A numpy-formatted array of all the targets/label for this thinker.
"""
targets = list()
for s... | [
"def",
"get_targets",
"(",
"self",
")",
":",
"targets",
"=",
"list",
"(",
")",
"for",
"sess",
"in",
"self",
".",
"sessions",
":",
"if",
"hasattr",
"(",
"self",
".",
"sessions",
"[",
"sess",
"]",
",",
"'get_targets'",
")",
":",
"targets",
".",
"append... | [
657,
4
] | [
672,
38
] | python | en | ['en', 'error', 'th'] | False |
Dataset.__init__ | (self, thinkers, dataset_id=None, task_id=None, return_trial_id=False, return_session_id=False,
return_person_id=False, return_dataset_id=False, return_task_id=False, dataset_info=None) |
Collects recordings from multiple people, intended to be of the same task, at different times or
conditions.
Optionally, can specify whether to return person, session, dataset and task labels. Person and session ids will
be converted to an enumerated set of integer ids, rather than thos... |
Collects recordings from multiple people, intended to be of the same task, at different times or
conditions.
Optionally, can specify whether to return person, session, dataset and task labels. Person and session ids will
be converted to an enumerated set of integer ids, rather than thos... | def __init__(self, thinkers, dataset_id=None, task_id=None, return_trial_id=False, return_session_id=False,
return_person_id=False, return_dataset_id=False, return_task_id=False, dataset_info=None):
"""
Collects recordings from multiple people, intended to be of the same task, at differ... | [
"def",
"__init__",
"(",
"self",
",",
"thinkers",
",",
"dataset_id",
"=",
"None",
",",
"task_id",
"=",
"None",
",",
"return_trial_id",
"=",
"False",
",",
"return_session_id",
"=",
"False",
",",
"return_person_id",
"=",
"False",
",",
"return_dataset_id",
"=",
... | [
699,
4
] | [
763,
119
] | python | en | ['en', 'error', 'th'] | False |
Dataset.update_id_returns | (self, trial=None, session=None, person=None, task=None, dataset=None) |
Updates which ids are to be returned by the dataset. If any argument is `None` it preserves the previous value.
Parameters
----------
trial : None, bool
Whether to return trial ids.
session : None, bool
Whether to return session ids.
... |
Updates which ids are to be returned by the dataset. If any argument is `None` it preserves the previous value. | def update_id_returns(self, trial=None, session=None, person=None, task=None, dataset=None):
"""
Updates which ids are to be returned by the dataset. If any argument is `None` it preserves the previous value.
Parameters
----------
trial : None, bool
Whether to ... | [
"def",
"update_id_returns",
"(",
"self",
",",
"trial",
"=",
"None",
",",
"session",
"=",
"None",
",",
"person",
"=",
"None",
",",
"task",
"=",
"None",
",",
"dataset",
"=",
"None",
")",
":",
"self",
".",
"return_trial_id",
"=",
"self",
".",
"return_tria... | [
765,
4
] | [
790,
41
] | python | en | ['en', 'error', 'th'] | False |
Dataset.safe_mode | (self, mode=True) |
This allows switching *safe_mode* on or off. When safe_mode is on, if data is ever NaN, it is captured
before being returned and a report is generated.
Parameters
----------
mode : bool
The status of whether in safe mode or not.
|
This allows switching *safe_mode* on or off. When safe_mode is on, if data is ever NaN, it is captured
before being returned and a report is generated. | def safe_mode(self, mode=True):
"""
This allows switching *safe_mode* on or off. When safe_mode is on, if data is ever NaN, it is captured
before being returned and a report is generated.
Parameters
----------
mode : bool
The status of whether in safe mode o... | [
"def",
"safe_mode",
"(",
"self",
",",
"mode",
"=",
"True",
")",
":",
"self",
".",
"_safe_mode",
"=",
"mode"
] | [
865,
4
] | [
875,
30
] | python | en | ['en', 'error', 'th'] | False |
Dataset.preprocess | (self, preprocessor: Preprocessor, apply_transform=True, thinkers=None) |
Applies a preprocessor to the dataset
Parameters
----------
preprocessor : Preprocessor
A preprocessor to be applied
thinkers : (None, Iterable)
If specified (default is None), the thinkers to use for preprocessing calculation
a... |
Applies a preprocessor to the dataset | def preprocess(self, preprocessor: Preprocessor, apply_transform=True, thinkers=None):
"""
Applies a preprocessor to the dataset
Parameters
----------
preprocessor : Preprocessor
A preprocessor to be applied
thinkers : (None, Iterable)
... | [
"def",
"preprocess",
"(",
"self",
",",
"preprocessor",
":",
"Preprocessor",
",",
"apply_transform",
"=",
"True",
",",
"thinkers",
"=",
"None",
")",
":",
"thinkers",
"=",
"self",
".",
"get_thinkers",
"(",
")",
"if",
"thinkers",
"is",
"None",
"else",
"thinke... | [
877,
4
] | [
903,
27
] | python | en | ['en', 'error', 'th'] | False |
Dataset.get_thinkers | (self) |
Accumulates a consistently ordered list of all the thinkers in the dataset. It is this order that any automatic
segmenting through :py:meth:`loso()` and :py:meth:`lmso()` will be done.
Returns
-------
thinker_names : list
|
Accumulates a consistently ordered list of all the thinkers in the dataset. It is this order that any automatic
segmenting through :py:meth:`loso()` and :py:meth:`lmso()` will be done. | def get_thinkers(self):
"""
Accumulates a consistently ordered list of all the thinkers in the dataset. It is this order that any automatic
segmenting through :py:meth:`loso()` and :py:meth:`lmso()` will be done.
Returns
-------
thinker_names : list
"""
r... | [
"def",
"get_thinkers",
"(",
"self",
")",
":",
"return",
"list",
"(",
"self",
".",
"thinkers",
".",
"keys",
"(",
")",
")"
] | [
937,
4
] | [
946,
41
] | python | en | ['en', 'error', 'th'] | False |
Dataset.get_sessions | (self) |
Accumulates all the sessions from each thinker in the dataset in a nested dictionary.
Returns
-------
session_dict: dict
Keys are the thinkers of :py:meth:`get_thinkers()`, values are each another dictionary that maps
session ids to :any:`_Re... |
Accumulates all the sessions from each thinker in the dataset in a nested dictionary. | def get_sessions(self):
"""
Accumulates all the sessions from each thinker in the dataset in a nested dictionary.
Returns
-------
session_dict: dict
Keys are the thinkers of :py:meth:`get_thinkers()`, values are each another dictionary that maps
... | [
"def",
"get_sessions",
"(",
"self",
")",
":",
"return",
"{",
"th",
":",
"self",
".",
"thinkers",
"[",
"th",
"]",
".",
"sessions",
".",
"copy",
"(",
")",
"for",
"th",
"in",
"self",
".",
"thinkers",
"}"
] | [
948,
4
] | [
958,
78
] | python | en | ['en', 'error', 'th'] | False |
Dataset.loso | (self, validation_person_id=None, test_person_id=None) |
This *generates* a "Leave-one-subject-out" (LOSO) split. Tests each person one-by-one, and validates on the
previous (the first is validated with the last).
Parameters
----------
validation_person_id : (int, str, list, optional)
If specified, and ... |
This *generates* a "Leave-one-subject-out" (LOSO) split. Tests each person one-by-one, and validates on the
previous (the first is validated with the last). | def loso(self, validation_person_id=None, test_person_id=None):
"""
This *generates* a "Leave-one-subject-out" (LOSO) split. Tests each person one-by-one, and validates on the
previous (the first is validated with the last).
Parameters
----------
validation_person_id : (... | [
"def",
"loso",
"(",
"self",
",",
"validation_person_id",
"=",
"None",
",",
"test_person_id",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"test_person_id",
",",
"(",
"str",
",",
"int",
")",
")",
"and",
"isinstance",
"(",
"validation_person_id",
",",
"("... | [
1004,
4
] | [
1053,
108
] | python | en | ['en', 'error', 'th'] | False |
Dataset.lmso | (self, folds=10, test_splits=None, validation_splits=None) |
This *generates* a "Leave-multiple-subject-out" (LMSO) split. In other words X-fold cross-validation, with
boundaries enforced at thinkers (each person's data is not split into different folds).
Parameters
----------
folds : int
If this is specified and `splits`... |
This *generates* a "Leave-multiple-subject-out" (LMSO) split. In other words X-fold cross-validation, with
boundaries enforced at thinkers (each person's data is not split into different folds). | def lmso(self, folds=10, test_splits=None, validation_splits=None):
"""
This *generates* a "Leave-multiple-subject-out" (LMSO) split. In other words X-fold cross-validation, with
boundaries enforced at thinkers (each person's data is not split into different folds).
Parameters
-... | [
"def",
"lmso",
"(",
"self",
",",
"folds",
"=",
"10",
",",
"test_splits",
"=",
"None",
",",
"validation_splits",
"=",
"None",
")",
":",
"def",
"is_nested",
"(",
"split",
":",
"list",
")",
":",
"should_be_nested",
"=",
"isinstance",
"(",
"split",
"[",
"0... | [
1055,
4
] | [
1108,
72
] | python | en | ['en', 'error', 'th'] | False |
Dataset.get_targets | (self) |
Collect all the targets (i.e. labels) that this Thinker's data is annotated with.
Returns
-------
targets: np.ndarray
A numpy-formatted array of all the targets/label for this thinker.
|
Collect all the targets (i.e. labels) that this Thinker's data is annotated with. | def get_targets(self):
"""
Collect all the targets (i.e. labels) that this Thinker's data is annotated with.
Returns
-------
targets: np.ndarray
A numpy-formatted array of all the targets/label for this thinker.
"""
targets = list()
for t... | [
"def",
"get_targets",
"(",
"self",
")",
":",
"targets",
"=",
"list",
"(",
")",
"for",
"tid",
"in",
"self",
".",
"thinkers",
":",
"if",
"hasattr",
"(",
"self",
".",
"thinkers",
"[",
"tid",
"]",
",",
"'get_targets'",
")",
":",
"targets",
".",
"append",... | [
1116,
4
] | [
1135,
23
] | python | en | ['en', 'error', 'th'] | False |
Dataset.dump_dataset | (self, toplevel, compressed=True, apply_transforms=True, summary_file='dataset-dump.npz',
chunksize=100) |
Dumps the dataset to the directory specified by toplevel, with a single file per index.
Parameters
----------
toplevel : str
The toplevel location to dump the dataset to. This folder (and path) will be created if it does not
exist.
apply_transf... |
Dumps the dataset to the directory specified by toplevel, with a single file per index. | def dump_dataset(self, toplevel, compressed=True, apply_transforms=True, summary_file='dataset-dump.npz',
chunksize=100):
"""
Dumps the dataset to the directory specified by toplevel, with a single file per index.
Parameters
----------
toplevel : str
... | [
"def",
"dump_dataset",
"(",
"self",
",",
"toplevel",
",",
"compressed",
"=",
"True",
",",
"apply_transforms",
"=",
"True",
",",
"summary_file",
"=",
"'dataset-dump.npz'",
",",
"chunksize",
"=",
"100",
")",
":",
"if",
"apply_transforms",
"is",
"False",
":",
"... | [
1137,
4
] | [
1175,
63
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the departure sensor. | Set up the departure sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the departure sensor."""
planner = vasttrafik.JournyPlanner(config.get(CONF_KEY), config.get(CONF_SECRET))
sensors = []
for departure in config.get(CONF_DEPARTURES):
sensors.append(
VasttrafikDepartureSe... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"planner",
"=",
"vasttrafik",
".",
"JournyPlanner",
"(",
"config",
".",
"get",
"(",
"CONF_KEY",
")",
",",
"config",
".",
"get",
"(",
"... | [
55,
0
] | [
72,
31
] | python | en | ['en', 'da', 'en'] | True |
VasttrafikDepartureSensor.__init__ | (self, planner, name, departure, heading, lines, delay) | Initialize the sensor. | Initialize the sensor. | def __init__(self, planner, name, departure, heading, lines, delay):
"""Initialize the sensor."""
self._planner = planner
self._name = name or departure
self._departure = self.get_station_id(departure)
self._heading = self.get_station_id(heading) if heading else None
self... | [
"def",
"__init__",
"(",
"self",
",",
"planner",
",",
"name",
",",
"departure",
",",
"heading",
",",
"lines",
",",
"delay",
")",
":",
"self",
".",
"_planner",
"=",
"planner",
"self",
".",
"_name",
"=",
"name",
"or",
"departure",
"self",
".",
"_departure... | [
78,
4
] | [
88,
31
] | python | en | ['en', 'en', 'en'] | True |
VasttrafikDepartureSensor.get_station_id | (self, location) | Get the station ID. | Get the station ID. | def get_station_id(self, location):
"""Get the station ID."""
if location.isdecimal():
station_info = {"station_name": location, "station_id": location}
else:
station_id = self._planner.location_name(location)[0]["id"]
station_info = {"station_name": location,... | [
"def",
"get_station_id",
"(",
"self",
",",
"location",
")",
":",
"if",
"location",
".",
"isdecimal",
"(",
")",
":",
"station_info",
"=",
"{",
"\"station_name\"",
":",
"location",
",",
"\"station_id\"",
":",
"location",
"}",
"else",
":",
"station_id",
"=",
... | [
90,
4
] | [
97,
27
] | python | en | ['en', 'en', 'en'] | True |
VasttrafikDepartureSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
100,
4
] | [
102,
25
] | python | en | ['en', 'mi', 'en'] | True |
VasttrafikDepartureSensor.icon | (self) | Return the icon for the frontend. | Return the icon for the frontend. | def icon(self):
"""Return the icon for the frontend."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
105,
4
] | [
107,
19
] | python | en | ['en', 'en', 'en'] | True |
VasttrafikDepartureSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attributes"
] | [
110,
4
] | [
112,
31
] | python | en | ['en', 'en', 'en'] | True |
VasttrafikDepartureSensor.state | (self) | Return the next departure time. | Return the next departure time. | def state(self):
"""Return the next departure time."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
115,
4
] | [
117,
26
] | python | en | ['en', 'en', 'en'] | True |
VasttrafikDepartureSensor.update | (self) | Get the departure board. | Get the departure board. | def update(self):
"""Get the departure board."""
try:
self._departureboard = self._planner.departureboard(
self._departure["station_id"],
direction=self._heading["station_id"] if self._heading else None,
date=now() + self._delay,
)
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_departureboard",
"=",
"self",
".",
"_planner",
".",
"departureboard",
"(",
"self",
".",
"_departure",
"[",
"\"station_id\"",
"]",
",",
"direction",
"=",
"self",
".",
"_heading",
"[",
"\"s... | [
120,
4
] | [
160,
25
] | python | en | ['en', 'en', 'en'] | True |
convert_state_dict_from_pt | (model_class: ABC, state: Dict, config: PretrainedConfig) |
Converts a PyTorch parameter state dict to an equivalent Flax parameter state dict
|
Converts a PyTorch parameter state dict to an equivalent Flax parameter state dict
| def convert_state_dict_from_pt(model_class: ABC, state: Dict, config: PretrainedConfig):
"""
Converts a PyTorch parameter state dict to an equivalent Flax parameter state dict
"""
state = {k: v.numpy() for k, v in state.items()}
state = model_class.convert_from_pytorch(state, config)
state = unf... | [
"def",
"convert_state_dict_from_pt",
"(",
"model_class",
":",
"ABC",
",",
"state",
":",
"Dict",
",",
"config",
":",
"PretrainedConfig",
")",
":",
"state",
"=",
"{",
"k",
":",
"v",
".",
"numpy",
"(",
")",
"for",
"k",
",",
"v",
"in",
"state",
".",
"ite... | [
397,
0
] | [
404,
16
] | python | en | ['en', 'error', 'th'] | False |
FlaxPreTrainedModel.from_pretrained | (
cls,
pretrained_model_name_or_path: Union[str, os.PathLike],
dtype: jnp.dtype = jnp.float32,
*model_args,
**kwargs
) | r"""
Instantiate a pretrained flax model from a pre-trained model configuration.
The warning `Weights from XXX not initialized from pretrained model` means that the weights of XXX do not come
pretrained with the rest of the model. It is up to you to train those weights with a downstream fine-tu... | r"""
Instantiate a pretrained flax model from a pre-trained model configuration. | def from_pretrained(
cls,
pretrained_model_name_or_path: Union[str, os.PathLike],
dtype: jnp.dtype = jnp.float32,
*model_args,
**kwargs
):
r"""
Instantiate a pretrained flax model from a pre-trained model configuration.
The warning `Weights from XXX ... | [
"def",
"from_pretrained",
"(",
"cls",
",",
"pretrained_model_name_or_path",
":",
"Union",
"[",
"str",
",",
"os",
".",
"PathLike",
"]",
",",
"dtype",
":",
"jnp",
".",
"dtype",
"=",
"jnp",
".",
"float32",
",",
"*",
"model_args",
",",
"*",
"*",
"kwargs",
... | [
129,
4
] | [
370,
20
] | python | cy | ['en', 'cy', 'hi'] | False |
FlaxPreTrainedModel.save_pretrained | (self, save_directory: Union[str, os.PathLike]) |
Save a model and its configuration file to a directory, so that it can be re-loaded using the
`:func:`~transformers.FlaxPreTrainedModel.from_pretrained`` class method
Arguments:
save_directory (:obj:`str` or :obj:`os.PathLike`):
Directory to which to save. Will be c... |
Save a model and its configuration file to a directory, so that it can be re-loaded using the
`:func:`~transformers.FlaxPreTrainedModel.from_pretrained`` class method | def save_pretrained(self, save_directory: Union[str, os.PathLike]):
"""
Save a model and its configuration file to a directory, so that it can be re-loaded using the
`:func:`~transformers.FlaxPreTrainedModel.from_pretrained`` class method
Arguments:
save_directory (:obj:`str... | [
"def",
"save_pretrained",
"(",
"self",
",",
"save_directory",
":",
"Union",
"[",
"str",
",",
"os",
".",
"PathLike",
"]",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"save_directory",
")",
":",
"logger",
".",
"error",
"(",
"\"Provided path ({})... | [
372,
4
] | [
394,
32
] | python | en | ['en', 'error', 'th'] | False |
test_nightlight | (hass: HomeAssistant) | Test nightlight sensor. | Test nightlight sensor. | async def test_nightlight(hass: HomeAssistant):
"""Test nightlight sensor."""
mocked_bulb = _mocked_bulb()
with patch(f"{MODULE}.Bulb", return_value=mocked_bulb), patch(
f"{MODULE}.config_flow.yeelight.Bulb", return_value=mocked_bulb
):
await async_setup_component(hass, DOMAIN, YAML_CONF... | [
"async",
"def",
"test_nightlight",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"mocked_bulb",
"=",
"_mocked_bulb",
"(",
")",
"with",
"patch",
"(",
"f\"{MODULE}.Bulb\"",
",",
"return_value",
"=",
"mocked_bulb",
")",
",",
"patch",
"(",
"f\"{MODULE}.config_flow.yeel... | [
13,
0
] | [
35,
63
] | python | en | ['en', 'sv', 'en'] | True |
test_platform_manually_configured | (hass) | Test that we do not discover anything or try to set up a gateway. | Test that we do not discover anything or try to set up a gateway. | async def test_platform_manually_configured(hass):
"""Test that we do not discover anything or try to set up a gateway."""
assert (
await async_setup_component(
hass, SENSOR_DOMAIN, {"sensor": {"platform": DECONZ_DOMAIN}}
)
is True
)
assert DECONZ_DOMAIN not in hass.d... | [
"async",
"def",
"test_platform_manually_configured",
"(",
"hass",
")",
":",
"assert",
"(",
"await",
"async_setup_component",
"(",
"hass",
",",
"SENSOR_DOMAIN",
",",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"DECONZ_DOMAIN",
"}",
"}",
")",
"is",
"True",
... | [
87,
0
] | [
95,
41
] | python | en | ['en', 'en', 'en'] | True |
test_no_sensors | (hass) | Test that no sensors in deconz results in no sensor entities. | Test that no sensors in deconz results in no sensor entities. | async def test_no_sensors(hass):
"""Test that no sensors in deconz results in no sensor entities."""
await setup_deconz_integration(hass)
assert len(hass.states.async_all()) == 0 | [
"async",
"def",
"test_no_sensors",
"(",
"hass",
")",
":",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"assert",
"len",
"(",
"hass",
".",
"states",
".",
"async_all",
"(",
")",
")",
"==",
"0"
] | [
98,
0
] | [
101,
44
] | python | en | ['en', 'en', 'en'] | True |
test_sensors | (hass) | Test successful creation of sensor entities. | Test successful creation of sensor entities. | async def test_sensors(hass):
"""Test successful creation of sensor entities."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["sensors"] = deepcopy(SENSORS)
config_entry = await setup_deconz_integration(hass, get_state_response=data)
gateway = get_gateway_from_config_entry(hass, config_entry)
asser... | [
"async",
"def",
"test_sensors",
"(",
"hass",
")",
":",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"sensors\"",
"]",
"=",
"deepcopy",
"(",
"SENSORS",
")",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
",",
... | [
104,
0
] | [
167,
44
] | python | en | ['en', 'en', 'en'] | True |
test_allow_clip_sensors | (hass) | Test that CLIP sensors can be allowed. | Test that CLIP sensors can be allowed. | async def test_allow_clip_sensors(hass):
"""Test that CLIP sensors can be allowed."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["sensors"] = deepcopy(SENSORS)
config_entry = await setup_deconz_integration(
hass,
options={CONF_ALLOW_CLIP_SENSOR: True},
get_state_response=data,
... | [
"async",
"def",
"test_allow_clip_sensors",
"(",
"hass",
")",
":",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"sensors\"",
"]",
"=",
"deepcopy",
"(",
"SENSORS",
")",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass... | [
170,
0
] | [
201,
60
] | python | en | ['en', 'en', 'en'] | True |
test_add_new_sensor | (hass) | Test that adding a new sensor works. | Test that adding a new sensor works. | async def test_add_new_sensor(hass):
"""Test that adding a new sensor works."""
config_entry = await setup_deconz_integration(hass)
gateway = get_gateway_from_config_entry(hass, config_entry)
assert len(hass.states.async_all()) == 0
state_added_event = {
"t": "event",
"e": "added",
... | [
"async",
"def",
"test_add_new_sensor",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"setup_deconz_integration",
"(",
"hass",
")",
"gateway",
"=",
"get_gateway_from_config_entry",
"(",
"hass",
",",
"config_entry",
")",
"assert",
"len",
"(",
"hass",
".",
"... | [
204,
0
] | [
221,
72
] | python | en | ['en', 'en', 'en'] | True |
test_add_battery_later | (hass) | Test that a sensor without an initial battery state creates a battery sensor once state exist. | Test that a sensor without an initial battery state creates a battery sensor once state exist. | async def test_add_battery_later(hass):
"""Test that a sensor without an initial battery state creates a battery sensor once state exist."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["sensors"] = {"1": deepcopy(SENSORS["3"])}
config_entry = await setup_deconz_integration(hass, get_state_response=data)
... | [
"async",
"def",
"test_add_battery_later",
"(",
"hass",
")",
":",
"data",
"=",
"deepcopy",
"(",
"DECONZ_WEB_REQUEST",
")",
"data",
"[",
"\"sensors\"",
"]",
"=",
"{",
"\"1\"",
":",
"deepcopy",
"(",
"SENSORS",
"[",
"\"3\"",
"]",
")",
"}",
"config_entry",
"=",... | [
224,
0
] | [
243,
59
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.