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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
XiaomiPlugGenericSwitch._try_command | (self, mask_error, func, *args, **kwargs) | Call a plug command handling error messages. | Call a plug command handling error messages. | async def _try_command(self, mask_error, func, *args, **kwargs):
"""Call a plug command handling error messages."""
try:
result = await self.hass.async_add_executor_job(
partial(func, *args, **kwargs)
)
_LOGGER.debug("Response received from plug: %s",... | [
"async",
"def",
"_try_command",
"(",
"self",
",",
"mask_error",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"result",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"partial",
"(",
"func",
",",
... | [
267,
4
] | [
286,
24
] | python | en | ['en', 'pt', 'en'] | True |
XiaomiPlugGenericSwitch.async_turn_on | (self, **kwargs) | Turn the plug on. | Turn the plug on. | async def async_turn_on(self, **kwargs):
"""Turn the plug on."""
result = await self._try_command("Turning the plug on failed.", self._plug.on)
if result:
self._state = True
self._skip_update = True | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the plug on failed.\"",
",",
"self",
".",
"_plug",
".",
"on",
")",
"if",
"result",
":",
"self",
".",
"_s... | [
288,
4
] | [
294,
36
] | python | en | ['en', 'et', 'en'] | True |
XiaomiPlugGenericSwitch.async_turn_off | (self, **kwargs) | Turn the plug off. | Turn the plug off. | async def async_turn_off(self, **kwargs):
"""Turn the plug off."""
result = await self._try_command("Turning the plug off failed.", self._plug.off)
if result:
self._state = False
self._skip_update = True | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the plug off failed.\"",
",",
"self",
".",
"_plug",
".",
"off",
")",
"if",
"result",
":",
"self",
".",
... | [
296,
4
] | [
302,
36
] | python | en | ['en', 'et', 'en'] | True |
XiaomiPlugGenericSwitch.async_update | (self) | Fetch state from the device. | Fetch state from the device. | async def async_update(self):
"""Fetch state from the device."""
# On state change the device doesn't provide the new state immediately.
if self._skip_update:
self._skip_update = False
return
try:
state = await self.hass.async_add_executor_job(self._p... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"# On state change the device doesn't provide the new state immediately.",
"if",
"self",
".",
"_skip_update",
":",
"self",
".",
"_skip_update",
"=",
"False",
"return",
"try",
":",
"state",
"=",
"await",
"self",
... | [
304,
4
] | [
322,
79
] | python | en | ['en', 'en', 'en'] | True |
XiaomiPlugGenericSwitch.async_set_wifi_led_on | (self) | Turn the wifi led on. | Turn the wifi led on. | async def async_set_wifi_led_on(self):
"""Turn the wifi led on."""
if self._device_features & FEATURE_SET_WIFI_LED == 0:
return
await self._try_command(
"Turning the wifi led on failed.", self._plug.set_wifi_led, True
) | [
"async",
"def",
"async_set_wifi_led_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_SET_WIFI_LED",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the wifi led on failed.\"",
",",
"self",
".",
"_plug... | [
324,
4
] | [
331,
9
] | python | en | ['en', 'en', 'en'] | True |
XiaomiPlugGenericSwitch.async_set_wifi_led_off | (self) | Turn the wifi led on. | Turn the wifi led on. | async def async_set_wifi_led_off(self):
"""Turn the wifi led on."""
if self._device_features & FEATURE_SET_WIFI_LED == 0:
return
await self._try_command(
"Turning the wifi led off failed.", self._plug.set_wifi_led, False
) | [
"async",
"def",
"async_set_wifi_led_off",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_SET_WIFI_LED",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the wifi led off failed.\"",
",",
"self",
".",
"_pl... | [
333,
4
] | [
340,
9
] | python | en | ['en', 'en', 'en'] | True |
XiaomiPlugGenericSwitch.async_set_power_price | (self, price: int) | Set the power price. | Set the power price. | async def async_set_power_price(self, price: int):
"""Set the power price."""
if self._device_features & FEATURE_SET_POWER_PRICE == 0:
return
await self._try_command(
"Setting the power price of the power strip failed.",
self._plug.set_power_price,
... | [
"async",
"def",
"async_set_power_price",
"(",
"self",
",",
"price",
":",
"int",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_SET_POWER_PRICE",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Setting the power price of the ... | [
342,
4
] | [
351,
9
] | python | en | ['en', 'lt', 'en'] | True |
XiaomiPowerStripSwitch.__init__ | (self, name, plug, model, unique_id) | Initialize the plug switch. | Initialize the plug switch. | def __init__(self, name, plug, model, unique_id):
"""Initialize the plug switch."""
super().__init__(name, plug, model, unique_id)
if self._model == MODEL_POWER_STRIP_V2:
self._device_features = FEATURE_FLAGS_POWER_STRIP_V2
else:
self._device_features = FEATURE_F... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"plug",
",",
"model",
",",
"unique_id",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"name",
",",
"plug",
",",
"model",
",",
"unique_id",
")",
"if",
"self",
".",
"_model",
"==",
"MODEL_POWER_STR... | [
357,
4
] | [
375,
54
] | python | en | ['en', 'pl', 'en'] | True |
XiaomiPowerStripSwitch.async_update | (self) | Fetch state from the device. | Fetch state from the device. | async def async_update(self):
"""Fetch state from the device."""
# On state change the device doesn't provide the new state immediately.
if self._skip_update:
self._skip_update = False
return
try:
state = await self.hass.async_add_executor_job(self._p... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"# On state change the device doesn't provide the new state immediately.",
"if",
"self",
".",
"_skip_update",
":",
"self",
".",
"_skip_update",
"=",
"False",
"return",
"try",
":",
"state",
"=",
"await",
"self",
... | [
377,
4
] | [
409,
79
] | python | en | ['en', 'en', 'en'] | True |
XiaomiPowerStripSwitch.async_set_power_mode | (self, mode: str) | Set the power mode. | Set the power mode. | async def async_set_power_mode(self, mode: str):
"""Set the power mode."""
if self._device_features & FEATURE_SET_POWER_MODE == 0:
return
await self._try_command(
"Setting the power mode of the power strip failed.",
self._plug.set_power_mode,
Powe... | [
"async",
"def",
"async_set_power_mode",
"(",
"self",
",",
"mode",
":",
"str",
")",
":",
"if",
"self",
".",
"_device_features",
"&",
"FEATURE_SET_POWER_MODE",
"==",
"0",
":",
"return",
"await",
"self",
".",
"_try_command",
"(",
"\"Setting the power mode of the powe... | [
411,
4
] | [
420,
9
] | python | en | ['en', 'pt', 'en'] | True |
ChuangMiPlugSwitch.__init__ | (self, name, plug, model, unique_id, channel_usb) | Initialize the plug switch. | Initialize the plug switch. | def __init__(self, name, plug, model, unique_id, channel_usb):
"""Initialize the plug switch."""
name = f"{name} USB" if channel_usb else name
if unique_id is not None and channel_usb:
unique_id = f"{unique_id}-usb"
super().__init__(name, plug, model, unique_id)
sel... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"plug",
",",
"model",
",",
"unique_id",
",",
"channel_usb",
")",
":",
"name",
"=",
"f\"{name} USB\"",
"if",
"channel_usb",
"else",
"name",
"if",
"unique_id",
"is",
"not",
"None",
"and",
"channel_usb",
":",
... | [
426,
4
] | [
440,
57
] | python | en | ['en', 'pl', 'en'] | True |
ChuangMiPlugSwitch.async_turn_on | (self, **kwargs) | Turn a channel on. | Turn a channel on. | async def async_turn_on(self, **kwargs):
"""Turn a channel on."""
if self._channel_usb:
result = await self._try_command(
"Turning the plug on failed.", self._plug.usb_on
)
else:
result = await self._try_command(
"Turning the pl... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_channel_usb",
":",
"result",
"=",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the plug on failed.\"",
",",
"self",
".",
"_plug",
".",
"usb_on",
... | [
442,
4
] | [
455,
36
] | python | en | ['it', 'en', 'en'] | True |
ChuangMiPlugSwitch.async_turn_off | (self, **kwargs) | Turn a channel off. | Turn a channel off. | async def async_turn_off(self, **kwargs):
"""Turn a channel off."""
if self._channel_usb:
result = await self._try_command(
"Turning the plug on failed.", self._plug.usb_off
)
else:
result = await self._try_command(
"Turning the... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_channel_usb",
":",
"result",
"=",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the plug on failed.\"",
",",
"self",
".",
"_plug",
".",
"usb_off",
... | [
457,
4
] | [
470,
36
] | python | en | ['en', 'en', 'en'] | True |
ChuangMiPlugSwitch.async_update | (self) | Fetch state from the device. | Fetch state from the device. | async def async_update(self):
"""Fetch state from the device."""
# On state change the device doesn't provide the new state immediately.
if self._skip_update:
self._skip_update = False
return
try:
state = await self.hass.async_add_executor_job(self._p... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"# On state change the device doesn't provide the new state immediately.",
"if",
"self",
".",
"_skip_update",
":",
"self",
".",
"_skip_update",
"=",
"False",
"return",
"try",
":",
"state",
"=",
"await",
"self",
... | [
472,
4
] | [
500,
79
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirConditioningCompanionSwitch.__init__ | (self, name, plug, model, unique_id) | Initialize the acpartner switch. | Initialize the acpartner switch. | def __init__(self, name, plug, model, unique_id):
"""Initialize the acpartner switch."""
super().__init__(name, plug, model, unique_id)
self._state_attrs.update({ATTR_TEMPERATURE: None, ATTR_LOAD_POWER: None}) | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"plug",
",",
"model",
",",
"unique_id",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"name",
",",
"plug",
",",
"model",
",",
"unique_id",
")",
"self",
".",
"_state_attrs",
".",
"update",
"(",
... | [
506,
4
] | [
510,
81
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirConditioningCompanionSwitch.async_turn_on | (self, **kwargs) | Turn the socket on. | Turn the socket on. | async def async_turn_on(self, **kwargs):
"""Turn the socket on."""
result = await self._try_command(
"Turning the socket on failed.", self._plug.socket_on
)
if result:
self._state = True
self._skip_update = True | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the socket on failed.\"",
",",
"self",
".",
"_plug",
".",
"socket_on",
")",
"if",
"result",
":",
"self",
"... | [
512,
4
] | [
520,
36
] | python | en | ['en', 'et', 'en'] | True |
XiaomiAirConditioningCompanionSwitch.async_turn_off | (self, **kwargs) | Turn the socket off. | Turn the socket off. | async def async_turn_off(self, **kwargs):
"""Turn the socket off."""
result = await self._try_command(
"Turning the socket off failed.", self._plug.socket_off
)
if result:
self._state = False
self._skip_update = True | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"await",
"self",
".",
"_try_command",
"(",
"\"Turning the socket off failed.\"",
",",
"self",
".",
"_plug",
".",
"socket_off",
")",
"if",
"result",
":",
"self",
... | [
522,
4
] | [
530,
36
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAirConditioningCompanionSwitch.async_update | (self) | Fetch state from the device. | Fetch state from the device. | async def async_update(self):
"""Fetch state from the device."""
# On state change the device doesn't provide the new state immediately.
if self._skip_update:
self._skip_update = False
return
try:
state = await self.hass.async_add_executor_job(self._p... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"# On state change the device doesn't provide the new state immediately.",
"if",
"self",
".",
"_skip_update",
":",
"self",
".",
"_skip_update",
"=",
"False",
"return",
"try",
":",
"state",
"=",
"await",
"self",
... | [
532,
4
] | [
550,
79
] | python | en | ['en', 'en', 'en'] | True |
is_valid_datetime | (string: str) | Test if string dt is a valid datetime. | Test if string dt is a valid datetime. | def is_valid_datetime(string: str) -> bool:
"""Test if string dt is a valid datetime."""
try:
return dt_util.parse_datetime(string) is not None
except ValueError:
return False | [
"def",
"is_valid_datetime",
"(",
"string",
":",
"str",
")",
"->",
"bool",
":",
"try",
":",
"return",
"dt_util",
".",
"parse_datetime",
"(",
"string",
")",
"is",
"not",
"None",
"except",
"ValueError",
":",
"return",
"False"
] | [
23,
0
] | [
28,
20
] | python | en | ['en', 'en', 'en'] | True |
is_valid_date | (string: str) | Test if string dt is a valid date. | Test if string dt is a valid date. | def is_valid_date(string: str) -> bool:
"""Test if string dt is a valid date."""
return dt_util.parse_date(string) is not None | [
"def",
"is_valid_date",
"(",
"string",
":",
"str",
")",
"->",
"bool",
":",
"return",
"dt_util",
".",
"parse_date",
"(",
"string",
")",
"is",
"not",
"None"
] | [
31,
0
] | [
33,
49
] | python | en | ['en', 'en', 'en'] | True |
is_valid_time | (string: str) | Test if string dt is a valid time. | Test if string dt is a valid time. | def is_valid_time(string: str) -> bool:
"""Test if string dt is a valid time."""
return dt_util.parse_time(string) is not None | [
"def",
"is_valid_time",
"(",
"string",
":",
"str",
")",
"->",
"bool",
":",
"return",
"dt_util",
".",
"parse_time",
"(",
"string",
")",
"is",
"not",
"None"
] | [
36,
0
] | [
38,
49
] | python | en | ['en', 'en', 'en'] | True |
_async_reproduce_state | (
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce a single state. | Reproduce a single state. | async def _async_reproduce_state(
hass: HomeAssistantType,
state: State,
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce a single state."""
cur_state = hass.states.get(state.entity_id)
if cur_state is None:
_LOGGE... | [
"async",
"def",
"_async_reproduce_state",
"(",
"hass",
":",
"HomeAssistantType",
",",
"state",
":",
"State",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",... | [
41,
0
] | [
99,
5
] | python | en | ['en', 'en', 'en'] | True |
async_reproduce_states | (
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) | Reproduce Input datetime states. | Reproduce Input datetime states. | async def async_reproduce_states(
hass: HomeAssistantType,
states: Iterable[State],
*,
context: Optional[Context] = None,
reproduce_options: Optional[Dict[str, Any]] = None,
) -> None:
"""Reproduce Input datetime states."""
await asyncio.gather(
*(
_async_reproduce_state(... | [
"async",
"def",
"async_reproduce_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"states",
":",
"Iterable",
"[",
"State",
"]",
",",
"*",
",",
"context",
":",
"Optional",
"[",
"Context",
"]",
"=",
"None",
",",
"reproduce_options",
":",
"Optional",
"[",
... | [
102,
0
] | [
117,
5
] | python | en | ['fr', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the Almond component. | Set up the Almond component. | async def async_setup(hass, config):
"""Set up the Almond component."""
hass.data[DOMAIN] = {}
if DOMAIN not in config:
return True
conf = config[DOMAIN]
host = conf[CONF_HOST]
if conf[CONF_TYPE] == TYPE_OAUTH2:
config_flow.AlmondFlowHandler.async_register_implementation(
... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"host",
"=",
"conf... | [
66,
0
] | [
99,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: config_entries.ConfigEntry) | Set up Almond config entry. | Set up Almond config entry. | async def async_setup_entry(hass: HomeAssistant, entry: config_entries.ConfigEntry):
"""Set up Almond config entry."""
websession = aiohttp_client.async_get_clientsession(hass)
if entry.data["type"] == TYPE_LOCAL:
auth = AlmondLocalAuth(entry.data["host"], websession)
else:
# OAuth2
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"websession",
"=",
"aiohttp_client",
".",
"async_get_clientsession",
"(",
"hass",
")",
"if",
"entry",
".",
"data",
"[",
"... | [
102,
0
] | [
147,
15
] | python | en | ['en', 'en', 'en'] | True |
_configure_almond_for_ha | (
hass: HomeAssistant, entry: config_entries.ConfigEntry, api: WebAlmondAPI
) | Configure Almond to connect to HA. | Configure Almond to connect to HA. | async def _configure_almond_for_ha(
hass: HomeAssistant, entry: config_entries.ConfigEntry, api: WebAlmondAPI
):
"""Configure Almond to connect to HA."""
try:
if entry.data["type"] == TYPE_OAUTH2:
# If we're connecting over OAuth2, we will only set up connection
# with Home A... | [
"async",
"def",
"_configure_almond_for_ha",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
",",
"api",
":",
"WebAlmondAPI",
")",
":",
"try",
":",
"if",
"entry",
".",
"data",
"[",
"\"type\"",
"]",
"==",
"TYPE_OAUTH... | [
150,
0
] | [
215,
61
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload Almond. | Unload Almond. | async def async_unload_entry(hass, entry):
"""Unload Almond."""
conversation.async_set_agent(hass, None)
return True | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"conversation",
".",
"async_set_agent",
"(",
"hass",
",",
"None",
")",
"return",
"True"
] | [
218,
0
] | [
221,
15
] | python | en | ['en', 'zh', 'en'] | False |
AlmondOAuth.__init__ | (
self,
host: str,
websession: ClientSession,
oauth_session: config_entry_oauth2_flow.OAuth2Session,
) | Initialize Almond auth. | Initialize Almond auth. | def __init__(
self,
host: str,
websession: ClientSession,
oauth_session: config_entry_oauth2_flow.OAuth2Session,
):
"""Initialize Almond auth."""
super().__init__(host, websession)
self._oauth_session = oauth_session | [
"def",
"__init__",
"(",
"self",
",",
"host",
":",
"str",
",",
"websession",
":",
"ClientSession",
",",
"oauth_session",
":",
"config_entry_oauth2_flow",
".",
"OAuth2Session",
",",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"host",
",",
"websession",
... | [
227,
4
] | [
235,
43
] | python | en | ['en', 'en', 'nl'] | True |
AlmondOAuth.async_get_access_token | (self) | Return a valid access token. | Return a valid access token. | async def async_get_access_token(self):
"""Return a valid access token."""
if not self._oauth_session.valid_token:
await self._oauth_session.async_ensure_token_valid()
return self._oauth_session.token["access_token"] | [
"async",
"def",
"async_get_access_token",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_oauth_session",
".",
"valid_token",
":",
"await",
"self",
".",
"_oauth_session",
".",
"async_ensure_token_valid",
"(",
")",
"return",
"self",
".",
"_oauth_session",
".",... | [
237,
4
] | [
242,
56
] | python | en | ['en', 'lb', 'en'] | True |
AlmondAgent.__init__ | (
self, hass: HomeAssistant, api: WebAlmondAPI, entry: config_entries.ConfigEntry
) | Initialize the agent. | Initialize the agent. | def __init__(
self, hass: HomeAssistant, api: WebAlmondAPI, entry: config_entries.ConfigEntry
):
"""Initialize the agent."""
self.hass = hass
self.api = api
self.entry = entry | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"api",
":",
"WebAlmondAPI",
",",
"entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"api",
"=",
"api",
"self",
".",
"entry... | [
248,
4
] | [
254,
26
] | python | en | ['en', 'en', 'en'] | True |
AlmondAgent.attribution | (self) | Return the attribution. | Return the attribution. | def attribution(self):
"""Return the attribution."""
return {"name": "Powered by Almond", "url": "https://almond.stanford.edu/"} | [
"def",
"attribution",
"(",
"self",
")",
":",
"return",
"{",
"\"name\"",
":",
"\"Powered by Almond\"",
",",
"\"url\"",
":",
"\"https://almond.stanford.edu/\"",
"}"
] | [
257,
4
] | [
259,
83
] | python | en | ['en', 'ja', 'en'] | True |
AlmondAgent.async_get_onboarding | (self) | Get onboard url if not onboarded. | Get onboard url if not onboarded. | async def async_get_onboarding(self):
"""Get onboard url if not onboarded."""
if self.entry.data.get("onboarded"):
return None
host = self.entry.data["host"]
if self.entry.data.get("is_hassio"):
host = "/core_almond"
return {
"text": "Would yo... | [
"async",
"def",
"async_get_onboarding",
"(",
"self",
")",
":",
"if",
"self",
".",
"entry",
".",
"data",
".",
"get",
"(",
"\"onboarded\"",
")",
":",
"return",
"None",
"host",
"=",
"self",
".",
"entry",
".",
"data",
"[",
"\"host\"",
"]",
"if",
"self",
... | [
261,
4
] | [
272,
9
] | python | en | ['en', 'fy', 'en'] | True |
AlmondAgent.async_set_onboarding | (self, shown) | Set onboarding status. | Set onboarding status. | async def async_set_onboarding(self, shown):
"""Set onboarding status."""
self.hass.config_entries.async_update_entry(
self.entry, data={**self.entry.data, "onboarded": shown}
)
return True | [
"async",
"def",
"async_set_onboarding",
"(",
"self",
",",
"shown",
")",
":",
"self",
".",
"hass",
".",
"config_entries",
".",
"async_update_entry",
"(",
"self",
".",
"entry",
",",
"data",
"=",
"{",
"*",
"*",
"self",
".",
"entry",
".",
"data",
",",
"\"o... | [
274,
4
] | [
280,
19
] | python | en | ['en', 'nl', 'en'] | True |
AlmondAgent.async_process | (
self, text: str, context: Context, conversation_id: Optional[str] = None
) | Process a sentence. | Process a sentence. | async def async_process(
self, text: str, context: Context, conversation_id: Optional[str] = None
) -> intent.IntentResponse:
"""Process a sentence."""
response = await self.api.async_converse_text(text, conversation_id)
first_choice = True
buffer = ""
for message in... | [
"async",
"def",
"async_process",
"(",
"self",
",",
"text",
":",
"str",
",",
"context",
":",
"Context",
",",
"conversation_id",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"intent",
".",
"IntentResponse",
":",
"response",
"=",
"await",
"self... | [
282,
4
] | [
309,
28
] | python | en | ['en', 'mk', 'en'] | True |
async_setup | (hass, config) | Set up the logger component. | Set up the logger component. | async def async_setup(hass, config):
"""Set up the logger component."""
hass.data[DOMAIN] = {}
logging.setLoggerClass(_get_logger_class(hass.data[DOMAIN]))
@callback
def set_default_log_level(level):
"""Set the default log level for components."""
_set_log_level(logging.getLogger(""... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"}",
"logging",
".",
"setLoggerClass",
"(",
"_get_logger_class",
"(",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
")",
")",
"@",
"cal... | [
49,
0
] | [
94,
15
] | python | en | ['en', 'en', 'en'] | True |
_set_log_level | (logger, level) | Set the log level.
Any logger fetched before this integration is loaded will use old class.
| Set the log level. | def _set_log_level(logger, level):
"""Set the log level.
Any logger fetched before this integration is loaded will use old class.
"""
getattr(logger, "orig_setLevel", logger.setLevel)(LOGSEVERITY[level]) | [
"def",
"_set_log_level",
"(",
"logger",
",",
"level",
")",
":",
"getattr",
"(",
"logger",
",",
"\"orig_setLevel\"",
",",
"logger",
".",
"setLevel",
")",
"(",
"LOGSEVERITY",
"[",
"level",
"]",
")"
] | [
97,
0
] | [
102,
73
] | python | en | ['en', 'zu', 'en'] | True |
_get_logger_class | (hass_overrides) | Create a logger subclass.
logging.setLoggerClass checks if it is a subclass of Logger and
so we cannot use partial to inject hass_overrides.
| Create a logger subclass. | def _get_logger_class(hass_overrides):
"""Create a logger subclass.
logging.setLoggerClass checks if it is a subclass of Logger and
so we cannot use partial to inject hass_overrides.
"""
class HassLogger(logging.Logger):
"""Home Assistant aware logger class."""
def setLevel(self, ... | [
"def",
"_get_logger_class",
"(",
"hass_overrides",
")",
":",
"class",
"HassLogger",
"(",
"logging",
".",
"Logger",
")",
":",
"\"\"\"Home Assistant aware logger class.\"\"\"",
"def",
"setLevel",
"(",
"self",
",",
"level",
")",
"->",
"None",
":",
"\"\"\"Set the log le... | [
105,
0
] | [
127,
21
] | python | en | ['en', 'ga', 'en'] | True |
test_state | (hass, service, state) | Test that we can turn a state into a service call. | Test that we can turn a state into a service call. | async def test_state(hass, service, state):
"""Test that we can turn a state into a service call."""
calls_1 = async_mock_service(hass, DOMAIN, service)
if service != SERVICE_TURN_ON:
async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
await async_reproduce_states(hass, [State(ENTITY_1, state)])
... | [
"async",
"def",
"test_state",
"(",
"hass",
",",
"service",
",",
"state",
")",
":",
"calls_1",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"service",
")",
"if",
"service",
"!=",
"SERVICE_TURN_ON",
":",
"async_mock_service",
"(",
"hass",
",",
... | [
50,
0
] | [
61,
53
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on_with_mode | (hass) | Test that state with additional attributes call multiple services. | Test that state with additional attributes call multiple services. | async def test_turn_on_with_mode(hass):
"""Test that state with additional attributes call multiple services."""
calls_1 = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
calls_2 = async_mock_service(hass, DOMAIN, SERVICE_SELECT_SOUND_MODE)
await async_reproduce_states(
hass, [State(ENTITY_1,... | [
"async",
"def",
"test_turn_on_with_mode",
"(",
"hass",
")",
":",
"calls_1",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")",
"calls_2",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_SELECT_SOUND_MODE",
")",... | [
64,
0
] | [
79,
79
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_same_state | (hass) | Test that multiple states with same state gets calls. | Test that multiple states with same state gets calls. | async def test_multiple_same_state(hass):
"""Test that multiple states with same state gets calls."""
calls_1 = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
await async_reproduce_states(hass, [State(ENTITY_1, "on"), State(ENTITY_2, "on")])
await hass.async_block_till_done()
assert len(calls_... | [
"async",
"def",
"test_multiple_same_state",
"(",
"hass",
")",
":",
"calls_1",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")",
"await",
"async_reproduce_states",
"(",
"hass",
",",
"[",
"State",
"(",
"ENTITY_1",
",",
"\"on\"",
... | [
82,
0
] | [
93,
84
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_different_state | (hass) | Test that multiple states with different state gets calls. | Test that multiple states with different state gets calls. | async def test_multiple_different_state(hass):
"""Test that multiple states with different state gets calls."""
calls_1 = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
calls_2 = async_mock_service(hass, DOMAIN, SERVICE_TURN_OFF)
await async_reproduce_states(hass, [State(ENTITY_1, "on"), State(ENTIT... | [
"async",
"def",
"test_multiple_different_state",
"(",
"hass",
")",
":",
"calls_1",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")",
"calls_2",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_OFF",
")",
... | [
96,
0
] | [
108,
65
] | python | en | ['en', 'en', 'en'] | True |
test_state_with_context | (hass) | Test that context is forwarded. | Test that context is forwarded. | async def test_state_with_context(hass):
"""Test that context is forwarded."""
calls = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
context = Context()
await async_reproduce_states(hass, [State(ENTITY_1, "on")], context=context)
await hass.async_block_till_done()
assert len(calls) == 1
... | [
"async",
"def",
"test_state_with_context",
"(",
"hass",
")",
":",
"calls",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")",
"context",
"=",
"Context",
"(",
")",
"await",
"async_reproduce_states",
"(",
"hass",
",",
"[",
"State... | [
111,
0
] | [
123,
38
] | python | en | ['en', 'en', 'en'] | True |
test_attribute_no_state | (hass) | Test that no state service call is made with none state. | Test that no state service call is made with none state. | async def test_attribute_no_state(hass):
"""Test that no state service call is made with none state."""
calls_1 = async_mock_service(hass, DOMAIN, SERVICE_TURN_ON)
calls_2 = async_mock_service(hass, DOMAIN, SERVICE_TURN_OFF)
calls_3 = async_mock_service(hass, DOMAIN, SERVICE_SELECT_SOUND_MODE)
valu... | [
"async",
"def",
"test_attribute_no_state",
"(",
"hass",
")",
":",
"calls_1",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_ON",
")",
"calls_2",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_TURN_OFF",
")",
"call... | [
126,
0
] | [
143,
77
] | python | en | ['en', 'en', 'en'] | True |
test_attribute | (hass, service, attribute) | Test that service call is made for each attribute. | Test that service call is made for each attribute. | async def test_attribute(hass, service, attribute):
"""Test that service call is made for each attribute."""
calls_1 = async_mock_service(hass, DOMAIN, service)
value = "dummy"
await async_reproduce_states(hass, [State(ENTITY_1, None, {attribute: value})])
await hass.async_block_till_done()
... | [
"async",
"def",
"test_attribute",
"(",
"hass",
",",
"service",
",",
"attribute",
")",
":",
"calls_1",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"service",
")",
"value",
"=",
"\"dummy\"",
"await",
"async_reproduce_states",
"(",
"hass",
",",
... | [
155,
0
] | [
166,
71
] | python | en | ['en', 'en', 'en'] | True |
test_play_media | (hass) | Test that no state service call is made with none state. | Test that no state service call is made with none state. | async def test_play_media(hass):
"""Test that no state service call is made with none state."""
calls_1 = async_mock_service(hass, DOMAIN, SERVICE_PLAY_MEDIA)
value_1 = "dummy_1"
value_2 = "dummy_2"
value_3 = "dummy_3"
await async_reproduce_states(
hass,
[
State(
... | [
"async",
"def",
"test_play_media",
"(",
"hass",
")",
":",
"calls_1",
"=",
"async_mock_service",
"(",
"hass",
",",
"DOMAIN",
",",
"SERVICE_PLAY_MEDIA",
")",
"value_1",
"=",
"\"dummy_1\"",
"value_2",
"=",
"\"dummy_2\"",
"value_3",
"=",
"\"dummy_3\"",
"await",
"asy... | [
169,
0
] | [
217,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Risco alarm control panel. | Set up the Risco alarm control panel. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Risco alarm control panel."""
platform = entity_platform.current_platform.get()
platform.async_register_entity_service(SERVICE_BYPASS_ZONE, {}, "async_bypass_zone")
platform.async_register_entity_service(
SERVICE_... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"platform",
"=",
"entity_platform",
".",
"current_platform",
".",
"get",
"(",
")",
"platform",
".",
"async_register_entity_service",
"(",
"SERVICE_BYPASS_ZONE",... | [
14,
0
] | [
27,
39
] | python | en | ['en', 'en', 'en'] | True |
RiscoBinarySensor.__init__ | (self, coordinator, zone_id, zone) | Init the zone. | Init the zone. | def __init__(self, coordinator, zone_id, zone):
"""Init the zone."""
super().__init__(coordinator)
self._zone_id = zone_id
self._zone = zone | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"zone_id",
",",
"zone",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_zone_id",
"=",
"zone_id",
"self",
".",
"_zone",
"=",
"zone"
] | [
33,
4
] | [
37,
25
] | python | en | ['en', 'en', 'en'] | True |
RiscoBinarySensor.device_info | (self) | Return device info for this device. | Return device info for this device. | def device_info(self):
"""Return device info for this device."""
return {
"identifiers": {(DOMAIN, self.unique_id)},
"name": self.name,
"manufacturer": "Risco",
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"unique_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"manufacturer\"",
":",
"\"Risco\"",
",",
"}"
] | [
43,
4
] | [
49,
9
] | python | en | ['en', 'en', 'en'] | True |
RiscoBinarySensor.name | (self) | Return the name of the zone. | Return the name of the zone. | def name(self):
"""Return the name of the zone."""
return self._zone.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_zone",
".",
"name"
] | [
52,
4
] | [
54,
30
] | python | en | ['en', 'en', 'en'] | True |
RiscoBinarySensor.unique_id | (self) | Return a unique id for this zone. | Return a unique id for this zone. | def unique_id(self):
"""Return a unique id for this zone."""
return binary_sensor_unique_id(self._risco, self._zone_id) | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"binary_sensor_unique_id",
"(",
"self",
".",
"_risco",
",",
"self",
".",
"_zone_id",
")"
] | [
57,
4
] | [
59,
66
] | python | en | ['en', 'en', 'en'] | True |
RiscoBinarySensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {"zone_id": self._zone_id, "bypassed": self._zone.bypassed} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"\"zone_id\"",
":",
"self",
".",
"_zone_id",
",",
"\"bypassed\"",
":",
"self",
".",
"_zone",
".",
"bypassed",
"}"
] | [
62,
4
] | [
64,
74
] | python | en | ['en', 'en', 'en'] | True |
RiscoBinarySensor.is_on | (self) | Return true if sensor is on. | Return true if sensor is on. | def is_on(self):
"""Return true if sensor is on."""
return self._zone.triggered | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_zone",
".",
"triggered"
] | [
67,
4
] | [
69,
35
] | python | en | ['en', 'et', 'en'] | True |
RiscoBinarySensor.device_class | (self) | Return the class of this sensor, from DEVICE_CLASSES. | Return the class of this sensor, from DEVICE_CLASSES. | def device_class(self):
"""Return the class of this sensor, from DEVICE_CLASSES."""
return DEVICE_CLASS_MOTION | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_MOTION"
] | [
72,
4
] | [
74,
34
] | python | en | ['en', 'en', 'en'] | True |
RiscoBinarySensor.async_bypass_zone | (self) | Bypass this zone. | Bypass this zone. | async def async_bypass_zone(self):
"""Bypass this zone."""
await self._bypass(True) | [
"async",
"def",
"async_bypass_zone",
"(",
"self",
")",
":",
"await",
"self",
".",
"_bypass",
"(",
"True",
")"
] | [
81,
4
] | [
83,
32
] | python | en | ['en', 'en', 'en'] | True |
RiscoBinarySensor.async_unbypass_zone | (self) | Unbypass this zone. | Unbypass this zone. | async def async_unbypass_zone(self):
"""Unbypass this zone."""
await self._bypass(False) | [
"async",
"def",
"async_unbypass_zone",
"(",
"self",
")",
":",
"await",
"self",
".",
"_bypass",
"(",
"False",
")"
] | [
85,
4
] | [
87,
33
] | python | en | ['en', 'en', 'en'] | True |
test_sensor | (hass, create_registrations, webhook_client) | Test that sensors can be registered and updated. | Test that sensors can be registered and updated. | async def test_sensor(hass, create_registrations, webhook_client):
"""Test that sensors can be registered and updated."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
reg_resp = await webhook_client.post(
webhook_url,
json={
"... | [
"async",
"def",
"test_sensor",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}\"",
"reg_resp",
"=",
"aw... | [
5,
0
] | [
70,
60
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_must_register | (hass, create_registrations, webhook_client) | Test that sensors must be registered before updating. | Test that sensors must be registered before updating. | async def test_sensor_must_register(hass, create_registrations, webhook_client):
"""Test that sensors must be registered before updating."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
resp = await webhook_client.post(
webhook_url,
json={... | [
"async",
"def",
"test_sensor_must_register",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}\"",
"resp",
... | [
73,
0
] | [
89,
69
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_id_no_dupes | (hass, create_registrations, webhook_client, caplog) | Test that a duplicate unique ID in registration updates the sensor. | Test that a duplicate unique ID in registration updates the sensor. | async def test_sensor_id_no_dupes(hass, create_registrations, webhook_client, caplog):
"""Test that a duplicate unique ID in registration updates the sensor."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
payload = {
"type": "register_sensor",
... | [
"async",
"def",
"test_sensor_id_no_dupes",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
",",
"caplog",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}... | [
92,
0
] | [
151,
31
] | python | en | ['en', 'en', 'en'] | True |
test_register_sensor_no_state | (hass, create_registrations, webhook_client) | Test that sensors can be registered, when there is no (unknown) state. | Test that sensors can be registered, when there is no (unknown) state. | async def test_register_sensor_no_state(hass, create_registrations, webhook_client):
"""Test that sensors can be registered, when there is no (unknown) state."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
reg_resp = await webhook_client.post(
w... | [
"async",
"def",
"test_register_sensor_no_state",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}\"",
"reg_r... | [
154,
0
] | [
208,
40
] | python | en | ['en', 'en', 'en'] | True |
test_update_sensor_no_state | (hass, create_registrations, webhook_client) | Test that sensors can be updated, when there is no (unknown) state. | Test that sensors can be updated, when there is no (unknown) state. | async def test_update_sensor_no_state(hass, create_registrations, webhook_client):
"""Test that sensors can be updated, when there is no (unknown) state."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
reg_resp = await webhook_client.post(
webhoo... | [
"async",
"def",
"test_update_sensor_no_state",
"(",
"hass",
",",
"create_registrations",
",",
"webhook_client",
")",
":",
"webhook_id",
"=",
"create_registrations",
"[",
"1",
"]",
"[",
"\"webhook_id\"",
"]",
"webhook_url",
"=",
"f\"/api/webhook/{webhook_id}\"",
"reg_res... | [
211,
0
] | [
253,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form | (hass) | Test we get the form. | Test we get the form. | async def test_form(hass):
"""Test we get the form."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert result["errors"] == {}
with patch(
"homeassistant.components.risco.config_fl... | [
"async",
"def",
"test_form",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")",
"assert",... | [
43,
0
] | [
75,
36
] | python | en | ['en', 'en', 'en'] | True |
test_form_invalid_auth | (hass) | Test we handle invalid auth. | Test we handle invalid auth. | async def test_form_invalid_auth(hass):
"""Test we handle invalid auth."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.risco.config_flow.RiscoAPI.login",
side_effect=Unauthoriz... | [
"async",
"def",
"test_form_invalid_auth",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")"... | [
78,
0
] | [
94,
36
] | python | en | ['en', 'en', 'en'] | True |
test_form_cannot_connect | (hass) | Test we handle cannot connect error. | Test we handle cannot connect error. | async def test_form_cannot_connect(hass):
"""Test we handle cannot connect error."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.risco.config_flow.RiscoAPI.login",
side_effect=... | [
"async",
"def",
"test_form_cannot_connect",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
"... | [
97,
0
] | [
113,
36
] | python | en | ['en', 'en', 'en'] | True |
test_form_exception | (hass) | Test we handle unknown exception. | Test we handle unknown exception. | async def test_form_exception(hass):
"""Test we handle unknown exception."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.risco.config_flow.RiscoAPI.login",
side_effect=Exceptio... | [
"async",
"def",
"test_form_exception",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"config_entries",
".",
"SOURCE_USER",
"}",
")",
... | [
116,
0
] | [
132,
36
] | python | en | ['en', 'en', 'en'] | True |
test_form_already_exists | (hass) | Test that a flow with an existing username aborts. | Test that a flow with an existing username aborts. | async def test_form_already_exists(hass):
"""Test that a flow with an existing username aborts."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=TEST_DATA["username"],
data=TEST_DATA,
)
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
... | [
"async",
"def",
"test_form_already_exists",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"TEST_DATA",
"[",
"\"username\"",
"]",
",",
"data",
"=",
"TEST_DATA",
",",
")",
"entry",
".",
"add_to_has... | [
135,
0
] | [
154,
52
] | python | en | ['en', 'en', 'en'] | True |
test_options_flow | (hass) | Test options flow. | Test options flow. | async def test_options_flow(hass):
"""Test options flow."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=TEST_DATA["username"],
data=TEST_DATA,
)
entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
assert result["type"] ==... | [
"async",
"def",
"test_options_flow",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"TEST_DATA",
"[",
"\"username\"",
"]",
",",
"data",
"=",
"TEST_DATA",
",",
")",
"entry",
".",
"add_to_hass",
"... | [
157,
0
] | [
198,
5
] | python | en | ['en', 'fr', 'en'] | True |
test_ha_to_risco_schema | (hass) | Test that the schema for the ha-to-risco mapping step is generated properly. | Test that the schema for the ha-to-risco mapping step is generated properly. | async def test_ha_to_risco_schema(hass):
"""Test that the schema for the ha-to-risco mapping step is generated properly."""
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=TEST_DATA["username"],
data=TEST_DATA,
)
entry.add_to_hass(hass)
result = await hass.config_entries.... | [
"async",
"def",
"test_ha_to_risco_schema",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"unique_id",
"=",
"TEST_DATA",
"[",
"\"username\"",
"]",
",",
"data",
"=",
"TEST_DATA",
",",
")",
"entry",
".",
"add_to_hass... | [
201,
0
] | [
234,
9
] | python | en | ['en', 'en', 'en'] | True |
setup_demo_humidifier | (hass) | Initialize setup demo humidifier. | Initialize setup demo humidifier. | async def setup_demo_humidifier(hass):
"""Initialize setup demo humidifier."""
assert await async_setup_component(
hass, DOMAIN, {"humidifier": {"platform": "demo"}}
)
await hass.async_block_till_done() | [
"async",
"def",
"setup_demo_humidifier",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"DOMAIN",
",",
"{",
"\"humidifier\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
")",
"await",
"hass",
".",
"async_block_til... | [
32,
0
] | [
37,
38
] | python | en | ['en', 'zh-Latn', 'en'] | True |
test_setup_params | (hass) | Test the initial parameters. | Test the initial parameters. | def test_setup_params(hass):
"""Test the initial parameters."""
state = hass.states.get(ENTITY_DEHUMIDIFIER)
assert state.state == STATE_ON
assert state.attributes.get(ATTR_HUMIDITY) == 54 | [
"def",
"test_setup_params",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_DEHUMIDIFIER",
")",
"assert",
"state",
".",
"state",
"==",
"STATE_ON",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_HUMIDITY",
... | [
40,
0
] | [
44,
52
] | python | en | ['en', 'en', 'en'] | True |
test_default_setup_params | (hass) | Test the setup with default parameters. | Test the setup with default parameters. | def test_default_setup_params(hass):
"""Test the setup with default parameters."""
state = hass.states.get(ENTITY_DEHUMIDIFIER)
assert state.attributes.get(ATTR_MIN_HUMIDITY) == 0
assert state.attributes.get(ATTR_MAX_HUMIDITY) == 100 | [
"def",
"test_default_setup_params",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_DEHUMIDIFIER",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_MIN_HUMIDITY",
")",
"==",
"0",
"assert",
"state",
".",
... | [
47,
0
] | [
51,
57
] | python | en | ['en', 'en', 'en'] | True |
test_set_target_humidity_bad_attr | (hass) | Test setting the target humidity without required attribute. | Test setting the target humidity without required attribute. | async def test_set_target_humidity_bad_attr(hass):
"""Test setting the target humidity without required attribute."""
state = hass.states.get(ENTITY_DEHUMIDIFIER)
assert state.attributes.get(ATTR_HUMIDITY) == 54
with pytest.raises(vol.Invalid):
await hass.services.async_call(
DOMAIN... | [
"async",
"def",
"test_set_target_humidity_bad_attr",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_DEHUMIDIFIER",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_HUMIDITY",
")",
"==",
"54",
"with",
"py... | [
54,
0
] | [
69,
52
] | python | en | ['en', 'en', 'en'] | True |
test_set_target_humidity | (hass) | Test the setting of the target humidity. | Test the setting of the target humidity. | async def test_set_target_humidity(hass):
"""Test the setting of the target humidity."""
state = hass.states.get(ENTITY_DEHUMIDIFIER)
assert state.attributes.get(ATTR_HUMIDITY) == 54
await hass.services.async_call(
DOMAIN,
SERVICE_SET_HUMIDITY,
{ATTR_HUMIDITY: 64, ATTR_ENTITY_ID... | [
"async",
"def",
"test_set_target_humidity",
"(",
"hass",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"ENTITY_DEHUMIDIFIER",
")",
"assert",
"state",
".",
"attributes",
".",
"get",
"(",
"ATTR_HUMIDITY",
")",
"==",
"54",
"await",
"hass",
"... | [
72,
0
] | [
86,
52
] | python | en | ['en', 'en', 'en'] | True |
test_set_hold_mode_away | (hass) | Test setting the hold mode away. | Test setting the hold mode away. | async def test_set_hold_mode_away(hass):
"""Test setting the hold mode away."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_MODE,
{ATTR_MODE: MODE_AWAY, ATTR_ENTITY_ID: ENTITY_HYGROSTAT},
blocking=True,
)
await hass.async_block_till_done()
state = hass.states... | [
"async",
"def",
"test_set_hold_mode_away",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_MODE",
",",
"{",
"ATTR_MODE",
":",
"MODE_AWAY",
",",
"ATTR_ENTITY_ID",
":",
"ENTITY_HYGROSTAT",
"}",
",",
"b... | [
89,
0
] | [
100,
55
] | python | en | ['en', 'en', 'en'] | True |
test_set_hold_mode_eco | (hass) | Test setting the hold mode eco. | Test setting the hold mode eco. | async def test_set_hold_mode_eco(hass):
"""Test setting the hold mode eco."""
await hass.services.async_call(
DOMAIN,
SERVICE_SET_MODE,
{ATTR_MODE: MODE_ECO, ATTR_ENTITY_ID: ENTITY_HYGROSTAT},
blocking=True,
)
await hass.async_block_till_done()
state = hass.states.ge... | [
"async",
"def",
"test_set_hold_mode_eco",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_SET_MODE",
",",
"{",
"ATTR_MODE",
":",
"MODE_ECO",
",",
"ATTR_ENTITY_ID",
":",
"ENTITY_HYGROSTAT",
"}",
",",
"blo... | [
103,
0
] | [
114,
54
] | python | en | ['en', 'en', 'en'] | True |
test_turn_on | (hass) | Test turn on device. | Test turn on device. | async def test_turn_on(hass):
"""Test turn on device."""
await hass.services.async_call(
DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
)
state = hass.states.get(ENTITY_DEHUMIDIFIER)
assert state.state == STATE_OFF
await hass.services.async_call(
... | [
"async",
"def",
"test_turn_on",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_TURN_OFF",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_DEHUMIDIFIER",
"}",
",",
"blocking",
"=",
"True",
")",
"state",
"=",
... | [
117,
0
] | [
129,
34
] | python | en | ['fr', 'en', 'en'] | True |
test_turn_off | (hass) | Test turn off device. | Test turn off device. | async def test_turn_off(hass):
"""Test turn off device."""
await hass.services.async_call(
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
)
state = hass.states.get(ENTITY_DEHUMIDIFIER)
assert state.state == STATE_ON
await hass.services.async_call(
... | [
"async",
"def",
"test_turn_off",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_TURN_ON",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_DEHUMIDIFIER",
"}",
",",
"blocking",
"=",
"True",
")",
"state",
"=",
... | [
132,
0
] | [
144,
35
] | python | en | ['en', 'en', 'en'] | True |
test_toggle | (hass) | Test toggle device. | Test toggle device. | async def test_toggle(hass):
"""Test toggle device."""
await hass.services.async_call(
DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_DEHUMIDIFIER}, blocking=True
)
state = hass.states.get(ENTITY_DEHUMIDIFIER)
assert state.state == STATE_ON
await hass.services.async_call(
DOMA... | [
"async",
"def",
"test_toggle",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"DOMAIN",
",",
"SERVICE_TURN_ON",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_DEHUMIDIFIER",
"}",
",",
"blocking",
"=",
"True",
")",
"state",
"=",
... | [
147,
0
] | [
165,
34
] | python | en | ['fr', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up a Toon binary sensors based on a config entry. | Set up a Toon binary sensors based on a config entry. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) -> None:
"""Set up a Toon binary sensors based on a config entry."""
coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
[ToonThermostatDevice(coordinator, name="Thermostat", icon="mdi:... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
... | [
31,
0
] | [
38,
5
] | python | en | ['en', 'en', 'en'] | True |
ToonThermostatDevice.unique_id | (self) | Return the unique ID for this thermostat. | Return the unique ID for this thermostat. | def unique_id(self) -> str:
"""Return the unique ID for this thermostat."""
agreement_id = self.coordinator.data.agreement.agreement_id
# This unique ID is a bit ugly and contains unneeded information.
# It is here for lecagy / backward compatible reasons.
return f"{DOMAIN}_{agre... | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"agreement_id",
"=",
"self",
".",
"coordinator",
".",
"data",
".",
"agreement",
".",
"agreement_id",
"# This unique ID is a bit ugly and contains unneeded information.",
"# It is here for lecagy / backward compatible rea... | [
45,
4
] | [
50,
49
] | python | en | ['en', 'en', 'en'] | True |
ToonThermostatDevice.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_TARGET_TEMPERATURE",
"|",
"SUPPORT_PRESET_MODE"
] | [
53,
4
] | [
55,
63
] | python | en | ['en', 'en', 'en'] | True |
ToonThermostatDevice.hvac_mode | (self) | Return hvac operation ie. heat, cool mode. | Return hvac operation ie. heat, cool mode. | def hvac_mode(self) -> str:
"""Return hvac operation ie. heat, cool mode."""
return HVAC_MODE_HEAT | [
"def",
"hvac_mode",
"(",
"self",
")",
"->",
"str",
":",
"return",
"HVAC_MODE_HEAT"
] | [
58,
4
] | [
60,
29
] | python | bg | ['en', 'bg', 'bg'] | True |
ToonThermostatDevice.hvac_modes | (self) | Return the list of available hvac operation modes. | Return the list of available hvac operation modes. | def hvac_modes(self) -> List[str]:
"""Return the list of available hvac operation modes."""
return [HVAC_MODE_HEAT] | [
"def",
"hvac_modes",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"HVAC_MODE_HEAT",
"]"
] | [
63,
4
] | [
65,
31
] | python | en | ['en', 'en', 'en'] | True |
ToonThermostatDevice.hvac_action | (self) | Return the current running hvac operation. | Return the current running hvac operation. | def hvac_action(self) -> Optional[str]:
"""Return the current running hvac operation."""
if self.coordinator.data.thermostat.heating:
return CURRENT_HVAC_HEAT
return CURRENT_HVAC_IDLE | [
"def",
"hvac_action",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"coordinator",
".",
"data",
".",
"thermostat",
".",
"heating",
":",
"return",
"CURRENT_HVAC_HEAT",
"return",
"CURRENT_HVAC_IDLE"
] | [
68,
4
] | [
72,
32
] | python | en | ['en', 'is', 'en'] | True |
ToonThermostatDevice.temperature_unit | (self) | Return the unit of measurement. | Return the unit of measurement. | def temperature_unit(self) -> str:
"""Return the unit of measurement."""
return TEMP_CELSIUS | [
"def",
"temperature_unit",
"(",
"self",
")",
"->",
"str",
":",
"return",
"TEMP_CELSIUS"
] | [
75,
4
] | [
77,
27
] | python | en | ['en', 'la', 'en'] | True |
ToonThermostatDevice.preset_mode | (self) | Return the current preset mode, e.g., home, away, temp. | Return the current preset mode, e.g., home, away, temp. | def preset_mode(self) -> Optional[str]:
"""Return the current preset mode, e.g., home, away, temp."""
mapping = {
ACTIVE_STATE_AWAY: PRESET_AWAY,
ACTIVE_STATE_COMFORT: PRESET_COMFORT,
ACTIVE_STATE_HOME: PRESET_HOME,
ACTIVE_STATE_SLEEP: PRESET_SLEEP,
... | [
"def",
"preset_mode",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"mapping",
"=",
"{",
"ACTIVE_STATE_AWAY",
":",
"PRESET_AWAY",
",",
"ACTIVE_STATE_COMFORT",
":",
"PRESET_COMFORT",
",",
"ACTIVE_STATE_HOME",
":",
"PRESET_HOME",
",",
"ACTIVE_STATE_SLEEP... | [
80,
4
] | [
88,
73
] | python | en | ['en', 'pt', 'en'] | True |
ToonThermostatDevice.preset_modes | (self) | Return a list of available preset modes. | Return a list of available preset modes. | def preset_modes(self) -> List[str]:
"""Return a list of available preset modes."""
return [PRESET_AWAY, PRESET_COMFORT, PRESET_HOME, PRESET_SLEEP] | [
"def",
"preset_modes",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"PRESET_AWAY",
",",
"PRESET_COMFORT",
",",
"PRESET_HOME",
",",
"PRESET_SLEEP",
"]"
] | [
91,
4
] | [
93,
71
] | python | en | ['en', 'en', 'en'] | True |
ToonThermostatDevice.current_temperature | (self) | Return the current temperature. | Return the current temperature. | def current_temperature(self) -> Optional[float]:
"""Return the current temperature."""
return self.coordinator.data.thermostat.current_display_temperature | [
"def",
"current_temperature",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
".",
"thermostat",
".",
"current_display_temperature"
] | [
96,
4
] | [
98,
75
] | python | en | ['en', 'la', 'en'] | True |
ToonThermostatDevice.target_temperature | (self) | Return the temperature we try to reach. | Return the temperature we try to reach. | def target_temperature(self) -> Optional[float]:
"""Return the temperature we try to reach."""
return self.coordinator.data.thermostat.current_setpoint | [
"def",
"target_temperature",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
".",
"thermostat",
".",
"current_setpoint"
] | [
101,
4
] | [
103,
64
] | python | en | ['en', 'en', 'en'] | True |
ToonThermostatDevice.min_temp | (self) | Return the minimum temperature. | Return the minimum temperature. | def min_temp(self) -> float:
"""Return the minimum temperature."""
return DEFAULT_MIN_TEMP | [
"def",
"min_temp",
"(",
"self",
")",
"->",
"float",
":",
"return",
"DEFAULT_MIN_TEMP"
] | [
106,
4
] | [
108,
31
] | python | en | ['en', 'la', 'en'] | True |
ToonThermostatDevice.max_temp | (self) | Return the maximum temperature. | Return the maximum temperature. | def max_temp(self) -> float:
"""Return the maximum temperature."""
return DEFAULT_MAX_TEMP | [
"def",
"max_temp",
"(",
"self",
")",
"->",
"float",
":",
"return",
"DEFAULT_MAX_TEMP"
] | [
111,
4
] | [
113,
31
] | python | en | ['en', 'la', 'en'] | True |
ToonThermostatDevice.device_state_attributes | (self) | Return the current state of the burner. | Return the current state of the burner. | def device_state_attributes(self) -> Dict[str, Any]:
"""Return the current state of the burner."""
return {"heating_type": self.coordinator.data.agreement.heating_type} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"heating_type\"",
":",
"self",
".",
"coordinator",
".",
"data",
".",
"agreement",
".",
"heating_type",
"}"
] | [
116,
4
] | [
118,
77
] | python | en | ['en', 'en', 'en'] | True |
ToonThermostatDevice.async_set_temperature | (self, **kwargs) | Change the setpoint of the thermostat. | Change the setpoint of the thermostat. | async def async_set_temperature(self, **kwargs) -> None:
"""Change the setpoint of the thermostat."""
temperature = kwargs.get(ATTR_TEMPERATURE)
await self.coordinator.toon.set_current_setpoint(temperature) | [
"async",
"def",
"async_set_temperature",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"temperature",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_TEMPERATURE",
")",
"await",
"self",
".",
"coordinator",
".",
"toon",
".",
"set_current_setpoint",
"(",... | [
121,
4
] | [
124,
69
] | python | en | ['en', 'en', 'en'] | True |
ToonThermostatDevice.async_set_preset_mode | (self, preset_mode: str) | Set new preset mode. | Set new preset mode. | async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new preset mode."""
mapping = {
PRESET_AWAY: ACTIVE_STATE_AWAY,
PRESET_COMFORT: ACTIVE_STATE_COMFORT,
PRESET_HOME: ACTIVE_STATE_HOME,
PRESET_SLEEP: ACTIVE_STATE_SLEEP,
}
... | [
"async",
"def",
"async_set_preset_mode",
"(",
"self",
",",
"preset_mode",
":",
"str",
")",
"->",
"None",
":",
"mapping",
"=",
"{",
"PRESET_AWAY",
":",
"ACTIVE_STATE_AWAY",
",",
"PRESET_COMFORT",
":",
"ACTIVE_STATE_COMFORT",
",",
"PRESET_HOME",
":",
"ACTIVE_STATE_H... | [
127,
4
] | [
136,
78
] | python | en | ['en', 'sr', 'en'] | True |
ToonThermostatDevice.set_hvac_mode | (self, hvac_mode: str) | Set new target hvac mode. | Set new target hvac mode. | def set_hvac_mode(self, hvac_mode: str) -> None:
"""Set new target hvac mode.""" | [
"def",
"set_hvac_mode",
"(",
"self",
",",
"hvac_mode",
":",
"str",
")",
"->",
"None",
":"
] | [
138,
4
] | [
139,
39
] | python | da | ['da', 'su', 'en'] | False |
_compute_mask_indices | (
shape: Tuple[int, int],
mask_prob: float,
mask_length: int,
attention_mask: Optional[torch.Tensor] = None,
min_masks: int = 0,
) |
Computes random mask spans for a given shape
Args:
shape: the the shape for which to compute masks.
should be of size 2 where first element is batch size and 2nd is timesteps
attention_mask: optional padding mask of the same size as shape, which will prevent masking padded elements... |
Computes random mask spans for a given shape | def _compute_mask_indices(
shape: Tuple[int, int],
mask_prob: float,
mask_length: int,
attention_mask: Optional[torch.Tensor] = None,
min_masks: int = 0,
) -> np.ndarray:
"""
Computes random mask spans for a given shape
Args:
shape: the the shape for which to compute masks.
... | [
"def",
"_compute_mask_indices",
"(",
"shape",
":",
"Tuple",
"[",
"int",
",",
"int",
"]",
",",
"mask_prob",
":",
"float",
",",
"mask_length",
":",
"int",
",",
"attention_mask",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
"None",
",",
"min_mask... | [
46,
0
] | [
114,
15
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2Attention.forward | (
self,
hidden_states: torch.Tensor,
key_value_states: Optional[torch.Tensor] = None,
past_key_value: Optional[Tuple[torch.Tensor]] = None,
attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
output_attentions: bool = Fal... | Input shape: Batch x Time x Channel | Input shape: Batch x Time x Channel | def forward(
self,
hidden_states: torch.Tensor,
key_value_states: Optional[torch.Tensor] = None,
past_key_value: Optional[Tuple[torch.Tensor]] = None,
attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
output_attentions:... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
":",
"torch",
".",
"Tensor",
",",
"key_value_states",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
"None",
",",
"past_key_value",
":",
"Optional",
"[",
"Tuple",
"[",
"torch",
".",
"Tensor",
... | [
302,
4
] | [
411,
65
] | python | en | ['en', 'pl', 'en'] | True |
Wav2Vec2PreTrainedModel._init_weights | (self, module) | Initialize the weights | Initialize the weights | def _init_weights(self, module):
""" Initialize the weights """
if isinstance(module, nn.Linear):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Linear",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
"# cf https://github.com/pytorch/pytorch/pull/5617",
... | [
681,
4
] | [
693,
36
] | python | en | ['en', 'en', 'en'] | True |
Wav2Vec2PreTrainedModel._get_feat_extract_output_lengths | (self, input_lengths: torch.LongTensor) |
Computes the output length of the convolutional layers
|
Computes the output length of the convolutional layers
| def _get_feat_extract_output_lengths(self, input_lengths: torch.LongTensor):
"""
Computes the output length of the convolutional layers
"""
def _conv_out_length(input_length, kernel_size, stride):
# 1D convolutional layer output length formula taken
# from https:... | [
"def",
"_get_feat_extract_output_lengths",
"(",
"self",
",",
"input_lengths",
":",
"torch",
".",
"LongTensor",
")",
":",
"def",
"_conv_out_length",
"(",
"input_length",
",",
"kernel_size",
",",
"stride",
")",
":",
"# 1D convolutional layer output length formula taken",
... | [
695,
4
] | [
708,
43
] | python | en | ['en', 'error', 'th'] | False |
ConfigFlowHandler.async_get_options_flow | (
config_entry: config_entries.ConfigEntry,
) | Get options flow. | Get options flow. | def async_get_options_flow(
config_entry: config_entries.ConfigEntry,
) -> "OptionsFlowHandler":
"""Get options flow."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
",",
")",
"->",
"\"OptionsFlowHandler\"",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
48,
4
] | [
52,
47
] | python | en | ['en', 'nl', 'en'] | True |
ConfigFlowHandler.async_step_import | (
self, user_input: Optional[Dict[str, Any]] = None
) | Handle import initiated config flow. | Handle import initiated config flow. | async def async_step_import(
self, user_input: Optional[Dict[str, Any]] = None
) -> Dict[str, Any]:
"""Handle import initiated config flow."""
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"await",
"self",
".",
"async_step_user",
... | [
97,
4
] | [
101,
53
] | 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.