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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
AtenSwitch.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self) -> str:
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_OUTLET | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEVICE_CLASS_OUTLET"
] | [
89,
4
] | [
91,
34
] | python | en | ['en', 'en', 'en'] | True |
AtenSwitch.is_on | (self) | Return True if entity is on. | Return True if entity is on. | def is_on(self) -> bool:
"""Return True if entity is on."""
return self._enabled | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_enabled"
] | [
94,
4
] | [
96,
28
] | python | en | ['en', 'cy', 'en'] | True |
AtenSwitch.current_power_w | (self) | Return the current power usage in W. | Return the current power usage in W. | def current_power_w(self) -> float:
"""Return the current power usage in W."""
return self._outlet_power | [
"def",
"current_power_w",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"_outlet_power"
] | [
99,
4
] | [
101,
33
] | python | en | ['en', 'en', 'en'] | True |
AtenSwitch.async_turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | async def async_turn_on(self, **kwargs):
"""Turn the switch on."""
await self._device.setOutletStatus(self._outlet, "on")
self._enabled = True | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"setOutletStatus",
"(",
"self",
".",
"_outlet",
",",
"\"on\"",
")",
"self",
".",
"_enabled",
"=",
"True"
] | [
103,
4
] | [
106,
28
] | python | en | ['en', 'en', 'en'] | True |
AtenSwitch.async_turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | async def async_turn_off(self, **kwargs):
"""Turn the switch off."""
await self._device.setOutletStatus(self._outlet, "off")
self._enabled = False | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"setOutletStatus",
"(",
"self",
".",
"_outlet",
",",
"\"off\"",
")",
"self",
".",
"_enabled",
"=",
"False"
] | [
108,
4
] | [
111,
29
] | python | en | ['en', 'en', 'en'] | True |
AtenSwitch.async_update | (self) | Process update from entity. | Process update from entity. | async def async_update(self):
"""Process update from entity."""
status = await self._device.displayOutletStatus(self._outlet)
if status == "on":
self._enabled = True
self._outlet_power = await self._device.outletPower(self._outlet)
elif status == "off":
... | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"status",
"=",
"await",
"self",
".",
"_device",
".",
"displayOutletStatus",
"(",
"self",
".",
"_outlet",
")",
"if",
"status",
"==",
"\"on\"",
":",
"self",
".",
"_enabled",
"=",
"True",
"self",
".",
... | [
113,
4
] | [
121,
36
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow.__init__ | (self) | Set up flow instance. | Set up flow instance. | def __init__(self):
"""Set up flow instance."""
self.addon_config = None
self.network_key = None
self.usb_path = None
self.use_addon = False
# If we install the add-on we should uninstall it on entry remove.
self.integration_created_addon = False | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"addon_config",
"=",
"None",
"self",
".",
"network_key",
"=",
"None",
"self",
".",
"usb_path",
"=",
"None",
"self",
".",
"use_addon",
"=",
"False",
"# If we install the add-on we should uninstall it on entry r... | [
30,
4
] | [
37,
46
] | python | en | ['en', 'da', 'en'] | True |
DomainConfigFlow.async_step_user | (self, user_input=None) | Handle the initial step. | Handle the initial step. | async def async_step_user(self, user_input=None):
"""Handle the initial step."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
# Currently all flow results need the MQTT integration.
# This will change when we have the direct MQT... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"_async_current_entries",
"(",
")",
":",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
"\"single_instance_allowed\"",
")",
"# Currently all f... | [
39,
4
] | [
53,
52
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow._async_create_entry_from_vars | (self) | Return a config entry for the flow. | Return a config entry for the flow. | def _async_create_entry_from_vars(self):
"""Return a config entry for the flow."""
return self.async_create_entry(
title=TITLE,
data={
CONF_USB_PATH: self.usb_path,
CONF_NETWORK_KEY: self.network_key,
CONF_USE_ADDON: self.use_addon,... | [
"def",
"_async_create_entry_from_vars",
"(",
"self",
")",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"TITLE",
",",
"data",
"=",
"{",
"CONF_USB_PATH",
":",
"self",
".",
"usb_path",
",",
"CONF_NETWORK_KEY",
":",
"self",
".",
"network_ke... | [
55,
4
] | [
65,
9
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow._async_use_mqtt_integration | (self) | Handle logic when using the MQTT integration.
This is the entry point for the logic that is needed
when this integration will depend on the MQTT integration.
| Handle logic when using the MQTT integration. | def _async_use_mqtt_integration(self):
"""Handle logic when using the MQTT integration.
This is the entry point for the logic that is needed
when this integration will depend on the MQTT integration.
"""
return self._async_create_entry_from_vars() | [
"def",
"_async_use_mqtt_integration",
"(",
"self",
")",
":",
"return",
"self",
".",
"_async_create_entry_from_vars",
"(",
")"
] | [
68,
4
] | [
74,
51
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow.async_step_on_supervisor | (self, user_input=None) | Handle logic when on Supervisor host. | Handle logic when on Supervisor host. | async def async_step_on_supervisor(self, user_input=None):
"""Handle logic when on Supervisor host."""
if user_input is None:
return self.async_show_form(
step_id="on_supervisor", data_schema=ON_SUPERVISOR_SCHEMA
)
if not user_input[CONF_USE_ADDON]:
... | [
"async",
"def",
"async_step_on_supervisor",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"on_supervisor\"",
",",
"data_schema",
"=",
"ON_SUPERVISOR_... | [
76,
4
] | [
93,
52
] | python | en | ['en', 'no', 'en'] | True |
DomainConfigFlow.async_step_install_addon | (self) | Install OpenZWave add-on. | Install OpenZWave add-on. | async def async_step_install_addon(self):
"""Install OpenZWave add-on."""
try:
await self.hass.components.hassio.async_install_addon("core_zwave")
except self.hass.components.hassio.HassioAPIError as err:
_LOGGER.error("Failed to install OpenZWave add-on: %s", err)
... | [
"async",
"def",
"async_step_install_addon",
"(",
"self",
")",
":",
"try",
":",
"await",
"self",
".",
"hass",
".",
"components",
".",
"hassio",
".",
"async_install_addon",
"(",
"\"core_zwave\"",
")",
"except",
"self",
".",
"hass",
".",
"components",
".",
"has... | [
95,
4
] | [
104,
50
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow.async_step_start_addon | (self, user_input=None) | Ask for config and start OpenZWave add-on. | Ask for config and start OpenZWave add-on. | async def async_step_start_addon(self, user_input=None):
"""Ask for config and start OpenZWave add-on."""
if self.addon_config is None:
self.addon_config = await self._async_get_addon_config()
errors = {}
if user_input is not None:
self.network_key = user_input[... | [
"async",
"def",
"async_step_start_addon",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"self",
".",
"addon_config",
"is",
"None",
":",
"self",
".",
"addon_config",
"=",
"await",
"self",
".",
"_async_get_addon_config",
"(",
")",
"errors",
"=",... | [
106,
4
] | [
144,
9
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow._async_get_addon_info | (self) | Return and cache OpenZWave add-on info. | Return and cache OpenZWave add-on info. | async def _async_get_addon_info(self):
"""Return and cache OpenZWave add-on info."""
try:
addon_info = await self.hass.components.hassio.async_get_addon_info(
"core_zwave"
)
except self.hass.components.hassio.HassioAPIError as err:
_LOGGER.erro... | [
"async",
"def",
"_async_get_addon_info",
"(",
"self",
")",
":",
"try",
":",
"addon_info",
"=",
"await",
"self",
".",
"hass",
".",
"components",
".",
"hassio",
".",
"async_get_addon_info",
"(",
"\"core_zwave\"",
")",
"except",
"self",
".",
"hass",
".",
"compo... | [
146,
4
] | [
156,
25
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow._async_is_addon_running | (self) | Return True if OpenZWave add-on is running. | Return True if OpenZWave add-on is running. | async def _async_is_addon_running(self):
"""Return True if OpenZWave add-on is running."""
addon_info = await self._async_get_addon_info()
return addon_info["state"] == "started" | [
"async",
"def",
"_async_is_addon_running",
"(",
"self",
")",
":",
"addon_info",
"=",
"await",
"self",
".",
"_async_get_addon_info",
"(",
")",
"return",
"addon_info",
"[",
"\"state\"",
"]",
"==",
"\"started\""
] | [
158,
4
] | [
161,
47
] | python | en | ['en', 'de', 'en'] | True |
DomainConfigFlow._async_is_addon_installed | (self) | Return True if OpenZWave add-on is installed. | Return True if OpenZWave add-on is installed. | async def _async_is_addon_installed(self):
"""Return True if OpenZWave add-on is installed."""
addon_info = await self._async_get_addon_info()
return addon_info["version"] is not None | [
"async",
"def",
"_async_is_addon_installed",
"(",
"self",
")",
":",
"addon_info",
"=",
"await",
"self",
".",
"_async_get_addon_info",
"(",
")",
"return",
"addon_info",
"[",
"\"version\"",
"]",
"is",
"not",
"None"
] | [
163,
4
] | [
166,
48
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow._async_get_addon_config | (self) | Get OpenZWave add-on config. | Get OpenZWave add-on config. | async def _async_get_addon_config(self):
"""Get OpenZWave add-on config."""
addon_info = await self._async_get_addon_info()
return addon_info["options"] | [
"async",
"def",
"_async_get_addon_config",
"(",
"self",
")",
":",
"addon_info",
"=",
"await",
"self",
".",
"_async_get_addon_info",
"(",
")",
"return",
"addon_info",
"[",
"\"options\"",
"]"
] | [
168,
4
] | [
171,
36
] | python | en | ['en', 'en', 'en'] | True |
DomainConfigFlow._async_set_addon_config | (self, config) | Set OpenZWave add-on config. | Set OpenZWave add-on config. | async def _async_set_addon_config(self, config):
"""Set OpenZWave add-on config."""
options = {"options": config}
try:
await self.hass.components.hassio.async_set_addon_options(
"core_zwave", options
)
except self.hass.components.hassio.HassioAPIEr... | [
"async",
"def",
"_async_set_addon_config",
"(",
"self",
",",
"config",
")",
":",
"options",
"=",
"{",
"\"options\"",
":",
"config",
"}",
"try",
":",
"await",
"self",
".",
"hass",
".",
"components",
".",
"hassio",
".",
"async_set_addon_options",
"(",
"\"core_... | [
173,
4
] | [
182,
63
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Etherscan.io sensors. | Set up the Etherscan.io sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Etherscan.io sensors."""
address = config.get(CONF_ADDRESS)
name = config.get(CONF_NAME)
token = config.get(CONF_TOKEN)
token_address = config.get(CONF_TOKEN_ADDRESS)
if token:
token = token.upper()
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"address",
"=",
"config",
".",
"get",
"(",
"CONF_ADDRESS",
")",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"token",
"="... | [
27,
0
] | [
41,
78
] | python | en | ['en', 'en', 'en'] | True |
EtherscanSensor.__init__ | (self, name, address, token, token_address) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, address, token, token_address):
"""Initialize the sensor."""
self._name = name
self._address = address
self._token_address = token_address
self._token = token
self._state = None
self._unit_of_measurement = self._token or "ETH" | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"address",
",",
"token",
",",
"token_address",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_address",
"=",
"address",
"self",
".",
"_token_address",
"=",
"token_address",
"self",
".",
"_tok... | [
47,
4
] | [
54,
56
] | python | en | ['en', 'en', 'en'] | True |
EtherscanSensor.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"
] | [
57,
4
] | [
59,
25
] | python | en | ['en', 'mi', 'en'] | True |
EtherscanSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
62,
4
] | [
64,
26
] | python | en | ['en', 'en', 'en'] | True |
EtherscanSensor.unit_of_measurement | (self) | Return the unit of measurement this sensor expresses itself in. | Return the unit of measurement this sensor expresses itself in. | def unit_of_measurement(self):
"""Return the unit of measurement this sensor expresses itself in."""
return self._unit_of_measurement | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit_of_measurement"
] | [
67,
4
] | [
69,
40
] | python | en | ['en', 'en', 'en'] | True |
EtherscanSensor.device_state_attributes | (self) | Return the state attributes of the sensor. | Return the state attributes of the sensor. | def device_state_attributes(self):
"""Return the state attributes of the sensor."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
72,
4
] | [
74,
46
] | python | en | ['en', 'en', 'en'] | True |
EtherscanSensor.update | (self) | Get the latest state of the sensor. | Get the latest state of the sensor. | def update(self):
"""Get the latest state of the sensor."""
if self._token_address:
self._state = get_balance(self._address, self._token_address)
elif self._token:
self._state = get_balance(self._address, self._token)
else:
self._state = get_balance(s... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"self",
".",
"_token_address",
":",
"self",
".",
"_state",
"=",
"get_balance",
"(",
"self",
".",
"_address",
",",
"self",
".",
"_token_address",
")",
"elif",
"self",
".",
"_token",
":",
"self",
".",
"_state... | [
76,
4
] | [
84,
52
] | python | en | ['en', 'en', 'en'] | True |
shift_tokens_right | (input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int) |
Shift input ids one token to the right.
|
Shift input ids one token to the right.
| def shift_tokens_right(input_ids: torch.Tensor, pad_token_id: int, decoder_start_token_id: int):
"""
Shift input ids one token to the right.
"""
shifted_input_ids = input_ids.new_zeros(input_ids.shape)
shifted_input_ids[:, 1:] = input_ids[:, :-1].clone()
shifted_input_ids[:, 0] = decoder_start_t... | [
"def",
"shift_tokens_right",
"(",
"input_ids",
":",
"torch",
".",
"Tensor",
",",
"pad_token_id",
":",
"int",
",",
"decoder_start_token_id",
":",
"int",
")",
":",
"shifted_input_ids",
"=",
"input_ids",
".",
"new_zeros",
"(",
"input_ids",
".",
"shape",
")",
"shi... | [
57,
0
] | [
69,
28
] | python | en | ['en', 'error', 'th'] | False |
_make_causal_mask | (input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0) |
Make causal mask used for bi-directional self-attention.
|
Make causal mask used for bi-directional self-attention.
| def _make_causal_mask(input_ids_shape: torch.Size, dtype: torch.dtype, past_key_values_length: int = 0):
"""
Make causal mask used for bi-directional self-attention.
"""
bsz, tgt_len = input_ids_shape
mask = torch.full((tgt_len, tgt_len), float("-inf"))
mask_cond = torch.arange(mask.size(-1))
... | [
"def",
"_make_causal_mask",
"(",
"input_ids_shape",
":",
"torch",
".",
"Size",
",",
"dtype",
":",
"torch",
".",
"dtype",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"tgt_len",
"=",
"input_ids_shape",
"mask",
"=",
"torch",
"."... | [
73,
0
] | [
85,
91
] | python | en | ['en', 'error', 'th'] | False |
_expand_mask | (mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None) |
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
| def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
"""
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
"""
bsz, src_len = mask.size()
tgt_len = tgt_len if tgt_len is not None else src_len
expanded_mask = mask[:, None, N... | [
"def",
"_expand_mask",
"(",
"mask",
":",
"torch",
".",
"Tensor",
",",
"dtype",
":",
"torch",
".",
"dtype",
",",
"tgt_len",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
":",
"bsz",
",",
"src_len",
"=",
"mask",
".",
"size",
"(",
")",
"tgt_len"... | [
89,
0
] | [
100,
82
] | python | en | ['en', 'error', 'th'] | False |
Speech2TextSinusoidalPositionalEmbedding.get_embedding | (num_embeddings: int, embedding_dim: int, padding_idx: Optional[int] = None) |
Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly from the
description in Section 3.5 of "Attention Is All You Need".
|
Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly from the
description in Section 3.5 of "Attention Is All You Need".
| def get_embedding(num_embeddings: int, embedding_dim: int, padding_idx: Optional[int] = None):
"""
Build sinusoidal embeddings. This matches the implementation in tensor2tensor, but differs slightly from the
description in Section 3.5 of "Attention Is All You Need".
"""
half_dim ... | [
"def",
"get_embedding",
"(",
"num_embeddings",
":",
"int",
",",
"embedding_dim",
":",
"int",
",",
"padding_idx",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
":",
"half_dim",
"=",
"embedding_dim",
"//",
"2",
"emb",
"=",
"math",
".",
"log",
"(",
... | [
159,
4
] | [
174,
18
] | python | en | ['en', 'error', 'th'] | False |
Speech2TextSinusoidalPositionalEmbedding.create_position_ids_from_input_ids | (
self, input_ids: torch.Tensor, padding_idx: int, past_key_values_length: Optional[int] = 0
) |
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding
symbols are ignored. This is modified from fairseq's `utils.make_positions`.
Args:
x: torch.Tensor x:
Returns: torch.Tensor
|
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding
symbols are ignored. This is modified from fairseq's `utils.make_positions`. | def create_position_ids_from_input_ids(
self, input_ids: torch.Tensor, padding_idx: int, past_key_values_length: Optional[int] = 0
):
"""
Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding
symbols are ignored. This is modified fr... | [
"def",
"create_position_ids_from_input_ids",
"(",
"self",
",",
"input_ids",
":",
"torch",
".",
"Tensor",
",",
"padding_idx",
":",
"int",
",",
"past_key_values_length",
":",
"Optional",
"[",
"int",
"]",
"=",
"0",
")",
":",
"# The series of casts and type-conversions ... | [
191,
4
] | [
205,
55
] | python | en | ['en', 'error', 'th'] | False |
Speech2TextAttention.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",
... | [
239,
4
] | [
348,
65
] | python | en | ['en', 'pl', 'en'] | True |
Speech2TextEncoderLayer.forward | (
self,
hidden_states: torch.Tensor,
attention_mask: torch.Tensor,
layer_head_mask: torch.Tensor,
output_attentions: bool = False,
) |
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape :obj:`(seq_len, batch, embed_dim)`
attention_mask (:obj:`torch.FloatTensor`): attention mask of size
:obj:`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negativ... |
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape :obj:`(seq_len, batch, embed_dim)`
attention_mask (:obj:`torch.FloatTensor`): attention mask of size
:obj:`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negativ... | def forward(
self,
hidden_states: torch.Tensor,
attention_mask: torch.Tensor,
layer_head_mask: torch.Tensor,
output_attentions: bool = False,
):
"""
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape :obj:`(seq_len, batch, ... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
":",
"torch",
".",
"Tensor",
",",
"attention_mask",
":",
"torch",
".",
"Tensor",
",",
"layer_head_mask",
":",
"torch",
".",
"Tensor",
",",
"output_attentions",
":",
"bool",
"=",
"False",
",",
")",
":",
... | [
368,
4
] | [
416,
22
] | python | en | ['en', 'error', 'th'] | False |
Speech2TextDecoderLayer.forward | (
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
encoder_layer_head_mask... |
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape :obj:`(seq_len, batch, embed_dim)`
attention_mask (:obj:`torch.FloatTensor`): attention mask of size
:obj:`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negativ... |
Args:
hidden_states (:obj:`torch.FloatTensor`): input to the layer of shape :obj:`(seq_len, batch, embed_dim)`
attention_mask (:obj:`torch.FloatTensor`): attention mask of size
:obj:`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negativ... | def forward(
self,
hidden_states: torch.Tensor,
attention_mask: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
layer_head_mask: Optional[torch.Tensor] = None,
encoder_laye... | [
"def",
"forward",
"(",
"self",
",",
"hidden_states",
":",
"torch",
".",
"Tensor",
",",
"attention_mask",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_hidden_states",
":",
"Optional",
"[",
"torch",
".",
"Tensor",
"]",
"=",
... | [
446,
4
] | [
532,
22
] | python | en | ['en', 'error', 'th'] | False |
Speech2TextPreTrainedModel._get_subsampled_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_subsampled_output_lengths(self, input_lengths: torch.LongTensor):
"""
Computes the output length of the convolutional layers
"""
for i in range(self.config.num_conv_layers):
input_lengths = (input_lengths - 1) // 2 + 1
return input_lengths | [
"def",
"_get_subsampled_output_lengths",
"(",
"self",
",",
"input_lengths",
":",
"torch",
".",
"LongTensor",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"config",
".",
"num_conv_layers",
")",
":",
"input_lengths",
"=",
"(",
"input_lengths",
"-",
"... | [
550,
4
] | [
558,
28
] | python | en | ['en', 'error', 'th'] | False |
Speech2TextEncoder.forward | (
self,
input_features,
attention_mask=None,
head_mask=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
) | r"""
Args:
input_features (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length, feature_size)`):
Float values of fbank features extracted from the raw speech waveform. Raw speech waveform can be
obtained by loading a ``.flac`` or ``.wav`` audio file in... | r"""
Args:
input_features (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length, feature_size)`):
Float values of fbank features extracted from the raw speech waveform. Raw speech waveform can be
obtained by loading a ``.flac`` or ``.wav`` audio file in... | def forward(
self,
input_features,
attention_mask=None,
head_mask=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
):
r"""
Args:
input_features (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_... | [
"def",
"forward",
"(",
"self",
",",
"input_features",
",",
"attention_mask",
"=",
"None",
",",
"head_mask",
"=",
"None",
",",
"output_attentions",
"=",
"None",
",",
"output_hidden_states",
"=",
"None",
",",
"return_dict",
"=",
"None",
",",
")",
":",
"output_... | [
699,
4
] | [
818,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
Speech2TextDecoder.forward | (
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
head_mask=None,
encoder_head_mask=None,
past_key_values=None,
inputs_embeds=None,
use_cache=None,
output_attentions=None,
... | r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using :class:`~transfor... | r"""
Args:
input_ids (:obj:`torch.LongTensor` of shape :obj:`(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it. | def forward(
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
encoder_attention_mask=None,
head_mask=None,
encoder_head_mask=None,
past_key_values=None,
inputs_embeds=None,
use_cache=None,
output_attentions=Non... | [
"def",
"forward",
"(",
"self",
",",
"input_ids",
"=",
"None",
",",
"attention_mask",
"=",
"None",
",",
"encoder_hidden_states",
"=",
"None",
",",
"encoder_attention_mask",
"=",
"None",
",",
"head_mask",
"=",
"None",
",",
"encoder_head_mask",
"=",
"None",
",",
... | [
874,
4
] | [
1081,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
PretrainedConfig.use_return_dict | (self) |
:obj:`bool`: Whether or not return :class:`~transformers.file_utils.ModelOutput` instead of tuples.
|
:obj:`bool`: Whether or not return :class:`~transformers.file_utils.ModelOutput` instead of tuples.
| def use_return_dict(self) -> bool:
"""
:obj:`bool`: Whether or not return :class:`~transformers.file_utils.ModelOutput` instead of tuples.
"""
# If torchscript is set, force `return_dict=False` to avoid jit errors
return self.return_dict and not self.torchscript | [
"def",
"use_return_dict",
"(",
"self",
")",
"->",
"bool",
":",
"# If torchscript is set, force `return_dict=False` to avoid jit errors",
"return",
"self",
".",
"return_dict",
"and",
"not",
"self",
".",
"torchscript"
] | [
281,
4
] | [
286,
56
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.num_labels | (self) |
:obj:`int`: The number of labels for classification models.
|
:obj:`int`: The number of labels for classification models.
| def num_labels(self) -> int:
"""
:obj:`int`: The number of labels for classification models.
"""
return len(self.id2label) | [
"def",
"num_labels",
"(",
"self",
")",
"->",
"int",
":",
"return",
"len",
"(",
"self",
".",
"id2label",
")"
] | [
289,
4
] | [
293,
33
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.save_pretrained | (self, save_directory: Union[str, os.PathLike]) |
Save a configuration object to the directory ``save_directory``, so that it can be re-loaded using the
:func:`~transformers.PretrainedConfig.from_pretrained` class method.
Args:
save_directory (:obj:`str` or :obj:`os.PathLike`):
Directory where the configuration JSO... |
Save a configuration object to the directory ``save_directory``, so that it can be re-loaded using the
:func:`~transformers.PretrainedConfig.from_pretrained` class method. | def save_pretrained(self, save_directory: Union[str, os.PathLike]):
"""
Save a configuration object to the directory ``save_directory``, so that it can be re-loaded using the
:func:`~transformers.PretrainedConfig.from_pretrained` class method.
Args:
save_directory (:obj:`str... | [
"def",
"save_pretrained",
"(",
"self",
",",
"save_directory",
":",
"Union",
"[",
"str",
",",
"os",
".",
"PathLike",
"]",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"save_directory",
")",
":",
"raise",
"AssertionError",
"(",
"\"Provided path ({}... | [
301,
4
] | [
317,
67
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.from_pretrained | (cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs) | r"""
Instantiate a :class:`~transformers.PretrainedConfig` (or a derived class) from a pretrained model
configuration.
Args:
pretrained_model_name_or_path (:obj:`str` or :obj:`os.PathLike`):
This can be either:
- a string, the `model id` of a pretrai... | r"""
Instantiate a :class:`~transformers.PretrainedConfig` (or a derived class) from a pretrained model
configuration. | def from_pretrained(cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs) -> "PretrainedConfig":
r"""
Instantiate a :class:`~transformers.PretrainedConfig` (or a derived class) from a pretrained model
configuration.
Args:
pretrained_model_name_or_path (:obj:... | [
"def",
"from_pretrained",
"(",
"cls",
",",
"pretrained_model_name_or_path",
":",
"Union",
"[",
"str",
",",
"os",
".",
"PathLike",
"]",
",",
"*",
"*",
"kwargs",
")",
"->",
"\"PretrainedConfig\"",
":",
"config_dict",
",",
"kwargs",
"=",
"cls",
".",
"get_config... | [
320,
4
] | [
395,
51
] | python | cy | ['en', 'cy', 'hi'] | False |
PretrainedConfig.get_config_dict | (
cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs
) |
From a ``pretrained_model_name_or_path``, resolve to a dictionary of parameters, to be used for instantiating a
:class:`~transformers.PretrainedConfig` using ``from_dict``.
Parameters:
pretrained_model_name_or_path (:obj:`str` or :obj:`os.PathLike`):
The identifie... |
From a ``pretrained_model_name_or_path``, resolve to a dictionary of parameters, to be used for instantiating a
:class:`~transformers.PretrainedConfig` using ``from_dict``. | def get_config_dict(
cls, pretrained_model_name_or_path: Union[str, os.PathLike], **kwargs
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""
From a ``pretrained_model_name_or_path``, resolve to a dictionary of parameters, to be used for instantiating a
:class:`~transformers.PretrainedC... | [
"def",
"get_config_dict",
"(",
"cls",
",",
"pretrained_model_name_or_path",
":",
"Union",
"[",
"str",
",",
"os",
".",
"PathLike",
"]",
",",
"*",
"*",
"kwargs",
")",
"->",
"Tuple",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"Dict",
"[",
"str",
","... | [
398,
4
] | [
473,
34
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.from_dict | (cls, config_dict: Dict[str, Any], **kwargs) |
Instantiates a :class:`~transformers.PretrainedConfig` from a Python dictionary of parameters.
Args:
config_dict (:obj:`Dict[str, Any]`):
Dictionary that will be used to instantiate the configuration object. Such a dictionary can be
retrieved from a pretrain... |
Instantiates a :class:`~transformers.PretrainedConfig` from a Python dictionary of parameters. | def from_dict(cls, config_dict: Dict[str, Any], **kwargs) -> "PretrainedConfig":
"""
Instantiates a :class:`~transformers.PretrainedConfig` from a Python dictionary of parameters.
Args:
config_dict (:obj:`Dict[str, Any]`):
Dictionary that will be used to instantiate ... | [
"def",
"from_dict",
"(",
"cls",
",",
"config_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"*",
"*",
"kwargs",
")",
"->",
"\"PretrainedConfig\"",
":",
"return_unused_kwargs",
"=",
"kwargs",
".",
"pop",
"(",
"\"return_unused_kwargs\"",
",",
"False",
... | [
476,
4
] | [
511,
25
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.from_json_file | (cls, json_file: Union[str, os.PathLike]) |
Instantiates a :class:`~transformers.PretrainedConfig` from the path to a JSON file of parameters.
Args:
json_file (:obj:`str` or :obj:`os.PathLike`):
Path to the JSON file containing the parameters.
Returns:
:class:`PretrainedConfig`: The configuration... |
Instantiates a :class:`~transformers.PretrainedConfig` from the path to a JSON file of parameters. | def from_json_file(cls, json_file: Union[str, os.PathLike]) -> "PretrainedConfig":
"""
Instantiates a :class:`~transformers.PretrainedConfig` from the path to a JSON file of parameters.
Args:
json_file (:obj:`str` or :obj:`os.PathLike`):
Path to the JSON file contain... | [
"def",
"from_json_file",
"(",
"cls",
",",
"json_file",
":",
"Union",
"[",
"str",
",",
"os",
".",
"PathLike",
"]",
")",
"->",
"\"PretrainedConfig\"",
":",
"config_dict",
"=",
"cls",
".",
"_dict_from_json_file",
"(",
"json_file",
")",
"return",
"cls",
"(",
"... | [
514,
4
] | [
527,
33
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.to_diff_dict | (self) |
Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.
Returns:
:obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance,
|
Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary. | def to_diff_dict(self) -> Dict[str, Any]:
"""
Removes all attributes from config which correspond to the default config attributes for better readability and
serializes to a Python dictionary.
Returns:
:obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this... | [
"def",
"to_diff_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"config_dict",
"=",
"self",
".",
"to_dict",
"(",
")",
"# get the default config dict",
"default_config_dict",
"=",
"PretrainedConfig",
"(",
")",
".",
"to_dict",
"(",
")"... | [
541,
4
] | [
569,
39
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.to_dict | (self) |
Serializes this instance to a Python dictionary.
Returns:
:obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
|
Serializes this instance to a Python dictionary. | def to_dict(self) -> Dict[str, Any]:
"""
Serializes this instance to a Python dictionary.
Returns:
:obj:`Dict[str, Any]`: Dictionary of all the attributes that make up this configuration instance.
"""
output = copy.deepcopy(self.__dict__)
if hasattr(self.__cl... | [
"def",
"to_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"output",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"__dict__",
")",
"if",
"hasattr",
"(",
"self",
".",
"__class__",
",",
"\"model_type\"",
")",
":",
"output",
... | [
571,
4
] | [
585,
21
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.to_json_string | (self, use_diff: bool = True) |
Serializes this instance to a JSON string.
Args:
use_diff (:obj:`bool`, `optional`, defaults to :obj:`True`):
If set to ``True``, only the difference between the config instance and the default
``PretrainedConfig()`` is serialized to JSON string.
Re... |
Serializes this instance to a JSON string. | def to_json_string(self, use_diff: bool = True) -> str:
"""
Serializes this instance to a JSON string.
Args:
use_diff (:obj:`bool`, `optional`, defaults to :obj:`True`):
If set to ``True``, only the difference between the config instance and the default
... | [
"def",
"to_json_string",
"(",
"self",
",",
"use_diff",
":",
"bool",
"=",
"True",
")",
"->",
"str",
":",
"if",
"use_diff",
"is",
"True",
":",
"config_dict",
"=",
"self",
".",
"to_diff_dict",
"(",
")",
"else",
":",
"config_dict",
"=",
"self",
".",
"to_di... | [
587,
4
] | [
603,
71
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.to_json_file | (self, json_file_path: Union[str, os.PathLike], use_diff: bool = True) |
Save this instance to a JSON file.
Args:
json_file_path (:obj:`str` or :obj:`os.PathLike`):
Path to the JSON file in which this configuration instance's parameters will be saved.
use_diff (:obj:`bool`, `optional`, defaults to :obj:`True`):
If set... |
Save this instance to a JSON file. | def to_json_file(self, json_file_path: Union[str, os.PathLike], use_diff: bool = True):
"""
Save this instance to a JSON file.
Args:
json_file_path (:obj:`str` or :obj:`os.PathLike`):
Path to the JSON file in which this configuration instance's parameters will be sav... | [
"def",
"to_json_file",
"(",
"self",
",",
"json_file_path",
":",
"Union",
"[",
"str",
",",
"os",
".",
"PathLike",
"]",
",",
"use_diff",
":",
"bool",
"=",
"True",
")",
":",
"with",
"open",
"(",
"json_file_path",
",",
"\"w\"",
",",
"encoding",
"=",
"\"utf... | [
605,
4
] | [
617,
64
] | python | en | ['en', 'error', 'th'] | False |
PretrainedConfig.update | (self, config_dict: Dict[str, Any]) |
Updates attributes of this class with attributes from ``config_dict``.
Args:
config_dict (:obj:`Dict[str, Any]`): Dictionary of attributes that shall be updated for this class.
|
Updates attributes of this class with attributes from ``config_dict``. | def update(self, config_dict: Dict[str, Any]):
"""
Updates attributes of this class with attributes from ``config_dict``.
Args:
config_dict (:obj:`Dict[str, Any]`): Dictionary of attributes that shall be updated for this class.
"""
for key, value in config_dict.items... | [
"def",
"update",
"(",
"self",
",",
"config_dict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
":",
"for",
"key",
",",
"value",
"in",
"config_dict",
".",
"items",
"(",
")",
":",
"setattr",
"(",
"self",
",",
"key",
",",
"value",
")"
] | [
619,
4
] | [
627,
37
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up a Foscam IP Camera. | Set up a Foscam IP Camera. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up a Foscam IP Camera."""
async def async_handle_ptz(service):
"""Handle PTZ service call."""
movement = service.data[ATTR_MOVEMENT]
travel_time = service.data[ATTR_TRAVELTIME]
entity_i... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"async",
"def",
"async_handle_ptz",
"(",
"service",
")",
":",
"\"\"\"Handle PTZ service call.\"\"\"",
"movement",
"=",
"servi... | [
90,
0
] | [
148,
5
] | python | en | ['en', 'pt', 'en'] | True |
HassFoscamCamera.__init__ | (self, camera, name, username, password, rtsp_port, motion_status) | Initialize a Foscam camera. | Initialize a Foscam camera. | def __init__(self, camera, name, username, password, rtsp_port, motion_status):
"""Initialize a Foscam camera."""
super().__init__()
self._foscam_session = camera
self._name = name
self._username = username
self._password = password
self._rtsp_port = rtsp_port
... | [
"def",
"__init__",
"(",
"self",
",",
"camera",
",",
"name",
",",
"username",
",",
"password",
",",
"rtsp_port",
",",
"motion_status",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_foscam_session",
"=",
"camera",
"self",
".",
"_... | [
154,
4
] | [
163,
43
] | python | en | ['en', 'pt', 'it'] | False |
HassFoscamCamera.async_added_to_hass | (self) | Handle entity addition to hass. | Handle entity addition to hass. | async def async_added_to_hass(self):
"""Handle entity addition to hass."""
entities = self.hass.data.setdefault(FOSCAM_DATA, {}).setdefault(
FOSCAM_ENTITIES, []
)
entities.append(self) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"entities",
"=",
"self",
".",
"hass",
".",
"data",
".",
"setdefault",
"(",
"FOSCAM_DATA",
",",
"{",
"}",
")",
".",
"setdefault",
"(",
"FOSCAM_ENTITIES",
",",
"[",
"]",
")",
"entities",
".",
... | [
165,
4
] | [
170,
29
] | python | en | ['en', 'en', 'en'] | True |
HassFoscamCamera.camera_image | (self) | Return a still image response from the camera. | Return a still image response from the camera. | def camera_image(self):
"""Return a still image response from the camera."""
# Send the request to snap a picture and return raw jpg data
# Handle exception if host is not reachable or url failed
result, response = self._foscam_session.snap_picture_2()
if result != 0:
... | [
"def",
"camera_image",
"(",
"self",
")",
":",
"# Send the request to snap a picture and return raw jpg data",
"# Handle exception if host is not reachable or url failed",
"result",
",",
"response",
"=",
"self",
".",
"_foscam_session",
".",
"snap_picture_2",
"(",
")",
"if",
"r... | [
172,
4
] | [
180,
23
] | python | en | ['en', 'en', 'en'] | True |
HassFoscamCamera.supported_features | (self) | Return supported features. | Return supported features. | def supported_features(self):
"""Return supported features."""
if self._rtsp_port:
return SUPPORT_STREAM
return 0 | [
"def",
"supported_features",
"(",
"self",
")",
":",
"if",
"self",
".",
"_rtsp_port",
":",
"return",
"SUPPORT_STREAM",
"return",
"0"
] | [
183,
4
] | [
187,
16
] | python | en | ['en', 'en', 'en'] | True |
HassFoscamCamera.stream_source | (self) | Return the stream source. | Return the stream source. | async def stream_source(self):
"""Return the stream source."""
if self._rtsp_port:
return f"rtsp://{self._username}:{self._password}@{self._foscam_session.host}:{self._rtsp_port}/videoMain"
return None | [
"async",
"def",
"stream_source",
"(",
"self",
")",
":",
"if",
"self",
".",
"_rtsp_port",
":",
"return",
"f\"rtsp://{self._username}:{self._password}@{self._foscam_session.host}:{self._rtsp_port}/videoMain\"",
"return",
"None"
] | [
189,
4
] | [
193,
19
] | python | en | ['en', 'ig', 'en'] | True |
HassFoscamCamera.motion_detection_enabled | (self) | Camera Motion Detection Status. | Camera Motion Detection Status. | def motion_detection_enabled(self):
"""Camera Motion Detection Status."""
return self._motion_status | [
"def",
"motion_detection_enabled",
"(",
"self",
")",
":",
"return",
"self",
".",
"_motion_status"
] | [
196,
4
] | [
198,
34
] | python | en | ['sv', 'ja', 'en'] | False |
HassFoscamCamera.enable_motion_detection | (self) | Enable motion detection in camera. | Enable motion detection in camera. | def enable_motion_detection(self):
"""Enable motion detection in camera."""
try:
ret = self._foscam_session.enable_motion_detection()
if ret != 0:
return
self._motion_status = True
except TypeError:
_LOGGER.debug("Communication pr... | [
"def",
"enable_motion_detection",
"(",
"self",
")",
":",
"try",
":",
"ret",
"=",
"self",
".",
"_foscam_session",
".",
"enable_motion_detection",
"(",
")",
"if",
"ret",
"!=",
"0",
":",
"return",
"self",
".",
"_motion_status",
"=",
"True",
"except",
"TypeError... | [
200,
4
] | [
210,
50
] | python | en | ['it', 'en', 'en'] | True |
HassFoscamCamera.disable_motion_detection | (self) | Disable motion detection. | Disable motion detection. | def disable_motion_detection(self):
"""Disable motion detection."""
try:
ret = self._foscam_session.disable_motion_detection()
if ret != 0:
return
self._motion_status = False
except TypeError:
_LOGGER.debug("Communication problem"... | [
"def",
"disable_motion_detection",
"(",
"self",
")",
":",
"try",
":",
"ret",
"=",
"self",
".",
"_foscam_session",
".",
"disable_motion_detection",
"(",
")",
"if",
"ret",
"!=",
"0",
":",
"return",
"self",
".",
"_motion_status",
"=",
"False",
"except",
"TypeEr... | [
212,
4
] | [
222,
50
] | python | en | ['fr', 'en', 'en'] | True |
HassFoscamCamera.async_perform_ptz | (self, movement, travel_time) | Perform a PTZ action on the camera. | Perform a PTZ action on the camera. | async def async_perform_ptz(self, movement, travel_time):
"""Perform a PTZ action on the camera."""
_LOGGER.debug("PTZ action '%s' on %s", movement, self._name)
movement_function = getattr(self._foscam_session, MOVEMENT_ATTRS[movement])
ret, _ = await self.hass.async_add_executor_job(m... | [
"async",
"def",
"async_perform_ptz",
"(",
"self",
",",
"movement",
",",
"travel_time",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"PTZ action '%s' on %s\"",
",",
"movement",
",",
"self",
".",
"_name",
")",
"movement_function",
"=",
"getattr",
"(",
"self",
".",
... | [
224,
4
] | [
244,
18
] | python | en | ['en', 'en', 'en'] | True |
HassFoscamCamera.name | (self) | Return the name of this camera. | Return the name of this camera. | def name(self):
"""Return the name of this camera."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
247,
4
] | [
249,
25
] | python | en | ['en', 'en', 'en'] | True |
mock_session_response | (*args, **kwargs) | Mock data generation for session response. | Mock data generation for session response. | def mock_session_response(*args, **kwargs):
"""Mock data generation for session response."""
class MockSessionResponse:
def __init__(self, text, status_code):
self.text = text
self.status_code = status_code
# Username: foo
# Password: bar
if args[0].headers["Authori... | [
"def",
"mock_session_response",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"class",
"MockSessionResponse",
":",
"def",
"__init__",
"(",
"self",
",",
"text",
",",
"status_code",
")",
":",
"self",
".",
"text",
"=",
"text",
"self",
".",
"status_co... | [
21,
0
] | [
46,
41
] | python | en | ['en', 'no', 'en'] | True |
mock_exception_logger | () | Mock pyunifi. | Mock pyunifi. | def mock_exception_logger():
"""Mock pyunifi."""
with mock.patch(
"homeassistant.components.tomato.device_tracker._LOGGER.exception"
) as mock_exception_logger:
yield mock_exception_logger | [
"def",
"mock_exception_logger",
"(",
")",
":",
"with",
"mock",
".",
"patch",
"(",
"\"homeassistant.components.tomato.device_tracker._LOGGER.exception\"",
")",
"as",
"mock_exception_logger",
":",
"yield",
"mock_exception_logger"
] | [
50,
0
] | [
55,
35
] | python | en | ['en', 'tr', 'it'] | False |
mock_session_send | () | Mock requests.Session().send. | Mock requests.Session().send. | def mock_session_send():
"""Mock requests.Session().send."""
with mock.patch("requests.Session.send") as mock_session_send:
yield mock_session_send | [
"def",
"mock_session_send",
"(",
")",
":",
"with",
"mock",
".",
"patch",
"(",
"\"requests.Session.send\"",
")",
"as",
"mock_session_send",
":",
"yield",
"mock_session_send"
] | [
59,
0
] | [
62,
31
] | python | en | ['en', 'da', 'en'] | False |
test_config_missing_optional_params | (hass, mock_session_send) | Test the setup without optional parameters. | Test the setup without optional parameters. | def test_config_missing_optional_params(hass, mock_session_send):
"""Test the setup without optional parameters."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_USERNAME: "foo",
... | [
"def",
"test_config_missing_optional_params",
"(",
"hass",
",",
"mock_session_send",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",... | [
65,
0
] | [
86,
44
] | python | en | ['en', 'en', 'en'] | True |
test_config_default_nonssl_port | (hass, mock_session_send) | Test the setup without a default port set without ssl enabled. | Test the setup without a default port set without ssl enabled. | def test_config_default_nonssl_port(hass, mock_session_send):
"""Test the setup without a default port set without ssl enabled."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_USERN... | [
"def",
"test_config_default_nonssl_port",
"(",
"hass",
",",
"mock_session_send",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
"... | [
91,
0
] | [
105,
65
] | python | en | ['en', 'en', 'en'] | True |
test_config_default_ssl_port | (hass, mock_session_send) | Test the setup without a default port set with ssl enabled. | Test the setup without a default port set with ssl enabled. | def test_config_default_ssl_port(hass, mock_session_send):
"""Test the setup without a default port set with ssl enabled."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_SSL: True,
... | [
"def",
"test_config_default_ssl_port",
"(",
"hass",
",",
"mock_session_send",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
",",... | [
110,
0
] | [
125,
67
] | python | en | ['en', 'en', 'en'] | True |
test_config_verify_ssl_but_no_ssl_enabled | (hass, mock_session_send) | Test the setup with a string with ssl_verify but ssl not enabled. | Test the setup with a string with ssl_verify but ssl not enabled. | def test_config_verify_ssl_but_no_ssl_enabled(hass, mock_session_send):
"""Test the setup with a string with ssl_verify but ssl not enabled."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
... | [
"def",
"test_config_verify_ssl_but_no_ssl_enabled",
"(",
"hass",
",",
"mock_session_send",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-rout... | [
130,
0
] | [
156,
78
] | python | en | ['en', 'en', 'en'] | True |
test_config_valid_verify_ssl_path | (hass, mock_session_send) | Test the setup with a string for ssl_verify.
Representing the absolute path to a CA certificate bundle.
| Test the setup with a string for ssl_verify. | def test_config_valid_verify_ssl_path(hass, mock_session_send):
"""Test the setup with a string for ssl_verify.
Representing the absolute path to a CA certificate bundle.
"""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
C... | [
"def",
"test_config_valid_verify_ssl_path",
"(",
"hass",
",",
"mock_session_send",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
... | [
161,
0
] | [
192,
5
] | python | en | ['en', 'pt', 'en'] | True |
test_config_valid_verify_ssl_bool | (hass, mock_session_send) | Test the setup with a bool for ssl_verify. | Test the setup with a bool for ssl_verify. | def test_config_valid_verify_ssl_bool(hass, mock_session_send):
"""Test the setup with a bool for ssl_verify."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_PORT: 1234,
... | [
"def",
"test_config_valid_verify_ssl_bool",
"(",
"hass",
",",
"mock_session_send",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
... | [
195,
0
] | [
223,
5
] | python | en | ['en', 'en', 'en'] | True |
test_config_errors | () | Test for configuration errors. | Test for configuration errors. | def test_config_errors():
"""Test for configuration errors."""
with pytest.raises(vol.Invalid):
tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
# No Host,
CONF_PORT: 1234,
CONF_SSL: True,
CONF_VERIFY_SSL:... | [
"def",
"test_config_errors",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"# No Host,",
"CONF_PORT",
":",
"1234",
",",
... | [
226,
0
] | [
292,
9
] | python | en | ['da', 'en', 'en'] | True |
test_config_bad_credentials | (hass, mock_exception_logger) | Test the setup with bad credentials. | Test the setup with bad credentials. | def test_config_bad_credentials(hass, mock_exception_logger):
"""Test the setup with bad credentials."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_USERNAME: "i_am",
... | [
"def",
"test_config_bad_credentials",
"(",
"hass",
",",
"mock_exception_logger",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
"... | [
296,
0
] | [
315,
5
] | python | en | ['en', 'en', 'en'] | True |
test_bad_response | (hass, mock_exception_logger) | Test the setup with bad response from router. | Test the setup with bad response from router. | def test_bad_response(hass, mock_exception_logger):
"""Test the setup with bad response from router."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_USERNAME: "foo",
... | [
"def",
"test_bad_response",
"(",
"hass",
",",
"mock_exception_logger",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
",",
"CON... | [
319,
0
] | [
338,
5
] | python | en | ['en', 'en', 'en'] | True |
test_scan_devices | (hass, mock_exception_logger) | Test scanning for new devices. | Test scanning for new devices. | def test_scan_devices(hass, mock_exception_logger):
"""Test scanning for new devices."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_USERNAME: "foo",
CONF_PASSWORD:... | [
"def",
"test_scan_devices",
"(",
"hass",
",",
"mock_exception_logger",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
",",
"CON... | [
342,
0
] | [
357,
79
] | python | en | ['en', 'en', 'en'] | True |
test_bad_connection | (hass, mock_exception_logger) | Test the router with a connection error. | Test the router with a connection error. | def test_bad_connection(hass, mock_exception_logger):
"""Test the router with a connection error."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_USERNAME: "foo",
CO... | [
"def",
"test_bad_connection",
"(",
"hass",
",",
"mock_exception_logger",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
",",
"C... | [
361,
0
] | [
385,
5
] | python | en | ['en', 'en', 'en'] | True |
test_router_timeout | (hass, mock_exception_logger) | Test the router with a timeout error. | Test the router with a timeout error. | def test_router_timeout(hass, mock_exception_logger):
"""Test the router with a timeout error."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_USERNAME: "foo",
CONF_... | [
"def",
"test_router_timeout",
"(",
"hass",
",",
"mock_exception_logger",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
",",
"C... | [
389,
0
] | [
413,
5
] | python | en | ['en', 'en', 'en'] | True |
test_get_device_name | (hass, mock_exception_logger) | Test getting device names. | Test getting device names. | def test_get_device_name(hass, mock_exception_logger):
"""Test getting device names."""
config = {
DOMAIN: tomato.PLATFORM_SCHEMA(
{
CONF_PLATFORM: tomato.DOMAIN,
CONF_HOST: "tomato-router",
CONF_USERNAME: "foo",
CONF_PASSWORD: ... | [
"def",
"test_get_device_name",
"(",
"hass",
",",
"mock_exception_logger",
")",
":",
"config",
"=",
"{",
"DOMAIN",
":",
"tomato",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"tomato",
".",
"DOMAIN",
",",
"CONF_HOST",
":",
"\"tomato-router\"",
",",
"... | [
417,
0
] | [
434,
63
] | python | en | ['de', 'en', 'en'] | True |
host_port | (data) | Return a list with host and port. | Return a list with host and port. | def host_port(data):
"""Return a list with host and port."""
return (data[CONF_HOST], data[CONF_PORT]) | [
"def",
"host_port",
"(",
"data",
")",
":",
"return",
"(",
"data",
"[",
"CONF_HOST",
"]",
",",
"data",
"[",
"CONF_PORT",
"]",
")"
] | [
26,
0
] | [
28,
45
] | python | en | ['en', 'en', 'en'] | True |
create_schema | (previous_input=None) | Create a schema with given values as default. | Create a schema with given values as default. | def create_schema(previous_input=None):
"""Create a schema with given values as default."""
if previous_input is not None:
host, port = host_port(previous_input)
else:
host = DEFAULT_HOST
port = DEFAULT_PORT
return vol.Schema(
{
vol.Required(CONF_HOST, defaul... | [
"def",
"create_schema",
"(",
"previous_input",
"=",
"None",
")",
":",
"if",
"previous_input",
"is",
"not",
"None",
":",
"host",
",",
"port",
"=",
"host_port",
"(",
"previous_input",
")",
"else",
":",
"host",
"=",
"DEFAULT_HOST",
"port",
"=",
"DEFAULT_PORT",
... | [
31,
0
] | [
44,
5
] | python | en | ['en', 'en', 'en'] | True |
BleBoxConfigFlow.__init__ | (self) | Initialize the BleBox config flow. | Initialize the BleBox config flow. | def __init__(self):
"""Initialize the BleBox config flow."""
self.device_config = {} | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"device_config",
"=",
"{",
"}"
] | [
60,
4
] | [
62,
31
] | python | en | ['en', 'en', 'en'] | True |
BleBoxConfigFlow.handle_step_exception | (
self, step, exception, schema, host, port, message_id, log_fn
) | Handle step exceptions. | Handle step exceptions. | def handle_step_exception(
self, step, exception, schema, host, port, message_id, log_fn
):
"""Handle step exceptions."""
log_fn("%s at %s:%d (%s)", LOG_MSG[message_id], host, port, exception)
return self.async_show_form(
step_id="user",
data_schema=schema,
... | [
"def",
"handle_step_exception",
"(",
"self",
",",
"step",
",",
"exception",
",",
"schema",
",",
"host",
",",
"port",
",",
"message_id",
",",
"log_fn",
")",
":",
"log_fn",
"(",
"\"%s at %s:%d (%s)\"",
",",
"LOG_MSG",
"[",
"message_id",
"]",
",",
"host",
","... | [
64,
4
] | [
76,
9
] | python | en | ['en', 'en', 'en'] | True |
BleBoxConfigFlow.async_step_user | (self, user_input=None) | Handle initial user-triggered config step. | Handle initial user-triggered config step. | async def async_step_user(self, user_input=None):
"""Handle initial user-triggered config step."""
hass = self.hass
schema = create_schema(user_input)
if user_input is None:
return self.async_show_form(
step_id="user",
data_schema=schema,
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"hass",
"=",
"self",
".",
"hass",
"schema",
"=",
"create_schema",
"(",
"user_input",
")",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_fo... | [
78,
4
] | [
127,
75
] | python | en | ['da', 'en', 'en'] | True |
test_jewish_calendar_min_config | (hass) | Test minimum jewish calendar configuration. | Test minimum jewish calendar configuration. | async def test_jewish_calendar_min_config(hass):
"""Test minimum jewish calendar configuration."""
assert await async_setup_component(
hass, jewish_calendar.DOMAIN, {"jewish_calendar": {}}
)
await hass.async_block_till_done()
assert hass.states.get("sensor.jewish_calendar_date") is not None | [
"async",
"def",
"test_jewish_calendar_min_config",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"jewish_calendar",
".",
"DOMAIN",
",",
"{",
"\"jewish_calendar\"",
":",
"{",
"}",
"}",
")",
"await",
"hass",
".",
"async_block... | [
19,
0
] | [
25,
69
] | python | de | ['de', 'la', 'en'] | False |
test_jewish_calendar_hebrew | (hass) | Test jewish calendar sensor with language set to hebrew. | Test jewish calendar sensor with language set to hebrew. | async def test_jewish_calendar_hebrew(hass):
"""Test jewish calendar sensor with language set to hebrew."""
assert await async_setup_component(
hass, jewish_calendar.DOMAIN, {"jewish_calendar": {"language": "hebrew"}}
)
await hass.async_block_till_done()
assert hass.states.get("sensor.jewish... | [
"async",
"def",
"test_jewish_calendar_hebrew",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"jewish_calendar",
".",
"DOMAIN",
",",
"{",
"\"jewish_calendar\"",
":",
"{",
"\"language\"",
":",
"\"hebrew\"",
"}",
"}",
")",
"aw... | [
28,
0
] | [
34,
69
] | python | en | ['en', 'su', 'en'] | True |
test_jewish_calendar_sensor | (
hass,
legacy_patchable_time,
now,
tzname,
latitude,
longitude,
language,
sensor,
diaspora,
result,
) | Test Jewish calendar sensor output. | Test Jewish calendar sensor output. | async def test_jewish_calendar_sensor(
hass,
legacy_patchable_time,
now,
tzname,
latitude,
longitude,
language,
sensor,
diaspora,
result,
):
"""Test Jewish calendar sensor output."""
time_zone = dt_util.get_time_zone(tzname)
test_time = time_zone.localize(now)
ha... | [
"async",
"def",
"test_jewish_calendar_sensor",
"(",
"hass",
",",
"legacy_patchable_time",
",",
"now",
",",
"tzname",
",",
"latitude",
",",
"longitude",
",",
"language",
",",
"sensor",
",",
"diaspora",
",",
"result",
",",
")",
":",
"time_zone",
"=",
"dt_util",
... | [
150,
0
] | [
198,
59
] | python | en | ['en', 'su', 'en'] | True |
test_shabbat_times_sensor | (
hass,
legacy_patchable_time,
language,
now,
candle_lighting,
havdalah,
diaspora,
tzname,
latitude,
longitude,
result,
) | Test sensor output for upcoming shabbat/yomtov times. | Test sensor output for upcoming shabbat/yomtov times. | async def test_shabbat_times_sensor(
hass,
legacy_patchable_time,
language,
now,
candle_lighting,
havdalah,
diaspora,
tzname,
latitude,
longitude,
result,
):
"""Test sensor output for upcoming shabbat/yomtov times."""
time_zone = dt_util.get_time_zone(tzname)
test... | [
"async",
"def",
"test_shabbat_times_sensor",
"(",
"hass",
",",
"legacy_patchable_time",
",",
"language",
",",
"now",
",",
"candle_lighting",
",",
"havdalah",
",",
"diaspora",
",",
"tzname",
",",
"latitude",
",",
"longitude",
",",
"result",
",",
")",
":",
"time... | [
492,
0
] | [
570,
45
] | python | en | ['en', 'en', 'en'] | True |
test_omer_sensor | (hass, legacy_patchable_time, test_time, result) | Test Omer Count sensor output. | Test Omer Count sensor output. | async def test_omer_sensor(hass, legacy_patchable_time, test_time, result):
"""Test Omer Count sensor output."""
test_time = hass.config.time_zone.localize(test_time)
with alter_time(test_time):
assert await async_setup_component(
hass, jewish_calendar.DOMAIN, {"jewish_calendar": {"name... | [
"async",
"def",
"test_omer_sensor",
"(",
"hass",
",",
"legacy_patchable_time",
",",
"test_time",
",",
"result",
")",
":",
"test_time",
"=",
"hass",
".",
"config",
".",
"time_zone",
".",
"localize",
"(",
"test_time",
")",
"with",
"alter_time",
"(",
"test_time",... | [
592,
0
] | [
606,
73
] | python | da | ['sv', 'da', 'en'] | False |
test_dafyomi_sensor | (hass, legacy_patchable_time, test_time, result) | Test Daf Yomi sensor output. | Test Daf Yomi sensor output. | async def test_dafyomi_sensor(hass, legacy_patchable_time, test_time, result):
"""Test Daf Yomi sensor output."""
test_time = hass.config.time_zone.localize(test_time)
with alter_time(test_time):
assert await async_setup_component(
hass, jewish_calendar.DOMAIN, {"jewish_calendar": {"nam... | [
"async",
"def",
"test_dafyomi_sensor",
"(",
"hass",
",",
"legacy_patchable_time",
",",
"test_time",
",",
"result",
")",
":",
"test_time",
"=",
"hass",
".",
"config",
".",
"time_zone",
".",
"localize",
"(",
"test_time",
")",
"with",
"alter_time",
"(",
"test_tim... | [
626,
0
] | [
640,
66
] | python | da | ['da', 'is', 'en'] | False |
test_reloadable | (hass) | Test that we can reload. | Test that we can reload. | async def test_reloadable(hass):
"""Test that we can reload."""
hass.states.async_set("sensor.test_sensor", "mytest")
await async_setup_component(
hass,
"sensor",
{
"sensor": {
"platform": DOMAIN,
"sensors": {
"state": ... | [
"async",
"def",
"test_reloadable",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.test_sensor\"",
",",
"\"mytest\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sensor\"",
":",
"{",
"\"pla... | [
13,
0
] | [
57,
83
] | python | en | ['en', 'en', 'en'] | True |
test_reloadable_can_remove | (hass) | Test that we can reload and remove all template sensors. | Test that we can reload and remove all template sensors. | async def test_reloadable_can_remove(hass):
"""Test that we can reload and remove all template sensors."""
hass.states.async_set("sensor.test_sensor", "mytest")
await async_setup_component(
hass,
"sensor",
{
"sensor": {
"platform": DOMAIN,
... | [
"async",
"def",
"test_reloadable_can_remove",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.test_sensor\"",
",",
"\"mytest\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sensor\"",
":",
"{... | [
60,
0
] | [
100,
44
] | python | en | ['en', 'en', 'en'] | True |
test_reloadable_stops_on_invalid_config | (hass) | Test we stop the reload if configuration.yaml is completely broken. | Test we stop the reload if configuration.yaml is completely broken. | async def test_reloadable_stops_on_invalid_config(hass):
"""Test we stop the reload if configuration.yaml is completely broken."""
hass.states.async_set("sensor.test_sensor", "mytest")
await async_setup_component(
hass,
"sensor",
{
"sensor": {
"platform":... | [
"async",
"def",
"test_reloadable_stops_on_invalid_config",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.test_sensor\"",
",",
"\"mytest\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sensor\""... | [
103,
0
] | [
145,
44
] | python | en | ['en', 'en', 'en'] | True |
test_reloadable_handles_partial_valid_config | (hass) | Test we can still setup valid sensors when configuration.yaml has a broken entry. | Test we can still setup valid sensors when configuration.yaml has a broken entry. | async def test_reloadable_handles_partial_valid_config(hass):
"""Test we can still setup valid sensors when configuration.yaml has a broken entry."""
hass.states.async_set("sensor.test_sensor", "mytest")
await async_setup_component(
hass,
"sensor",
{
"sensor": {
... | [
"async",
"def",
"test_reloadable_handles_partial_valid_config",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.test_sensor\"",
",",
"\"mytest\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sens... | [
148,
0
] | [
193,
83
] | python | en | ['en', 'en', 'en'] | True |
test_reloadable_multiple_platforms | (hass) | Test that we can reload. | Test that we can reload. | async def test_reloadable_multiple_platforms(hass):
"""Test that we can reload."""
hass.states.async_set("sensor.test_sensor", "mytest")
await async_setup_component(
hass,
"sensor",
{
"sensor": {
"platform": DOMAIN,
"sensors": {
... | [
"async",
"def",
"test_reloadable_multiple_platforms",
"(",
"hass",
")",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"sensor.test_sensor\"",
",",
"\"mytest\"",
")",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sensor\"",
"... | [
196,
0
] | [
256,
83
] | python | en | ['en', 'en', 'en'] | True |
test_reload_sensors_that_reference_other_template_sensors | (hass) | Test that we can reload sensor that reference other template sensors. | Test that we can reload sensor that reference other template sensors. | async def test_reload_sensors_that_reference_other_template_sensors(hass):
"""Test that we can reload sensor that reference other template sensors."""
await async_setup_component(
hass,
"sensor",
{
"sensor": {
"platform": DOMAIN,
"sensors": {
... | [
"async",
"def",
"test_reload_sensors_that_reference_other_template_sensors",
"(",
"hass",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"DOMAIN",
",",
"\"sensors\"",
":",
"{",
"\"st... | [
259,
0
] | [
301,
55
] | python | en | ['en', 'en', 'en'] | True |
test_static_vars | () | Test static vars. | Test static vars. | async def test_static_vars():
"""Test static vars."""
orig = {"hello": "world"}
var = cv.SCRIPT_VARIABLES_SCHEMA(orig)
rendered = var.async_render(None, None)
assert rendered is not orig
assert rendered == orig | [
"async",
"def",
"test_static_vars",
"(",
")",
":",
"orig",
"=",
"{",
"\"hello\"",
":",
"\"world\"",
"}",
"var",
"=",
"cv",
".",
"SCRIPT_VARIABLES_SCHEMA",
"(",
"orig",
")",
"rendered",
"=",
"var",
".",
"async_render",
"(",
"None",
",",
"None",
")",
"asse... | [
6,
0
] | [
12,
27
] | python | en | ['en', 'hi-Latn', 'en'] | True |
test_static_vars_run_args | () | Test static vars. | Test static vars. | async def test_static_vars_run_args():
"""Test static vars."""
orig = {"hello": "world"}
orig_copy = dict(orig)
var = cv.SCRIPT_VARIABLES_SCHEMA(orig)
rendered = var.async_render(None, {"hello": "override", "run": "var"})
assert rendered == {"hello": "override", "run": "var"}
# Make sure we ... | [
"async",
"def",
"test_static_vars_run_args",
"(",
")",
":",
"orig",
"=",
"{",
"\"hello\"",
":",
"\"world\"",
"}",
"orig_copy",
"=",
"dict",
"(",
"orig",
")",
"var",
"=",
"cv",
".",
"SCRIPT_VARIABLES_SCHEMA",
"(",
"orig",
")",
"rendered",
"=",
"var",
".",
... | [
15,
0
] | [
23,
28
] | python | en | ['en', 'hi-Latn', 'en'] | True |
test_static_vars_no_default | () | Test static vars. | Test static vars. | async def test_static_vars_no_default():
"""Test static vars."""
orig = {"hello": "world"}
var = cv.SCRIPT_VARIABLES_SCHEMA(orig)
rendered = var.async_render(None, None, render_as_defaults=False)
assert rendered is not orig
assert rendered == orig | [
"async",
"def",
"test_static_vars_no_default",
"(",
")",
":",
"orig",
"=",
"{",
"\"hello\"",
":",
"\"world\"",
"}",
"var",
"=",
"cv",
".",
"SCRIPT_VARIABLES_SCHEMA",
"(",
"orig",
")",
"rendered",
"=",
"var",
".",
"async_render",
"(",
"None",
",",
"None",
"... | [
26,
0
] | [
32,
27
] | python | en | ['en', 'hi-Latn', 'en'] | True |
test_static_vars_run_args_no_default | () | Test static vars. | Test static vars. | async def test_static_vars_run_args_no_default():
"""Test static vars."""
orig = {"hello": "world"}
orig_copy = dict(orig)
var = cv.SCRIPT_VARIABLES_SCHEMA(orig)
rendered = var.async_render(
None, {"hello": "override", "run": "var"}, render_as_defaults=False
)
assert rendered == {"he... | [
"async",
"def",
"test_static_vars_run_args_no_default",
"(",
")",
":",
"orig",
"=",
"{",
"\"hello\"",
":",
"\"world\"",
"}",
"orig_copy",
"=",
"dict",
"(",
"orig",
")",
"var",
"=",
"cv",
".",
"SCRIPT_VARIABLES_SCHEMA",
"(",
"orig",
")",
"rendered",
"=",
"var... | [
35,
0
] | [
45,
28
] | python | en | ['en', 'hi-Latn', 'en'] | True |
test_template_vars | (hass) | Test template vars. | Test template vars. | async def test_template_vars(hass):
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA({"hello": "{{ 1 + 1 }}"})
rendered = var.async_render(hass, None)
assert rendered == {"hello": 2} | [
"async",
"def",
"test_template_vars",
"(",
"hass",
")",
":",
"var",
"=",
"cv",
".",
"SCRIPT_VARIABLES_SCHEMA",
"(",
"{",
"\"hello\"",
":",
"\"{{ 1 + 1 }}\"",
"}",
")",
"rendered",
"=",
"var",
".",
"async_render",
"(",
"hass",
",",
"None",
")",
"assert",
"r... | [
48,
0
] | [
52,
35
] | python | en | ['en', 'et', 'en'] | True |
test_template_vars_run_args | (hass) | Test template vars. | Test template vars. | async def test_template_vars_run_args(hass):
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA(
{
"something": "{{ run_var_ex + 1 }}",
"something_2": "{{ run_var_ex + 1 }}",
}
)
rendered = var.async_render(
hass,
{
"run_var_ex"... | [
"async",
"def",
"test_template_vars_run_args",
"(",
"hass",
")",
":",
"var",
"=",
"cv",
".",
"SCRIPT_VARIABLES_SCHEMA",
"(",
"{",
"\"something\"",
":",
"\"{{ run_var_ex + 1 }}\"",
",",
"\"something_2\"",
":",
"\"{{ run_var_ex + 1 }}\"",
",",
"}",
")",
"rendered",
"=... | [
55,
0
] | [
74,
5
] | python | en | ['en', 'et', 'en'] | True |
test_template_vars_no_default | (hass) | Test template vars. | Test template vars. | async def test_template_vars_no_default(hass):
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA({"hello": "{{ 1 + 1 }}"})
rendered = var.async_render(hass, None, render_as_defaults=False)
assert rendered == {"hello": 2} | [
"async",
"def",
"test_template_vars_no_default",
"(",
"hass",
")",
":",
"var",
"=",
"cv",
".",
"SCRIPT_VARIABLES_SCHEMA",
"(",
"{",
"\"hello\"",
":",
"\"{{ 1 + 1 }}\"",
"}",
")",
"rendered",
"=",
"var",
".",
"async_render",
"(",
"hass",
",",
"None",
",",
"re... | [
77,
0
] | [
81,
35
] | python | en | ['en', 'et', 'en'] | True |
test_template_vars_run_args_no_default | (hass) | Test template vars. | Test template vars. | async def test_template_vars_run_args_no_default(hass):
"""Test template vars."""
var = cv.SCRIPT_VARIABLES_SCHEMA(
{
"something": "{{ run_var_ex + 1 }}",
"something_2": "{{ run_var_ex + 1 }}",
}
)
rendered = var.async_render(
hass,
{
"... | [
"async",
"def",
"test_template_vars_run_args_no_default",
"(",
"hass",
")",
":",
"var",
"=",
"cv",
".",
"SCRIPT_VARIABLES_SCHEMA",
"(",
"{",
"\"something\"",
":",
"\"{{ run_var_ex + 1 }}\"",
",",
"\"something_2\"",
":",
"\"{{ run_var_ex + 1 }}\"",
",",
"}",
")",
"rend... | [
84,
0
] | [
104,
5
] | python | en | ['en', 'et', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.