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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
MockEntity.unique_id | (self) | Return unique ID of entity. | Return unique ID of entity. | def unique_id(self):
"""Return unique ID of entity."""
return self._config["id"] | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"\"id\"",
"]"
] | [
33,
4
] | [
35,
33
] | python | en | ['en', 'cy', 'en'] | True |
MockEntity.name | (self) | Return name of entity. | Return name of entity. | def name(self):
"""Return name of entity."""
return self._config["name"] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"\"name\"",
"]"
] | [
38,
4
] | [
40,
35
] | python | en | ['en', 'ig', 'en'] | True |
MockEntity.state | (self) | Return state of entity. | Return state of entity. | def state(self):
"""Return state of entity."""
return self._config["state"] | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"\"state\"",
"]"
] | [
43,
4
] | [
45,
36
] | python | en | ['en', 'en', 'en'] | True |
MockEntity.async_update_config | (self, config) | Update entity config. | Update entity config. | async def async_update_config(self, config):
"""Update entity config."""
self._config = config
self.async_write_ha_state() | [
"async",
"def",
"async_update_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
47,
4
] | [
50,
35
] | python | en | ['en', 'en', 'en'] | True |
MockStorageCollection._process_create_data | (self, data: dict) | Validate the config is valid. | Validate the config is valid. | async def _process_create_data(self, data: dict) -> dict:
"""Validate the config is valid."""
if "name" not in data:
raise ValueError("invalid")
return data | [
"async",
"def",
"_process_create_data",
"(",
"self",
",",
"data",
":",
"dict",
")",
"->",
"dict",
":",
"if",
"\"name\"",
"not",
"in",
"data",
":",
"raise",
"ValueError",
"(",
"\"invalid\"",
")",
"return",
"data"
] | [
56,
4
] | [
61,
19
] | python | en | ['en', 'en', 'en'] | True |
MockStorageCollection._get_suggested_id | (self, info: dict) | Suggest an ID based on the config. | Suggest an ID based on the config. | def _get_suggested_id(self, info: dict) -> str:
"""Suggest an ID based on the config."""
return info["name"] | [
"def",
"_get_suggested_id",
"(",
"self",
",",
"info",
":",
"dict",
")",
"->",
"str",
":",
"return",
"info",
"[",
"\"name\"",
"]"
] | [
63,
4
] | [
65,
27
] | python | en | ['en', 'en', 'en'] | True |
MockStorageCollection._update_data | (self, data: dict, update_data: dict) | Return a new updated data object. | Return a new updated data object. | async def _update_data(self, data: dict, update_data: dict) -> dict:
"""Return a new updated data object."""
return {**data, **update_data} | [
"async",
"def",
"_update_data",
"(",
"self",
",",
"data",
":",
"dict",
",",
"update_data",
":",
"dict",
")",
"->",
"dict",
":",
"return",
"{",
"*",
"*",
"data",
",",
"*",
"*",
"update_data",
"}"
] | [
67,
4
] | [
69,
38
] | python | en | ['en', 'en', 'en'] | True |
TFConvBertEmbeddings.call | (
self,
input_ids: tf.Tensor = None,
position_ids: tf.Tensor = None,
token_type_ids: tf.Tensor = None,
inputs_embeds: tf.Tensor = None,
training: bool = False,
) |
Applies embedding based on inputs tensor.
Returns:
final_embeddings (:obj:`tf.Tensor`): output embedding tensor.
|
Applies embedding based on inputs tensor. | def call(
self,
input_ids: tf.Tensor = None,
position_ids: tf.Tensor = None,
token_type_ids: tf.Tensor = None,
inputs_embeds: tf.Tensor = None,
training: bool = False,
) -> tf.Tensor:
"""
Applies embedding based on inputs tensor.
Returns:
... | [
"def",
"call",
"(",
"self",
",",
"input_ids",
":",
"tf",
".",
"Tensor",
"=",
"None",
",",
"position_ids",
":",
"tf",
".",
"Tensor",
"=",
"None",
",",
"token_type_ids",
":",
"tf",
".",
"Tensor",
"=",
"None",
",",
"inputs_embeds",
":",
"tf",
".",
"Tens... | [
106,
4
] | [
140,
31
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Demo alarm control panel platform. | Set up the Demo alarm control panel platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Demo alarm control panel platform."""
async_add_entities(
[
ManualAlarm(
hass,
"Alarm",
"1234",
None,
True,
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"async_add_entities",
"(",
"[",
"ManualAlarm",
"(",
"hass",
",",
"\"Alarm\"",
",",
"\"1234\"",
",",
"None",
",",
"True"... | [
17,
0
] | [
59,
5
] | python | en | ['en', 'ru', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Demo config entry. | Set up the Demo config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Demo config entry."""
await async_setup_platform(hass, {}, async_add_entities) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"await",
"async_setup_platform",
"(",
"hass",
",",
"{",
"}",
",",
"async_add_entities",
")"
] | [
62,
0
] | [
64,
60
] | python | en | ['en', 'en', 'en'] | True |
test_sensors | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) | Test the creation and values of the WLED sensors. | Test the creation and values of the WLED sensors. | async def test_sensors(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the creation and values of the WLED sensors."""
entry = await init_integration(hass, aioclient_mock, skip_setup=True)
registry = await hass.helpers.entity_registry.async_get_registry()
# Pre-create ... | [
"async",
"def",
"test_sensors",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
"->",
"None",
":",
"entry",
"=",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
",",
"skip_setup",
"=",
"True",
")",
"r... | [
31,
0
] | [
168,
55
] | python | en | ['en', 'en', 'en'] | True |
test_disabled_by_default_sensors | (
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, entity_id: str
) | Test the disabled by default WLED sensors. | Test the disabled by default WLED sensors. | async def test_disabled_by_default_sensors(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, entity_id: str
) -> None:
"""Test the disabled by default WLED sensors."""
await init_integration(hass, aioclient_mock)
registry = await hass.helpers.entity_registry.async_get_registry()
state = ha... | [
"async",
"def",
"test_disabled_by_default_sensors",
"(",
"hass",
":",
"HomeAssistant",
",",
"aioclient_mock",
":",
"AiohttpClientMocker",
",",
"entity_id",
":",
"str",
")",
"->",
"None",
":",
"await",
"init_integration",
"(",
"hass",
",",
"aioclient_mock",
")",
"r... | [
182,
0
] | [
195,
45
] | python | en | ['en', 'en', 'en'] | True |
IterativePruner.__init__ | (self, model, config_list, optimizer=None, pruning_algorithm='slim', trainer=None, criterion=None,
num_iterations=20, epochs_per_iteration=5, dependency_aware=False, dummy_input=None, **algo_kwargs) |
Parameters
----------
model: torch.nn.Module
Model to be pruned
config_list: list
List on pruning configs
optimizer: torch.optim.Optimizer
Optimizer used to train model
pruning_algorithm: str
algorithms being used to prune ... |
Parameters
----------
model: torch.nn.Module
Model to be pruned
config_list: list
List on pruning configs
optimizer: torch.optim.Optimizer
Optimizer used to train model
pruning_algorithm: str
algorithms being used to prune ... | def __init__(self, model, config_list, optimizer=None, pruning_algorithm='slim', trainer=None, criterion=None,
num_iterations=20, epochs_per_iteration=5, dependency_aware=False, dummy_input=None, **algo_kwargs):
"""
Parameters
----------
model: torch.nn.Module
... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"config_list",
",",
"optimizer",
"=",
"None",
",",
"pruning_algorithm",
"=",
"'slim'",
",",
"trainer",
"=",
"None",
",",
"criterion",
"=",
"None",
",",
"num_iterations",
"=",
"20",
",",
"epochs_per_iteration... | [
23,
4
] | [
68,
35
] | python | en | ['en', 'error', 'th'] | False |
AGPPruner.validate_config | (self, model, config_list) |
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list
List on pruning configs
|
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list
List on pruning configs
| def validate_config(self, model, config_list):
"""
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list
List on pruning configs
"""
schema = CompressorSchema([{
'sparsity': And(float, lambda n: 0 <... | [
"def",
"validate_config",
"(",
"self",
",",
"model",
",",
"config_list",
")",
":",
"schema",
"=",
"CompressorSchema",
"(",
"[",
"{",
"'sparsity'",
":",
"And",
"(",
"float",
",",
"lambda",
"n",
":",
"0",
"<=",
"n",
"<=",
"1",
")",
",",
"Optional",
"("... | [
130,
4
] | [
145,
36
] | python | en | ['en', 'error', 'th'] | False |
AGPPruner.calc_mask | (self, wrapper, wrapper_idx=None) |
Calculate the mask of given layer.
Scale factors with the smallest absolute value in the BN layer are masked.
Parameters
----------
wrapper : Module
the layer to instrument the compression operation
wrapper_idx: int
index of this wrapper in pruner... |
Calculate the mask of given layer.
Scale factors with the smallest absolute value in the BN layer are masked.
Parameters
----------
wrapper : Module
the layer to instrument the compression operation
wrapper_idx: int
index of this wrapper in pruner... | def calc_mask(self, wrapper, wrapper_idx=None):
"""
Calculate the mask of given layer.
Scale factors with the smallest absolute value in the BN layer are masked.
Parameters
----------
wrapper : Module
the layer to instrument the compression operation
w... | [
"def",
"calc_mask",
"(",
"self",
",",
"wrapper",
",",
"wrapper_idx",
"=",
"None",
")",
":",
"config",
"=",
"wrapper",
".",
"config",
"if",
"wrapper",
".",
"if_calculated",
":",
"return",
"None",
"if",
"not",
"self",
".",
"now_epoch",
"%",
"self",
".",
... | [
150,
4
] | [
182,
23
] | python | en | ['en', 'error', 'th'] | False |
AGPPruner.compute_target_sparsity | (self, config) |
Calculate the sparsity for pruning
Parameters
----------
config : dict
Layer's pruning config
Returns
-------
float
Target sparsity to be pruned
|
Calculate the sparsity for pruning
Parameters
----------
config : dict
Layer's pruning config
Returns
-------
float
Target sparsity to be pruned
| def compute_target_sparsity(self, config):
"""
Calculate the sparsity for pruning
Parameters
----------
config : dict
Layer's pruning config
Returns
-------
float
Target sparsity to be pruned
"""
initial_sparsity = ... | [
"def",
"compute_target_sparsity",
"(",
"self",
",",
"config",
")",
":",
"initial_sparsity",
"=",
"0",
"self",
".",
"target_sparsity",
"=",
"final_sparsity",
"=",
"config",
".",
"get",
"(",
"'sparsity'",
",",
"0",
")",
"if",
"initial_sparsity",
">=",
"final_spa... | [
184,
4
] | [
210,
35
] | python | en | ['en', 'error', 'th'] | False |
AGPPruner.update_epoch | (self, epoch) |
Update epoch
Parameters
----------
epoch : int
current training epoch
|
Update epoch
Parameters
----------
epoch : int
current training epoch
| def update_epoch(self, epoch):
"""
Update epoch
Parameters
----------
epoch : int
current training epoch
"""
if epoch > 0:
self.now_epoch = epoch
for wrapper in self.get_modules_wrapper():
wrapper.if_calculated ... | [
"def",
"update_epoch",
"(",
"self",
",",
"epoch",
")",
":",
"if",
"epoch",
">",
"0",
":",
"self",
".",
"now_epoch",
"=",
"epoch",
"for",
"wrapper",
"in",
"self",
".",
"get_modules_wrapper",
"(",
")",
":",
"wrapper",
".",
"if_calculated",
"=",
"False"
] | [
212,
4
] | [
224,
45
] | python | en | ['en', 'error', 'th'] | False |
ADMMPruner.validate_config | (self, model, config_list) |
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list
List on pruning configs
|
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list
List on pruning configs
| def validate_config(self, model, config_list):
"""
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list
List on pruning configs
"""
if self._base_algo == 'level':
schema = CompressorSchema([{
... | [
"def",
"validate_config",
"(",
"self",
",",
"model",
",",
"config_list",
")",
":",
"if",
"self",
".",
"_base_algo",
"==",
"'level'",
":",
"schema",
"=",
"CompressorSchema",
"(",
"[",
"{",
"'sparsity'",
":",
"And",
"(",
"float",
",",
"lambda",
"n",
":",
... | [
290,
4
] | [
313,
36
] | python | en | ['en', 'error', 'th'] | False |
ADMMPruner._projection | (self, weight, sparsity, wrapper) |
Return the Euclidean projection of the weight matrix according to the pruning mode.
Parameters
----------
weight : tensor
original matrix
sparsity : float
the ratio of parameters which need to be set to zero
wrapper: PrunerModuleWrapper
... |
Return the Euclidean projection of the weight matrix according to the pruning mode. | def _projection(self, weight, sparsity, wrapper):
'''
Return the Euclidean projection of the weight matrix according to the pruning mode.
Parameters
----------
weight : tensor
original matrix
sparsity : float
the ratio of parameters which need to ... | [
"def",
"_projection",
"(",
"self",
",",
"weight",
",",
"sparsity",
",",
"wrapper",
")",
":",
"wrapper_copy",
"=",
"copy",
".",
"deepcopy",
"(",
"wrapper",
")",
"wrapper_copy",
".",
"module",
".",
"weight",
".",
"data",
"=",
"weight",
"return",
"weight",
... | [
318,
4
] | [
338,
92
] | python | en | ['en', 'error', 'th'] | False |
ADMMPruner.compress | (self) |
Compress the model with ADMM.
Returns
-------
torch.nn.Module
model with specified modules compressed.
|
Compress the model with ADMM. | def compress(self):
"""
Compress the model with ADMM.
Returns
-------
torch.nn.Module
model with specified modules compressed.
"""
logger.info('Starting ADMM Compression...')
# initiaze Z, U
# Z_i^0 = W_i^0
# U_i^0 = 0
... | [
"def",
"compress",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Starting ADMM Compression...'",
")",
"# initiaze Z, U",
"# Z_i^0 = W_i^0",
"# U_i^0 = 0",
"self",
".",
"Z",
"=",
"[",
"]",
"self",
".",
"U",
"=",
"[",
"]",
"for",
"wrapper",
"in",
"sel... | [
346,
4
] | [
389,
31
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up an Arlo IP sensor. | Set up an Arlo IP sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up an Arlo IP sensor."""
arlo = hass.data.get(DATA_ARLO)
if not arlo:
return
sensors = []
for sensor_type in config[CONF_MONITORED_CONDITIONS]:
if sensor_type == "total_cameras":
sensors.append(A... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"arlo",
"=",
"hass",
".",
"data",
".",
"get",
"(",
"DATA_ARLO",
")",
"if",
"not",
"arlo",
":",
"return",
"sensors",
"=",
"[",
"]",
... | [
46,
0
] | [
72,
31
] | python | en | ['en', 'su', 'en'] | True |
ArloSensor.__init__ | (self, name, device, sensor_type) | Initialize an Arlo sensor. | Initialize an Arlo sensor. | def __init__(self, name, device, sensor_type):
"""Initialize an Arlo sensor."""
_LOGGER.debug("ArloSensor created for %s", name)
self._name = name
self._data = device
self._sensor_type = sensor_type
self._state = None
self._icon = f"mdi:{SENSOR_TYPES.get(self._sen... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"device",
",",
"sensor_type",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"ArloSensor created for %s\"",
",",
"name",
")",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_data",
"=",
"device",
"self",
"."... | [
78,
4
] | [
85,
68
] | python | it | ['it', 'zh-Latn', 'it'] | True |
ArloSensor.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"
] | [
88,
4
] | [
90,
25
] | python | en | ['en', 'en', 'en'] | True |
ArloSensor.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_ARLO, self._update_callback
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_UPDATE_ARLO",
",",
"self",
".",
"_update_callback",
")",
")"
] | [
92,
4
] | [
98,
9
] | python | en | ['en', 'no', 'en'] | False |
ArloSensor._update_callback | (self) | Call update method. | Call update method. | def _update_callback(self):
"""Call update method."""
self.async_schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"async_schedule_update_ha_state",
"(",
"True",
")"
] | [
101,
4
] | [
103,
49
] | python | en | ['en', 'sn', 'en'] | True |
ArloSensor.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"
] | [
106,
4
] | [
108,
26
] | python | en | ['en', 'en', 'en'] | True |
ArloSensor.icon | (self) | Icon to use in the frontend, if any. | Icon to use in the frontend, if any. | def icon(self):
"""Icon to use in the frontend, if any."""
if self._sensor_type == "battery_level" and self._state is not None:
return icon_for_battery_level(
battery_level=int(self._state), charging=False
)
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sensor_type",
"==",
"\"battery_level\"",
"and",
"self",
".",
"_state",
"is",
"not",
"None",
":",
"return",
"icon_for_battery_level",
"(",
"battery_level",
"=",
"int",
"(",
"self",
".",
"_state",
")... | [
111,
4
] | [
117,
25
] | python | en | ['en', 'en', 'en'] | True |
ArloSensor.unit_of_measurement | (self) | Return the units of measurement. | Return the units of measurement. | def unit_of_measurement(self):
"""Return the units of measurement."""
return SENSOR_TYPES.get(self._sensor_type)[1] | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"SENSOR_TYPES",
".",
"get",
"(",
"self",
".",
"_sensor_type",
")",
"[",
"1",
"]"
] | [
120,
4
] | [
122,
53
] | python | en | ['en', 'bg', 'en'] | True |
ArloSensor.device_class | (self) | Return the device class of the sensor. | Return the device class of the sensor. | def device_class(self):
"""Return the device class of the sensor."""
if self._sensor_type == "temperature":
return DEVICE_CLASS_TEMPERATURE
if self._sensor_type == "humidity":
return DEVICE_CLASS_HUMIDITY
return None | [
"def",
"device_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sensor_type",
"==",
"\"temperature\"",
":",
"return",
"DEVICE_CLASS_TEMPERATURE",
"if",
"self",
".",
"_sensor_type",
"==",
"\"humidity\"",
":",
"return",
"DEVICE_CLASS_HUMIDITY",
"return",
"None"
] | [
125,
4
] | [
131,
19
] | python | en | ['en', 'en', 'en'] | True |
ArloSensor.update | (self) | Get the latest data and updates the state. | Get the latest data and updates the state. | def update(self):
"""Get the latest data and updates the state."""
_LOGGER.debug("Updating Arlo sensor %s", self.name)
if self._sensor_type == "total_cameras":
self._state = len(self._data.cameras)
elif self._sensor_type == "captured_today":
self._state = len(sel... | [
"def",
"update",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Updating Arlo sensor %s\"",
",",
"self",
".",
"name",
")",
"if",
"self",
".",
"_sensor_type",
"==",
"\"total_cameras\"",
":",
"self",
".",
"_state",
"=",
"len",
"(",
"self",
".",
"_... | [
133,
4
] | [
182,
34
] | python | en | ['en', 'en', 'en'] | True |
ArloSensor.device_state_attributes | (self) | Return the device state attributes. | Return the device state attributes. | def device_state_attributes(self):
"""Return the device state attributes."""
attrs = {}
attrs[ATTR_ATTRIBUTION] = ATTRIBUTION
attrs["brand"] = DEFAULT_BRAND
if self._sensor_type != "total_cameras":
attrs["model"] = self._data.model_id
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"{",
"}",
"attrs",
"[",
"ATTR_ATTRIBUTION",
"]",
"=",
"ATTRIBUTION",
"attrs",
"[",
"\"brand\"",
"]",
"=",
"DEFAULT_BRAND",
"if",
"self",
".",
"_sensor_type",
"!=",
"\"total_cameras\"",
":",... | [
185,
4
] | [
195,
20
] | python | en | ['en', 'en', 'en'] | True |
patch_setup_entry | (domain: str, *, enabled: bool = True) | Patch async_setup_entry for specified domain. | Patch async_setup_entry for specified domain. | def patch_setup_entry(domain: str, *, enabled: bool = True):
"""Patch async_setup_entry for specified domain."""
if not enabled:
return nullcontext()
return patch(f"homeassistant.components.bond.{domain}.async_setup_entry") | [
"def",
"patch_setup_entry",
"(",
"domain",
":",
"str",
",",
"*",
",",
"enabled",
":",
"bool",
"=",
"True",
")",
":",
"if",
"not",
"enabled",
":",
"return",
"nullcontext",
"(",
")",
"return",
"patch",
"(",
"f\"homeassistant.components.bond.{domain}.async_setup_en... | [
16,
0
] | [
21,
77
] | python | en | ['en', 'en', 'en'] | True |
setup_bond_entity | (
hass: core.HomeAssistant,
config_entry: MockConfigEntry,
*,
patch_version=False,
patch_device_ids=False,
patch_platforms=False,
) | Set up Bond entity. | Set up Bond entity. | async def setup_bond_entity(
hass: core.HomeAssistant,
config_entry: MockConfigEntry,
*,
patch_version=False,
patch_device_ids=False,
patch_platforms=False,
):
"""Set up Bond entity."""
config_entry.add_to_hass(hass)
with patch_bond_version(enabled=patch_version), patch_bond_device_... | [
"async",
"def",
"setup_bond_entity",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"config_entry",
":",
"MockConfigEntry",
",",
"*",
",",
"patch_version",
"=",
"False",
",",
"patch_device_ids",
"=",
"False",
",",
"patch_platforms",
"=",
"False",
",",
")... | [
24,
0
] | [
44,
75
] | python | en | ['en', 'hu', 'en'] | True |
setup_platform | (
hass: core.HomeAssistant,
platform: str,
discovered_device: Dict[str, Any],
*,
bond_device_id: str = "bond-device-id",
bond_version: Dict[str, Any] = None,
props: Dict[str, Any] = None,
state: Dict[str, Any] = None,
) | Set up the specified Bond platform. | Set up the specified Bond platform. | async def setup_platform(
hass: core.HomeAssistant,
platform: str,
discovered_device: Dict[str, Any],
*,
bond_device_id: str = "bond-device-id",
bond_version: Dict[str, Any] = None,
props: Dict[str, Any] = None,
state: Dict[str, Any] = None,
):
"""Set up the specified Bond platform."... | [
"async",
"def",
"setup_platform",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"platform",
":",
"str",
",",
"discovered_device",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"*",
",",
"bond_device_id",
":",
"str",
"=",
"\"bond-device-id\"",
",",
... | [
47,
0
] | [
77,
21
] | python | en | ['en', 'da', 'en'] | True |
patch_bond_version | (
enabled: bool = True, return_value: Optional[dict] = None, side_effect=None
) | Patch Bond API version endpoint. | Patch Bond API version endpoint. | def patch_bond_version(
enabled: bool = True, return_value: Optional[dict] = None, side_effect=None
):
"""Patch Bond API version endpoint."""
if not enabled:
return nullcontext()
if return_value is None:
return_value = {"bondid": "test-bond-id"}
return patch(
"homeassistant... | [
"def",
"patch_bond_version",
"(",
"enabled",
":",
"bool",
"=",
"True",
",",
"return_value",
":",
"Optional",
"[",
"dict",
"]",
"=",
"None",
",",
"side_effect",
"=",
"None",
")",
":",
"if",
"not",
"enabled",
":",
"return",
"nullcontext",
"(",
")",
"if",
... | [
80,
0
] | [
94,
5
] | python | en | ['en', 'cs', 'en'] | True |
patch_bond_device_ids | (enabled: bool = True, return_value=None, side_effect=None) | Patch Bond API devices endpoint. | Patch Bond API devices endpoint. | def patch_bond_device_ids(enabled: bool = True, return_value=None, side_effect=None):
"""Patch Bond API devices endpoint."""
if not enabled:
return nullcontext()
if return_value is None:
return_value = []
return patch(
"homeassistant.components.bond.Bond.devices",
retur... | [
"def",
"patch_bond_device_ids",
"(",
"enabled",
":",
"bool",
"=",
"True",
",",
"return_value",
"=",
"None",
",",
"side_effect",
"=",
"None",
")",
":",
"if",
"not",
"enabled",
":",
"return",
"nullcontext",
"(",
")",
"if",
"return_value",
"is",
"None",
":",
... | [
97,
0
] | [
109,
5
] | python | en | ['en', 'fr', 'en'] | True |
patch_bond_device | (return_value=None) | Patch Bond API device endpoint. | Patch Bond API device endpoint. | def patch_bond_device(return_value=None):
"""Patch Bond API device endpoint."""
return patch(
"homeassistant.components.bond.Bond.device",
return_value=return_value,
) | [
"def",
"patch_bond_device",
"(",
"return_value",
"=",
"None",
")",
":",
"return",
"patch",
"(",
"\"homeassistant.components.bond.Bond.device\"",
",",
"return_value",
"=",
"return_value",
",",
")"
] | [
112,
0
] | [
117,
5
] | python | en | ['en', 'cs', 'en'] | True |
patch_bond_action | () | Patch Bond API action endpoint. | Patch Bond API action endpoint. | def patch_bond_action():
"""Patch Bond API action endpoint."""
return patch("homeassistant.components.bond.Bond.action") | [
"def",
"patch_bond_action",
"(",
")",
":",
"return",
"patch",
"(",
"\"homeassistant.components.bond.Bond.action\"",
")"
] | [
120,
0
] | [
122,
61
] | python | en | ['en', 'fr', 'en'] | True |
patch_bond_device_properties | (return_value=None) | Patch Bond API device properties endpoint. | Patch Bond API device properties endpoint. | def patch_bond_device_properties(return_value=None):
"""Patch Bond API device properties endpoint."""
if return_value is None:
return_value = {}
return patch(
"homeassistant.components.bond.Bond.device_properties",
return_value=return_value,
) | [
"def",
"patch_bond_device_properties",
"(",
"return_value",
"=",
"None",
")",
":",
"if",
"return_value",
"is",
"None",
":",
"return_value",
"=",
"{",
"}",
"return",
"patch",
"(",
"\"homeassistant.components.bond.Bond.device_properties\"",
",",
"return_value",
"=",
"re... | [
125,
0
] | [
133,
5
] | python | en | ['en', 'cs', 'en'] | True |
patch_bond_device_state | (return_value=None, side_effect=None) | Patch Bond API device state endpoint. | Patch Bond API device state endpoint. | def patch_bond_device_state(return_value=None, side_effect=None):
"""Patch Bond API device state endpoint."""
if return_value is None:
return_value = {}
return patch(
"homeassistant.components.bond.Bond.device_state",
return_value=return_value,
side_effect=side_effect,
) | [
"def",
"patch_bond_device_state",
"(",
"return_value",
"=",
"None",
",",
"side_effect",
"=",
"None",
")",
":",
"if",
"return_value",
"is",
"None",
":",
"return_value",
"=",
"{",
"}",
"return",
"patch",
"(",
"\"homeassistant.components.bond.Bond.device_state\"",
",",... | [
136,
0
] | [
145,
5
] | python | en | ['en', 'cs', 'en'] | True |
help_test_entity_available | (
hass: core.HomeAssistant, domain: str, device: Dict[str, Any], entity_id: str
) | Run common test to verify available property. | Run common test to verify available property. | async def help_test_entity_available(
hass: core.HomeAssistant, domain: str, device: Dict[str, Any], entity_id: str
):
"""Run common test to verify available property."""
await setup_platform(hass, domain, device)
assert hass.states.get(entity_id).state != STATE_UNAVAILABLE
with patch_bond_device_... | [
"async",
"def",
"help_test_entity_available",
"(",
"hass",
":",
"core",
".",
"HomeAssistant",
",",
"domain",
":",
"str",
",",
"device",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"entity_id",
":",
"str",
")",
":",
"await",
"setup_platform",
"(",
"has... | [
148,
0
] | [
164,
64
] | python | en | ['en', 'en', 'en'] | True |
test_thread_with_exception_invalid | (hass) | Test throwing an invalid thread exception. | Test throwing an invalid thread exception. | async def test_thread_with_exception_invalid(hass):
"""Test throwing an invalid thread exception."""
finish_event = asyncio.Event()
def _do_nothing(*_):
run_callback_threadsafe(hass.loop, finish_event.set)
test_thread = ThreadWithException(target=_do_nothing)
test_thread.start()
await... | [
"async",
"def",
"test_thread_with_exception_invalid",
"(",
"hass",
")",
":",
"finish_event",
"=",
"asyncio",
".",
"Event",
"(",
")",
"def",
"_do_nothing",
"(",
"*",
"_",
")",
":",
"run_callback_threadsafe",
"(",
"hass",
".",
"loop",
",",
"finish_event",
".",
... | [
10,
0
] | [
24,
22
] | python | en | ['en', 'en', 'en'] | True |
test_thread_not_started | (hass) | Test throwing when the thread is not started. | Test throwing when the thread is not started. | async def test_thread_not_started(hass):
"""Test throwing when the thread is not started."""
test_thread = ThreadWithException(target=lambda *_: None)
with pytest.raises(AssertionError):
test_thread.raise_exc(TimeoutError) | [
"async",
"def",
"test_thread_not_started",
"(",
"hass",
")",
":",
"test_thread",
"=",
"ThreadWithException",
"(",
"target",
"=",
"lambda",
"*",
"_",
":",
"None",
")",
"with",
"pytest",
".",
"raises",
"(",
"AssertionError",
")",
":",
"test_thread",
".",
"rais... | [
27,
0
] | [
33,
43
] | python | en | ['en', 'en', 'en'] | True |
test_thread_fails_raise | (hass) | Test throwing after already ended. | Test throwing after already ended. | async def test_thread_fails_raise(hass):
"""Test throwing after already ended."""
finish_event = asyncio.Event()
def _do_nothing(*_):
run_callback_threadsafe(hass.loop, finish_event.set)
test_thread = ThreadWithException(target=_do_nothing)
test_thread.start()
await asyncio.wait_for(f... | [
"async",
"def",
"test_thread_fails_raise",
"(",
"hass",
")",
":",
"finish_event",
"=",
"asyncio",
".",
"Event",
"(",
")",
"def",
"_do_nothing",
"(",
"*",
"_",
")",
":",
"run_callback_threadsafe",
"(",
"hass",
".",
"loop",
",",
"finish_event",
".",
"set",
"... | [
36,
0
] | [
50,
41
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up ZHA from config. | Set up ZHA from config. | async def async_setup(hass, config):
"""Set up ZHA from config."""
hass.data[DATA_ZHA] = {}
if DOMAIN in config:
conf = config[DOMAIN]
hass.data[DATA_ZHA][DATA_ZHA_CONFIG] = conf
return True | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DATA_ZHA",
"]",
"=",
"{",
"}",
"if",
"DOMAIN",
"in",
"config",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"hass",
".",
"data",
"[",
"DATA_ZHA",
"]"... | [
70,
0
] | [
78,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry) | Set up ZHA.
Will automatically load components to support devices found on the network.
| Set up ZHA. | async def async_setup_entry(hass, config_entry):
"""Set up ZHA.
Will automatically load components to support devices found on the network.
"""
zha_data = hass.data.setdefault(DATA_ZHA, {})
config = zha_data.get(DATA_ZHA_CONFIG, {})
for component in COMPONENTS:
zha_data.setdefault(com... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"zha_data",
"=",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DATA_ZHA",
",",
"{",
"}",
")",
"config",
"=",
"zha_data",
".",
"get",
"(",
"DATA_ZHA_CONFIG",
",",
"{",
"}",
... | [
81,
0
] | [
126,
15
] | python | en | ['en', 'zu', 'en'] | True |
async_unload_entry | (hass, config_entry) | Unload ZHA config entry. | Unload ZHA config entry. | async def async_unload_entry(hass, config_entry):
"""Unload ZHA config entry."""
await hass.data[DATA_ZHA][DATA_ZHA_GATEWAY].shutdown()
GROUP_PROBE.cleanup()
api.async_unload_api(hass)
dispatchers = hass.data[DATA_ZHA].get(DATA_ZHA_DISPATCHERS, [])
for unsub_dispatcher in dispatchers:
... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"config_entry",
")",
":",
"await",
"hass",
".",
"data",
"[",
"DATA_ZHA",
"]",
"[",
"DATA_ZHA_GATEWAY",
"]",
".",
"shutdown",
"(",
")",
"GROUP_PROBE",
".",
"cleanup",
"(",
")",
"api",
".",
"async_unloa... | [
129,
0
] | [
143,
15
] | python | en | ['da', 'en', 'en'] | True |
async_load_entities | (hass: HomeAssistantType) | Load entities after integration was setup. | Load entities after integration was setup. | async def async_load_entities(hass: HomeAssistantType) -> None:
"""Load entities after integration was setup."""
await hass.data[DATA_ZHA][DATA_ZHA_GATEWAY].async_initialize_devices_and_entities()
to_setup = hass.data[DATA_ZHA][DATA_ZHA_PLATFORM_LOADED]
results = await asyncio.gather(*to_setup, return_e... | [
"async",
"def",
"async_load_entities",
"(",
"hass",
":",
"HomeAssistantType",
")",
"->",
"None",
":",
"await",
"hass",
".",
"data",
"[",
"DATA_ZHA",
"]",
"[",
"DATA_ZHA_GATEWAY",
"]",
".",
"async_initialize_devices_and_entities",
"(",
")",
"to_setup",
"=",
"hass... | [
146,
0
] | [
154,
52
] | python | en | ['en', 'en', 'en'] | True |
async_migrate_entry | (
hass: HomeAssistantType, config_entry: config_entries.ConfigEntry
) | Migrate old entry. | Migrate old entry. | async def async_migrate_entry(
hass: HomeAssistantType, config_entry: config_entries.ConfigEntry
):
"""Migrate old entry."""
_LOGGER.debug("Migrating from version %s", config_entry.version)
if config_entry.version == 1:
data = {
CONF_RADIO_TYPE: config_entry.data[CONF_RADIO_TYPE],
... | [
"async",
"def",
"async_migrate_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Migrating from version %s\"",
",",
"config_entry",
".",
"version",
")",
"if",
"... | [
157,
0
] | [
177,
15
] | python | en | ['en', 'en', 'en'] | True |
build_tf_xlnet_to_pytorch_map | (model, config, tf_weights=None) |
A map of modules from TF to PyTorch. I use a map to keep the PyTorch model as identical to the original PyTorch
model as possible.
|
A map of modules from TF to PyTorch. I use a map to keep the PyTorch model as identical to the original PyTorch
model as possible.
| def build_tf_xlnet_to_pytorch_map(model, config, tf_weights=None):
"""
A map of modules from TF to PyTorch. I use a map to keep the PyTorch model as identical to the original PyTorch
model as possible.
"""
tf_to_pt_map = {}
if hasattr(model, "transformer"):
if hasattr(model, "lm_loss")... | [
"def",
"build_tf_xlnet_to_pytorch_map",
"(",
"model",
",",
"config",
",",
"tf_weights",
"=",
"None",
")",
":",
"tf_to_pt_map",
"=",
"{",
"}",
"if",
"hasattr",
"(",
"model",
",",
"\"transformer\"",
")",
":",
"if",
"hasattr",
"(",
"model",
",",
"\"lm_loss\"",
... | [
60,
0
] | [
140,
23
] | python | en | ['en', 'error', 'th'] | False |
load_tf_weights_in_xlnet | (model, config, tf_path) | Load tf checkpoints in a pytorch model | Load tf checkpoints in a pytorch model | def load_tf_weights_in_xlnet(model, config, tf_path):
"""Load tf checkpoints in a pytorch model"""
try:
import numpy as np
import tensorflow as tf
except ImportError:
logger.error(
"Loading a TensorFlow models in PyTorch, requires TensorFlow to be installed. Please see "
... | [
"def",
"load_tf_weights_in_xlnet",
"(",
"model",
",",
"config",
",",
"tf_path",
")",
":",
"try",
":",
"import",
"numpy",
"as",
"np",
"import",
"tensorflow",
"as",
"tf",
"except",
"ImportError",
":",
"logger",
".",
"error",
"(",
"\"Loading a TensorFlow models in ... | [
143,
0
] | [
207,
16
] | python | en | ['en', 'en', 'en'] | True |
XLNetRelativeAttention.rel_shift | (x, klen=-1) | perform relative shift to form the relative attention score. | perform relative shift to form the relative attention score. | def rel_shift(x, klen=-1):
"""perform relative shift to form the relative attention score."""
x_size = x.shape
x = x.reshape(x_size[1], x_size[0], x_size[2], x_size[3])
x = x[1:, ...]
x = x.reshape(x_size[0], x_size[1] - 1, x_size[2], x_size[3])
# x = x[:, 0:klen, :, :]
... | [
"def",
"rel_shift",
"(",
"x",
",",
"klen",
"=",
"-",
"1",
")",
":",
"x_size",
"=",
"x",
".",
"shape",
"x",
"=",
"x",
".",
"reshape",
"(",
"x_size",
"[",
"1",
"]",
",",
"x_size",
"[",
"0",
"]",
",",
"x_size",
"[",
"2",
"]",
",",
"x_size",
"[... | [
243,
4
] | [
253,
16
] | python | en | ['en', 'en', 'en'] | True |
XLNetRelativeAttention.rel_attn_core | (
self,
q_head,
k_head_h,
v_head_h,
k_head_r,
seg_mat=None,
attn_mask=None,
head_mask=None,
output_attentions=False,
) | Core relative positional attention operations. | Core relative positional attention operations. | def rel_attn_core(
self,
q_head,
k_head_h,
v_head_h,
k_head_r,
seg_mat=None,
attn_mask=None,
head_mask=None,
output_attentions=False,
):
"""Core relative positional attention operations."""
# content based attention score
... | [
"def",
"rel_attn_core",
"(",
"self",
",",
"q_head",
",",
"k_head_h",
",",
"v_head_h",
",",
"k_head_r",
",",
"seg_mat",
"=",
"None",
",",
"attn_mask",
"=",
"None",
",",
"head_mask",
"=",
"None",
",",
"output_attentions",
"=",
"False",
",",
")",
":",
"# co... | [
270,
4
] | [
320,
23
] | python | en | ['en', 'en', 'en'] | True |
XLNetRelativeAttention.post_attention | (self, h, attn_vec, residual=True) | Post-attention processing. | Post-attention processing. | def post_attention(self, h, attn_vec, residual=True):
"""Post-attention processing."""
# post-attention projection (back to `d_model`)
attn_out = torch.einsum("ibnd,hnd->ibh", attn_vec, self.o)
attn_out = self.dropout(attn_out)
if residual:
attn_out = attn_out + h
... | [
"def",
"post_attention",
"(",
"self",
",",
"h",
",",
"attn_vec",
",",
"residual",
"=",
"True",
")",
":",
"# post-attention projection (back to `d_model`)",
"attn_out",
"=",
"torch",
".",
"einsum",
"(",
"\"ibnd,hnd->ibh\"",
",",
"attn_vec",
",",
"self",
".",
"o",... | [
322,
4
] | [
332,
21
] | python | en | ['en', 'en', 'en'] | False |
XLNetPreTrainedModel._init_weights | (self, module) | Initialize the weights. | Initialize the weights. | def _init_weights(self, module):
"""Initialize the weights."""
if isinstance(module, nn.Linear):
# Slightly different from the TF version which uses truncated_normal for initialization
# cf https://github.com/pytorch/pytorch/pull/5617
module.weight.data.normal_(mean=0... | [
"def",
"_init_weights",
"(",
"self",
",",
"module",
")",
":",
"if",
"isinstance",
"(",
"module",
",",
"nn",
".",
"Linear",
")",
":",
"# Slightly different from the TF version which uses truncated_normal for initialization",
"# cf https://github.com/pytorch/pytorch/pull/5617",
... | [
553,
4
] | [
582,
85
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up ESPHome binary sensors based on a config entry. | Set up ESPHome binary sensors based on a config entry. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up ESPHome binary sensors based on a config entry."""
await platform_async_setup_entry(
hass,
entry,
async_add_entities,
component_key="binary_sensor",
info_type=BinarySensorInfo,
entity_type=Esp... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"await",
"platform_async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
",",
"component_key",
"=",
"\"binary_sensor\"",
",",
"info_type",
"=",
... | [
10,
0
] | [
20,
5
] | python | en | ['en', 'en', 'en'] | True |
EsphomeBinarySensor.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self) -> Optional[bool]:
"""Return true if the binary sensor is on."""
if self._static_info.is_status_binary_sensor:
# Status binary sensors indicated connected state.
# So in their case what's usually _availability_ is now state
return self._entry_data.avai... | [
"def",
"is_on",
"(",
"self",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"if",
"self",
".",
"_static_info",
".",
"is_status_binary_sensor",
":",
"# Status binary sensors indicated connected state.",
"# So in their case what's usually _availability_ is now state",
"return",
... | [
35,
4
] | [
45,
32
] | python | en | ['en', 'fy', 'en'] | True |
EsphomeBinarySensor.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 self._static_info.device_class | [
"def",
"device_class",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_static_info",
".",
"device_class"
] | [
48,
4
] | [
50,
45
] | python | en | ['en', 'en', 'en'] | True |
EsphomeBinarySensor.available | (self) | Return True if entity is available. | Return True if entity is available. | def available(self) -> bool:
"""Return True if entity is available."""
if self._static_info.is_status_binary_sensor:
return True
return super().available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"_static_info",
".",
"is_status_binary_sensor",
":",
"return",
"True",
"return",
"super",
"(",
")",
".",
"available"
] | [
53,
4
] | [
57,
32
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Somfy switch platform. | Set up the Somfy switch platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Somfy switch platform."""
def get_shutters():
"""Retrieve switches."""
domain_data = hass.data[DOMAIN]
coordinator = domain_data[COORDINATOR]
api = domain_data[API]
return [
S... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"def",
"get_shutters",
"(",
")",
":",
"\"\"\"Retrieve switches.\"\"\"",
"domain_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"coordinator",
"=",
"... | [
10,
0
] | [
25,
77
] | python | en | ['en', 'da', 'en'] | True |
SomfyCameraShutter.__init__ | (self, coordinator, device_id, api) | Initialize the Somfy device. | Initialize the Somfy device. | def __init__(self, coordinator, device_id, api):
"""Initialize the Somfy device."""
super().__init__(coordinator, device_id, api)
self._create_device() | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"device_id",
",",
"api",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
",",
"device_id",
",",
"api",
")",
"self",
".",
"_create_device",
"(",
")"
] | [
31,
4
] | [
34,
29
] | python | en | ['en', 'en', 'en'] | True |
SomfyCameraShutter._create_device | (self) | Update the device with the latest data. | Update the device with the latest data. | def _create_device(self):
"""Update the device with the latest data."""
self.shutter = CameraProtect(self.device, self.api) | [
"def",
"_create_device",
"(",
"self",
")",
":",
"self",
".",
"shutter",
"=",
"CameraProtect",
"(",
"self",
".",
"device",
",",
"self",
".",
"api",
")"
] | [
36,
4
] | [
38,
59
] | python | en | ['en', 'en', 'en'] | True |
SomfyCameraShutter.turn_on | (self, **kwargs) | Turn the entity on. | Turn the entity on. | def turn_on(self, **kwargs) -> None:
"""Turn the entity on."""
self.shutter.open_shutter() | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"self",
".",
"shutter",
".",
"open_shutter",
"(",
")"
] | [
40,
4
] | [
42,
35
] | python | en | ['en', 'en', 'en'] | True |
SomfyCameraShutter.turn_off | (self, **kwargs) | Turn the entity off. | Turn the entity off. | def turn_off(self, **kwargs):
"""Turn the entity off."""
self.shutter.close_shutter() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"shutter",
".",
"close_shutter",
"(",
")"
] | [
44,
4
] | [
46,
36
] | python | en | ['en', 'en', 'en'] | True |
SomfyCameraShutter.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.shutter.get_shutter_position() == "opened" | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"shutter",
".",
"get_shutter_position",
"(",
")",
"==",
"\"opened\""
] | [
49,
4
] | [
51,
62
] | python | en | ['en', 'cy', 'en'] | True |
BarthezTokenizerFast.build_inputs_with_special_tokens | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A BARThez sequence has the following format:
- single sequence: ``<s> X </s>``
- pair of sequences: ``<s> A </s></s> B </s>``
Args:
... |
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A BARThez sequence has the following format: | def build_inputs_with_special_tokens(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. A BARThez sequence ha... | [
"def",
"build_inputs_with_special_tokens",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"if",
"token_ids_1",
... | [
140,
4
] | [
164,
64
] | python | en | ['en', 'error', 'th'] | False |
BarthezTokenizerFast.get_special_tokens_mask | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) |
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method.
Args:
token_ids_0 (:obj:`List[int]`):
List of IDs.
token_ids_1 (:obj:`List[int]`,... |
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens using the tokenizer ``prepare_for_model`` method. | def get_special_tokens_mask(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
) -> List[int]:
"""
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
special tokens ... | [
"def",
"get_special_tokens_mask",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
",",
"already_has_special_tokens",
":",
"bool",
"=",
"False",
")",
"->",
... | [
166,
4
] | [
194,
87
] | python | en | ['en', 'error', 'th'] | False |
BarthezTokenizerFast.create_token_type_ids_from_sequences | (
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) |
Create a mask from the two sequences passed to be used in a sequence-pair classification task.
Args:
token_ids_0 (:obj:`List[int]`):
List of IDs.
token_ids_1 (:obj:`List[int]`, `optional`):
Optional second list of IDs for sequence pairs.
... |
Create a mask from the two sequences passed to be used in a sequence-pair classification task. | def create_token_type_ids_from_sequences(
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None
) -> List[int]:
"""
Create a mask from the two sequences passed to be used in a sequence-pair classification task.
Args:
token_ids_0 (:obj:`List[int]`):
... | [
"def",
"create_token_type_ids_from_sequences",
"(",
"self",
",",
"token_ids_0",
":",
"List",
"[",
"int",
"]",
",",
"token_ids_1",
":",
"Optional",
"[",
"List",
"[",
"int",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"int",
"]",
":",
"sep",
"=",
"[",... | [
196,
4
] | [
216,
75
] | python | en | ['en', 'error', 'th'] | False |
async_describe_on_off_states | (
hass: HomeAssistantType, registry: GroupIntegrationRegistry
) | Describe group on off states. | Describe group on off states. | def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.on_off_states({STATE_LOCKED}, STATE_UNLOCKED) | [
"def",
"async_describe_on_off_states",
"(",
"hass",
":",
"HomeAssistantType",
",",
"registry",
":",
"GroupIntegrationRegistry",
")",
"->",
"None",
":",
"registry",
".",
"on_off_states",
"(",
"{",
"STATE_LOCKED",
"}",
",",
"STATE_UNLOCKED",
")"
] | [
10,
0
] | [
14,
58
] | python | en | ['en', 'en', 'en'] | True |
load_vocab | (vocab_file) | Loads a vocabulary file into a dictionary. | Loads a vocabulary file into a dictionary. | def load_vocab(vocab_file):
"""Loads a vocabulary file into a dictionary."""
vocab = collections.OrderedDict()
index = 0
with open(vocab_file, "r", encoding="utf-8") as reader:
while True:
token = reader.readline()
if not token:
break
token = t... | [
"def",
"load_vocab",
"(",
"vocab_file",
")",
":",
"vocab",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"index",
"=",
"0",
"with",
"open",
"(",
"vocab_file",
",",
"\"r\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
"as",
"reader",
":",
"while",
"True",... | [
49,
0
] | [
61,
16
] | python | en | ['en', 'en', 'en'] | True |
whitespace_tokenize | (text) | Runs basic whitespace cleaning and splitting on a peice of text. | Runs basic whitespace cleaning and splitting on a peice of text. | def whitespace_tokenize(text):
"""Runs basic whitespace cleaning and splitting on a peice of text."""
text = text.strip()
if not text:
return []
tokens = text.split()
return tokens | [
"def",
"whitespace_tokenize",
"(",
"text",
")",
":",
"text",
"=",
"text",
".",
"strip",
"(",
")",
"if",
"not",
"text",
":",
"return",
"[",
"]",
"tokens",
"=",
"text",
".",
"split",
"(",
")",
"return",
"tokens"
] | [
64,
0
] | [
70,
17
] | python | en | ['en', 'en', 'en'] | True |
_is_whitespace | (char) | Checks whether `chars` is a whitespace character. | Checks whether `chars` is a whitespace character. | def _is_whitespace(char):
"""Checks whether `chars` is a whitespace character."""
# \t, \n, and \r are technically contorl characters but we treat them
# as whitespace since they are generally considered as such.
if char == " " or char == "\t" or char == "\n" or char == "\r":
return True
cat... | [
"def",
"_is_whitespace",
"(",
"char",
")",
":",
"# \\t, \\n, and \\r are technically contorl characters but we treat them",
"# as whitespace since they are generally considered as such.",
"if",
"char",
"==",
"\" \"",
"or",
"char",
"==",
"\"\\t\"",
"or",
"char",
"==",
"\"\\n\"",... | [
333,
0
] | [
342,
16
] | python | en | ['en', 'en', 'en'] | True |
_is_control | (char) | Checks whether `chars` is a control character. | Checks whether `chars` is a control character. | def _is_control(char):
"""Checks whether `chars` is a control character."""
# These are technically control characters but we count them as whitespace
# characters.
if char == "\t" or char == "\n" or char == "\r":
return False
cat = unicodedata.category(char)
if cat.startswith("C"):
... | [
"def",
"_is_control",
"(",
"char",
")",
":",
"# These are technically control characters but we count them as whitespace",
"# characters.",
"if",
"char",
"==",
"\"\\t\"",
"or",
"char",
"==",
"\"\\n\"",
"or",
"char",
"==",
"\"\\r\"",
":",
"return",
"False",
"cat",
"=",... | [
345,
0
] | [
354,
16
] | python | en | ['en', 'en', 'en'] | True |
_is_punctuation | (char) | Checks whether `chars` is a punctuation character. | Checks whether `chars` is a punctuation character. | def _is_punctuation(char):
"""Checks whether `chars` is a punctuation character."""
cp = ord(char)
# We treat all non-letter/number ASCII as punctuation.
# Characters such as "^", "$", and "`" are not in the Unicode
# Punctuation class but we treat them as punctuation anyways, for
# consistency.... | [
"def",
"_is_punctuation",
"(",
"char",
")",
":",
"cp",
"=",
"ord",
"(",
"char",
")",
"# We treat all non-letter/number ASCII as punctuation.",
"# Characters such as \"^\", \"$\", and \"`\" are not in the Unicode",
"# Punctuation class but we treat them as punctuation anyways, for",
"# ... | [
357,
0
] | [
370,
16
] | python | en | ['en', 'en', 'en'] | True |
BertTokenizer.convert_tokens_to_ids | (self, tokens) | Converts a sequence of tokens into ids using the vocab. | Converts a sequence of tokens into ids using the vocab. | def convert_tokens_to_ids(self, tokens):
"""Converts a sequence of tokens into ids using the vocab."""
ids = []
for token in tokens:
ids.append(self.vocab[token])
if len(ids) > self.max_len:
raise ValueError(
"Token indices sequence length is longe... | [
"def",
"convert_tokens_to_ids",
"(",
"self",
",",
"tokens",
")",
":",
"ids",
"=",
"[",
"]",
"for",
"token",
"in",
"tokens",
":",
"ids",
".",
"append",
"(",
"self",
".",
"vocab",
"[",
"token",
"]",
")",
"if",
"len",
"(",
"ids",
")",
">",
"self",
"... | [
97,
4
] | [
108,
18
] | python | en | ['en', 'en', 'en'] | True |
BertTokenizer.convert_ids_to_tokens | (self, ids) | Converts a sequence of ids in wordpiece tokens using the vocab. | Converts a sequence of ids in wordpiece tokens using the vocab. | def convert_ids_to_tokens(self, ids):
"""Converts a sequence of ids in wordpiece tokens using the vocab."""
tokens = []
for i in ids:
tokens.append(self.ids_to_tokens[i])
return tokens | [
"def",
"convert_ids_to_tokens",
"(",
"self",
",",
"ids",
")",
":",
"tokens",
"=",
"[",
"]",
"for",
"i",
"in",
"ids",
":",
"tokens",
".",
"append",
"(",
"self",
".",
"ids_to_tokens",
"[",
"i",
"]",
")",
"return",
"tokens"
] | [
110,
4
] | [
115,
21
] | python | en | ['en', 'en', 'en'] | True |
BertTokenizer.from_pretrained | (cls, pretrained_model_name_or_path, cache_dir=None, *inputs, **kwargs) |
Instantiate a PreTrainedBertModel from a pre-trained model file.
Download and cache the pre-trained model file if needed.
|
Instantiate a PreTrainedBertModel from a pre-trained model file.
Download and cache the pre-trained model file if needed.
| def from_pretrained(cls, pretrained_model_name_or_path, cache_dir=None, *inputs, **kwargs):
"""
Instantiate a PreTrainedBertModel from a pre-trained model file.
Download and cache the pre-trained model file if needed.
"""
if pretrained_model_name_or_path in PRETRAINED_VOCAB_ARCHI... | [
"def",
"from_pretrained",
"(",
"cls",
",",
"pretrained_model_name_or_path",
",",
"cache_dir",
"=",
"None",
",",
"*",
"inputs",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"pretrained_model_name_or_path",
"in",
"PRETRAINED_VOCAB_ARCHIVE_MAP",
":",
"vocab_file",
"=",
"... | [
118,
4
] | [
153,
24
] | python | en | ['en', 'error', 'th'] | False |
BasicTokenizer.__init__ | (self,
do_lower_case=True,
never_split=("[UNK]", "[SEP]", "[PAD]", "[CLS]", "[MASK]")) | Constructs a BasicTokenizer.
Args:
do_lower_case: Whether to lower case the input.
| Constructs a BasicTokenizer. | def __init__(self,
do_lower_case=True,
never_split=("[UNK]", "[SEP]", "[PAD]", "[CLS]", "[MASK]")):
"""Constructs a BasicTokenizer.
Args:
do_lower_case: Whether to lower case the input.
"""
self.do_lower_case = do_lower_case
self.never... | [
"def",
"__init__",
"(",
"self",
",",
"do_lower_case",
"=",
"True",
",",
"never_split",
"=",
"(",
"\"[UNK]\"",
",",
"\"[SEP]\"",
",",
"\"[PAD]\"",
",",
"\"[CLS]\"",
",",
"\"[MASK]\"",
")",
")",
":",
"self",
".",
"do_lower_case",
"=",
"do_lower_case",
"self",
... | [
159,
4
] | [
168,
38
] | python | en | ['en', 'de', 'en'] | True |
BasicTokenizer.tokenize | (self, text) | Tokenizes a piece of text. | Tokenizes a piece of text. | def tokenize(self, text):
"""Tokenizes a piece of text."""
text = self._clean_text(text)
# This was added on November 1st, 2018 for the multilingual and Chinese
# models. This is also applied to the English models now, but it doesn't
# matter since the English models were not tra... | [
"def",
"tokenize",
"(",
"self",
",",
"text",
")",
":",
"text",
"=",
"self",
".",
"_clean_text",
"(",
"text",
")",
"# This was added on November 1st, 2018 for the multilingual and Chinese",
"# models. This is also applied to the English models now, but it doesn't",
"# matter since... | [
170,
4
] | [
189,
28
] | python | en | ['en', 'el-Latn', 'en'] | True |
BasicTokenizer._run_strip_accents | (self, text) | Strips accents from a piece of text. | Strips accents from a piece of text. | def _run_strip_accents(self, text):
"""Strips accents from a piece of text."""
text = unicodedata.normalize("NFD", text)
output = []
for char in text:
cat = unicodedata.category(char)
if cat == "Mn":
continue
output.append(char)
... | [
"def",
"_run_strip_accents",
"(",
"self",
",",
"text",
")",
":",
"text",
"=",
"unicodedata",
".",
"normalize",
"(",
"\"NFD\"",
",",
"text",
")",
"output",
"=",
"[",
"]",
"for",
"char",
"in",
"text",
":",
"cat",
"=",
"unicodedata",
".",
"category",
"(",... | [
191,
4
] | [
200,
30
] | python | en | ['en', 'en', 'en'] | True |
BasicTokenizer._run_split_on_punc | (self, text) | Splits punctuation on a piece of text. | Splits punctuation on a piece of text. | def _run_split_on_punc(self, text):
"""Splits punctuation on a piece of text."""
if text in self.never_split:
return [text]
chars = list(text)
i = 0
start_new_word = True
output = []
while i < len(chars):
char = chars[i]
if _is_... | [
"def",
"_run_split_on_punc",
"(",
"self",
",",
"text",
")",
":",
"if",
"text",
"in",
"self",
".",
"never_split",
":",
"return",
"[",
"text",
"]",
"chars",
"=",
"list",
"(",
"text",
")",
"i",
"=",
"0",
"start_new_word",
"=",
"True",
"output",
"=",
"["... | [
202,
4
] | [
222,
43
] | python | en | ['en', 'en', 'en'] | True |
BasicTokenizer._tokenize_chinese_chars | (self, text) | Adds whitespace around any CJK character. | Adds whitespace around any CJK character. | def _tokenize_chinese_chars(self, text):
"""Adds whitespace around any CJK character."""
output = []
for char in text:
cp = ord(char)
if self._is_chinese_char(cp):
output.append(" ")
output.append(char)
output.append(" ")
... | [
"def",
"_tokenize_chinese_chars",
"(",
"self",
",",
"text",
")",
":",
"output",
"=",
"[",
"]",
"for",
"char",
"in",
"text",
":",
"cp",
"=",
"ord",
"(",
"char",
")",
"if",
"self",
".",
"_is_chinese_char",
"(",
"cp",
")",
":",
"output",
".",
"append",
... | [
224,
4
] | [
235,
30
] | python | en | ['en', 'en', 'en'] | True |
BasicTokenizer._is_chinese_char | (self, cp) | Checks whether CP is the codepoint of a CJK character. | Checks whether CP is the codepoint of a CJK character. | def _is_chinese_char(self, cp):
"""Checks whether CP is the codepoint of a CJK character."""
# This defines a "chinese character" as anything in the CJK Unicode block:
# https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block)
#
# Note that the CJK Unicode block is ... | [
"def",
"_is_chinese_char",
"(",
"self",
",",
"cp",
")",
":",
"# This defines a \"chinese character\" as anything in the CJK Unicode block:",
"# https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block)",
"#",
"# Note that the CJK Unicode block is NOT all Japanese and Korean charac... | [
237,
4
] | [
257,
20
] | python | en | ['en', 'en', 'en'] | True |
BasicTokenizer._clean_text | (self, text) | Performs invalid character removal and whitespace cleanup on text. | Performs invalid character removal and whitespace cleanup on text. | def _clean_text(self, text):
"""Performs invalid character removal and whitespace cleanup on text."""
output = []
for char in text:
cp = ord(char)
if cp == 0 or cp == 0xfffd or _is_control(char):
continue
if _is_whitespace(char):
... | [
"def",
"_clean_text",
"(",
"self",
",",
"text",
")",
":",
"output",
"=",
"[",
"]",
"for",
"char",
"in",
"text",
":",
"cp",
"=",
"ord",
"(",
"char",
")",
"if",
"cp",
"==",
"0",
"or",
"cp",
"==",
"0xfffd",
"or",
"_is_control",
"(",
"char",
")",
"... | [
259,
4
] | [
270,
30
] | python | en | ['en', 'en', 'en'] | True |
WordpieceTokenizer.tokenize | (self, text) | Tokenizes a piece of text into its word pieces.
This uses a greedy longest-match-first algorithm to perform tokenization
using the given vocabulary.
For example:
input = "unaffable"
output = ["un", "##aff", "##able"]
Args:
text: A single token or whitespa... | Tokenizes a piece of text into its word pieces. | def tokenize(self, text):
"""Tokenizes a piece of text into its word pieces.
This uses a greedy longest-match-first algorithm to perform tokenization
using the given vocabulary.
For example:
input = "unaffable"
output = ["un", "##aff", "##able"]
Args:
... | [
"def",
"tokenize",
"(",
"self",
",",
"text",
")",
":",
"output_tokens",
"=",
"[",
"]",
"for",
"token",
"in",
"whitespace_tokenize",
"(",
"text",
")",
":",
"chars",
"=",
"list",
"(",
"token",
")",
"if",
"len",
"(",
"chars",
")",
">",
"self",
".",
"m... | [
281,
4
] | [
330,
28
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the UpCloud server binary sensor. | Set up the UpCloud server binary sensor. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the UpCloud server binary sensor."""
coordinator = hass.data[DATA_UPCLOUD].coordinators[config_entry.data[CONF_USERNAME]]
entities = [UpCloudBinarySensor(coordinator, uuid) for uuid in coordinator.data]
async_add_entities(ent... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DATA_UPCLOUD",
"]",
".",
"coordinators",
"[",
"config_entry",
".",
"data",
"[",
"CONF_USERNAME",
"]",
"]"... | [
15,
0
] | [
19,
38
] | python | en | ['en', 'su', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the sensor platform. | Set up the sensor platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the sensor platform."""
meter_number = config[CONF_METER_NUMBER]
try:
meter = Meter(meter_number)
except MeterError:
_LOGGER.error("Unable to create Oru meter")
return
add_entities([CurrentEner... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"meter_number",
"=",
"config",
"[",
"CONF_METER_NUMBER",
"]",
"try",
":",
"meter",
"=",
"Meter",
"(",
"meter_number",
")",
"except",
"Mete... | [
24,
0
] | [
38,
56
] | python | en | ['en', 'da', 'en'] | True |
CurrentEnergyUsageSensor.__init__ | (self, meter) | Initialize the sensor. | Initialize the sensor. | def __init__(self, meter):
"""Initialize the sensor."""
self._state = None
self._available = None
self.meter = meter | [
"def",
"__init__",
"(",
"self",
",",
"meter",
")",
":",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_available",
"=",
"None",
"self",
".",
"meter",
"=",
"meter"
] | [
44,
4
] | [
48,
26
] | python | en | ['en', 'en', 'en'] | True |
CurrentEnergyUsageSensor.unique_id | (self) | Return a unique, Home Assistant friendly identifier for this entity. | Return a unique, Home Assistant friendly identifier for this entity. | def unique_id(self):
"""Return a unique, Home Assistant friendly identifier for this entity."""
return self.meter.meter_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"meter",
".",
"meter_id"
] | [
51,
4
] | [
53,
34
] | python | en | ['en', 'en', 'en'] | True |
CurrentEnergyUsageSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return SENSOR_NAME | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"SENSOR_NAME"
] | [
56,
4
] | [
58,
26
] | python | en | ['en', 'mi', 'en'] | True |
CurrentEnergyUsageSensor.icon | (self) | Return the icon of the sensor. | Return the icon of the sensor. | def icon(self):
"""Return the icon of the sensor."""
return SENSOR_ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"SENSOR_ICON"
] | [
61,
4
] | [
63,
26
] | python | en | ['en', 'en', 'en'] | True |
CurrentEnergyUsageSensor.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"
] | [
66,
4
] | [
68,
26
] | python | en | ['en', 'en', 'en'] | True |
CurrentEnergyUsageSensor.unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def unit_of_measurement(self):
"""Return the unit of measurement."""
return ENERGY_KILO_WATT_HOUR | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"ENERGY_KILO_WATT_HOUR"
] | [
71,
4
] | [
73,
36
] | python | en | ['en', 'la', 'en'] | True |
CurrentEnergyUsageSensor.update | (self) | Fetch new state data for the sensor. | Fetch new state data for the sensor. | def update(self):
"""Fetch new state data for the sensor."""
try:
last_read = self.meter.last_read()
self._state = last_read
self._available = True
_LOGGER.debug(
"%s = %s %s", self.name, self._state, self.unit_of_measurement
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"last_read",
"=",
"self",
".",
"meter",
".",
"last_read",
"(",
")",
"self",
".",
"_state",
"=",
"last_read",
"self",
".",
"_available",
"=",
"True",
"_LOGGER",
".",
"debug",
"(",
"\"%s = %s %s\"",
","... | [
75,
4
] | [
89,
64
] | python | en | ['en', 'en', 'en'] | True |
relative_url | (url) | Convert an absolute url to a relative one. | Convert an absolute url to a relative one. | def relative_url(url):
"""Convert an absolute url to a relative one."""
return str(yarl.URL(url).relative()) | [
"def",
"relative_url",
"(",
"url",
")",
":",
"return",
"str",
"(",
"yarl",
".",
"URL",
"(",
"url",
")",
".",
"relative",
"(",
")",
")"
] | [
22,
0
] | [
24,
40
] | python | en | ['en', 'en', 'en'] | True |
demo_provider | () | Demo TTS provider. | Demo TTS provider. | def demo_provider():
"""Demo TTS provider."""
return DemoProvider("en") | [
"def",
"demo_provider",
"(",
")",
":",
"return",
"DemoProvider",
"(",
"\"en\"",
")"
] | [
28,
0
] | [
30,
29
] | python | en | ['es', 'it', 'en'] | False |
mock_get_cache_files | () | Mock the list TTS cache function. | Mock the list TTS cache function. | def mock_get_cache_files():
"""Mock the list TTS cache function."""
with patch(
"homeassistant.components.tts._get_cache_files", return_value={}
) as mock_cache_files:
yield mock_cache_files | [
"def",
"mock_get_cache_files",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.tts._get_cache_files\"",
",",
"return_value",
"=",
"{",
"}",
")",
"as",
"mock_cache_files",
":",
"yield",
"mock_cache_files"
] | [
34,
0
] | [
39,
30
] | python | en | ['en', 'en', 'en'] | True |
mock_init_cache_dir | () | Mock the TTS cache dir in memory. | Mock the TTS cache dir in memory. | def mock_init_cache_dir():
"""Mock the TTS cache dir in memory."""
with patch(
"homeassistant.components.tts._init_tts_cache_dir",
side_effect=lambda hass, cache_dir: hass.config.path(cache_dir),
) as mock_cache_dir:
yield mock_cache_dir | [
"def",
"mock_init_cache_dir",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.tts._init_tts_cache_dir\"",
",",
"side_effect",
"=",
"lambda",
"hass",
",",
"cache_dir",
":",
"hass",
".",
"config",
".",
"path",
"(",
"cache_dir",
")",
",",
")",
"as"... | [
43,
0
] | [
49,
28
] | python | en | ['en', 'nl', 'en'] | True |
empty_cache_dir | (tmp_path, mock_init_cache_dir, mock_get_cache_files, request) | Mock the TTS cache dir with empty dir. | Mock the TTS cache dir with empty dir. | def empty_cache_dir(tmp_path, mock_init_cache_dir, mock_get_cache_files, request):
"""Mock the TTS cache dir with empty dir."""
mock_init_cache_dir.side_effect = None
mock_init_cache_dir.return_value = str(tmp_path)
# Restore original get cache files behavior, we're working with a real dir.
mock_ge... | [
"def",
"empty_cache_dir",
"(",
"tmp_path",
",",
"mock_init_cache_dir",
",",
"mock_get_cache_files",
",",
"request",
")",
":",
"mock_init_cache_dir",
".",
"side_effect",
"=",
"None",
"mock_init_cache_dir",
".",
"return_value",
"=",
"str",
"(",
"tmp_path",
")",
"# Res... | [
53,
0
] | [
72,
16
] | python | en | ['en', 'ga', 'en'] | True |
mutagen_mock | () | Mock writing tags. | Mock writing tags. | def mutagen_mock():
"""Mock writing tags."""
with patch(
"homeassistant.components.tts.SpeechManager.write_tags",
side_effect=lambda *args: args[1],
):
yield | [
"def",
"mutagen_mock",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.tts.SpeechManager.write_tags\"",
",",
"side_effect",
"=",
"lambda",
"*",
"args",
":",
"args",
"[",
"1",
"]",
",",
")",
":",
"yield"
] | [
76,
0
] | [
82,
13
] | python | en | ['en', 'ceb', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.