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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ConfigFlow.async_step_import | (self, user_input) | Handle import. | Handle import. | async def async_step_import(self, user_input):
"""Handle import."""
if user_input:
info, errors = await self._async_validate_or_error(user_input)
if not errors:
await self.async_set_unique_id(
info["mac_addr"], raise_on_progress=False
... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
")",
":",
"if",
"user_input",
":",
"info",
",",
"errors",
"=",
"await",
"self",
".",
"_async_validate_or_error",
"(",
"user_input",
")",
"if",
"not",
"errors",
":",
"await",
"self",
".",
... | [
116,
4
] | [
126,
53
] | python | en | ['en', 'ja', 'en'] | False |
ConfigFlow._async_validate_or_error | (self, user_input) | Validate doorbird or error. | Validate doorbird or error. | async def _async_validate_or_error(self, user_input):
"""Validate doorbird or error."""
errors = {}
info = {}
try:
info = await validate_input(self.hass, user_input)
except CannotConnect:
errors["base"] = "cannot_connect"
except InvalidAuth:
... | [
"async",
"def",
"_async_validate_or_error",
"(",
"self",
",",
"user_input",
")",
":",
"errors",
"=",
"{",
"}",
"info",
"=",
"{",
"}",
"try",
":",
"info",
"=",
"await",
"validate_input",
"(",
"self",
".",
"hass",
",",
"user_input",
")",
"except",
"CannotC... | [
128,
4
] | [
141,
27
] | python | nl | ['nl', 'nl', 'en'] | True |
ConfigFlow.async_get_options_flow | (config_entry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry):
"""Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"OptionsFlowHandler",
"(",
"config_entry",
")"
] | [
145,
4
] | [
147,
47
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.__init__ | (self, config_entry: config_entries.ConfigEntry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry: config_entries.ConfigEntry):
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
":",
"config_entries",
".",
"ConfigEntry",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
153,
4
] | [
155,
40
] | python | en | ['en', 'en', 'en'] | True |
OptionsFlowHandler.async_step_init | (self, user_input=None) | Handle options flow. | Handle options flow. | async def async_step_init(self, user_input=None):
"""Handle options flow."""
if user_input is not None:
events = [event.strip() for event in user_input[CONF_EVENTS].split(",")]
return self.async_create_entry(title="", data={CONF_EVENTS: events})
current_events = self.co... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"events",
"=",
"[",
"event",
".",
"strip",
"(",
")",
"for",
"event",
"in",
"user_input",
"[",
"CONF_EVENTS",
"]",
".... | [
157,
4
] | [
171,
79
] | python | en | ['en', 'nl', 'en'] | True |
setup | (hass, config) | Set up the Dovado component. | Set up the Dovado component. | def setup(hass, config):
"""Set up the Dovado component."""
hass.data[DOMAIN] = DovadoData(
dovado.Dovado(
config[DOMAIN][CONF_USERNAME],
config[DOMAIN][CONF_PASSWORD],
config[DOMAIN].get(CONF_HOST),
config[DOMAIN].get(CONF_PORT),
)
)
retu... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"DovadoData",
"(",
"dovado",
".",
"Dovado",
"(",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_USERNAME",
"]",
",",
"config",
"[",
"DOMAIN",
"]",
"[",
"C... | [
38,
0
] | [
49,
15
] | python | en | ['en', 'en', 'en'] | True |
DovadoData.__init__ | (self, client) | Set up a new Dovado connection. | Set up a new Dovado connection. | def __init__(self, client):
"""Set up a new Dovado connection."""
self._client = client
self.state = {} | [
"def",
"__init__",
"(",
"self",
",",
"client",
")",
":",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"state",
"=",
"{",
"}"
] | [
55,
4
] | [
58,
23
] | python | en | ['pt', 'en', 'en'] | True |
DovadoData.name | (self) | Name of the router. | Name of the router. | def name(self):
"""Name of the router."""
return self.state.get("product name", DEVICE_DEFAULT_NAME) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"state",
".",
"get",
"(",
"\"product name\"",
",",
"DEVICE_DEFAULT_NAME",
")"
] | [
61,
4
] | [
63,
66
] | python | en | ['en', 'en', 'en'] | True |
DovadoData.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
try:
self.state = self._client.state or {}
if not self.state:
return False
self.state.update(connected=self.state.get("modem status") == "CONNECTED")
_LOGGER.debug("Received: %s", self.state)
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"state",
"=",
"self",
".",
"_client",
".",
"state",
"or",
"{",
"}",
"if",
"not",
"self",
".",
"state",
":",
"return",
"False",
"self",
".",
"state",
".",
"update",
"(",
"connected",
... | [
66,
4
] | [
76,
70
] | python | en | ['fr', 'en', 'en'] | True |
DovadoData.client | (self) | Dovado client instance. | Dovado client instance. | def client(self):
"""Dovado client instance."""
return self._client | [
"def",
"client",
"(",
"self",
")",
":",
"return",
"self",
".",
"_client"
] | [
79,
4
] | [
81,
27
] | python | en | ['pt', 'fr', 'en'] | False |
graph_dumps | (graph) |
Dump the graph.
|
Dump the graph.
| def graph_dumps(graph):
'''
Dump the graph.
'''
return json.dumps(graph, default=lambda obj: obj.__dict__) | [
"def",
"graph_dumps",
"(",
"graph",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"graph",
",",
"default",
"=",
"lambda",
"obj",
":",
"obj",
".",
"__dict__",
")"
] | [
124,
0
] | [
128,
62
] | python | en | ['en', 'error', 'th'] | False |
graph_loads | (graph_json) |
Load graph
|
Load graph
| def graph_loads(graph_json):
'''
Load graph
'''
layers = []
for layer in graph_json['layers']:
layer_info = Layer(layer['graph_type'], layer['input'], layer['output'], layer['size'], layer['hash_id'])
layer_info.is_delete = layer['is_delete']
_logger.debug('append layer {}'.f... | [
"def",
"graph_loads",
"(",
"graph_json",
")",
":",
"layers",
"=",
"[",
"]",
"for",
"layer",
"in",
"graph_json",
"[",
"'layers'",
"]",
":",
"layer_info",
"=",
"Layer",
"(",
"layer",
"[",
"'graph_type'",
"]",
",",
"layer",
"[",
"'input'",
"]",
",",
"laye... | [
130,
0
] | [
143,
16
] | python | en | ['en', 'error', 'th'] | False |
Layer.update_hash | (self, layers: Iterable) |
Calculation of `hash_id` of Layer. Which is determined by the properties of itself, and the `hash_id`s of input layers
|
Calculation of `hash_id` of Layer. Which is determined by the properties of itself, and the `hash_id`s of input layers
| def update_hash(self, layers: Iterable):
"""
Calculation of `hash_id` of Layer. Which is determined by the properties of itself, and the `hash_id`s of input layers
"""
if self.graph_type == LayerType.input.value:
return
hasher = hashlib.md5()
hasher.update(Lay... | [
"def",
"update_hash",
"(",
"self",
",",
"layers",
":",
"Iterable",
")",
":",
"if",
"self",
".",
"graph_type",
"==",
"LayerType",
".",
"input",
".",
"value",
":",
"return",
"hasher",
"=",
"hashlib",
".",
"md5",
"(",
")",
"hasher",
".",
"update",
"(",
... | [
82,
4
] | [
95,
41
] | python | en | ['en', 'error', 'th'] | False |
Layer.set_size | (self, graph_id, size) |
Set size.
|
Set size.
| def set_size(self, graph_id, size):
'''
Set size.
'''
if self.graph_type == LayerType.attention.value:
if self.input[0] == graph_id:
self.size = size
if self.graph_type == LayerType.rnn.value:
self.size = size
if self.graph_type == ... | [
"def",
"set_size",
"(",
"self",
",",
"graph_id",
",",
"size",
")",
":",
"if",
"self",
".",
"graph_type",
"==",
"LayerType",
".",
"attention",
".",
"value",
":",
"if",
"self",
".",
"input",
"[",
"0",
"]",
"==",
"graph_id",
":",
"self",
".",
"size",
... | [
97,
4
] | [
111,
19
] | python | en | ['en', 'error', 'th'] | False |
Layer.clear_size | (self) |
Clear size
|
Clear size
| def clear_size(self):
'''
Clear size
'''
if self.graph_type == LayerType.attention.value or \
LayerType.rnn.value or LayerType.self_attention.value:
self.size = None | [
"def",
"clear_size",
"(",
"self",
")",
":",
"if",
"self",
".",
"graph_type",
"==",
"LayerType",
".",
"attention",
".",
"value",
"or",
"LayerType",
".",
"rnn",
".",
"value",
"or",
"LayerType",
".",
"self_attention",
".",
"value",
":",
"self",
".",
"size",... | [
113,
4
] | [
119,
28
] | python | en | ['en', 'error', 'th'] | False |
Graph.is_topology | (self, layers=None) |
valid the topology
|
valid the topology
| def is_topology(self, layers=None):
'''
valid the topology
'''
if layers is None:
layers = self.layers
layers_nodle = []
result = []
for i, layer in enumerate(layers):
if layer.is_delete is False:
layers_nodle.append(i)
... | [
"def",
"is_topology",
"(",
"self",
",",
"layers",
"=",
"None",
")",
":",
"if",
"layers",
"is",
"None",
":",
"layers",
"=",
"self",
".",
"layers",
"layers_nodle",
"=",
"[",
"]",
"result",
"=",
"[",
"]",
"for",
"i",
",",
"layer",
"in",
"enumerate",
"... | [
164,
4
] | [
199,
21
] | python | en | ['en', 'error', 'th'] | False |
Graph.layer_num | (self, layers=None) |
Reutn number of layer.
|
Reutn number of layer.
| def layer_num(self, layers=None):
'''
Reutn number of layer.
'''
if layers is None:
layers = self.layers
layer_num = 0
for layer in layers:
if layer.is_delete is False and layer.graph_type != LayerType.input.value\
and layer.graph_t... | [
"def",
"layer_num",
"(",
"self",
",",
"layers",
"=",
"None",
")",
":",
"if",
"layers",
"is",
"None",
":",
"layers",
"=",
"self",
".",
"layers",
"layer_num",
"=",
"0",
"for",
"layer",
"in",
"layers",
":",
"if",
"layer",
".",
"is_delete",
"is",
"False"... | [
201,
4
] | [
212,
24
] | python | en | ['en', 'error', 'th'] | False |
Graph.is_legal | (self, layers=None) |
Judge whether is legal for layers
|
Judge whether is legal for layers
| def is_legal(self, layers=None):
'''
Judge whether is legal for layers
'''
if layers is None:
layers = self.layers
for layer in layers:
if layer.is_delete is False:
if len(layer.input) != layer.input_size:
return False
... | [
"def",
"is_legal",
"(",
"self",
",",
"layers",
"=",
"None",
")",
":",
"if",
"layers",
"is",
"None",
":",
"layers",
"=",
"self",
".",
"layers",
"for",
"layer",
"in",
"layers",
":",
"if",
"layer",
".",
"is_delete",
"is",
"False",
":",
"if",
"len",
"(... | [
214,
4
] | [
236,
19
] | python | en | ['en', 'error', 'th'] | False |
Graph.update_hash | (self) |
update hash id of each layer, in topological order/recursively
hash id will be used in weight sharing
|
update hash id of each layer, in topological order/recursively
hash id will be used in weight sharing
| def update_hash(self):
"""
update hash id of each layer, in topological order/recursively
hash id will be used in weight sharing
"""
_logger.debug('update hash')
layer_in_cnt = [len(layer.input) for layer in self.layers]
topo_queue = deque([i for i, layer in enume... | [
"def",
"update_hash",
"(",
"self",
")",
":",
"_logger",
".",
"debug",
"(",
"'update hash'",
")",
"layer_in_cnt",
"=",
"[",
"len",
"(",
"layer",
".",
"input",
")",
"for",
"layer",
"in",
"self",
".",
"layers",
"]",
"topo_queue",
"=",
"deque",
"(",
"[",
... | [
238,
4
] | [
252,
50
] | python | en | ['en', 'error', 'th'] | False |
Graph.mutation | (self, only_add=False) |
Mutation for a graph
|
Mutation for a graph
| def mutation(self, only_add=False):
'''
Mutation for a graph
'''
types = []
if self.layer_num() < self.max_layer_num:
types.append(0)
types.append(1)
if self.layer_num() > self.min_layer_num and only_add is False:
types.append(2)
... | [
"def",
"mutation",
"(",
"self",
",",
"only_add",
"=",
"False",
")",
":",
"types",
"=",
"[",
"]",
"if",
"self",
".",
"layer_num",
"(",
")",
"<",
"self",
".",
"max_layer_num",
":",
"types",
".",
"append",
"(",
"0",
")",
"types",
".",
"append",
"(",
... | [
254,
4
] | [
328,
26
] | python | en | ['en', 'error', 'th'] | False |
apply_compression_results | (model, masks_file, map_location=None) |
Apply the masks from ```masks_file``` to the model
Note: this API is for inference, because it simply multiplies weights with
corresponding masks when this API is called.
Parameters
----------
model : torch.nn.Module
The model to be compressed
masks_file : str
The path of t... |
Apply the masks from ```masks_file``` to the model
Note: this API is for inference, because it simply multiplies weights with
corresponding masks when this API is called. | def apply_compression_results(model, masks_file, map_location=None):
"""
Apply the masks from ```masks_file``` to the model
Note: this API is for inference, because it simply multiplies weights with
corresponding masks when this API is called.
Parameters
----------
model : torch.nn.Module
... | [
"def",
"apply_compression_results",
"(",
"model",
",",
"masks_file",
",",
"map_location",
"=",
"None",
")",
":",
"masks",
"=",
"torch",
".",
"load",
"(",
"masks_file",
",",
"map_location",
")",
"for",
"name",
",",
"module",
"in",
"model",
".",
"named_modules... | [
8,
0
] | [
28,
77
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the air_quality norway sensor. | Set up the air_quality norway sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the air_quality norway sensor."""
forecast = config.get(CONF_FORECAST)
latitude = config.get(CONF_LATITUDE, hass.config.latitude)
longitude = config.get(CONF_LONGITUDE, hass.config.longitude)
name = conf... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"forecast",
"=",
"config",
".",
"get",
"(",
"CONF_FORECAST",
")",
"latitude",
"=",
"config",
".",
"get",
"(",
"CONF_L... | [
38,
0
] | [
53,
5
] | python | en | ['en', 'en', 'en'] | True |
round_state | (func) | Round state. | Round state. | def round_state(func):
"""Round state."""
def _decorator(self):
res = func(self)
if isinstance(res, float):
return round(res, 2)
return res
return _decorator | [
"def",
"round_state",
"(",
"func",
")",
":",
"def",
"_decorator",
"(",
"self",
")",
":",
"res",
"=",
"func",
"(",
"self",
")",
"if",
"isinstance",
"(",
"res",
",",
"float",
")",
":",
"return",
"round",
"(",
"res",
",",
"2",
")",
"return",
"res",
... | [
56,
0
] | [
65,
21
] | python | en | ['en', 'sn', 'en'] | False |
AirSensor.__init__ | (self, name, coordinates, forecast, session) | Initialize the sensor. | Initialize the sensor. | def __init__(self, name, coordinates, forecast, session):
"""Initialize the sensor."""
self._name = name
self._api = metno.AirQualityData(coordinates, forecast, session) | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"coordinates",
",",
"forecast",
",",
"session",
")",
":",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_api",
"=",
"metno",
".",
"AirQualityData",
"(",
"coordinates",
",",
"forecast",
",",
"session",
... | [
71,
4
] | [
74,
72
] | python | en | ['en', 'en', 'en'] | True |
AirSensor.attribution | (self) | Return the attribution. | Return the attribution. | def attribution(self) -> str:
"""Return the attribution."""
return ATTRIBUTION | [
"def",
"attribution",
"(",
"self",
")",
"->",
"str",
":",
"return",
"ATTRIBUTION"
] | [
77,
4
] | [
79,
26
] | python | en | ['en', 'ja', 'en'] | True |
AirSensor.device_state_attributes | (self) | Return other details about the sensor state. | Return other details about the sensor state. | def device_state_attributes(self) -> dict:
"""Return other details about the sensor state."""
return {
"level": self._api.data.get("level"),
"location": self._api.data.get("location"),
} | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"\"level\"",
":",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"\"level\"",
")",
",",
"\"location\"",
":",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
... | [
82,
4
] | [
87,
9
] | python | en | ['en', 'en', 'en'] | True |
AirSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
90,
4
] | [
92,
25
] | python | en | ['en', 'mi', 'en'] | True |
AirSensor.air_quality_index | (self) | Return the Air Quality Index (AQI). | Return the Air Quality Index (AQI). | def air_quality_index(self):
"""Return the Air Quality Index (AQI)."""
return self._api.data.get("aqi") | [
"def",
"air_quality_index",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"\"aqi\"",
")"
] | [
96,
4
] | [
98,
40
] | python | en | ['en', 'cy', 'en'] | True |
AirSensor.nitrogen_dioxide | (self) | Return the NO2 (nitrogen dioxide) level. | Return the NO2 (nitrogen dioxide) level. | def nitrogen_dioxide(self):
"""Return the NO2 (nitrogen dioxide) level."""
return self._api.data.get("no2_concentration") | [
"def",
"nitrogen_dioxide",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"\"no2_concentration\"",
")"
] | [
102,
4
] | [
104,
54
] | python | en | ['en', 'da', 'en'] | True |
AirSensor.ozone | (self) | Return the O3 (ozone) level. | Return the O3 (ozone) level. | def ozone(self):
"""Return the O3 (ozone) level."""
return self._api.data.get("o3_concentration") | [
"def",
"ozone",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"\"o3_concentration\"",
")"
] | [
108,
4
] | [
110,
53
] | python | en | ['en', 'ig', 'en'] | True |
AirSensor.particulate_matter_2_5 | (self) | Return the particulate matter 2.5 level. | Return the particulate matter 2.5 level. | def particulate_matter_2_5(self):
"""Return the particulate matter 2.5 level."""
return self._api.data.get("pm25_concentration") | [
"def",
"particulate_matter_2_5",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"\"pm25_concentration\"",
")"
] | [
114,
4
] | [
116,
55
] | python | en | ['en', 'en', 'en'] | True |
AirSensor.particulate_matter_10 | (self) | Return the particulate matter 10 level. | Return the particulate matter 10 level. | def particulate_matter_10(self):
"""Return the particulate matter 10 level."""
return self._api.data.get("pm10_concentration") | [
"def",
"particulate_matter_10",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"\"pm10_concentration\"",
")"
] | [
120,
4
] | [
122,
55
] | python | en | ['en', 'en', 'en'] | True |
AirSensor.unit_of_measurement | (self) | Return the unit of measurement of this entity, if any. | Return the unit of measurement of this entity, if any. | def unit_of_measurement(self):
"""Return the unit of measurement of this entity, if any."""
return self._api.units.get("pm25_concentration") | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"units",
".",
"get",
"(",
"\"pm25_concentration\"",
")"
] | [
125,
4
] | [
127,
56
] | python | en | ['en', 'en', 'en'] | True |
AirSensor.async_update | (self) | Update the sensor. | Update the sensor. | async def async_update(self) -> None:
"""Update the sensor."""
await self._api.update() | [
"async",
"def",
"async_update",
"(",
"self",
")",
"->",
"None",
":",
"await",
"self",
".",
"_api",
".",
"update",
"(",
")"
] | [
129,
4
] | [
131,
32
] | python | en | ['en', 'nl', 'en'] | True |
test_setup_entry | (hass) | Test setup entry fails if deCONZ is not available. | Test setup entry fails if deCONZ is not available. | async def test_setup_entry(hass):
"""Test setup entry fails if deCONZ is not available."""
config_entry = await init_integration(hass)
assert config_entry.state == "loaded"
assert hass.data[srp_energy.SRP_ENERGY_DOMAIN] | [
"async",
"def",
"test_setup_entry",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"init_integration",
"(",
"hass",
")",
"assert",
"config_entry",
".",
"state",
"==",
"\"loaded\"",
"assert",
"hass",
".",
"data",
"[",
"srp_energy",
".",
"SRP_ENERGY_DOMAIN",... | [
6,
0
] | [
10,
50
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass) | Test being able to unload an entry. | Test being able to unload an entry. | async def test_unload_entry(hass):
"""Test being able to unload an entry."""
config_entry = await init_integration(hass)
assert hass.data[srp_energy.SRP_ENERGY_DOMAIN]
assert await srp_energy.async_unload_entry(hass, config_entry)
assert not hass.data[srp_energy.SRP_ENERGY_DOMAIN] | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
")",
":",
"config_entry",
"=",
"await",
"init_integration",
"(",
"hass",
")",
"assert",
"hass",
".",
"data",
"[",
"srp_energy",
".",
"SRP_ENERGY_DOMAIN",
"]",
"assert",
"await",
"srp_energy",
".",
"async_unload_e... | [
13,
0
] | [
19,
54
] | python | en | ['en', 'en', 'en'] | True |
test_async_setup_entry_with_exception | (hass) | Test exception when SrpClient can't load. | Test exception when SrpClient can't load. | async def test_async_setup_entry_with_exception(hass):
"""Test exception when SrpClient can't load."""
await init_integration(hass, side_effect=Exception())
assert srp_energy.SRP_ENERGY_DOMAIN not in hass.data | [
"async",
"def",
"test_async_setup_entry_with_exception",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
",",
"side_effect",
"=",
"Exception",
"(",
")",
")",
"assert",
"srp_energy",
".",
"SRP_ENERGY_DOMAIN",
"not",
"in",
"hass",
".",
"data"
] | [
22,
0
] | [
25,
56
] | python | en | ['en', 'en', 'en'] | True |
calls | (hass) | Track calls to a mock service. | Track calls to a mock service. | def calls(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation") | [
"def",
"calls",
"(",
"hass",
")",
":",
"return",
"async_mock_service",
"(",
"hass",
",",
"\"test\"",
",",
"\"automation\"",
")"
] | [
34,
0
] | [
36,
57
] | python | en | ['en', 'en', 'en'] | True |
test_missing_optional_config | (hass, calls) | Test: missing optional template is ok. | Test: missing optional template is ok. | async def test_missing_optional_config(hass, calls):
"""Test: missing optional template is ok."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "template",
... | [
"async",
"def",
"test_missing_optional_config",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",
"\"fan\"... | [
40,
0
] | [
64,
45
] | python | en | ['en', 'en', 'en'] | True |
test_missing_value_template_config | (hass, calls) | Test: missing 'value_template' will fail. | Test: missing 'value_template' will fail. | async def test_missing_value_template_config(hass, calls):
"""Test: missing 'value_template' will fail."""
with assert_setup_component(0, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "templat... | [
"async",
"def",
"test_missing_value_template_config",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",
"\... | [
67,
0
] | [
90,
40
] | python | en | ['en', 'en', 'en'] | True |
test_missing_turn_on_config | (hass, calls) | Test: missing 'turn_on' will fail. | Test: missing 'turn_on' will fail. | async def test_missing_turn_on_config(hass, calls):
"""Test: missing 'turn_on' will fail."""
with assert_setup_component(0, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "template",
... | [
"async",
"def",
"test_missing_turn_on_config",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",
"\"fan\""... | [
93,
0
] | [
116,
40
] | python | en | ['en', 'en', 'en'] | True |
test_missing_turn_off_config | (hass, calls) | Test: missing 'turn_off' will fail. | Test: missing 'turn_off' will fail. | async def test_missing_turn_off_config(hass, calls):
"""Test: missing 'turn_off' will fail."""
with assert_setup_component(0, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "template",
... | [
"async",
"def",
"test_missing_turn_off_config",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",
"\"fan\"... | [
119,
0
] | [
142,
40
] | python | en | ['en', 'mt', 'en'] | True |
test_invalid_config | (hass, calls) | Test: missing 'turn_off' will fail. | Test: missing 'turn_off' will fail. | async def test_invalid_config(hass, calls):
"""Test: missing 'turn_off' will fail."""
with assert_setup_component(0, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"platform": "template",
"fans": {
... | [
"async",
"def",
"test_invalid_config",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"0",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",
"\"platform\"",
... | [
145,
0
] | [
166,
40
] | python | en | ['en', 'mt', 'en'] | True |
test_templates_with_entities | (hass, calls) | Test tempalates with values from other entities. | Test tempalates with values from other entities. | async def test_templates_with_entities(hass, calls):
"""Test tempalates with values from other entities."""
value_template = """
{% if is_state('input_boolean.state', 'True') %}
{{ 'on' }}
{% else %}
{{ 'off' }}
{% endif %}
"""
with assert_setup_component... | [
"async",
"def",
"test_templates_with_entities",
"(",
"hass",
",",
"calls",
")",
":",
"value_template",
"=",
"\"\"\"\n {% if is_state('input_boolean.state', 'True') %}\n {{ 'on' }}\n {% else %}\n {{ 'off' }}\n {% endif %}\n \"\"\"",
"with",
"ass... | [
173,
0
] | [
216,
66
] | python | en | ['en', 'en', 'en'] | True |
test_template_with_unavailable_entities | (hass, calls) | Test unavailability with value_template. | Test unavailability with value_template. | async def test_template_with_unavailable_entities(hass, calls):
"""Test unavailability with value_template."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "te... | [
"async",
"def",
"test_template_with_unavailable_entities",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",... | [
219,
0
] | [
243,
56
] | python | en | ['en', 'en', 'en'] | True |
test_template_with_unavailable_parameters | (hass, calls) | Test unavailability of speed, direction and oscillating parameters. | Test unavailability of speed, direction and oscillating parameters. | async def test_template_with_unavailable_parameters(hass, calls):
"""Test unavailability of speed, direction and oscillating parameters."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
... | [
"async",
"def",
"test_template_with_unavailable_parameters",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{... | [
246,
0
] | [
274,
45
] | python | en | ['en', 'en', 'en'] | True |
test_availability_template_with_entities | (hass, calls) | Test availability tempalates with values from other entities. | Test availability tempalates with values from other entities. | async def test_availability_template_with_entities(hass, calls):
"""Test availability tempalates with values from other entities."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
... | [
"async",
"def",
"test_availability_template_with_entities",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{"... | [
277,
0
] | [
318,
64
] | python | en | ['en', 'en', 'en'] | True |
test_templates_with_valid_values | (hass, calls) | Test templates with valid values. | Test templates with valid values. | async def test_templates_with_valid_values(hass, calls):
"""Test templates with valid values."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "template",
... | [
"async",
"def",
"test_templates_with_valid_values",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",
"\"f... | [
321,
0
] | [
348,
66
] | python | en | ['en', 'en', 'en'] | True |
test_templates_invalid_values | (hass, calls) | Test templates with invalid values. | Test templates with invalid values. | async def test_templates_invalid_values(hass, calls):
"""Test templates with invalid values."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "template",
... | [
"async",
"def",
"test_templates_invalid_values",
"(",
"hass",
",",
"calls",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",
"\"fan\... | [
351,
0
] | [
378,
46
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_availability_template_keeps_component_available | (hass, caplog) | Test that an invalid availability keeps the device available. | Test that an invalid availability keeps the device available. | async def test_invalid_availability_template_keeps_component_available(hass, caplog):
"""Test that an invalid availability keeps the device available."""
with assert_setup_component(1, "fan"):
assert await setup.async_setup_component(
hass,
"fan",
{
"... | [
"async",
"def",
"test_invalid_availability_template_keeps_component_available",
"(",
"hass",
",",
"caplog",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"fan\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\... | [
381,
0
] | [
413,
29
] | python | en | ['en', 'en', 'en'] | True |
test_on_off | (hass, calls) | Test turn on and turn off. | Test turn on and turn off. | async def test_on_off(hass, calls):
"""Test turn on and turn off."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# verify
assert hass.states.get(_STATE_INPUT_BOOLEAN).state == STATE_ON
_verify(hass, STATE_ON, None, None, None)
# Turn off ... | [
"async",
"def",
"test_on_off",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# verify",
"assert",
"hass",
".",
"states",
... | [
420,
0
] | [
436,
46
] | python | en | ['en', 'en', 'en'] | True |
test_on_with_speed | (hass, calls) | Test turn on with speed. | Test turn on with speed. | async def test_on_with_speed(hass, calls):
"""Test turn on with speed."""
await _register_components(hass)
# Turn on fan with high speed
await common.async_turn_on(hass, _TEST_FAN, SPEED_HIGH)
# verify
assert hass.states.get(_STATE_INPUT_BOOLEAN).state == STATE_ON
assert hass.states.get(_S... | [
"async",
"def",
"test_on_with_speed",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan with high speed",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
",",
"SPEED_HIGH",
")",
"# verify... | [
439,
0
] | [
449,
51
] | python | en | ['en', 'en', 'en'] | True |
test_set_speed | (hass, calls) | Test set valid speed. | Test set valid speed. | async def test_set_speed(hass, calls):
"""Test set valid speed."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's speed to high
await common.async_set_speed(hass, _TEST_FAN, SPEED_HIGH)
# verify
assert hass.states.get(_SPEED_INPU... | [
"async",
"def",
"test_set_speed",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's speed to high",
"await",
"common",
... | [
452,
0
] | [
471,
53
] | python | en | ['en', 'et', 'en'] | True |
test_set_invalid_speed_from_initial_stage | (hass, calls) | Test set invalid speed when fan is in initial state. | Test set invalid speed when fan is in initial state. | async def test_set_invalid_speed_from_initial_stage(hass, calls):
"""Test set invalid speed when fan is in initial state."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's speed to 'invalid'
await common.async_set_speed(hass, _TEST_FAN, "... | [
"async",
"def",
"test_set_invalid_speed_from_initial_stage",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's speed to 'in... | [
474,
0
] | [
486,
45
] | python | en | ['en', 'en', 'en'] | True |
test_set_invalid_speed | (hass, calls) | Test set invalid speed when fan has valid speed. | Test set invalid speed when fan has valid speed. | async def test_set_invalid_speed(hass, calls):
"""Test set invalid speed when fan has valid speed."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's speed to high
await common.async_set_speed(hass, _TEST_FAN, SPEED_HIGH)
# verify
... | [
"async",
"def",
"test_set_invalid_speed",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's speed to high",
"await",
"c... | [
489,
0
] | [
508,
51
] | python | en | ['en', 'fy', 'en'] | True |
test_custom_speed_list | (hass, calls) | Test set custom speed list. | Test set custom speed list. | async def test_custom_speed_list(hass, calls):
"""Test set custom speed list."""
await _register_components(hass, ["1", "2", "3"])
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's speed to '1'
await common.async_set_speed(hass, _TEST_FAN, "1")
# verify
assert hass... | [
"async",
"def",
"test_custom_speed_list",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
",",
"[",
"\"1\"",
",",
"\"2\"",
",",
"\"3\"",
"]",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
... | [
511,
0
] | [
530,
44
] | python | en | ['en', 'et', 'en'] | True |
test_set_osc | (hass, calls) | Test set oscillating. | Test set oscillating. | async def test_set_osc(hass, calls):
"""Test set oscillating."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's osc to True
await common.async_oscillate(hass, _TEST_FAN, True)
# verify
assert hass.states.get(_OSC_INPUT).state == ... | [
"async",
"def",
"test_set_osc",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's osc to True",
"await",
"common",
".... | [
533,
0
] | [
552,
46
] | python | en | ['en', 'is', 'en'] | True |
test_set_invalid_osc_from_initial_state | (hass, calls) | Test set invalid oscillating when fan is in initial state. | Test set invalid oscillating when fan is in initial state. | async def test_set_invalid_osc_from_initial_state(hass, calls):
"""Test set invalid oscillating when fan is in initial state."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's osc to 'invalid'
with pytest.raises(vol.Invalid):
awai... | [
"async",
"def",
"test_set_invalid_osc_from_initial_state",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's osc to 'invali... | [
555,
0
] | [
568,
45
] | python | en | ['en', 'en', 'en'] | True |
test_set_invalid_osc | (hass, calls) | Test set invalid oscillating when fan has valid osc. | Test set invalid oscillating when fan has valid osc. | async def test_set_invalid_osc(hass, calls):
"""Test set invalid oscillating when fan has valid osc."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's osc to True
await common.async_oscillate(hass, _TEST_FAN, True)
# verify
asser... | [
"async",
"def",
"test_set_invalid_osc",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's osc to True",
"await",
"commo... | [
571,
0
] | [
591,
45
] | python | en | ['en', 'en', 'en'] | True |
test_set_direction | (hass, calls) | Test set valid direction. | Test set valid direction. | async def test_set_direction(hass, calls):
"""Test set valid direction."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's direction to forward
await common.async_set_direction(hass, _TEST_FAN, DIRECTION_FORWARD)
# verify
assert h... | [
"async",
"def",
"test_set_direction",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's direction to forward",
"await",
... | [
594,
0
] | [
613,
58
] | python | en | ['en', 'da', 'en'] | True |
test_set_invalid_direction_from_initial_stage | (hass, calls) | Test set invalid direction when fan is in initial state. | Test set invalid direction when fan is in initial state. | async def test_set_invalid_direction_from_initial_stage(hass, calls):
"""Test set invalid direction when fan is in initial state."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's direction to 'invalid'
await common.async_set_direction(ha... | [
"async",
"def",
"test_set_invalid_direction_from_initial_stage",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's directio... | [
616,
0
] | [
628,
45
] | python | en | ['en', 'en', 'en'] | True |
test_set_invalid_direction | (hass, calls) | Test set invalid direction when fan has valid direction. | Test set invalid direction when fan has valid direction. | async def test_set_invalid_direction(hass, calls):
"""Test set invalid direction when fan has valid direction."""
await _register_components(hass)
# Turn on fan
await common.async_turn_on(hass, _TEST_FAN)
# Set fan's direction to forward
await common.async_set_direction(hass, _TEST_FAN, DIRECT... | [
"async",
"def",
"test_set_invalid_direction",
"(",
"hass",
",",
"calls",
")",
":",
"await",
"_register_components",
"(",
"hass",
")",
"# Turn on fan",
"await",
"common",
".",
"async_turn_on",
"(",
"hass",
",",
"_TEST_FAN",
")",
"# Set fan's direction to forward",
"a... | [
631,
0
] | [
650,
58
] | python | en | ['en', 'en', 'en'] | True |
_verify | (
hass, expected_state, expected_speed, expected_oscillating, expected_direction
) | Verify fan's state, speed and osc. | Verify fan's state, speed and osc. | def _verify(
hass, expected_state, expected_speed, expected_oscillating, expected_direction
):
"""Verify fan's state, speed and osc."""
state = hass.states.get(_TEST_FAN)
attributes = state.attributes
assert state.state == str(expected_state)
assert attributes.get(ATTR_SPEED) == expected_speed
... | [
"def",
"_verify",
"(",
"hass",
",",
"expected_state",
",",
"expected_speed",
",",
"expected_oscillating",
",",
"expected_direction",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"_TEST_FAN",
")",
"attributes",
"=",
"state",
".",
"attributes"... | [
653,
0
] | [
662,
63
] | python | en | ['en', 'en', 'en'] | True |
_register_components | (hass, speed_list=None) | Register basic components for testing. | Register basic components for testing. | async def _register_components(hass, speed_list=None):
"""Register basic components for testing."""
with assert_setup_component(1, "input_boolean"):
assert await setup.async_setup_component(
hass, "input_boolean", {"input_boolean": {"state": None}}
)
with assert_setup_component(... | [
"async",
"def",
"_register_components",
"(",
"hass",
",",
"speed_list",
"=",
"None",
")",
":",
"with",
"assert_setup_component",
"(",
"1",
",",
"\"input_boolean\"",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"input_bo... | [
665,
0
] | [
755,
38
] | python | en | ['en', 'da', 'en'] | True |
test_unique_id | (hass) | Test unique_id option only creates one fan per id. | Test unique_id option only creates one fan per id. | async def test_unique_id(hass):
"""Test unique_id option only creates one fan per id."""
await setup.async_setup_component(
hass,
"fan",
{
"fan": {
"platform": "template",
"fans": {
"test_template_fan_01": {
... | [
"async",
"def",
"test_unique_id",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"fan\"",
",",
"{",
"\"fan\"",
":",
"{",
"\"platform\"",
":",
"\"template\"",
",",
"\"fans\"",
":",
"{",
"\"test_template_fan_01\"",
":"... | [
758,
0
] | [
800,
44
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the NILU air quality sensor. | Set up the NILU air quality sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the NILU air quality sensor."""
name = config.get(CONF_NAME)
area = config.get(CONF_AREA)
stations = config.get(CONF_STATION)
show_on_map = config.get(CONF_SHOW_ON_MAP)
sensors = []
if area:
stations = l... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"name",
"=",
"config",
".",
"get",
"(",
"CONF_NAME",
")",
"area",
"=",
"config",
".",
"get",
"(",
"CONF_AREA",
")",
"stations",
"=",
... | [
111,
0
] | [
136,
31
] | python | en | ['en', 'pt', 'en'] | True |
NiluData.__init__ | (self, api) | Initialize the data object. | Initialize the data object. | def __init__(self, api):
"""Initialize the data object."""
self.api = api | [
"def",
"__init__",
"(",
"self",
",",
"api",
")",
":",
"self",
".",
"api",
"=",
"api"
] | [
142,
4
] | [
144,
22
] | python | en | ['en', 'en', 'en'] | True |
NiluData.data | (self) | Get data cached in client. | Get data cached in client. | def data(self):
"""Get data cached in client."""
return self.api.data | [
"def",
"data",
"(",
"self",
")",
":",
"return",
"self",
".",
"api",
".",
"data"
] | [
147,
4
] | [
149,
28
] | python | en | ['en', 'en', 'en'] | True |
NiluData.update | (self) | Get the latest data from nilu API. | Get the latest data from nilu API. | def update(self):
"""Get the latest data from nilu API."""
self.api.update() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"api",
".",
"update",
"(",
")"
] | [
152,
4
] | [
154,
25
] | python | en | ['en', 'en', 'en'] | True |
NiluSensor.__init__ | (self, api_data: NiluData, name: str, show_on_map: bool) | Initialize the sensor. | Initialize the sensor. | def __init__(self, api_data: NiluData, name: str, show_on_map: bool):
"""Initialize the sensor."""
self._api = api_data
self._name = f"{name} {api_data.data.name}"
self._max_aqi = None
self._attrs = {}
if show_on_map:
self._attrs[CONF_LATITUDE] = api_data.dat... | [
"def",
"__init__",
"(",
"self",
",",
"api_data",
":",
"NiluData",
",",
"name",
":",
"str",
",",
"show_on_map",
":",
"bool",
")",
":",
"self",
".",
"_api",
"=",
"api_data",
"self",
".",
"_name",
"=",
"f\"{name} {api_data.data.name}\"",
"self",
".",
"_max_aq... | [
160,
4
] | [
169,
65
] | python | en | ['en', 'en', 'en'] | True |
NiluSensor.attribution | (self) | Return the attribution. | Return the attribution. | def attribution(self) -> str:
"""Return the attribution."""
return ATTRIBUTION | [
"def",
"attribution",
"(",
"self",
")",
"->",
"str",
":",
"return",
"ATTRIBUTION"
] | [
172,
4
] | [
174,
26
] | python | en | ['en', 'ja', 'en'] | True |
NiluSensor.device_state_attributes | (self) | Return other details about the sensor state. | Return other details about the sensor state. | def device_state_attributes(self) -> dict:
"""Return other details about the sensor state."""
return self._attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"self",
".",
"_attrs"
] | [
177,
4
] | [
179,
26
] | python | en | ['en', 'en', 'en'] | True |
NiluSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self) -> str:
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_name"
] | [
182,
4
] | [
184,
25
] | python | en | ['en', 'mi', 'en'] | True |
NiluSensor.air_quality_index | (self) | Return the Air Quality Index (AQI). | Return the Air Quality Index (AQI). | def air_quality_index(self) -> str:
"""Return the Air Quality Index (AQI)."""
return self._max_aqi | [
"def",
"air_quality_index",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_max_aqi"
] | [
187,
4
] | [
189,
28
] | python | en | ['en', 'cy', 'en'] | True |
NiluSensor.carbon_monoxide | (self) | Return the CO (carbon monoxide) level. | Return the CO (carbon monoxide) level. | def carbon_monoxide(self) -> str:
"""Return the CO (carbon monoxide) level."""
return self.get_component_state(CO) | [
"def",
"carbon_monoxide",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"CO",
")"
] | [
192,
4
] | [
194,
43
] | python | en | ['en', 'fr', 'en'] | True |
NiluSensor.carbon_dioxide | (self) | Return the CO2 (carbon dioxide) level. | Return the CO2 (carbon dioxide) level. | def carbon_dioxide(self) -> str:
"""Return the CO2 (carbon dioxide) level."""
return self.get_component_state(CO2) | [
"def",
"carbon_dioxide",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"CO2",
")"
] | [
197,
4
] | [
199,
44
] | python | en | ['en', 'en', 'en'] | True |
NiluSensor.nitrogen_oxide | (self) | Return the N2O (nitrogen oxide) level. | Return the N2O (nitrogen oxide) level. | def nitrogen_oxide(self) -> str:
"""Return the N2O (nitrogen oxide) level."""
return self.get_component_state(NOX) | [
"def",
"nitrogen_oxide",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"NOX",
")"
] | [
202,
4
] | [
204,
44
] | python | en | ['en', 'no', 'en'] | True |
NiluSensor.nitrogen_monoxide | (self) | Return the NO (nitrogen monoxide) level. | Return the NO (nitrogen monoxide) level. | def nitrogen_monoxide(self) -> str:
"""Return the NO (nitrogen monoxide) level."""
return self.get_component_state(NO) | [
"def",
"nitrogen_monoxide",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"NO",
")"
] | [
207,
4
] | [
209,
43
] | python | en | ['en', 'fr', 'en'] | True |
NiluSensor.nitrogen_dioxide | (self) | Return the NO2 (nitrogen dioxide) level. | Return the NO2 (nitrogen dioxide) level. | def nitrogen_dioxide(self) -> str:
"""Return the NO2 (nitrogen dioxide) level."""
return self.get_component_state(NO2) | [
"def",
"nitrogen_dioxide",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"NO2",
")"
] | [
212,
4
] | [
214,
44
] | python | en | ['en', 'da', 'en'] | True |
NiluSensor.ozone | (self) | Return the O3 (ozone) level. | Return the O3 (ozone) level. | def ozone(self) -> str:
"""Return the O3 (ozone) level."""
return self.get_component_state(OZONE) | [
"def",
"ozone",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"OZONE",
")"
] | [
217,
4
] | [
219,
46
] | python | en | ['en', 'ig', 'en'] | True |
NiluSensor.particulate_matter_2_5 | (self) | Return the particulate matter 2.5 level. | Return the particulate matter 2.5 level. | def particulate_matter_2_5(self) -> str:
"""Return the particulate matter 2.5 level."""
return self.get_component_state(PM25) | [
"def",
"particulate_matter_2_5",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"PM25",
")"
] | [
222,
4
] | [
224,
45
] | python | en | ['en', 'en', 'en'] | True |
NiluSensor.particulate_matter_10 | (self) | Return the particulate matter 10 level. | Return the particulate matter 10 level. | def particulate_matter_10(self) -> str:
"""Return the particulate matter 10 level."""
return self.get_component_state(PM10) | [
"def",
"particulate_matter_10",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"PM10",
")"
] | [
227,
4
] | [
229,
45
] | python | en | ['en', 'en', 'en'] | True |
NiluSensor.particulate_matter_0_1 | (self) | Return the particulate matter 0.1 level. | Return the particulate matter 0.1 level. | def particulate_matter_0_1(self) -> str:
"""Return the particulate matter 0.1 level."""
return self.get_component_state(PM1) | [
"def",
"particulate_matter_0_1",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"PM1",
")"
] | [
232,
4
] | [
234,
44
] | python | en | ['en', 'en', 'en'] | True |
NiluSensor.sulphur_dioxide | (self) | Return the SO2 (sulphur dioxide) level. | Return the SO2 (sulphur dioxide) level. | def sulphur_dioxide(self) -> str:
"""Return the SO2 (sulphur dioxide) level."""
return self.get_component_state(SO2) | [
"def",
"sulphur_dioxide",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"get_component_state",
"(",
"SO2",
")"
] | [
237,
4
] | [
239,
44
] | python | en | ['en', 'no', 'en'] | True |
NiluSensor.get_component_state | (self, component_name: str) | Return formatted value of specified component. | Return formatted value of specified component. | def get_component_state(self, component_name: str) -> str:
"""Return formatted value of specified component."""
if component_name in self._api.data.sensors:
sensor = self._api.data.sensors[component_name]
return sensor.value
return None | [
"def",
"get_component_state",
"(",
"self",
",",
"component_name",
":",
"str",
")",
"->",
"str",
":",
"if",
"component_name",
"in",
"self",
".",
"_api",
".",
"data",
".",
"sensors",
":",
"sensor",
"=",
"self",
".",
"_api",
".",
"data",
".",
"sensors",
"... | [
241,
4
] | [
246,
19
] | python | en | ['en', 'en', 'en'] | True |
NiluSensor.update | (self) | Update the sensor. | Update the sensor. | def update(self) -> None:
"""Update the sensor."""
self._api.update()
sensors = self._api.data.sensors.values()
if sensors:
max_index = max([s.pollution_index for s in sensors])
self._max_aqi = max_index
self._attrs[ATTR_POLLUTION_INDEX] = POLLUTION_I... | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_api",
".",
"update",
"(",
")",
"sensors",
"=",
"self",
".",
"_api",
".",
"data",
".",
"sensors",
".",
"values",
"(",
")",
"if",
"sensors",
":",
"max_index",
"=",
"max",
"(",
"["... | [
248,
4
] | [
258,
52
] | python | en | ['en', 'nl', 'en'] | True |
TestVultrSensorSetup.add_entities | (self, devices, action) | Mock add devices. | Mock add devices. | def add_entities(self, devices, action):
"""Mock add devices."""
for device in devices:
self.DEVICES.append(device) | [
"def",
"add_entities",
"(",
"self",
",",
"devices",
",",
"action",
")",
":",
"for",
"device",
"in",
"devices",
":",
"self",
".",
"DEVICES",
".",
"append",
"(",
"device",
")"
] | [
28,
4
] | [
31,
39
] | python | en | ['es', 'en', 'en'] | True |
TestVultrSensorSetup.setUp | (self) | Initialize values for this testcase class. | Initialize values for this testcase class. | def setUp(self):
"""Initialize values for this testcase class."""
self.hass = get_test_home_assistant()
self.configs = [
{
CONF_NAME: vultr.DEFAULT_NAME,
CONF_SUBSCRIPTION: "576965",
CONF_MONITORED_CONDITIONS: vultr.MONITORED_CONDITIONS... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"configs",
"=",
"[",
"{",
"CONF_NAME",
":",
"vultr",
".",
"DEFAULT_NAME",
",",
"CONF_SUBSCRIPTION",
":",
"\"576965\"",
",",
"CONF_MONITORED_CON... | [
33,
4
] | [
53,
39
] | python | en | ['en', 'en', 'en'] | True |
TestVultrSensorSetup.test_sensor | (self, mock) | Test the Vultr sensor class and methods. | Test the Vultr sensor class and methods. | def test_sensor(self, mock):
"""Test the Vultr sensor class and methods."""
mock.get(
"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567",
text=load_fixture("vultr_account_info.json"),
)
with patch(
"vultr.Vultr.server_list",
re... | [
"def",
"test_sensor",
"(",
"self",
",",
"mock",
")",
":",
"mock",
".",
"get",
"(",
"\"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"vultr_account_info.json\"",
")",
",",
")",
"with",
"patch",
"(",
"\"vultr... | [
56,
4
] | [
119,
26
] | python | en | ['en', 'en', 'en'] | True |
TestVultrSensorSetup.test_invalid_sensor_config | (self) | Test config type failures. | Test config type failures. | def test_invalid_sensor_config(self):
"""Test config type failures."""
with pytest.raises(vol.Invalid): # No subscription
vultr.PLATFORM_SCHEMA(
{
CONF_PLATFORM: base_vultr.DOMAIN,
CONF_MONITORED_CONDITIONS: vultr.MONITORED_CONDITIONS,... | [
"def",
"test_invalid_sensor_config",
"(",
"self",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"# No subscription",
"vultr",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"base_vultr",
".",
"DOMAIN",
",",
"CONF_MON... | [
121,
4
] | [
137,
13
] | python | en | ['en', 'en', 'en'] | True |
TestVultrSensorSetup.test_invalid_sensors | (self, mock) | Test the VultrSensor fails. | Test the VultrSensor fails. | def test_invalid_sensors(self, mock):
"""Test the VultrSensor fails."""
mock.get(
"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567",
text=load_fixture("vultr_account_info.json"),
)
with patch(
"vultr.Vultr.server_list",
return... | [
"def",
"test_invalid_sensors",
"(",
"self",
",",
"mock",
")",
":",
"mock",
".",
"get",
"(",
"\"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"vultr_account_info.json\"",
")",
",",
")",
"with",
"patch",
"(",
... | [
140,
4
] | [
163,
37
] | python | en | ['en', 'no', 'en'] | True |
TestTTSGooglePlatform.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
asyncio.run_coroutine_threadsafe(
async_process_ha_core_config(
self.hass, {"internal_url": "http://example.local:8123"}
),
sel... | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"asyncio",
".",
"run_coroutine_threadsafe",
"(",
"async_process_ha_core_config",
"(",
"self",
".",
"hass",
",",
"{",
"\"internal_url\"",
":",
"\"http://exa... | [
22,
4
] | [
43,
9
] | python | en | ['en', 'en', 'en'] | True |
TestTTSGooglePlatform.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
default_tts = self.hass.config.path(tts.DEFAULT_CACHE_DIR)
if os.path.isdir(default_tts):
shutil.rmtree(default_tts)
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"default_tts",
"=",
"self",
".",
"hass",
".",
"config",
".",
"path",
"(",
"tts",
".",
"DEFAULT_CACHE_DIR",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"default_tts",
")",
":",
"shutil",
".",
"rmtree... | [
45,
4
] | [
51,
24
] | python | en | ['en', 'en', 'en'] | True |
TestTTSGooglePlatform.test_setup_component | (self) | Test setup component. | Test setup component. | def test_setup_component(self):
"""Test setup component."""
config = {tts.DOMAIN: {"platform": "google_translate"}}
with assert_setup_component(1, tts.DOMAIN):
setup_component(self.hass, tts.DOMAIN, config) | [
"def",
"test_setup_component",
"(",
"self",
")",
":",
"config",
"=",
"{",
"tts",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"google_translate\"",
"}",
"}",
"with",
"assert_setup_component",
"(",
"1",
",",
"tts",
".",
"DOMAIN",
")",
":",
"setup_component... | [
53,
4
] | [
58,
58
] | python | en | ['en', 'da', 'en'] | True |
TestTTSGooglePlatform.test_service_say | (self, mock_calculate, aioclient_mock) | Test service call say. | Test service call say. | def test_service_say(self, mock_calculate, aioclient_mock):
"""Test service call say."""
calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
aioclient_mock.get(self.url, params=self.url_param, status=200, content=b"test")
config = {tts.DOMAIN: {"platform": "google_translate"... | [
"def",
"test_service_say",
"(",
"self",
",",
"mock_calculate",
",",
"aioclient_mock",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"DOMAIN_MP",
",",
"SERVICE_PLAY_MEDIA",
")",
"aioclient_mock",
".",
"get",
"(",
"self",
".",
"url",
"... | [
61,
4
] | [
84,
70
] | python | en | ['en', 'en', 'en'] | True |
TestTTSGooglePlatform.test_service_say_german_config | (self, mock_calculate, aioclient_mock) | Test service call say with german code in the config. | Test service call say with german code in the config. | def test_service_say_german_config(self, mock_calculate, aioclient_mock):
"""Test service call say with german code in the config."""
calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
self.url_param["tl"] = "de"
aioclient_mock.get(self.url, params=self.url_param, status=200... | [
"def",
"test_service_say_german_config",
"(",
"self",
",",
"mock_calculate",
",",
"aioclient_mock",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"DOMAIN_MP",
",",
"SERVICE_PLAY_MEDIA",
")",
"self",
".",
"url_param",
"[",
"\"tl\"",
"]",
... | [
87,
4
] | [
110,
50
] | python | en | ['en', 'en', 'en'] | True |
TestTTSGooglePlatform.test_service_say_german_service | (self, mock_calculate, aioclient_mock) | Test service call say with german code in the service. | Test service call say with german code in the service. | def test_service_say_german_service(self, mock_calculate, aioclient_mock):
"""Test service call say with german code in the service."""
calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
self.url_param["tl"] = "de"
aioclient_mock.get(self.url, params=self.url_param, status=2... | [
"def",
"test_service_say_german_service",
"(",
"self",
",",
"mock_calculate",
",",
"aioclient_mock",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"DOMAIN_MP",
",",
"SERVICE_PLAY_MEDIA",
")",
"self",
".",
"url_param",
"[",
"\"tl\"",
"]",... | [
113,
4
] | [
139,
50
] | python | en | ['en', 'en', 'en'] | True |
TestTTSGooglePlatform.test_service_say_error | (self, mock_calculate, aioclient_mock) | Test service call say with http response 400. | Test service call say with http response 400. | def test_service_say_error(self, mock_calculate, aioclient_mock):
"""Test service call say with http response 400."""
calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
aioclient_mock.get(self.url, params=self.url_param, status=400, content=b"test")
config = {tts.DOMAIN: {"... | [
"def",
"test_service_say_error",
"(",
"self",
",",
"mock_calculate",
",",
"aioclient_mock",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"DOMAIN_MP",
",",
"SERVICE_PLAY_MEDIA",
")",
"aioclient_mock",
".",
"get",
"(",
"self",
".",
"url... | [
142,
4
] | [
164,
50
] | python | en | ['en', 'en', 'en'] | True |
TestTTSGooglePlatform.test_service_say_timeout | (self, mock_calculate, aioclient_mock) | Test service call say with http timeout. | Test service call say with http timeout. | def test_service_say_timeout(self, mock_calculate, aioclient_mock):
"""Test service call say with http timeout."""
calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
aioclient_mock.get(self.url, params=self.url_param, exc=asyncio.TimeoutError())
config = {tts.DOMAIN: {"plat... | [
"def",
"test_service_say_timeout",
"(",
"self",
",",
"mock_calculate",
",",
"aioclient_mock",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"DOMAIN_MP",
",",
"SERVICE_PLAY_MEDIA",
")",
"aioclient_mock",
".",
"get",
"(",
"self",
".",
"u... | [
167,
4
] | [
189,
50
] | python | en | ['en', 'en', 'en'] | True |
TestTTSGooglePlatform.test_service_say_long_size | (self, mock_calculate, aioclient_mock) | Test service call say with a lot of text. | Test service call say with a lot of text. | def test_service_say_long_size(self, mock_calculate, aioclient_mock):
"""Test service call say with a lot of text."""
calls = mock_service(self.hass, DOMAIN_MP, SERVICE_PLAY_MEDIA)
self.url_param["total"] = 9
self.url_param["q"] = "I%20person%20is%20on%20front%20of%20your%20door"
... | [
"def",
"test_service_say_long_size",
"(",
"self",
",",
"mock_calculate",
",",
"aioclient_mock",
")",
":",
"calls",
"=",
"mock_service",
"(",
"self",
".",
"hass",
",",
"DOMAIN_MP",
",",
"SERVICE_PLAY_MEDIA",
")",
"self",
".",
"url_param",
"[",
"\"total\"",
"]",
... | [
192,
4
] | [
234,
70
] | 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.