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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
GeonetnzQuakesFeedEntityManager.get_entry | (self, external_id) | Get feed entry by external id. | Get feed entry by external id. | def get_entry(self, external_id):
"""Get feed entry by external id."""
return self._feed_manager.feed_entries.get(external_id) | [
"def",
"get_entry",
"(",
"self",
",",
"external_id",
")",
":",
"return",
"self",
".",
"_feed_manager",
".",
"feed_entries",
".",
"get",
"(",
"external_id",
")"
] | [
189,
4
] | [
191,
63
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzQuakesFeedEntityManager.status_info | (self) | Return latest status update info received. | Return latest status update info received. | def status_info(self):
"""Return latest status update info received."""
return self._status_info | [
"def",
"status_info",
"(",
"self",
")",
":",
"return",
"self",
".",
"_status_info"
] | [
193,
4
] | [
195,
32
] | python | co | ['es', 'co', 'en'] | False |
GeonetnzQuakesFeedEntityManager._generate_entity | (self, external_id) | Generate new entity. | Generate new entity. | async def _generate_entity(self, external_id):
"""Generate new entity."""
async_dispatcher_send(
self._hass,
self.async_event_new_entity(),
self,
self._config_entry.unique_id,
external_id,
) | [
"async",
"def",
"_generate_entity",
"(",
"self",
",",
"external_id",
")",
":",
"async_dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"self",
".",
"async_event_new_entity",
"(",
")",
",",
"self",
",",
"self",
".",
"_config_entry",
".",
"unique_id",
",",
"e... | [
197,
4
] | [
205,
9
] | python | en | ['en', 'en', 'en'] | True |
GeonetnzQuakesFeedEntityManager._update_entity | (self, external_id) | Update entity. | Update entity. | async def _update_entity(self, external_id):
"""Update entity."""
async_dispatcher_send(self._hass, f"geonetnz_quakes_update_{external_id}") | [
"async",
"def",
"_update_entity",
"(",
"self",
",",
"external_id",
")",
":",
"async_dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"f\"geonetnz_quakes_update_{external_id}\"",
")"
] | [
207,
4
] | [
209,
82
] | python | en | ['es', 'en', 'en'] | False |
GeonetnzQuakesFeedEntityManager._remove_entity | (self, external_id) | Remove entity. | Remove entity. | async def _remove_entity(self, external_id):
"""Remove entity."""
async_dispatcher_send(self._hass, f"geonetnz_quakes_delete_{external_id}") | [
"async",
"def",
"_remove_entity",
"(",
"self",
",",
"external_id",
")",
":",
"async_dispatcher_send",
"(",
"self",
".",
"_hass",
",",
"f\"geonetnz_quakes_delete_{external_id}\"",
")"
] | [
211,
4
] | [
213,
82
] | python | en | ['es', 'it', 'en'] | False |
GeonetnzQuakesFeedEntityManager._status_update | (self, status_info) | Propagate status update. | Propagate status update. | async def _status_update(self, status_info):
"""Propagate status update."""
_LOGGER.debug("Status update received: %s", status_info)
self._status_info = status_info
async_dispatcher_send(
self._hass, f"geonetnz_quakes_status_{self._config_entry_id}"
) | [
"async",
"def",
"_status_update",
"(",
"self",
",",
"status_info",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Status update received: %s\"",
",",
"status_info",
")",
"self",
".",
"_status_info",
"=",
"status_info",
"async_dispatcher_send",
"(",
"self",
".",
"_hass... | [
215,
4
] | [
221,
9
] | python | co | ['en', 'co', 'sw'] | False |
get_service | (hass, config, discovery_info=None) | Get the Free Mobile SMS notification service. | Get the Free Mobile SMS notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Free Mobile SMS notification service."""
return FreeSMSNotificationService(config[CONF_USERNAME], config[CONF_ACCESS_TOKEN]) | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"return",
"FreeSMSNotificationService",
"(",
"config",
"[",
"CONF_USERNAME",
"]",
",",
"config",
"[",
"CONF_ACCESS_TOKEN",
"]",
")"
] | [
23,
0
] | [
25,
87
] | python | en | ['en', 'en', 'en'] | True |
FreeSMSNotificationService.__init__ | (self, username, access_token) | Initialize the service. | Initialize the service. | def __init__(self, username, access_token):
"""Initialize the service."""
self.free_client = FreeClient(username, access_token) | [
"def",
"__init__",
"(",
"self",
",",
"username",
",",
"access_token",
")",
":",
"self",
".",
"free_client",
"=",
"FreeClient",
"(",
"username",
",",
"access_token",
")"
] | [
31,
4
] | [
33,
61
] | python | en | ['en', 'en', 'en'] | True |
FreeSMSNotificationService.send_message | (self, message="", **kwargs) | Send a message to the Free Mobile user cell. | Send a message to the Free Mobile user cell. | def send_message(self, message="", **kwargs):
"""Send a message to the Free Mobile user cell."""
resp = self.free_client.send_sms(message)
if resp.status_code == HTTP_BAD_REQUEST:
_LOGGER.error("At least one parameter is missing")
elif resp.status_code == 402:
_L... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"resp",
"=",
"self",
".",
"free_client",
".",
"send_sms",
"(",
"message",
")",
"if",
"resp",
".",
"status_code",
"==",
"HTTP_BAD_REQUEST",
":",
"_LOGGER",... | [
35,
4
] | [
46,
52
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant, entry: ConfigEntry) | Stub to allow setting up this component.
Configuration through YAML is not supported at this time.
| Stub to allow setting up this component. | async def async_setup(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Stub to allow setting up this component.
Configuration through YAML is not supported at this time.
"""
hass.data.setdefault(DOMAIN, {})
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"return",
"True"
] | [
44,
0
] | [
50,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up Control4 from a config entry. | Set up Control4 from a config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Control4 from a config entry."""
entry_data = hass.data[DOMAIN].setdefault(entry.entry_id, {})
account_session = aiohttp_client.async_get_clientsession(hass)
config = entry.data
account = C4Account(config[CONF_USERNAME]... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"entry_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"setdefault",
"(",
"entry",
".",
"entry_id",
",",
"{",
"}",
")",
"account... | [
53,
0
] | [
122,
15
] | python | en | ['en', 'en', 'en'] | True |
update_listener | (hass, config_entry) | Update when config_entry options update. | Update when config_entry options update. | async def update_listener(hass, config_entry):
"""Update when config_entry options update."""
_LOGGER.debug("Config entry was updated, rerunning setup")
await hass.config_entries.async_reload(config_entry.entry_id) | [
"async",
"def",
"update_listener",
"(",
"hass",
",",
"config_entry",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Config entry was updated, rerunning setup\"",
")",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"config_entry",
".",
"entry_id",
")"
... | [
125,
0
] | [
128,
65
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
]
)
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload... | [
131,
0
] | [
146,
20
] | python | en | ['en', 'es', 'en'] | True |
get_items_of_category | (hass: HomeAssistant, entry: ConfigEntry, category: str) | Return a list of all Control4 items with the specified category. | Return a list of all Control4 items with the specified category. | async def get_items_of_category(hass: HomeAssistant, entry: ConfigEntry, category: str):
"""Return a list of all Control4 items with the specified category."""
director_all_items = hass.data[DOMAIN][entry.entry_id][CONF_DIRECTOR_ALL_ITEMS]
return_list = []
for item in director_all_items:
if "cat... | [
"async",
"def",
"get_items_of_category",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"category",
":",
"str",
")",
":",
"director_all_items",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"["... | [
149,
0
] | [
156,
22
] | python | en | ['en', 'en', 'en'] | True |
Control4Entity.__init__ | (
self,
entry_data: dict,
entry: ConfigEntry,
coordinator: DataUpdateCoordinator,
name: str,
idx: int,
device_name: str,
device_manufacturer: str,
device_model: str,
device_id: int,
) | Initialize a Control4 entity. | Initialize a Control4 entity. | def __init__(
self,
entry_data: dict,
entry: ConfigEntry,
coordinator: DataUpdateCoordinator,
name: str,
idx: int,
device_name: str,
device_manufacturer: str,
device_model: str,
device_id: int,
):
"""Initialize a Control4 entity... | [
"def",
"__init__",
"(",
"self",
",",
"entry_data",
":",
"dict",
",",
"entry",
":",
"ConfigEntry",
",",
"coordinator",
":",
"DataUpdateCoordinator",
",",
"name",
":",
"str",
",",
"idx",
":",
"int",
",",
"device_name",
":",
"str",
",",
"device_manufacturer",
... | [
162,
4
] | [
184,
35
] | python | en | ['en', 'en', 'it'] | True |
Control4Entity.name | (self) | Return name of entity. | Return name of entity. | def name(self):
"""Return name of entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
187,
4
] | [
189,
25
] | python | en | ['en', 'ig', 'en'] | True |
Control4Entity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return self._idx | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_idx"
] | [
192,
4
] | [
194,
24
] | python | ca | ['fr', 'ca', 'en'] | False |
Control4Entity.device_info | (self) | Return info of parent Control4 device of entity. | Return info of parent Control4 device of entity. | def device_info(self):
"""Return info of parent Control4 device of entity."""
return {
"config_entry_id": self.entry.entry_id,
"identifiers": {(DOMAIN, self._device_id)},
"name": self._device_name,
"manufacturer": self._device_manufacturer,
"mo... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"config_entry_id\"",
":",
"self",
".",
"entry",
".",
"entry_id",
",",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_device_id",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
... | [
197,
4
] | [
206,
9
] | python | en | ['en', 'en', 'en'] | True |
SklearnGeneticSelection.__init__ | (self, model, params) |
PARAMETERS:
• model — sklearn-like model which will be used for scoring;
• params — parameters dictionary:
○ epochs — iterations count (required);
○ population_size — number of chromosomes in population (required);
○ score_f — sklearn-... |
PARAMETERS:
• model — sklearn-like model which will be used for scoring;
• params — parameters dictionary:
○ epochs — iterations count (required);
○ population_size — number of chromosomes in population (required);
○ score_f — sklearn-... | def __init__(self, model, params):
'''
PARAMETERS:
• model — sklearn-like model which will be used for scoring;
• params — parameters dictionary:
○ epochs — iterations count (required);
○ population_size — number of chromosomes in population (... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"params",
")",
":",
"keys",
"=",
"list",
"(",
"params",
".",
"keys",
"(",
")",
")",
"assert",
"'epochs'",
"in",
"keys",
"assert",
"'population_size'",
"in",
"keys",
"assert",
"'score_f'",
"in",
"keys",
... | [
19,
4
] | [
121,
35
] | python | en | ['en', 'error', 'th'] | False |
CatBoostGeneticSelection.__init__ | (self, model, params) |
PARAMETERS:
• model — sklearn-like model which will be used for scoring;
• params — parameters dictionary:
○ epochs — iterations count (required);
○ population_size — number of chromosomes in population (required);
○ score_f — sklearn-... |
PARAMETERS:
• model — sklearn-like model which will be used for scoring;
• params — parameters dictionary:
○ epochs — iterations count (required);
○ population_size — number of chromosomes in population (required);
○ score_f — sklearn-... | def __init__(self, model, params):
'''
PARAMETERS:
• model — sklearn-like model which will be used for scoring;
• params — parameters dictionary:
○ epochs — iterations count (required);
○ population_size — number of chromosomes in population (r... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"params",
")",
":",
"keys",
"=",
"list",
"(",
"params",
".",
"keys",
"(",
")",
")",
"assert",
"'epochs'",
"in",
"keys",
"assert",
"'population_size'",
"in",
"keys",
"assert",
"'score_f'",
"in",
"keys",
... | [
514,
4
] | [
618,
35
] | python | en | ['en', 'error', 'th'] | False |
AwairFlowHandler.async_step_import | (self, conf: dict) | Import a configuration from config.yaml. | Import a configuration from config.yaml. | async def async_step_import(self, conf: dict):
"""Import a configuration from config.yaml."""
if self.hass.config_entries.async_entries(DOMAIN):
return self.async_abort(reason="already_setup")
user, error = await self._check_connection(conf[CONF_ACCESS_TOKEN])
if error is no... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"conf",
":",
"dict",
")",
":",
"if",
"self",
".",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
":",
"return",
"self",
".",
"async_abort",
"(",
"reason",
"=",
"\"already_setu... | [
21,
4
] | [
36,
9
] | python | en | ['en', 'en', 'en'] | True |
AwairFlowHandler.async_step_user | (self, user_input: Optional[dict] = None) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(self, user_input: Optional[dict] = None):
"""Handle a flow initialized by the user."""
errors = {}
if user_input is not None:
user, error = await self._check_connection(user_input[CONF_ACCESS_TOKEN])
if user is not None:
await s... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"user",
",",
"error",
"=",
"await",
"self",
".",
"_che... | [
38,
4
] | [
61,
9
] | python | en | ['en', 'en', 'en'] | True |
AwairFlowHandler.async_step_reauth | (self, user_input: Optional[dict] = None) | Handle re-auth if token invalid. | Handle re-auth if token invalid. | async def async_step_reauth(self, user_input: Optional[dict] = None):
"""Handle re-auth if token invalid."""
errors = {}
if user_input is not None:
access_token = user_input[CONF_ACCESS_TOKEN]
_, error = await self._check_connection(access_token)
if error is... | [
"async",
"def",
"async_step_reauth",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"access_token",
"=",
"user_input",
"[",
"CONF_ACCESS_TOKEN... | [
63,
4
] | [
89,
9
] | python | en | ['nl', 'en', 'en'] | True |
AwairFlowHandler._check_connection | (self, access_token: str) | Check the access token is valid. | Check the access token is valid. | async def _check_connection(self, access_token: str):
"""Check the access token is valid."""
session = async_get_clientsession(self.hass)
awair = Awair(access_token=access_token, session=session)
try:
user = await awair.user()
devices = await user.devices()
... | [
"async",
"def",
"_check_connection",
"(",
"self",
",",
"access_token",
":",
"str",
")",
":",
"session",
"=",
"async_get_clientsession",
"(",
"self",
".",
"hass",
")",
"awair",
"=",
"Awair",
"(",
"access_token",
"=",
"access_token",
",",
"session",
"=",
"sess... | [
91,
4
] | [
108,
36
] | python | en | ['en', 'en', 'en'] | True |
load_tf_weights_in_funnel | (model, config, tf_checkpoint_path) | Load tf checkpoints in a pytorch model. | Load tf checkpoints in a pytorch model. | def load_tf_weights_in_funnel(model, config, tf_checkpoint_path):
"""Load tf checkpoints in a pytorch model."""
try:
import re
import numpy as np
import tensorflow as tf
except ImportError:
logger.error(
"Loading a TensorFlow model in PyTorch, requires TensorFlow... | [
"def",
"load_tf_weights_in_funnel",
"(",
"model",
",",
"config",
",",
"tf_checkpoint_path",
")",
":",
"try",
":",
"import",
"re",
"import",
"numpy",
"as",
"np",
"import",
"tensorflow",
"as",
"tf",
"except",
"ImportError",
":",
"logger",
".",
"error",
"(",
"\... | [
68,
0
] | [
155,
16
] | python | en | ['en', 'en', 'en'] | True |
upsample | (x, stride, target_len, separate_cls=True, truncate_seq=False) |
Upsample tensor `x` to match `target_len` by repeating the tokens `stride` time on the sequence length dimension.
|
Upsample tensor `x` to match `target_len` by repeating the tokens `stride` time on the sequence length dimension.
| def upsample(x, stride, target_len, separate_cls=True, truncate_seq=False):
"""
Upsample tensor `x` to match `target_len` by repeating the tokens `stride` time on the sequence length dimension.
"""
if stride == 1:
return x
if separate_cls:
cls = x[:, :1]
x = x[:, 1:]
outp... | [
"def",
"upsample",
"(",
"x",
",",
"stride",
",",
"target_len",
",",
"separate_cls",
"=",
"True",
",",
"truncate_seq",
"=",
"False",
")",
":",
"if",
"stride",
"==",
"1",
":",
"return",
"x",
"if",
"separate_cls",
":",
"cls",
"=",
"x",
"[",
":",
",",
... | [
665,
0
] | [
682,
17
] | python | en | ['en', 'error', 'th'] | False |
FunnelAttentionStructure.init_attention_inputs | (self, inputs_embeds, attention_mask=None, token_type_ids=None) | Returns the attention inputs associated to the inputs of the model. | Returns the attention inputs associated to the inputs of the model. | def init_attention_inputs(self, inputs_embeds, attention_mask=None, token_type_ids=None):
""" Returns the attention inputs associated to the inputs of the model. """
# inputs_embeds has shape batch_size x seq_len x d_model
# attention_mask and token_type_ids have shape batch_size x seq_len
... | [
"def",
"init_attention_inputs",
"(",
"self",
",",
"inputs_embeds",
",",
"attention_mask",
"=",
"None",
",",
"token_type_ids",
"=",
"None",
")",
":",
"# inputs_embeds has shape batch_size x seq_len x d_model",
"# attention_mask and token_type_ids have shape batch_size x seq_len",
... | [
189,
4
] | [
202,
74
] | python | en | ['en', 'en', 'en'] | True |
FunnelAttentionStructure.token_type_ids_to_mat | (self, token_type_ids) | Convert `token_type_ids` to `token_type_mat`. | Convert `token_type_ids` to `token_type_mat`. | def token_type_ids_to_mat(self, token_type_ids):
"""Convert `token_type_ids` to `token_type_mat`."""
token_type_mat = token_type_ids[:, :, None] == token_type_ids[:, None]
# Treat <cls> as in the same segment as both A & B
cls_ids = token_type_ids == self.cls_token_type_id
cls_ma... | [
"def",
"token_type_ids_to_mat",
"(",
"self",
",",
"token_type_ids",
")",
":",
"token_type_mat",
"=",
"token_type_ids",
"[",
":",
",",
":",
",",
"None",
"]",
"==",
"token_type_ids",
"[",
":",
",",
"None",
"]",
"# Treat <cls> as in the same segment as both A & B",
"... | [
204,
4
] | [
210,
39
] | python | nl | ['en', 'nl', 'nl'] | True |
FunnelAttentionStructure.get_position_embeds | (self, seq_len, dtype, device) |
Create and cache inputs related to relative position encoding. Those are very different depending on whether we
are using the factorized or the relative shift attention:
For the factorized attention, it returns the matrices (phi, pi, psi, omega) used in the paper, appendix A.2.2,
final... |
Create and cache inputs related to relative position encoding. Those are very different depending on whether we
are using the factorized or the relative shift attention: | def get_position_embeds(self, seq_len, dtype, device):
"""
Create and cache inputs related to relative position encoding. Those are very different depending on whether we
are using the factorized or the relative shift attention:
For the factorized attention, it returns the matrices (phi... | [
"def",
"get_position_embeds",
"(",
"self",
",",
"seq_len",
",",
"dtype",
",",
"device",
")",
":",
"d_model",
"=",
"self",
".",
"config",
".",
"d_model",
"if",
"self",
".",
"config",
".",
"attention_type",
"==",
"\"factorized\"",
":",
"# Notations from the pape... | [
212,
4
] | [
288,
39
] | python | en | ['en', 'error', 'th'] | False |
FunnelAttentionStructure.stride_pool_pos | (self, pos_id, block_index) |
Pool `pos_id` while keeping the cls token separate (if `config.separate_cls=True`).
|
Pool `pos_id` while keeping the cls token separate (if `config.separate_cls=True`).
| def stride_pool_pos(self, pos_id, block_index):
"""
Pool `pos_id` while keeping the cls token separate (if `config.separate_cls=True`).
"""
if self.config.separate_cls:
# Under separate <cls>, we treat the <cls> as the first token in
# the previous block of the 1s... | [
"def",
"stride_pool_pos",
"(",
"self",
",",
"pos_id",
",",
"block_index",
")",
":",
"if",
"self",
".",
"config",
".",
"separate_cls",
":",
"# Under separate <cls>, we treat the <cls> as the first token in",
"# the previous block of the 1st real block. Since the 1st real",
"# bl... | [
290,
4
] | [
303,
30
] | python | en | ['en', 'error', 'th'] | False |
FunnelAttentionStructure.relative_pos | (self, pos, stride, pooled_pos=None, shift=1) |
Build the relative positional vector between `pos` and `pooled_pos`.
|
Build the relative positional vector between `pos` and `pooled_pos`.
| def relative_pos(self, pos, stride, pooled_pos=None, shift=1):
"""
Build the relative positional vector between `pos` and `pooled_pos`.
"""
if pooled_pos is None:
pooled_pos = pos
ref_point = pooled_pos[0] - pos[0]
num_remove = shift * len(pooled_pos)
... | [
"def",
"relative_pos",
"(",
"self",
",",
"pos",
",",
"stride",
",",
"pooled_pos",
"=",
"None",
",",
"shift",
"=",
"1",
")",
":",
"if",
"pooled_pos",
"is",
"None",
":",
"pooled_pos",
"=",
"pos",
"ref_point",
"=",
"pooled_pos",
"[",
"0",
"]",
"-",
"pos... | [
305,
4
] | [
317,
97
] | python | en | ['en', 'error', 'th'] | False |
FunnelAttentionStructure.stride_pool | (self, tensor, axis) |
Perform pooling by stride slicing the tensor along the given axis.
|
Perform pooling by stride slicing the tensor along the given axis.
| def stride_pool(self, tensor, axis):
"""
Perform pooling by stride slicing the tensor along the given axis.
"""
if tensor is None:
return None
# Do the stride pool recursively if axis is a list or a tuple of ints.
if isinstance(axis, (list, tuple)):
... | [
"def",
"stride_pool",
"(",
"self",
",",
"tensor",
",",
"axis",
")",
":",
"if",
"tensor",
"is",
"None",
":",
"return",
"None",
"# Do the stride pool recursively if axis is a list or a tuple of ints.",
"if",
"isinstance",
"(",
"axis",
",",
"(",
"list",
",",
"tuple",... | [
319,
4
] | [
346,
32
] | python | en | ['en', 'error', 'th'] | False |
FunnelAttentionStructure.pool_tensor | (self, tensor, mode="mean", stride=2) | Apply 1D pooling to a tensor of size [B x T (x H)]. | Apply 1D pooling to a tensor of size [B x T (x H)]. | def pool_tensor(self, tensor, mode="mean", stride=2):
"""Apply 1D pooling to a tensor of size [B x T (x H)]."""
if tensor is None:
return None
# Do the pool recursively if tensor is a list or tuple of tensors.
if isinstance(tensor, (tuple, list)):
return type(ten... | [
"def",
"pool_tensor",
"(",
"self",
",",
"tensor",
",",
"mode",
"=",
"\"mean\"",
",",
"stride",
"=",
"2",
")",
":",
"if",
"tensor",
"is",
"None",
":",
"return",
"None",
"# Do the pool recursively if tensor is a list or tuple of tensors.",
"if",
"isinstance",
"(",
... | [
348,
4
] | [
382,
21
] | python | en | ['en', 'en', 'en'] | True |
FunnelAttentionStructure.pre_attention_pooling | (self, output, attention_inputs) | Pool `output` and the proper parts of `attention_inputs` before the attention layer. | Pool `output` and the proper parts of `attention_inputs` before the attention layer. | def pre_attention_pooling(self, output, attention_inputs):
""" Pool `output` and the proper parts of `attention_inputs` before the attention layer. """
position_embeds, token_type_mat, attention_mask, cls_mask = attention_inputs
if self.config.pool_q_only:
if self.config.attention_ty... | [
"def",
"pre_attention_pooling",
"(",
"self",
",",
"output",
",",
"attention_inputs",
")",
":",
"position_embeds",
",",
"token_type_mat",
",",
"attention_mask",
",",
"cls_mask",
"=",
"attention_inputs",
"if",
"self",
".",
"config",
".",
"pool_q_only",
":",
"if",
... | [
384,
4
] | [
402,
39
] | python | en | ['en', 'en', 'en'] | True |
FunnelAttentionStructure.post_attention_pooling | (self, attention_inputs) | Pool the proper parts of `attention_inputs` after the attention layer. | Pool the proper parts of `attention_inputs` after the attention layer. | def post_attention_pooling(self, attention_inputs):
""" Pool the proper parts of `attention_inputs` after the attention layer. """
position_embeds, token_type_mat, attention_mask, cls_mask = attention_inputs
if self.config.pool_q_only:
self.pooling_mult *= 2
if self.confi... | [
"def",
"post_attention_pooling",
"(",
"self",
",",
"attention_inputs",
")",
":",
"position_embeds",
",",
"token_type_mat",
",",
"attention_mask",
",",
"cls_mask",
"=",
"attention_inputs",
"if",
"self",
".",
"config",
".",
"pool_q_only",
":",
"self",
".",
"pooling_... | [
404,
4
] | [
415,
31
] | python | en | ['en', 'en', 'en'] | True |
FunnelRelMultiheadAttention.relative_positional_attention | (self, position_embeds, q_head, context_len, cls_mask=None) | Relative attention score for the positional encodings | Relative attention score for the positional encodings | def relative_positional_attention(self, position_embeds, q_head, context_len, cls_mask=None):
""" Relative attention score for the positional encodings """
# q_head has shape batch_size x sea_len x n_head x d_head
if self.config.attention_type == "factorized":
# Notations from the pa... | [
"def",
"relative_positional_attention",
"(",
"self",
",",
"position_embeds",
",",
"q_head",
",",
"context_len",
",",
"cls_mask",
"=",
"None",
")",
":",
"# q_head has shape batch_size x sea_len x n_head x d_head",
"if",
"self",
".",
"config",
".",
"attention_type",
"==",... | [
458,
4
] | [
498,
30
] | python | en | ['en', 'en', 'en'] | True |
FunnelRelMultiheadAttention.relative_token_type_attention | (self, token_type_mat, q_head, cls_mask=None) | Relative attention score for the token_type_ids | Relative attention score for the token_type_ids | def relative_token_type_attention(self, token_type_mat, q_head, cls_mask=None):
""" Relative attention score for the token_type_ids """
if token_type_mat is None:
return 0
batch_size, seq_len, context_len = token_type_mat.shape
# q_head has shape batch_size x seq_len x n_head... | [
"def",
"relative_token_type_attention",
"(",
"self",
",",
"token_type_mat",
",",
"q_head",
",",
"cls_mask",
"=",
"None",
")",
":",
"if",
"token_type_mat",
"is",
"None",
":",
"return",
"0",
"batch_size",
",",
"seq_len",
",",
"context_len",
"=",
"token_type_mat",
... | [
500,
4
] | [
522,
30
] | python | en | ['en', 'en', 'en'] | True |
FunnelForPreTraining.forward | (
self,
input_ids=None,
attention_mask=None,
token_type_ids=None,
inputs_embeds=None,
labels=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
) | r"""
labels (``torch.LongTensor`` of shape ``(batch_size, sequence_length)``, `optional`):
Labels for computing the ELECTRA-style loss. Input should be a sequence of tokens (see :obj:`input_ids`
docstring) Indices should be in ``[0, 1]``:
- 0 indicates the token is an origin... | r"""
labels (``torch.LongTensor`` of shape ``(batch_size, sequence_length)``, `optional`):
Labels for computing the ELECTRA-style loss. Input should be a sequence of tokens (see :obj:`input_ids`
docstring) Indices should be in ``[0, 1]``: | def forward(
self,
input_ids=None,
attention_mask=None,
token_type_ids=None,
inputs_embeds=None,
labels=None,
output_attentions=None,
output_hidden_states=None,
return_dict=None,
):
r"""
labels (``torch.LongTensor`` of shape ``(... | [
"def",
"forward",
"(",
"self",
",",
"input_ids",
"=",
"None",
",",
"attention_mask",
"=",
"None",
",",
"token_type_ids",
"=",
"None",
",",
"inputs_embeds",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"output_attentions",
"=",
"None",
",",
"output_hidden_st... | [
1088,
4
] | [
1155,
9
] | python | cy | ['en', 'cy', 'hi'] | False |
test_duplicate_error | (hass, config_entry) | Test that errors are shown when duplicates are added. | Test that errors are shown when duplicates are added. | async def test_duplicate_error(hass, config_entry):
"""Test that errors are shown when duplicates are added."""
conf = {CONF_LATITUDE: -41.2, CONF_LONGITUDE: 174.7, CONF_RADIUS: 25}
config_entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "us... | [
"async",
"def",
"test_duplicate_error",
"(",
"hass",
",",
"config_entry",
")",
":",
"conf",
"=",
"{",
"CONF_LATITUDE",
":",
"-",
"41.2",
",",
"CONF_LONGITUDE",
":",
"174.7",
",",
"CONF_RADIUS",
":",
"25",
"}",
"config_entry",
".",
"add_to_hass",
"(",
"hass",... | [
20,
0
] | [
29,
51
] | python | en | ['en', 'en', 'en'] | True |
test_show_form | (hass) | Test that the form is served with no input. | Test that the form is served with no input. | async def test_show_form(hass):
"""Test that the form is served with no input."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user" | [
"async",
"def",
"test_show_form",
"(",
"hass",
")",
":",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",
"(",
"DOMAIN",
",",
"context",
"=",
"{",
"\"source\"",
":",
"\"user\"",
"}",
")",
"assert",
"result",
"[",
"\"... | [
32,
0
] | [
38,
38
] | python | en | ['en', 'en', 'en'] | True |
test_step_import | (hass) | Test that the import step works. | Test that the import step works. | async def test_step_import(hass):
"""Test that the import step works."""
conf = {
CONF_LATITUDE: -41.2,
CONF_LONGITUDE: 174.7,
CONF_RADIUS: 25,
CONF_UNIT_SYSTEM: "metric",
CONF_MMI: 2,
CONF_SCAN_INTERVAL: timedelta(minutes=4),
CONF_MINIMUM_MAGNITUDE: 2.5,
... | [
"async",
"def",
"test_step_import",
"(",
"hass",
")",
":",
"conf",
"=",
"{",
"CONF_LATITUDE",
":",
"-",
"41.2",
",",
"CONF_LONGITUDE",
":",
"174.7",
",",
"CONF_RADIUS",
":",
"25",
",",
"CONF_UNIT_SYSTEM",
":",
"\"metric\"",
",",
"CONF_MMI",
":",
"2",
",",
... | [
41,
0
] | [
69,
5
] | python | en | ['en', 'en', 'en'] | True |
test_step_user | (hass) | Test that the user step works. | Test that the user step works. | async def test_step_user(hass):
"""Test that the user step works."""
hass.config.latitude = -41.2
hass.config.longitude = 174.7
conf = {CONF_RADIUS: 25, CONF_MMI: 4}
with patch(
"homeassistant.components.geonetnz_quakes.async_setup_entry", return_value=True
), patch("homeassistant.compo... | [
"async",
"def",
"test_step_user",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"-",
"41.2",
"hass",
".",
"config",
".",
"longitude",
"=",
"174.7",
"conf",
"=",
"{",
"CONF_RADIUS",
":",
"25",
",",
"CONF_MMI",
":",
"4",
"}",
"wit... | [
72,
0
] | [
93,
5
] | python | en | ['en', 'en', 'en'] | True |
AmbientStationFlowHandler.__init__ | (self) | Initialize the config flow. | Initialize the config flow. | def __init__(self):
"""Initialize the config flow."""
self.data_schema = vol.Schema(
{vol.Required(CONF_API_KEY): str, vol.Required(CONF_APP_KEY): str}
) | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"CONF_API_KEY",
")",
":",
"str",
",",
"vol",
".",
"Required",
"(",
"CONF_APP_KEY",
")",
":",
"str",
"}",
")"
] | [
18,
4
] | [
22,
9
] | python | en | ['en', 'en', 'en'] | True |
AmbientStationFlowHandler._show_form | (self, errors=None) | Show the form to the user. | Show the form to the user. | async def _show_form(self, errors=None):
"""Show the form to the user."""
return self.async_show_form(
step_id="user",
data_schema=self.data_schema,
errors=errors if errors else {},
) | [
"async",
"def",
"_show_form",
"(",
"self",
",",
"errors",
"=",
"None",
")",
":",
"return",
"self",
".",
"async_show_form",
"(",
"step_id",
"=",
"\"user\"",
",",
"data_schema",
"=",
"self",
".",
"data_schema",
",",
"errors",
"=",
"errors",
"if",
"errors",
... | [
24,
4
] | [
30,
9
] | python | en | ['en', 'en', 'en'] | True |
AmbientStationFlowHandler.async_step_import | (self, import_config) | Import a config entry from configuration.yaml. | Import a config entry from configuration.yaml. | async def async_step_import(self, import_config):
"""Import a config entry from configuration.yaml."""
return await self.async_step_user(import_config) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_config",
")",
":",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"import_config",
")"
] | [
32,
4
] | [
34,
56
] | python | en | ['en', 'en', 'en'] | True |
AmbientStationFlowHandler.async_step_user | (self, user_input=None) | Handle the start of the config flow. | Handle the start of the config flow. | async def async_step_user(self, user_input=None):
"""Handle the start of the config flow."""
if not user_input:
return await self._show_form()
await self.async_set_unique_id(user_input[CONF_APP_KEY])
self._abort_if_unique_id_configured()
session = aiohttp_client.asy... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"not",
"user_input",
":",
"return",
"await",
"self",
".",
"_show_form",
"(",
")",
"await",
"self",
".",
"async_set_unique_id",
"(",
"user_input",
"[",
"CONF_APP_K... | [
36,
4
] | [
62,
9
] | python | en | ['en', 'en', 'en'] | True |
assert_tensors_close | (a, b, atol=1e-12, prefix="") | If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error. | If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error. | def assert_tensors_close(a, b, atol=1e-12, prefix=""):
"""If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error."""
if a is None and b is None:
return True
try:
if torch.allclose(a, b, atol=atol):
return True
rais... | [
"def",
"assert_tensors_close",
"(",
"a",
",",
"b",
",",
"atol",
"=",
"1e-12",
",",
"prefix",
"=",
"\"\"",
")",
":",
"if",
"a",
"is",
"None",
"and",
"b",
"is",
"None",
":",
"return",
"True",
"try",
":",
"if",
"torch",
".",
"allclose",
"(",
"a",
",... | [
254,
0
] | [
270,
33
] | python | en | ['en', 'en', 'en'] | True |
WanDouIpCrawler.parse | (self, html) |
parse html file to get proxies
:return:
|
parse html file to get proxies
:return:
| def parse(self, html):
"""
parse html file to get proxies
:return:
"""
doc = pq(html)
response = doc('p').text()
trs = json.loads(response)['data']
for tr in trs:
host = tr['ip']
port = tr['port']
yield Proxy(host=host, ... | [
"def",
"parse",
"(",
"self",
",",
"html",
")",
":",
"doc",
"=",
"pq",
"(",
"html",
")",
"response",
"=",
"doc",
"(",
"'p'",
")",
".",
"text",
"(",
")",
"trs",
"=",
"json",
".",
"loads",
"(",
"response",
")",
"[",
"'data'",
"]",
"for",
"tr",
"... | [
37,
4
] | [
48,
45
] | python | en | ['en', 'error', 'th'] | False |
metric_data_url | (port) | get metric_data url | get metric_data url | def metric_data_url(port):
'''get metric_data url'''
return '{0}:{1}{2}{3}'.format(BASE_URL, port, API_ROOT_URL, METRIC_DATA_API) | [
"def",
"metric_data_url",
"(",
"port",
")",
":",
"return",
"'{0}:{1}{2}{3}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"METRIC_DATA_API",
")"
] | [
33,
0
] | [
35,
80
] | python | en | ['en', 'id', 'en'] | True |
check_status_url | (port) | get check_status url | get check_status url | def check_status_url(port):
'''get check_status url'''
return '{0}:{1}{2}{3}'.format(BASE_URL, port, API_ROOT_URL, CHECK_STATUS_API) | [
"def",
"check_status_url",
"(",
"port",
")",
":",
"return",
"'{0}:{1}{2}{3}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"CHECK_STATUS_API",
")"
] | [
37,
0
] | [
39,
81
] | python | en | ['en', 'id', 'en'] | True |
cluster_metadata_url | (port) | get cluster_metadata_url | get cluster_metadata_url | def cluster_metadata_url(port):
'''get cluster_metadata_url'''
return '{0}:{1}{2}{3}'.format(BASE_URL, port, API_ROOT_URL, CLUSTER_METADATA_API) | [
"def",
"cluster_metadata_url",
"(",
"port",
")",
":",
"return",
"'{0}:{1}{2}{3}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"CLUSTER_METADATA_API",
")"
] | [
42,
0
] | [
44,
85
] | python | en | ['et', 'la', 'en'] | False |
import_data_url | (port) | get import_data_url | get import_data_url | def import_data_url(port):
'''get import_data_url'''
return '{0}:{1}{2}{3}'.format(BASE_URL, port, API_ROOT_URL, IMPORT_DATA_API) | [
"def",
"import_data_url",
"(",
"port",
")",
":",
"return",
"'{0}:{1}{2}{3}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"IMPORT_DATA_API",
")"
] | [
47,
0
] | [
49,
80
] | python | en | ['en', 'la', 'en'] | False |
experiment_url | (port) | get experiment_url | get experiment_url | def experiment_url(port):
'''get experiment_url'''
return '{0}:{1}{2}{3}'.format(BASE_URL, port, API_ROOT_URL, EXPERIMENT_API) | [
"def",
"experiment_url",
"(",
"port",
")",
":",
"return",
"'{0}:{1}{2}{3}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"EXPERIMENT_API",
")"
] | [
52,
0
] | [
54,
79
] | python | ca | ['sq', 'ca', 'en'] | False |
trial_jobs_url | (port) | get trial_jobs url | get trial_jobs url | def trial_jobs_url(port):
'''get trial_jobs url'''
return '{0}:{1}{2}{3}'.format(BASE_URL, port, API_ROOT_URL, TRIAL_JOBS_API) | [
"def",
"trial_jobs_url",
"(",
"port",
")",
":",
"return",
"'{0}:{1}{2}{3}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"TRIAL_JOBS_API",
")"
] | [
57,
0
] | [
59,
79
] | python | en | ['fr', 'nl', 'en'] | False |
trial_job_id_url | (port, job_id) | get trial_jobs with id url | get trial_jobs with id url | def trial_job_id_url(port, job_id):
'''get trial_jobs with id url'''
return '{0}:{1}{2}{3}/{4}'.format(BASE_URL, port, API_ROOT_URL, TRIAL_JOBS_API, job_id) | [
"def",
"trial_job_id_url",
"(",
"port",
",",
"job_id",
")",
":",
"return",
"'{0}:{1}{2}{3}/{4}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"TRIAL_JOBS_API",
",",
"job_id",
")"
] | [
62,
0
] | [
64,
91
] | python | en | ['en', 'en', 'en'] | True |
export_data_url | (port) | get export_data url | get export_data url | def export_data_url(port):
'''get export_data url'''
return '{0}:{1}{2}{3}'.format(BASE_URL, port, API_ROOT_URL, EXPORT_DATA_API) | [
"def",
"export_data_url",
"(",
"port",
")",
":",
"return",
"'{0}:{1}{2}{3}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"EXPORT_DATA_API",
")"
] | [
67,
0
] | [
69,
80
] | python | da | ['da', 'nl', 'en'] | False |
tensorboard_url | (port) | get tensorboard url | get tensorboard url | def tensorboard_url(port):
'''get tensorboard url'''
return '{0}:{1}{2}{3}'.format(BASE_URL, port, API_ROOT_URL, TENSORBOARD_API) | [
"def",
"tensorboard_url",
"(",
"port",
")",
":",
"return",
"'{0}:{1}{2}{3}'",
".",
"format",
"(",
"BASE_URL",
",",
"port",
",",
"API_ROOT_URL",
",",
"TENSORBOARD_API",
")"
] | [
72,
0
] | [
74,
80
] | python | da | ['da', 'nl', 'en'] | False |
get_local_urls | (port,prefix) | get urls of local machine | get urls of local machine | def get_local_urls(port,prefix):
'''get urls of local machine'''
url_list = []
for _, info in psutil.net_if_addrs().items():
for addr in info:
if socket.AddressFamily.AF_INET == addr.family:
url_list.append('http://{0}:{1}{2}'.format(addr.address, port, prefix))
retur... | [
"def",
"get_local_urls",
"(",
"port",
",",
"prefix",
")",
":",
"url_list",
"=",
"[",
"]",
"for",
"_",
",",
"info",
"in",
"psutil",
".",
"net_if_addrs",
"(",
")",
".",
"items",
"(",
")",
":",
"for",
"addr",
"in",
"info",
":",
"if",
"socket",
".",
... | [
77,
0
] | [
84,
19
] | python | en | ['en', 'de', 'en'] | True |
async_call_action_from_config | (
hass: HomeAssistant,
config: ConfigType,
variables: TemplateVarsType,
context: Context,
) | Change state based on configuration. | Change state based on configuration. | async def async_call_action_from_config(
hass: HomeAssistant,
config: ConfigType,
variables: TemplateVarsType,
context: Context,
) -> None:
"""Change state based on configuration."""
await toggle_entity.async_call_action_from_config(
hass, config, variables, context, DOMAIN
) | [
"async",
"def",
"async_call_action_from_config",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"variables",
":",
"TemplateVarsType",
",",
"context",
":",
"Context",
",",
")",
"->",
"None",
":",
"await",
"toggle_entity",
".",
"async_ca... | [
15,
0
] | [
24,
5
] | python | en | ['en', 'en', 'en'] | True |
async_get_actions | (hass: HomeAssistant, device_id: str) | List device actions. | List device actions. | async def async_get_actions(hass: HomeAssistant, device_id: str) -> List[dict]:
"""List device actions."""
return await toggle_entity.async_get_actions(hass, device_id, DOMAIN) | [
"async",
"def",
"async_get_actions",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"List",
"[",
"dict",
"]",
":",
"return",
"await",
"toggle_entity",
".",
"async_get_actions",
"(",
"hass",
",",
"device_id",
",",
"DOMAIN",
")"
] | [
27,
0
] | [
29,
73
] | python | en | ['fr', 'en', 'en'] | True |
client | (hass, hass_ws_client) | Fixture that can interact with the config manager API. | Fixture that can interact with the config manager API. | def client(hass, hass_ws_client):
"""Fixture that can interact with the config manager API."""
hass.loop.run_until_complete(entity_registry.async_setup(hass))
yield hass.loop.run_until_complete(hass_ws_client(hass)) | [
"def",
"client",
"(",
"hass",
",",
"hass_ws_client",
")",
":",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"entity_registry",
".",
"async_setup",
"(",
"hass",
")",
")",
"yield",
"hass",
".",
"loop",
".",
"run_until_complete",
"(",
"hass_ws_client",
... | [
13,
0
] | [
16,
60
] | python | en | ['en', 'en', 'en'] | True |
test_list_entities | (hass, client) | Test list entries. | Test list entries. | async def test_list_entities(hass, client):
"""Test list entries."""
entities = OrderedDict()
entities["test_domain.name"] = RegistryEntry(
entity_id="test_domain.name",
unique_id="1234",
platform="test_platform",
name="Hello World",
)
entities["test_domain.no_name"] ... | [
"async",
"def",
"test_list_entities",
"(",
"hass",
",",
"client",
")",
":",
"entities",
"=",
"OrderedDict",
"(",
")",
"entities",
"[",
"\"test_domain.name\"",
"]",
"=",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"test_domain.name\"",
",",
"unique_id",
"=",
"\"123... | [
19,
0
] | [
58,
5
] | python | en | ['fr', 'gd', 'en'] | False |
test_get_entity | (hass, client) | Test get entry. | Test get entry. | async def test_get_entity(hass, client):
"""Test get entry."""
mock_registry(
hass,
{
"test_domain.name": RegistryEntry(
entity_id="test_domain.name",
unique_id="1234",
platform="test_platform",
name="Hello World",
... | [
"async",
"def",
"test_get_entity",
"(",
"hass",
",",
"client",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"\"test_domain.name\"",
":",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"test_domain.name\"",
",",
"unique_id",
"=",
"\"1234\"",
",",
"platform",
"=",... | [
61,
0
] | [
122,
5
] | python | da | ['nl', 'da', 'en'] | False |
test_update_entity | (hass, client) | Test updating entity. | Test updating entity. | async def test_update_entity(hass, client):
"""Test updating entity."""
registry = mock_registry(
hass,
{
"test_domain.world": RegistryEntry(
entity_id="test_domain.world",
unique_id="1234",
# Using component.async_add_entities is equal... | [
"async",
"def",
"test_update_entity",
"(",
"hass",
",",
"client",
")",
":",
"registry",
"=",
"mock_registry",
"(",
"hass",
",",
"{",
"\"test_domain.world\"",
":",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"test_domain.world\"",
",",
"unique_id",
"=",
"\"1234\"",
... | [
125,
0
] | [
227,
5
] | python | en | ['en', 'en', 'en'] | True |
test_update_entity_require_restart | (hass, client) | Test updating entity. | Test updating entity. | async def test_update_entity_require_restart(hass, client):
"""Test updating entity."""
config_entry = MockConfigEntry(domain="test_platform")
config_entry.add_to_hass(hass)
mock_registry(
hass,
{
"test_domain.world": RegistryEntry(
config_entry_id=config_entr... | [
"async",
"def",
"test_update_entity_require_restart",
"(",
"hass",
",",
"client",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"test_platform\"",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"mock_registry",
"(",
"hass",
",... | [
230,
0
] | [
281,
5
] | python | en | ['en', 'en', 'en'] | True |
test_update_entity_no_changes | (hass, client) | Test update entity with no changes. | Test update entity with no changes. | async def test_update_entity_no_changes(hass, client):
"""Test update entity with no changes."""
mock_registry(
hass,
{
"test_domain.world": RegistryEntry(
entity_id="test_domain.world",
unique_id="1234",
# Using component.async_add_ent... | [
"async",
"def",
"test_update_entity_no_changes",
"(",
"hass",
",",
"client",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"\"test_domain.world\"",
":",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"test_domain.world\"",
",",
"unique_id",
"=",
"\"1234\"",
",",
"#... | [
284,
0
] | [
335,
41
] | python | en | ['en', 'en', 'en'] | True |
test_get_nonexisting_entity | (client) | Test get entry with nonexisting entity. | Test get entry with nonexisting entity. | async def test_get_nonexisting_entity(client):
"""Test get entry with nonexisting entity."""
await client.send_json(
{
"id": 6,
"type": "config/entity_registry/get",
"entity_id": "test_domain.no_name",
}
)
msg = await client.receive_json()
assert ... | [
"async",
"def",
"test_get_nonexisting_entity",
"(",
"client",
")",
":",
"await",
"client",
".",
"send_json",
"(",
"{",
"\"id\"",
":",
"6",
",",
"\"type\"",
":",
"\"config/entity_registry/get\"",
",",
"\"entity_id\"",
":",
"\"test_domain.no_name\"",
",",
"}",
")",
... | [
338,
0
] | [
349,
29
] | python | en | ['en', 'en', 'en'] | True |
test_update_nonexisting_entity | (client) | Test update a nonexisting entity. | Test update a nonexisting entity. | async def test_update_nonexisting_entity(client):
"""Test update a nonexisting entity."""
await client.send_json(
{
"id": 6,
"type": "config/entity_registry/update",
"entity_id": "test_domain.no_name",
"name": "new-name",
}
)
msg = await cl... | [
"async",
"def",
"test_update_nonexisting_entity",
"(",
"client",
")",
":",
"await",
"client",
".",
"send_json",
"(",
"{",
"\"id\"",
":",
"6",
",",
"\"type\"",
":",
"\"config/entity_registry/update\"",
",",
"\"entity_id\"",
":",
"\"test_domain.no_name\"",
",",
"\"nam... | [
352,
0
] | [
364,
29
] | python | en | ['en', 'en', 'it'] | True |
test_update_entity_id | (hass, client) | Test update entity id. | Test update entity id. | async def test_update_entity_id(hass, client):
"""Test update entity id."""
mock_registry(
hass,
{
"test_domain.world": RegistryEntry(
entity_id="test_domain.world",
unique_id="1234",
# Using component.async_add_entities is equal to pla... | [
"async",
"def",
"test_update_entity_id",
"(",
"hass",
",",
"client",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"\"test_domain.world\"",
":",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"test_domain.world\"",
",",
"unique_id",
"=",
"\"1234\"",
",",
"# Using c... | [
367,
0
] | [
415,
60
] | python | en | ['en', 'en', 'en'] | True |
test_update_existing_entity_id | (hass, client) | Test update entity id to an already registered entity id. | Test update entity id to an already registered entity id. | async def test_update_existing_entity_id(hass, client):
"""Test update entity id to an already registered entity id."""
mock_registry(
hass,
{
"test_domain.world": RegistryEntry(
entity_id="test_domain.world",
unique_id="1234",
# Using ... | [
"async",
"def",
"test_update_existing_entity_id",
"(",
"hass",
",",
"client",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"\"test_domain.world\"",
":",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"test_domain.world\"",
",",
"unique_id",
"=",
"\"1234\"",
",",
"... | [
418,
0
] | [
452,
29
] | python | en | ['en', 'en', 'en'] | True |
test_update_invalid_entity_id | (hass, client) | Test update entity id to an invalid entity id. | Test update entity id to an invalid entity id. | async def test_update_invalid_entity_id(hass, client):
"""Test update entity id to an invalid entity id."""
mock_registry(
hass,
{
"test_domain.world": RegistryEntry(
entity_id="test_domain.world",
unique_id="1234",
# Using component.as... | [
"async",
"def",
"test_update_invalid_entity_id",
"(",
"hass",
",",
"client",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"\"test_domain.world\"",
":",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"test_domain.world\"",
",",
"unique_id",
"=",
"\"1234\"",
",",
"#... | [
455,
0
] | [
483,
29
] | python | en | ['en', 'en', 'en'] | True |
test_remove_entity | (hass, client) | Test removing entity. | Test removing entity. | async def test_remove_entity(hass, client):
"""Test removing entity."""
registry = mock_registry(
hass,
{
"test_domain.world": RegistryEntry(
entity_id="test_domain.world",
unique_id="1234",
# Using component.async_add_entities is equal... | [
"async",
"def",
"test_remove_entity",
"(",
"hass",
",",
"client",
")",
":",
"registry",
"=",
"mock_registry",
"(",
"hass",
",",
"{",
"\"test_domain.world\"",
":",
"RegistryEntry",
"(",
"entity_id",
"=",
"\"test_domain.world\"",
",",
"unique_id",
"=",
"\"1234\"",
... | [
486,
0
] | [
512,
38
] | python | en | ['en', 'en', 'en'] | True |
test_remove_non_existing_entity | (hass, client) | Test removing non existing entity. | Test removing non existing entity. | async def test_remove_non_existing_entity(hass, client):
"""Test removing non existing entity."""
mock_registry(hass, {})
await client.send_json(
{
"id": 6,
"type": "config/entity_registry/remove",
"entity_id": "test_domain.world",
}
)
msg = awai... | [
"async",
"def",
"test_remove_non_existing_entity",
"(",
"hass",
",",
"client",
")",
":",
"mock_registry",
"(",
"hass",
",",
"{",
"}",
")",
"await",
"client",
".",
"send_json",
"(",
"{",
"\"id\"",
":",
"6",
",",
"\"type\"",
":",
"\"config/entity_registry/remove... | [
515,
0
] | [
529,
29
] | python | en | ['en', 'en', 'it'] | True |
async_update_programs_and_zones | (
hass: HomeAssistant, entry: ConfigEntry
) | Update program and zone DataUpdateCoordinators.
Program and zone updates always go together because of how linked they are:
programs affect zones and certain combinations of zones affect programs.
| Update program and zone DataUpdateCoordinators. | async def async_update_programs_and_zones(
hass: HomeAssistant, entry: ConfigEntry
) -> None:
"""Update program and zone DataUpdateCoordinators.
Program and zone updates always go together because of how linked they are:
programs affect zones and certain combinations of zones affect programs.
"""
... | [
"async",
"def",
"async_update_programs_and_zones",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_COORDINATOR"... | [
81,
0
] | [
98,
5
] | python | en | ['en', 'sn', 'en'] | True |
async_setup | (hass: HomeAssistant, config: dict) | Set up the RainMachine component. | Set up the RainMachine component. | async def async_setup(hass: HomeAssistant, config: dict) -> bool:
"""Set up the RainMachine component."""
hass.data[DOMAIN] = {DATA_CONTROLLER: {}, DATA_COORDINATOR: {}, DATA_LISTENER: {}}
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
")",
"->",
"bool",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"DATA_CONTROLLER",
":",
"{",
"}",
",",
"DATA_COORDINATOR",
":",
"{",
"}",
",",
"D... | [
101,
0
] | [
104,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass: HomeAssistant, entry: ConfigEntry) | Set up RainMachine as config entry. | Set up RainMachine as config entry. | async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up RainMachine as config entry."""
hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id] = {}
entry_updates = {}
if not entry.unique_id:
# If the config entry doesn't already have a unique ID, set one:
en... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_COORDINATOR",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"=",
"{",
"}",
... | [
107,
0
] | [
279,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Unload an RainMachine config entry. | Unload an RainMachine config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload an RainMachine config entry."""
unload_ok = all(
await asyncio.gather(
*[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in PLATFORMS
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"bool",
":",
"unload_ok",
"=",
"all",
"(",
"await",
"asyncio",
".",
"gather",
"(",
"*",
"[",
"hass",
".",
"config_entries",
".",
"async_fo... | [
282,
0
] | [
297,
20
] | python | en | ['en', 'en', 'en'] | True |
async_reload_entry | (hass: HomeAssistant, entry: ConfigEntry) | Handle an options update. | Handle an options update. | async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Handle an options update."""
await hass.config_entries.async_reload(entry.entry_id) | [
"async",
"def",
"async_reload_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"await",
"hass",
".",
"config_entries",
".",
"async_reload",
"(",
"entry",
".",
"entry_id",
")"
] | [
300,
0
] | [
302,
58
] | python | en | ['en', 'en', 'en'] | True |
RainMachineEntity.__init__ | (
self, coordinator: DataUpdateCoordinator, controller: Controller
) | Initialize. | Initialize. | def __init__(
self, coordinator: DataUpdateCoordinator, controller: Controller
) -> None:
"""Initialize."""
super().__init__(coordinator)
self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
self._controller = controller
self._device_class = None
# The colons... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"DataUpdateCoordinator",
",",
"controller",
":",
"Controller",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_attrs",
"=",
"{",
"ATTR_ATTRIBUTION",
... | [
308,
4
] | [
320,
25
] | python | en | ['en', 'en', 'it'] | False |
RainMachineEntity.device_class | (self) | Return the device class. | Return the device class. | def device_class(self) -> str:
"""Return the device class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_device_class"
] | [
323,
4
] | [
325,
33
] | python | en | ['en', 'en', 'en'] | True |
RainMachineEntity.device_info | (self) | Return device registry information for this entity. | Return device registry information for this entity. | def device_info(self) -> dict:
"""Return device registry information for this entity."""
return {
"identifiers": {(DOMAIN, self._controller.mac)},
"name": self._controller.name,
"manufacturer": "RainMachine",
"model": (
f"Version {self._con... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_controller",
".",
"mac",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"_controller",
".",
"name",
",",
"\"manufact... | [
328,
4
] | [
339,
9
] | python | en | ['en', 'en', 'en'] | True |
RainMachineEntity.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self) -> dict:
"""Return the state attributes."""
return self._attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"self",
".",
"_attrs"
] | [
342,
4
] | [
344,
26
] | python | en | ['en', 'en', 'en'] | True |
RainMachineEntity.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self) -> str:
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
347,
4
] | [
349,
25
] | python | en | ['en', 'en', 'en'] | True |
RainMachineEntity._handle_coordinator_update | (self) | Respond to a DataUpdateCoordinator update. | Respond to a DataUpdateCoordinator update. | def _handle_coordinator_update(self):
"""Respond to a DataUpdateCoordinator update."""
self.update_from_latest_data()
self.async_write_ha_state() | [
"def",
"_handle_coordinator_update",
"(",
"self",
")",
":",
"self",
".",
"update_from_latest_data",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
352,
4
] | [
355,
35
] | python | en | ['en', 'de', 'en'] | True |
RainMachineEntity.async_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_added_to_hass(self):
"""Handle entity which will be added."""
await super().async_added_to_hass()
self.update_from_latest_data() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"update_from_latest_data",
"(",
")"
] | [
357,
4
] | [
360,
38
] | python | en | ['en', 'en', 'en'] | True |
RainMachineEntity.update_from_latest_data | (self) | Update the state. | Update the state. | def update_from_latest_data(self) -> None:
"""Update the state."""
raise NotImplementedError | [
"def",
"update_from_latest_data",
"(",
"self",
")",
"->",
"None",
":",
"raise",
"NotImplementedError"
] | [
363,
4
] | [
365,
33
] | python | en | ['en', 'en', 'en'] | True |
test_one | (hass, rfxtrx) | Test with 1 sensor. | Test with 1 sensor. | async def test_one(hass, rfxtrx):
"""Test with 1 sensor."""
entry_data = create_rfx_test_cfg(devices={"0b1100cd0213c7f230010f71": {}})
mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data)
mock_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_entry.entr... | [
"async",
"def",
"test_one",
"(",
"hass",
",",
"rfxtrx",
")",
":",
"entry_data",
"=",
"create_rfx_test_cfg",
"(",
"devices",
"=",
"{",
"\"0b1100cd0213c7f230010f71\"",
":",
"{",
"}",
"}",
")",
"mock_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"\"rfxtrx\"... | [
22,
0
] | [
35,
67
] | python | en | ['en', 'en', 'en'] | True |
test_one_pt2262 | (hass, rfxtrx) | Test with 1 sensor. | Test with 1 sensor. | async def test_one_pt2262(hass, rfxtrx):
"""Test with 1 sensor."""
entry_data = create_rfx_test_cfg(
devices={
"0913000022670e013970": {
"data_bits": 4,
"command_on": 0xE,
"command_off": 0x7,
}
}
)
mock_entry = MockC... | [
"async",
"def",
"test_one_pt2262",
"(",
"hass",
",",
"rfxtrx",
")",
":",
"entry_data",
"=",
"create_rfx_test_cfg",
"(",
"devices",
"=",
"{",
"\"0913000022670e013970\"",
":",
"{",
"\"data_bits\"",
":",
"4",
",",
"\"command_on\"",
":",
"0xE",
",",
"\"command_off\"... | [
38,
0
] | [
68,
31
] | python | en | ['en', 'en', 'en'] | True |
test_pt2262_unconfigured | (hass, rfxtrx) | Test with discovery for PT2262. | Test with discovery for PT2262. | async def test_pt2262_unconfigured(hass, rfxtrx):
"""Test with discovery for PT2262."""
entry_data = create_rfx_test_cfg(
devices={"0913000022670e013970": {}, "09130000226707013970": {}}
)
mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data)
mock_entry.add_to_has... | [
"async",
"def",
"test_pt2262_unconfigured",
"(",
"hass",
",",
"rfxtrx",
")",
":",
"entry_data",
"=",
"create_rfx_test_cfg",
"(",
"devices",
"=",
"{",
"\"0913000022670e013970\"",
":",
"{",
"}",
",",
"\"09130000226707013970\"",
":",
"{",
"}",
"}",
")",
"mock_entry... | [
71,
0
] | [
92,
67
] | python | en | ['en', 'en', 'en'] | True |
test_state_restore | (hass, rfxtrx, state, event) | State restoration. | State restoration. | async def test_state_restore(hass, rfxtrx, state, event):
"""State restoration."""
entity_id = "binary_sensor.ac_213c7f2_48"
mock_restore_cache(hass, [State(entity_id, state, attributes={ATTR_EVENT: event})])
entry_data = create_rfx_test_cfg(devices={"0b1100cd0213c7f230010f71": {}})
mock_entry = ... | [
"async",
"def",
"test_state_restore",
"(",
"hass",
",",
"rfxtrx",
",",
"state",
",",
"event",
")",
":",
"entity_id",
"=",
"\"binary_sensor.ac_213c7f2_48\"",
"mock_restore_cache",
"(",
"hass",
",",
"[",
"State",
"(",
"entity_id",
",",
"state",
",",
"attributes",
... | [
99,
0
] | [
114,
52
] | python | en | ['en', 'hr', 'en'] | False |
test_several | (hass, rfxtrx) | Test with 3. | Test with 3. | async def test_several(hass, rfxtrx):
"""Test with 3."""
entry_data = create_rfx_test_cfg(
devices={
"0b1100cd0213c7f230010f71": {},
"0b1100100118cdea02010f70": {},
"0b1100101118cdea02010f70": {},
}
)
mock_entry = MockConfigEntry(domain="rfxtrx", uniqu... | [
"async",
"def",
"test_several",
"(",
"hass",
",",
"rfxtrx",
")",
":",
"entry_data",
"=",
"create_rfx_test_cfg",
"(",
"devices",
"=",
"{",
"\"0b1100cd0213c7f230010f71\"",
":",
"{",
"}",
",",
"\"0b1100100118cdea02010f70\"",
":",
"{",
"}",
",",
"\"0b1100101118cdea020... | [
117,
0
] | [
146,
67
] | python | en | ['en', 'en', 'en'] | True |
test_discover | (hass, rfxtrx_automatic) | Test with discovery. | Test with discovery. | async def test_discover(hass, rfxtrx_automatic):
"""Test with discovery."""
rfxtrx = rfxtrx_automatic
await rfxtrx.signal("0b1100100118cdea02010f70")
state = hass.states.get("binary_sensor.ac_118cdea_2")
assert state
assert state.state == "on"
await rfxtrx.signal("0b1100100118cdeb02010f70"... | [
"async",
"def",
"test_discover",
"(",
"hass",
",",
"rfxtrx_automatic",
")",
":",
"rfxtrx",
"=",
"rfxtrx_automatic",
"await",
"rfxtrx",
".",
"signal",
"(",
"\"0b1100100118cdea02010f70\"",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"binary_sensor... | [
149,
0
] | [
161,
30
] | python | en | ['en', 'en', 'en'] | True |
test_off_delay_restore | (hass, rfxtrx) | Make sure binary sensor restore as off, if off delay is active. | Make sure binary sensor restore as off, if off delay is active. | async def test_off_delay_restore(hass, rfxtrx):
"""Make sure binary sensor restore as off, if off delay is active."""
mock_restore_cache(
hass,
[
State(
"binary_sensor.ac_118cdea_2",
"on",
attributes={ATTR_EVENT: EVENT_AC_118CDEA_2_ON},... | [
"async",
"def",
"test_off_delay_restore",
"(",
"hass",
",",
"rfxtrx",
")",
":",
"mock_restore_cache",
"(",
"hass",
",",
"[",
"State",
"(",
"\"binary_sensor.ac_118cdea_2\"",
",",
"\"on\"",
",",
"attributes",
"=",
"{",
"ATTR_EVENT",
":",
"EVENT_AC_118CDEA_2_ON",
"}"... | [
164,
0
] | [
188,
31
] | python | en | ['en', 'en', 'en'] | True |
test_off_delay | (hass, rfxtrx, timestep) | Test with discovery. | Test with discovery. | async def test_off_delay(hass, rfxtrx, timestep):
"""Test with discovery."""
entry_data = create_rfx_test_cfg(
devices={"0b1100100118cdea02010f70": {"off_delay": 5}}
)
mock_entry = MockConfigEntry(domain="rfxtrx", unique_id=DOMAIN, data=entry_data)
mock_entry.add_to_hass(hass)
await ha... | [
"async",
"def",
"test_off_delay",
"(",
"hass",
",",
"rfxtrx",
",",
"timestep",
")",
":",
"entry_data",
"=",
"create_rfx_test_cfg",
"(",
"devices",
"=",
"{",
"\"0b1100100118cdea02010f70\"",
":",
"{",
"\"off_delay\"",
":",
"5",
"}",
"}",
")",
"mock_entry",
"=",
... | [
191,
0
] | [
239,
31
] | python | en | ['en', 'en', 'en'] | True |
test_panic | (hass, rfxtrx_automatic) | Test panic entities. | Test panic entities. | async def test_panic(hass, rfxtrx_automatic):
"""Test panic entities."""
rfxtrx = rfxtrx_automatic
entity_id = "binary_sensor.kd101_smoke_detector_a10900_32"
await rfxtrx.signal(EVENT_SMOKE_DETECTOR_PANIC)
assert hass.states.get(entity_id).state == "on"
assert hass.states.get(entity_id).attrib... | [
"async",
"def",
"test_panic",
"(",
"hass",
",",
"rfxtrx_automatic",
")",
":",
"rfxtrx",
"=",
"rfxtrx_automatic",
"entity_id",
"=",
"\"binary_sensor.kd101_smoke_detector_a10900_32\"",
"await",
"rfxtrx",
".",
"signal",
"(",
"EVENT_SMOKE_DETECTOR_PANIC",
")",
"assert",
"ha... | [
242,
0
] | [
253,
52
] | python | en | ['en', 'zh', 'it'] | False |
test_motion | (hass, rfxtrx_automatic) | Test motion entities. | Test motion entities. | async def test_motion(hass, rfxtrx_automatic):
"""Test motion entities."""
rfxtrx = rfxtrx_automatic
entity_id = "binary_sensor.x10_security_motion_detector_a10900_32"
await rfxtrx.signal(EVENT_MOTION_DETECTOR_MOTION)
assert hass.states.get(entity_id).state == "on"
assert hass.states.get(entit... | [
"async",
"def",
"test_motion",
"(",
"hass",
",",
"rfxtrx_automatic",
")",
":",
"rfxtrx",
"=",
"rfxtrx_automatic",
"entity_id",
"=",
"\"binary_sensor.x10_security_motion_detector_a10900_32\"",
"await",
"rfxtrx",
".",
"signal",
"(",
"EVENT_MOTION_DETECTOR_MOTION",
")",
"ass... | [
256,
0
] | [
267,
52
] | python | en | ['es', 'en', 'en'] | True |
test_light | (hass, rfxtrx_automatic) | Test light entities. | Test light entities. | async def test_light(hass, rfxtrx_automatic):
"""Test light entities."""
rfxtrx = rfxtrx_automatic
entity_id = "binary_sensor.x10_security_motion_detector_a10900_32"
await rfxtrx.signal(EVENT_LIGHT_DETECTOR_LIGHT)
assert hass.states.get(entity_id).state == "on"
await rfxtrx.signal(EVENT_LIGHT... | [
"async",
"def",
"test_light",
"(",
"hass",
",",
"rfxtrx_automatic",
")",
":",
"rfxtrx",
"=",
"rfxtrx_automatic",
"entity_id",
"=",
"\"binary_sensor.x10_security_motion_detector_a10900_32\"",
"await",
"rfxtrx",
".",
"signal",
"(",
"EVENT_LIGHT_DETECTOR_LIGHT",
")",
"assert... | [
270,
0
] | [
280,
52
] | python | en | ['fr', 'et', 'en'] | False |
test_pt2262_duplicate_id | (hass, rfxtrx) | Test with 1 sensor. | Test with 1 sensor. | async def test_pt2262_duplicate_id(hass, rfxtrx):
"""Test with 1 sensor."""
entry_data = create_rfx_test_cfg(
devices={
"0913000022670e013970": {
"data_bits": 4,
"command_on": 0xE,
"command_off": 0x7,
},
"091300002267070... | [
"async",
"def",
"test_pt2262_duplicate_id",
"(",
"hass",
",",
"rfxtrx",
")",
":",
"entry_data",
"=",
"create_rfx_test_cfg",
"(",
"devices",
"=",
"{",
"\"0913000022670e013970\"",
":",
"{",
"\"data_bits\"",
":",
"4",
",",
"\"command_on\"",
":",
"0xE",
",",
"\"comm... | [
283,
0
] | [
310,
67
] | python | en | ['en', 'en', 'en'] | True |
create_api_device | (host) | Create an API Device. | Create an API Device. | def create_api_device(host):
"""Create an API Device."""
try:
device = pywilight.device_from_host(host)
except (
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
) as err:
_LOGGER.error("Unable to access WiLight at %s (%s)", host, err)
return None... | [
"def",
"create_api_device",
"(",
"host",
")",
":",
"try",
":",
"device",
"=",
"pywilight",
".",
"device_from_host",
"(",
"host",
")",
"except",
"(",
"requests",
".",
"exceptions",
".",
"ConnectionError",
",",
"requests",
".",
"exceptions",
".",
"Timeout",
",... | [
93,
0
] | [
104,
17
] | python | en | ['en', 'haw', 'en'] | True |
WiLightParent.__init__ | (self, hass, config_entry) | Initialize the system. | Initialize the system. | def __init__(self, hass, config_entry):
"""Initialize the system."""
self._host = config_entry.data[CONF_HOST]
self._hass = hass
self._api = None | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"config_entry",
")",
":",
"self",
".",
"_host",
"=",
"config_entry",
".",
"data",
"[",
"CONF_HOST",
"]",
"self",
".",
"_hass",
"=",
"hass",
"self",
".",
"_api",
"=",
"None"
] | [
17,
4
] | [
21,
24
] | 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.