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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
FileSynchronizer.copy_and_rename | (source_path: str, target_dir: str, new_name: str = None) | Copy and rename a file.
Args:
source_path (str): path of the source.
target_dir (str): dir of the target.
new_name (str): name of the new file, if None, will not do rename.
| Copy and rename a file. | def copy_and_rename(source_path: str, target_dir: str, new_name: str = None):
"""Copy and rename a file.
Args:
source_path (str): path of the source.
target_dir (str): dir of the target.
new_name (str): name of the new file, if None, will not do rename.
"""
... | [
"def",
"copy_and_rename",
"(",
"source_path",
":",
"str",
",",
"target_dir",
":",
"str",
",",
"new_name",
":",
"str",
"=",
"None",
")",
":",
"source_path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"source_path",
")",
"target_dir",
"=",
"os",
".",
... | [
141,
4
] | [
160,
55
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the folder watcher. | Set up the folder watcher. | def setup(hass, config):
"""Set up the folder watcher."""
conf = config[DOMAIN]
for watcher in conf:
path = watcher[CONF_FOLDER]
patterns = watcher[CONF_PATTERNS]
if not hass.config.is_allowed_path(path):
_LOGGER.error("folder %s is not valid or allowed", path)
... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"conf",
"=",
"config",
"[",
"DOMAIN",
"]",
"for",
"watcher",
"in",
"conf",
":",
"path",
"=",
"watcher",
"[",
"CONF_FOLDER",
"]",
"patterns",
"=",
"watcher",
"[",
"CONF_PATTERNS",
"]",
"if",
"not",
... | [
38,
0
] | [
49,
15
] | python | en | ['en', 'lb', 'en'] | True |
create_event_handler | (patterns, hass) | Return the Watchdog EventHandler object. | Return the Watchdog EventHandler object. | def create_event_handler(patterns, hass):
"""Return the Watchdog EventHandler object."""
class EventHandler(PatternMatchingEventHandler):
"""Class for handling Watcher events."""
def __init__(self, patterns, hass):
"""Initialise the EventHandler."""
super().__init__(pat... | [
"def",
"create_event_handler",
"(",
"patterns",
",",
"hass",
")",
":",
"class",
"EventHandler",
"(",
"PatternMatchingEventHandler",
")",
":",
"\"\"\"Class for handling Watcher events.\"\"\"",
"def",
"__init__",
"(",
"self",
",",
"patterns",
",",
"hass",
")",
":",
"\... | [
52,
0
] | [
94,
39
] | python | en | ['en', 'lb', 'en'] | True |
Watcher.__init__ | (self, path, patterns, hass) | Initialise the watchdog observer. | Initialise the watchdog observer. | def __init__(self, path, patterns, hass):
"""Initialise the watchdog observer."""
self._observer = Observer()
self._observer.schedule(
create_event_handler(patterns, hass), path, recursive=True
)
hass.bus.listen_once(EVENT_HOMEASSISTANT_START, self.startup)
ha... | [
"def",
"__init__",
"(",
"self",
",",
"path",
",",
"patterns",
",",
"hass",
")",
":",
"self",
".",
"_observer",
"=",
"Observer",
"(",
")",
"self",
".",
"_observer",
".",
"schedule",
"(",
"create_event_handler",
"(",
"patterns",
",",
"hass",
")",
",",
"p... | [
100,
4
] | [
107,
69
] | python | en | ['en', 'en', 'en'] | True |
Watcher.startup | (self, event) | Start the watcher. | Start the watcher. | def startup(self, event):
"""Start the watcher."""
self._observer.start() | [
"def",
"startup",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_observer",
".",
"start",
"(",
")"
] | [
109,
4
] | [
111,
30
] | python | en | ['en', 'de', 'en'] | True |
Watcher.shutdown | (self, event) | Shutdown the watcher. | Shutdown the watcher. | def shutdown(self, event):
"""Shutdown the watcher."""
self._observer.stop()
self._observer.join() | [
"def",
"shutdown",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_observer",
".",
"stop",
"(",
")",
"self",
".",
"_observer",
".",
"join",
"(",
")"
] | [
113,
4
] | [
116,
29
] | python | en | ['en', 'sn', 'en'] | True |
test_entity_registry | (hass) | Tests that the devices are registered in the entity registry. | Tests that the devices are registered in the entity registry. | async def test_entity_registry(hass):
"""Tests that the devices are registered in the entity registry."""
await setup_platform(hass, SENSOR_DOMAIN)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
entry = entity_registry.async_get("sensor.environment_sensor_humidity")
asser... | [
"async",
"def",
"test_entity_registry",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"SENSOR_DOMAIN",
")",
"entity_registry",
"=",
"await",
"hass",
".",
"helpers",
".",
"entity_registry",
".",
"async_get_registry",
"(",
")",
"entry",
"=",
... | [
15,
0
] | [
21,
73
] | python | en | ['en', 'en', 'en'] | True |
test_attributes | (hass) | Test the sensor attributes are correct. | Test the sensor attributes are correct. | async def test_attributes(hass):
"""Test the sensor attributes are correct."""
await setup_platform(hass, SENSOR_DOMAIN)
state = hass.states.get("sensor.environment_sensor_humidity")
assert state.state == "32.0"
assert state.attributes.get(ATTR_DEVICE_ID) == "RF:02148e70"
assert not state.attri... | [
"async",
"def",
"test_attributes",
"(",
"hass",
")",
":",
"await",
"setup_platform",
"(",
"hass",
",",
"SENSOR_DOMAIN",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"sensor.environment_sensor_humidity\"",
")",
"assert",
"state",
".",
"state",
"... | [
24,
0
] | [
45,
73
] | python | en | ['en', 'it', 'en'] | True |
generate_search_space | (code_dir) | Generate search space from Python source code.
Return a serializable search space object.
code_dir: directory path of source files (str)
| Generate search space from Python source code.
Return a serializable search space object.
code_dir: directory path of source files (str)
| def generate_search_space(code_dir):
"""Generate search space from Python source code.
Return a serializable search space object.
code_dir: directory path of source files (str)
"""
code_dir = str(code_dir)
search_space = {}
if code_dir.endswith(slash):
code_dir = code_dir[:-1]
... | [
"def",
"generate_search_space",
"(",
"code_dir",
")",
":",
"code_dir",
"=",
"str",
"(",
"code_dir",
")",
"search_space",
"=",
"{",
"}",
"if",
"code_dir",
".",
"endswith",
"(",
"slash",
")",
":",
"code_dir",
"=",
"code_dir",
"[",
":",
"-",
"1",
"]",
"fo... | [
19,
0
] | [
45,
23
] | python | en | ['en', 'en', 'en'] | True |
expand_annotations | (src_dir, dst_dir, exp_id='', trial_id='', nas_mode=None) | Expand annotations in user code.
Return dst_dir if annotation detected; return src_dir if not.
src_dir: directory path of user code (str)
dst_dir: directory to place generated files (str)
nas_mode: the mode of NAS given that NAS interface is used
| Expand annotations in user code.
Return dst_dir if annotation detected; return src_dir if not.
src_dir: directory path of user code (str)
dst_dir: directory to place generated files (str)
nas_mode: the mode of NAS given that NAS interface is used
| def expand_annotations(src_dir, dst_dir, exp_id='', trial_id='', nas_mode=None):
"""Expand annotations in user code.
Return dst_dir if annotation detected; return src_dir if not.
src_dir: directory path of user code (str)
dst_dir: directory to place generated files (str)
nas_mode: the mode of NAS gi... | [
"def",
"expand_annotations",
"(",
"src_dir",
",",
"dst_dir",
",",
"exp_id",
"=",
"''",
",",
"trial_id",
"=",
"''",
",",
"nas_mode",
"=",
"None",
")",
":",
"src_dir",
",",
"dst_dir",
"=",
"str",
"(",
"src_dir",
")",
",",
"str",
"(",
"dst_dir",
")",
"i... | [
61,
0
] | [
106,
44
] | python | en | ['en', 'en', 'en'] | True |
get_new_request | (namespace, name, endpoint=None) | Generate a new API message. | Generate a new API message. | def get_new_request(namespace, name, endpoint=None):
"""Generate a new API message."""
raw_msg = {
"directive": {
"header": {
"namespace": namespace,
"name": name,
"messageId": str(uuid4()),
"correlationToken": str(uuid4()),
... | [
"def",
"get_new_request",
"(",
"namespace",
",",
"name",
",",
"endpoint",
"=",
"None",
")",
":",
"raw_msg",
"=",
"{",
"\"directive\"",
":",
"{",
"\"header\"",
":",
"{",
"\"namespace\"",
":",
"namespace",
",",
"\"name\"",
":",
"name",
",",
"\"messageId\"",
... | [
54,
0
] | [
76,
18
] | python | en | ['en', 'en', 'en'] | True |
assert_request_calls_service | (
namespace,
name,
endpoint,
service,
hass,
response_type="Response",
payload=None,
instance=None,
) | Assert an API request calls a hass service. | Assert an API request calls a hass service. | async def assert_request_calls_service(
namespace,
name,
endpoint,
service,
hass,
response_type="Response",
payload=None,
instance=None,
):
"""Assert an API request calls a hass service."""
context = Context()
request = get_new_request(namespace, name, endpoint)
if payloa... | [
"async",
"def",
"assert_request_calls_service",
"(",
"namespace",
",",
"name",
",",
"endpoint",
",",
"service",
",",
"hass",
",",
"response_type",
"=",
"\"Response\"",
",",
"payload",
"=",
"None",
",",
"instance",
"=",
"None",
",",
")",
":",
"context",
"=",
... | [
79,
0
] | [
110,
20
] | python | en | ['en', 'lb', 'en'] | True |
assert_request_fails | (
namespace, name, endpoint, service_not_called, hass, payload=None
) | Assert an API request returns an ErrorResponse. | Assert an API request returns an ErrorResponse. | async def assert_request_fails(
namespace, name, endpoint, service_not_called, hass, payload=None
):
"""Assert an API request returns an ErrorResponse."""
request = get_new_request(namespace, name, endpoint)
if payload:
request["directive"]["payload"] = payload
domain, service_name = servic... | [
"async",
"def",
"assert_request_fails",
"(",
"namespace",
",",
"name",
",",
"endpoint",
",",
"service_not_called",
",",
"hass",
",",
"payload",
"=",
"None",
")",
":",
"request",
"=",
"get_new_request",
"(",
"namespace",
",",
"name",
",",
"endpoint",
")",
"if... | [
113,
0
] | [
131,
14
] | python | en | ['en', 'lb', 'en'] | True |
assert_power_controller_works | (endpoint, on_service, off_service, hass) | Assert PowerController API requests work. | Assert PowerController API requests work. | async def assert_power_controller_works(endpoint, on_service, off_service, hass):
"""Assert PowerController API requests work."""
await assert_request_calls_service(
"Alexa.PowerController", "TurnOn", endpoint, on_service, hass
)
await assert_request_calls_service(
"Alexa.PowerControlle... | [
"async",
"def",
"assert_power_controller_works",
"(",
"endpoint",
",",
"on_service",
",",
"off_service",
",",
"hass",
")",
":",
"await",
"assert_request_calls_service",
"(",
"\"Alexa.PowerController\"",
",",
"\"TurnOn\"",
",",
"endpoint",
",",
"on_service",
",",
"hass... | [
134,
0
] | [
142,
5
] | python | en | ['en', 'lb', 'en'] | True |
assert_scene_controller_works | (
endpoint, activate_service, deactivate_service, hass
) | Assert SceneController API requests work. | Assert SceneController API requests work. | async def assert_scene_controller_works(
endpoint, activate_service, deactivate_service, hass
):
"""Assert SceneController API requests work."""
_, response = await assert_request_calls_service(
"Alexa.SceneController",
"Activate",
endpoint,
activate_service,
hass,
... | [
"async",
"def",
"assert_scene_controller_works",
"(",
"endpoint",
",",
"activate_service",
",",
"deactivate_service",
",",
"hass",
")",
":",
"_",
",",
"response",
"=",
"await",
"assert_request_calls_service",
"(",
"\"Alexa.SceneController\"",
",",
"\"Activate\"",
",",
... | [
145,
0
] | [
171,
58
] | python | en | ['en', 'nl', 'en'] | True |
reported_properties | (hass, endpoint) | Use ReportState to get properties and return them.
The result is a ReportedProperties instance, which has methods to make
assertions about the properties.
| Use ReportState to get properties and return them. | async def reported_properties(hass, endpoint):
"""Use ReportState to get properties and return them.
The result is a ReportedProperties instance, which has methods to make
assertions about the properties.
"""
request = get_new_request("Alexa", "ReportState", endpoint)
msg = await smart_home.asy... | [
"async",
"def",
"reported_properties",
"(",
"hass",
",",
"endpoint",
")",
":",
"request",
"=",
"get_new_request",
"(",
"\"Alexa\"",
",",
"\"ReportState\"",
",",
"endpoint",
")",
"msg",
"=",
"await",
"smart_home",
".",
"async_handle_message",
"(",
"hass",
",",
... | [
174,
0
] | [
183,
59
] | python | en | ['en', 'en', 'en'] | True |
MockConfig.supports_auth | (self) | Return if config supports auth. | Return if config supports auth. | def supports_auth(self):
"""Return if config supports auth."""
return True | [
"def",
"supports_auth",
"(",
"self",
")",
":",
"return",
"True"
] | [
25,
4
] | [
27,
19
] | python | en | ['en', 'en', 'en'] | True |
MockConfig.endpoint | (self) | Endpoint for report state. | Endpoint for report state. | def endpoint(self):
"""Endpoint for report state."""
return TEST_URL | [
"def",
"endpoint",
"(",
"self",
")",
":",
"return",
"TEST_URL"
] | [
30,
4
] | [
32,
23
] | python | en | ['en', 'en', 'en'] | True |
MockConfig.locale | (self) | Return config locale. | Return config locale. | def locale(self):
"""Return config locale."""
return TEST_LOCALE | [
"def",
"locale",
"(",
"self",
")",
":",
"return",
"TEST_LOCALE"
] | [
35,
4
] | [
37,
26
] | python | de | ['de', 'la', 'en'] | False |
MockConfig.should_expose | (self, entity_id) | If an entity should be exposed. | If an entity should be exposed. | def should_expose(self, entity_id):
"""If an entity should be exposed."""
return True | [
"def",
"should_expose",
"(",
"self",
",",
"entity_id",
")",
":",
"return",
"True"
] | [
39,
4
] | [
41,
19
] | python | en | ['en', 'en', 'en'] | True |
MockConfig.async_get_access_token | (self) | Get an access token. | Get an access token. | async def async_get_access_token(self):
"""Get an access token."""
return "thisisnotanacesstoken" | [
"async",
"def",
"async_get_access_token",
"(",
"self",
")",
":",
"return",
"\"thisisnotanacesstoken\""
] | [
43,
4
] | [
45,
38
] | python | en | ['en', 'lb', 'en'] | True |
MockConfig.async_accept_grant | (self, code) | Accept a grant. | Accept a grant. | async def async_accept_grant(self, code):
"""Accept a grant.""" | [
"async",
"def",
"async_accept_grant",
"(",
"self",
",",
"code",
")",
":"
] | [
47,
4
] | [
48,
29
] | python | en | ['en', 'it', 'en'] | True |
ReportedProperties.__init__ | (self, properties) | Initialize class. | Initialize class. | def __init__(self, properties):
"""Initialize class."""
self.properties = properties | [
"def",
"__init__",
"(",
"self",
",",
"properties",
")",
":",
"self",
".",
"properties",
"=",
"properties"
] | [
189,
4
] | [
191,
36
] | python | en | ['en', 'co', 'en'] | False |
ReportedProperties.assert_not_has_property | (self, namespace, name) | Assert a property does not exist. | Assert a property does not exist. | def assert_not_has_property(self, namespace, name):
"""Assert a property does not exist."""
for prop in self.properties:
if prop["namespace"] == namespace and prop["name"] == name:
assert False, "Property %s:%s exists" | [
"def",
"assert_not_has_property",
"(",
"self",
",",
"namespace",
",",
"name",
")",
":",
"for",
"prop",
"in",
"self",
".",
"properties",
":",
"if",
"prop",
"[",
"\"namespace\"",
"]",
"==",
"namespace",
"and",
"prop",
"[",
"\"name\"",
"]",
"==",
"name",
":... | [
193,
4
] | [
197,
53
] | python | en | ['en', 'lb', 'en'] | True |
ReportedProperties.assert_equal | (self, namespace, name, value) | Assert a property is equal to a given value. | Assert a property is equal to a given value. | def assert_equal(self, namespace, name, value):
"""Assert a property is equal to a given value."""
for prop in self.properties:
if prop["namespace"] == namespace and prop["name"] == name:
assert prop["value"] == value
return prop
assert False, f"prope... | [
"def",
"assert_equal",
"(",
"self",
",",
"namespace",
",",
"name",
",",
"value",
")",
":",
"for",
"prop",
"in",
"self",
".",
"properties",
":",
"if",
"prop",
"[",
"\"namespace\"",
"]",
"==",
"namespace",
"and",
"prop",
"[",
"\"name\"",
"]",
"==",
"name... | [
199,
4
] | [
206,
79
] | python | en | ['en', 'en', 'en'] | True |
test_setup_discovery | (hass: HomeAssistant) | Test setting up Yeelight by discovery. | Test setting up Yeelight by discovery. | async def test_setup_discovery(hass: HomeAssistant):
"""Test setting up Yeelight by discovery."""
config_entry = MockConfigEntry(domain=DOMAIN, data=CONFIG_ENTRY_DATA)
config_entry.add_to_hass(hass)
mocked_bulb = _mocked_bulb()
with _patch_discovery(MODULE), patch(f"{MODULE}.Bulb", return_value=moc... | [
"async",
"def",
"test_setup_discovery",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"CONFIG_ENTRY_DATA",
")",
"config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"mocked_b... | [
32,
0
] | [
48,
48
] | python | en | ['en', 'en', 'en'] | True |
test_setup_import | (hass: HomeAssistant) | Test import from yaml. | Test import from yaml. | async def test_setup_import(hass: HomeAssistant):
"""Test import from yaml."""
mocked_bulb = _mocked_bulb()
name = "yeelight"
with patch(f"{MODULE}.Bulb", return_value=mocked_bulb), patch(
f"{MODULE_CONFIG_FLOW}.yeelight.Bulb", return_value=mocked_bulb
):
assert await async_setup_com... | [
"async",
"def",
"test_setup_import",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"mocked_bulb",
"=",
"_mocked_bulb",
"(",
")",
"name",
"=",
"\"yeelight\"",
"with",
"patch",
"(",
"f\"{MODULE}.Bulb\"",
",",
"return_value",
"=",
"mocked_bulb",
")",
",",
"patch",
... | [
51,
0
] | [
76,
66
] | python | en | ['en', 'en', 'en'] | True |
test_unique_ids_device | (hass: HomeAssistant) | Test Yeelight unique IDs from yeelight device IDs. | Test Yeelight unique IDs from yeelight device IDs. | async def test_unique_ids_device(hass: HomeAssistant):
"""Test Yeelight unique IDs from yeelight device IDs."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={
**CONFIG_ENTRY_DATA,
CONF_NIGHTLIGHT_SWITCH: True,
},
unique_id=ID,
)
config_entry... | [
"async",
"def",
"test_unique_ids_device",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"*",
"*",
"CONFIG_ENTRY_DATA",
",",
"CONF_NIGHTLIGHT_SWITCH",
":",
"True",
",",
... | [
79,
0
] | [
101,
72
] | python | en | ['en', 'nl', 'en'] | True |
test_unique_ids_entry | (hass: HomeAssistant) | Test Yeelight unique IDs from entry IDs. | Test Yeelight unique IDs from entry IDs. | async def test_unique_ids_entry(hass: HomeAssistant):
"""Test Yeelight unique IDs from entry IDs."""
config_entry = MockConfigEntry(
domain=DOMAIN,
data={
**CONFIG_ENTRY_DATA,
CONF_NIGHTLIGHT_SWITCH: True,
},
)
config_entry.add_to_hass(hass)
mocked_bu... | [
"async",
"def",
"test_unique_ids_entry",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"*",
"*",
"CONFIG_ENTRY_DATA",
",",
"CONF_NIGHTLIGHT_SWITCH",
":",
"True",
",",
"... | [
104,
0
] | [
133,
5
] | python | en | ['en', 'en', 'en'] | True |
ProxylessNasTrainer.__init__ | (self, model, model_optim, device,
train_loader, valid_loader, label_smoothing=0.1,
n_epochs=120, init_lr=0.025, binary_mode='full_v2',
arch_init_type='normal', arch_init_ratio=1e-3,
arch_optim_lr=1e-3, arch_weight_decay=0,
grad_update... |
Parameters
----------
model : pytorch model
the user model, which has mutables
model_optim : pytorch optimizer
the user defined optimizer
device : pytorch device
the devices to train/search the model
train_loader : pytorch data loader
... |
Parameters
----------
model : pytorch model
the user model, which has mutables
model_optim : pytorch optimizer
the user defined optimizer
device : pytorch device
the devices to train/search the model
train_loader : pytorch data loader
... | def __init__(self, model, model_optim, device,
train_loader, valid_loader, label_smoothing=0.1,
n_epochs=120, init_lr=0.025, binary_mode='full_v2',
arch_init_type='normal', arch_init_ratio=1e-3,
arch_optim_lr=1e-3, arch_weight_decay=0,
... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"model_optim",
",",
"device",
",",
"train_loader",
",",
"valid_loader",
",",
"label_smoothing",
"=",
"0.1",
",",
"n_epochs",
"=",
"120",
",",
"init_lr",
"=",
"0.025",
",",
"binary_mode",
"=",
"'full_v2'",
... | [
20,
4
] | [
119,
33
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._init_arch_params | (self, init_type='normal', init_ratio=1e-3) |
Initialize architecture weights
|
Initialize architecture weights
| def _init_arch_params(self, init_type='normal', init_ratio=1e-3):
"""
Initialize architecture weights
"""
for param in self.mutator.get_architecture_parameters():
if init_type == 'normal':
param.data.normal_(0, init_ratio)
elif init_type == 'unifor... | [
"def",
"_init_arch_params",
"(",
"self",
",",
"init_type",
"=",
"'normal'",
",",
"init_ratio",
"=",
"1e-3",
")",
":",
"for",
"param",
"in",
"self",
".",
"mutator",
".",
"get_architecture_parameters",
"(",
")",
":",
"if",
"init_type",
"==",
"'normal'",
":",
... | [
121,
4
] | [
131,
41
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._validate | (self) |
Do validation. During validation, LayerChoices use the chosen active op.
Returns
-------
float, float, float
average loss, average top1 accuracy, average top5 accuracy
|
Do validation. During validation, LayerChoices use the chosen active op. | def _validate(self):
"""
Do validation. During validation, LayerChoices use the chosen active op.
Returns
-------
float, float, float
average loss, average top1 accuracy, average top5 accuracy
"""
self.valid_loader.batch_sampler.batch_size = self.vali... | [
"def",
"_validate",
"(",
"self",
")",
":",
"self",
".",
"valid_loader",
".",
"batch_sampler",
".",
"batch_size",
"=",
"self",
".",
"valid_batch_size",
"self",
".",
"valid_loader",
".",
"batch_sampler",
".",
"drop_last",
"=",
"False",
"self",
".",
"mutator",
... | [
133,
4
] | [
178,
45
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._warm_up | (self) |
Warm up the model, during warm up, architecture weights are not trained.
|
Warm up the model, during warm up, architecture weights are not trained.
| def _warm_up(self):
"""
Warm up the model, during warm up, architecture weights are not trained.
"""
lr_max = 0.05
data_loader = self.train_loader
nBatch = len(data_loader)
T_total = self.warmup_epochs * nBatch # total num of batches
for epoch in range(se... | [
"def",
"_warm_up",
"(",
"self",
")",
":",
"lr_max",
"=",
"0.05",
"data_loader",
"=",
"self",
".",
"train_loader",
"nBatch",
"=",
"len",
"(",
"data_loader",
")",
"T_total",
"=",
"self",
".",
"warmup_epochs",
"*",
"nBatch",
"# total num of batches",
"for",
"ep... | [
180,
4
] | [
248,
39
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._get_update_schedule | (self, nBatch) |
Generate schedule for training architecture weights. Key means after which minibatch
to update architecture weights, value means how many steps for the update.
Parameters
----------
nBatch : int
the total number of minibatches in one epoch
Returns
-... |
Generate schedule for training architecture weights. Key means after which minibatch
to update architecture weights, value means how many steps for the update. | def _get_update_schedule(self, nBatch):
"""
Generate schedule for training architecture weights. Key means after which minibatch
to update architecture weights, value means how many steps for the update.
Parameters
----------
nBatch : int
the total number of ... | [
"def",
"_get_update_schedule",
"(",
"self",
",",
"nBatch",
")",
":",
"schedule",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"nBatch",
")",
":",
"if",
"(",
"i",
"+",
"1",
")",
"%",
"self",
".",
"grad_update_arch_param_every",
"==",
"0",
":",
"sche... | [
250,
4
] | [
269,
23
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._calc_learning_rate | (self, epoch, batch=0, nBatch=None) |
Update learning rate.
|
Update learning rate.
| def _calc_learning_rate(self, epoch, batch=0, nBatch=None):
"""
Update learning rate.
"""
T_total = self.n_epochs * nBatch
T_cur = epoch * nBatch + batch
lr = 0.5 * self.init_lr * (1 + math.cos(math.pi * T_cur / T_total))
return lr | [
"def",
"_calc_learning_rate",
"(",
"self",
",",
"epoch",
",",
"batch",
"=",
"0",
",",
"nBatch",
"=",
"None",
")",
":",
"T_total",
"=",
"self",
".",
"n_epochs",
"*",
"nBatch",
"T_cur",
"=",
"epoch",
"*",
"nBatch",
"+",
"batch",
"lr",
"=",
"0.5",
"*",
... | [
271,
4
] | [
278,
17
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._adjust_learning_rate | (self, optimizer, epoch, batch=0, nBatch=None) |
Adjust learning of a given optimizer and return the new learning rate
Parameters
----------
optimizer : pytorch optimizer
the used optimizer
epoch : int
the current epoch number
batch : int
the current minibatch
nBatch : int
... |
Adjust learning of a given optimizer and return the new learning rate | def _adjust_learning_rate(self, optimizer, epoch, batch=0, nBatch=None):
"""
Adjust learning of a given optimizer and return the new learning rate
Parameters
----------
optimizer : pytorch optimizer
the used optimizer
epoch : int
the current epoch... | [
"def",
"_adjust_learning_rate",
"(",
"self",
",",
"optimizer",
",",
"epoch",
",",
"batch",
"=",
"0",
",",
"nBatch",
"=",
"None",
")",
":",
"new_lr",
"=",
"self",
".",
"_calc_learning_rate",
"(",
"epoch",
",",
"batch",
",",
"nBatch",
")",
"for",
"param_gr... | [
280,
4
] | [
303,
21
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._train | (self) |
Train the model, it trains model weights and architecute weights.
Architecture weights are trained according to the schedule.
Before updating architecture weights, ```requires_grad``` is enabled.
Then, it is disabled after the updating, in order not to update
architecture weight... |
Train the model, it trains model weights and architecute weights.
Architecture weights are trained according to the schedule.
Before updating architecture weights, ```requires_grad``` is enabled.
Then, it is disabled after the updating, in order not to update
architecture weight... | def _train(self):
"""
Train the model, it trains model weights and architecute weights.
Architecture weights are trained according to the schedule.
Before updating architecture weights, ```requires_grad``` is enabled.
Then, it is disabled after the updating, in order not to updat... | [
"def",
"_train",
"(",
"self",
")",
":",
"nBatch",
"=",
"len",
"(",
"self",
".",
"train_loader",
")",
"arch_param_num",
"=",
"self",
".",
"mutator",
".",
"num_arch_params",
"(",
")",
"binary_gates_num",
"=",
"self",
".",
"mutator",
".",
"num_arch_params",
"... | [
305,
4
] | [
383,
38
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._valid_next_batch | (self) |
Get next one minibatch from validation set
Returns
-------
(tensor, tensor)
the tuple of images and labels
|
Get next one minibatch from validation set | def _valid_next_batch(self):
"""
Get next one minibatch from validation set
Returns
-------
(tensor, tensor)
the tuple of images and labels
"""
if self._valid_iter is None:
self._valid_iter = iter(self.valid_loader)
try:
... | [
"def",
"_valid_next_batch",
"(",
"self",
")",
":",
"if",
"self",
".",
"_valid_iter",
"is",
"None",
":",
"self",
".",
"_valid_iter",
"=",
"iter",
"(",
"self",
".",
"valid_loader",
")",
"try",
":",
"data",
"=",
"next",
"(",
"self",
".",
"_valid_iter",
")... | [
385,
4
] | [
401,
19
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer._gradient_step | (self) |
This gradient step is for updating architecture weights.
Mutator is intensively used in this function to operate on
architecture weights.
Returns
-------
float, None
loss of the model, None
|
This gradient step is for updating architecture weights.
Mutator is intensively used in this function to operate on
architecture weights. | def _gradient_step(self):
"""
This gradient step is for updating architecture weights.
Mutator is intensively used in this function to operate on
architecture weights.
Returns
-------
float, None
loss of the model, None
"""
# use the s... | [
"def",
"_gradient_step",
"(",
"self",
")",
":",
"# use the same batch size as train batch size for architecture weights",
"self",
".",
"valid_loader",
".",
"batch_sampler",
".",
"batch_size",
"=",
"self",
".",
"train_batch_size",
"self",
".",
"valid_loader",
".",
"batch_s... | [
403,
4
] | [
441,
94
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer.save_checkpoint | (self) |
Save checkpoint of the whole model. Saving model weights and architecture weights in
```ckpt_path```, and saving currently chosen architecture in ```arch_path```.
|
Save checkpoint of the whole model. Saving model weights and architecture weights in
```ckpt_path```, and saving currently chosen architecture in ```arch_path```.
| def save_checkpoint(self):
"""
Save checkpoint of the whole model. Saving model weights and architecture weights in
```ckpt_path```, and saving currently chosen architecture in ```arch_path```.
"""
if self.ckpt_path:
state = {
'warmup_curr_epoch': self... | [
"def",
"save_checkpoint",
"(",
"self",
")",
":",
"if",
"self",
".",
"ckpt_path",
":",
"state",
"=",
"{",
"'warmup_curr_epoch'",
":",
"self",
".",
"warmup_curr_epoch",
",",
"'train_curr_epoch'",
":",
"self",
".",
"train_curr_epoch",
",",
"'model'",
":",
"self",... | [
443,
4
] | [
458,
39
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer.load_checkpoint | (self) |
Load the checkpoint from ```ckpt_path```.
|
Load the checkpoint from ```ckpt_path```.
| def load_checkpoint(self):
"""
Load the checkpoint from ```ckpt_path```.
"""
assert self.ckpt_path is not None, "If load_ckpt is not None, ckpt_path should not be None"
ckpt = torch.load(self.ckpt_path)
self.warmup_curr_epoch = ckpt['warmup_curr_epoch']
self.train... | [
"def",
"load_checkpoint",
"(",
"self",
")",
":",
"assert",
"self",
".",
"ckpt_path",
"is",
"not",
"None",
",",
"\"If load_ckpt is not None, ckpt_path should not be None\"",
"ckpt",
"=",
"torch",
".",
"load",
"(",
"self",
".",
"ckpt_path",
")",
"self",
".",
"warm... | [
460,
4
] | [
470,
63
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer.train | (self) |
Train the whole model.
|
Train the whole model.
| def train(self):
"""
Train the whole model.
"""
if self.load_ckpt:
self.load_checkpoint()
if self.warmup:
self._warm_up()
self._train() | [
"def",
"train",
"(",
"self",
")",
":",
"if",
"self",
".",
"load_ckpt",
":",
"self",
".",
"load_checkpoint",
"(",
")",
"if",
"self",
".",
"warmup",
":",
"self",
".",
"_warm_up",
"(",
")",
"self",
".",
"_train",
"(",
")"
] | [
472,
4
] | [
480,
21
] | python | en | ['en', 'error', 'th'] | False |
ProxylessNasTrainer.export | (self, file_name) |
Export the chosen architecture into a file
Parameters
----------
file_name : str
the file that stores exported chosen architecture
|
Export the chosen architecture into a file | def export(self, file_name):
"""
Export the chosen architecture into a file
Parameters
----------
file_name : str
the file that stores exported chosen architecture
"""
exported_arch = self.mutator.sample_final()
with open(file_name, 'w') as f:... | [
"def",
"export",
"(",
"self",
",",
"file_name",
")",
":",
"exported_arch",
"=",
"self",
".",
"mutator",
".",
"sample_final",
"(",
")",
"with",
"open",
"(",
"file_name",
",",
"'w'",
")",
"as",
"f",
":",
"json",
".",
"dump",
"(",
"exported_arch",
",",
... | [
482,
4
] | [
493,
89
] | python | en | ['en', 'error', 'th'] | False |
test_setup_entry | (hass: HomeAssistant) | Validate that setup entry also configure the client. | Validate that setup entry also configure the client. | async def test_setup_entry(hass: HomeAssistant):
"""Validate that setup entry also configure the client."""
id = str(uuid4())
config_entry = MockConfigEntry(
domain=TWINKLY_DOMAIN,
data={
CONF_ENTRY_HOST: TEST_HOST,
CONF_ENTRY_ID: id,
CONF_ENTRY_NAME: TES... | [
"async",
"def",
"test_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"id",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"TWINKLY_DOMAIN",
",",
"data",
"=",
"{",
"CONF_ENTRY_HOST",
":",
"TE... | [
19,
0
] | [
43,
52
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass: HomeAssistant) | Validate that unload entry also clear the client. | Validate that unload entry also clear the client. | async def test_unload_entry(hass: HomeAssistant):
"""Validate that unload entry also clear the client."""
id = str(uuid4())
config_entry = MockConfigEntry(
domain=TWINKLY_DOMAIN,
data={
CONF_ENTRY_HOST: TEST_HOST,
CONF_ENTRY_ID: id,
CONF_ENTRY_NAME: TEST_... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"id",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"config_entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"TWINKLY_DOMAIN",
",",
"data",
"=",
"{",
"CONF_ENTRY_HOST",
":",
"T... | [
46,
0
] | [
66,
52
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Create the Elk-M1 switch platform. | Create the Elk-M1 switch platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Create the Elk-M1 switch platform."""
elk_data = hass.data[DOMAIN][config_entry.entry_id]
entities = []
elk = elk_data["elk"]
create_elk_entities(elk_data, elk.outputs, "output", ElkOutput, entities)
async_add_entities(entit... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"elk_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"entities",
"=",
"[",
"]",
"elk",
"=",
"elk_dat... | [
7,
0
] | [
13,
38
] | python | en | ['en', 'de', 'en'] | True |
ElkOutput.is_on | (self) | Get the current output status. | Get the current output status. | def is_on(self) -> bool:
"""Get the current output status."""
return self._element.output_on | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_element",
".",
"output_on"
] | [
20,
4
] | [
22,
38
] | python | en | ['en', 'en', 'en'] | True |
ElkOutput.async_turn_on | (self, **kwargs) | Turn on the output. | Turn on the output. | async def async_turn_on(self, **kwargs):
"""Turn on the output."""
self._element.turn_on(0) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_element",
".",
"turn_on",
"(",
"0",
")"
] | [
24,
4
] | [
26,
32
] | python | en | ['en', 'en', 'en'] | True |
ElkOutput.async_turn_off | (self, **kwargs) | Turn off the output. | Turn off the output. | async def async_turn_off(self, **kwargs):
"""Turn off the output."""
self._element.turn_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_element",
".",
"turn_off",
"(",
")"
] | [
28,
4
] | [
30,
32
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up lights for KNX platform. | Set up lights for KNX platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up lights for KNX platform."""
entities = []
for device in hass.data[DOMAIN].xknx.devices:
if isinstance(device, XknxLight):
entities.append(KNXLight(device))
async_add_entities(entities) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"entities",
"=",
"[",
"]",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"xknx",
".",
"dev... | [
24,
0
] | [
30,
32
] | python | en | ['en', 'da', 'en'] | True |
KNXLight.__init__ | (self, device: XknxLight) | Initialize of KNX light. | Initialize of KNX light. | def __init__(self, device: XknxLight):
"""Initialize of KNX light."""
super().__init__(device)
self._min_kelvin = device.min_kelvin
self._max_kelvin = device.max_kelvin
self._min_mireds = color_util.color_temperature_kelvin_to_mired(
self._max_kelvin
)
... | [
"def",
"__init__",
"(",
"self",
",",
"device",
":",
"XknxLight",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")",
"self",
".",
"_min_kelvin",
"=",
"device",
".",
"min_kelvin",
"self",
".",
"_max_kelvin",
"=",
"device",
".",
"max_kelvin",... | [
36,
4
] | [
47,
9
] | python | en | ['en', 'en', 'en'] | True |
KNXLight.brightness | (self) | Return the brightness of this light between 0..255. | Return the brightness of this light between 0..255. | def brightness(self):
"""Return the brightness of this light between 0..255."""
if self._device.supports_brightness:
return self._device.current_brightness
hsv_color = self._hsv_color
if self._device.supports_color and hsv_color:
return round(hsv_color[-1] / 100 *... | [
"def",
"brightness",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"supports_brightness",
":",
"return",
"self",
".",
"_device",
".",
"current_brightness",
"hsv_color",
"=",
"self",
".",
"_hsv_color",
"if",
"self",
".",
"_device",
".",
"supports_... | [
50,
4
] | [
57,
19
] | python | en | ['en', 'en', 'en'] | True |
KNXLight.hs_color | (self) | Return the HS color value. | Return the HS color value. | def hs_color(self):
"""Return the HS color value."""
rgb = None
if self._device.supports_rgbw or self._device.supports_color:
rgb, _ = self._device.current_color
return color_util.color_RGB_to_hs(*rgb) if rgb else None | [
"def",
"hs_color",
"(",
"self",
")",
":",
"rgb",
"=",
"None",
"if",
"self",
".",
"_device",
".",
"supports_rgbw",
"or",
"self",
".",
"_device",
".",
"supports_color",
":",
"rgb",
",",
"_",
"=",
"self",
".",
"_device",
".",
"current_color",
"return",
"c... | [
60,
4
] | [
65,
64
] | python | en | ['en', 'en', 'en'] | True |
KNXLight._hsv_color | (self) | Return the HSV color value. | Return the HSV color value. | def _hsv_color(self):
"""Return the HSV color value."""
rgb = None
if self._device.supports_rgbw or self._device.supports_color:
rgb, _ = self._device.current_color
return color_util.color_RGB_to_hsv(*rgb) if rgb else None | [
"def",
"_hsv_color",
"(",
"self",
")",
":",
"rgb",
"=",
"None",
"if",
"self",
".",
"_device",
".",
"supports_rgbw",
"or",
"self",
".",
"_device",
".",
"supports_color",
":",
"rgb",
",",
"_",
"=",
"self",
".",
"_device",
".",
"current_color",
"return",
... | [
68,
4
] | [
73,
65
] | python | en | ['en', 'en', 'en'] | True |
KNXLight.white_value | (self) | Return the white value. | Return the white value. | def white_value(self):
"""Return the white value."""
white = None
if self._device.supports_rgbw:
_, white = self._device.current_color
return white | [
"def",
"white_value",
"(",
"self",
")",
":",
"white",
"=",
"None",
"if",
"self",
".",
"_device",
".",
"supports_rgbw",
":",
"_",
",",
"white",
"=",
"self",
".",
"_device",
".",
"current_color",
"return",
"white"
] | [
76,
4
] | [
81,
20
] | python | en | ['en', 'no', 'en'] | True |
KNXLight.color_temp | (self) | Return the color temperature in mireds. | Return the color temperature in mireds. | def color_temp(self):
"""Return the color temperature in mireds."""
if self._device.supports_color_temperature:
kelvin = self._device.current_color_temperature
if kelvin is not None:
return color_util.color_temperature_kelvin_to_mired(kelvin)
if self._devi... | [
"def",
"color_temp",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
".",
"supports_color_temperature",
":",
"kelvin",
"=",
"self",
".",
"_device",
".",
"current_color_temperature",
"if",
"kelvin",
"is",
"not",
"None",
":",
"return",
"color_util",
".",
... | [
84,
4
] | [
99,
19
] | python | en | ['en', 'en', 'en'] | True |
KNXLight.min_mireds | (self) | Return the coldest color temp this light supports in mireds. | Return the coldest color temp this light supports in mireds. | def min_mireds(self):
"""Return the coldest color temp this light supports in mireds."""
return self._min_mireds | [
"def",
"min_mireds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_min_mireds"
] | [
102,
4
] | [
104,
31
] | python | en | ['en', 'en', 'en'] | True |
KNXLight.max_mireds | (self) | Return the warmest color temp this light supports in mireds. | Return the warmest color temp this light supports in mireds. | def max_mireds(self):
"""Return the warmest color temp this light supports in mireds."""
return self._max_mireds | [
"def",
"max_mireds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_max_mireds"
] | [
107,
4
] | [
109,
31
] | python | en | ['en', 'en', 'en'] | True |
KNXLight.effect_list | (self) | Return the list of supported effects. | Return the list of supported effects. | def effect_list(self):
"""Return the list of supported effects."""
return None | [
"def",
"effect_list",
"(",
"self",
")",
":",
"return",
"None"
] | [
112,
4
] | [
114,
19
] | python | en | ['en', 'en', 'en'] | True |
KNXLight.effect | (self) | Return the current effect. | Return the current effect. | def effect(self):
"""Return the current effect."""
return None | [
"def",
"effect",
"(",
"self",
")",
":",
"return",
"None"
] | [
117,
4
] | [
119,
19
] | python | en | ['en', 'en', 'en'] | True |
KNXLight.is_on | (self) | Return true if light is on. | Return true if light is on. | def is_on(self):
"""Return true if light is on."""
return self._device.state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device",
".",
"state"
] | [
122,
4
] | [
124,
33
] | python | en | ['en', 'et', 'en'] | True |
KNXLight.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
flags = 0
if self._device.supports_brightness:
flags |= SUPPORT_BRIGHTNESS
if self._device.supports_color:
flags |= SUPPORT_COLOR | SUPPORT_BRIGHTNESS
if self._device.supports_rgbw:
f... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"flags",
"=",
"0",
"if",
"self",
".",
"_device",
".",
"supports_brightness",
":",
"flags",
"|=",
"SUPPORT_BRIGHTNESS",
"if",
"self",
".",
"_device",
".",
"supports_color",
":",
"flags",
"|=",
"SUPPORT_COLOR",... | [
127,
4
] | [
141,
20
] | python | en | ['da', 'en', 'en'] | True |
KNXLight.async_turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | async def async_turn_on(self, **kwargs):
"""Turn the light on."""
brightness = kwargs.get(ATTR_BRIGHTNESS, self.brightness)
hs_color = kwargs.get(ATTR_HS_COLOR, self.hs_color)
white_value = kwargs.get(ATTR_WHITE_VALUE, self.white_value)
mireds = kwargs.get(ATTR_COLOR_TEMP, self.c... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"brightness",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_BRIGHTNESS",
",",
"self",
".",
"brightness",
")",
"hs_color",
"=",
"kwargs",
".",
"get",
"(",
"ATTR_HS_COLOR",
",",
"self... | [
143,
4
] | [
199,
65
] | python | en | ['en', 'et', 'en'] | True |
KNXLight.async_turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | async def async_turn_off(self, **kwargs):
"""Turn the light off."""
await self._device.set_off() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_device",
".",
"set_off",
"(",
")"
] | [
201,
4
] | [
203,
36
] | python | en | ['en', 'zh', 'en'] | True |
test_coil_switch | (hass, mock_hub, regs, expected) | Run test for given config. | Run test for given config. | async def test_coil_switch(hass, mock_hub, regs, expected):
"""Run test for given config."""
switch_name = "modbus_test_switch"
scan_interval = 5
entity_id, now, device = await setup_base_test(
switch_name,
hass,
mock_hub,
{
CONF_COILS: [
{CONF... | [
"async",
"def",
"test_coil_switch",
"(",
"hass",
",",
"mock_hub",
",",
"regs",
",",
"expected",
")",
":",
"switch_name",
"=",
"\"modbus_test_switch\"",
"scan_interval",
"=",
"5",
"entity_id",
",",
"now",
",",
"device",
"=",
"await",
"setup_base_test",
"(",
"sw... | [
50,
0
] | [
75,
5
] | python | en | ['en', 'en', 'en'] | True |
test_register_switch | (hass, mock_hub, regs, expected) | Run test for given config. | Run test for given config. | async def test_register_switch(hass, mock_hub, regs, expected):
"""Run test for given config."""
switch_name = "modbus_test_switch"
scan_interval = 5
entity_id, now, device = await setup_base_test(
switch_name,
hass,
mock_hub,
{
CONF_REGISTERS: [
... | [
"async",
"def",
"test_register_switch",
"(",
"hass",
",",
"mock_hub",
",",
"regs",
",",
"expected",
")",
":",
"switch_name",
"=",
"\"modbus_test_switch\"",
"scan_interval",
"=",
"5",
"entity_id",
",",
"now",
",",
"device",
"=",
"await",
"setup_base_test",
"(",
... | [
103,
0
] | [
134,
5
] | python | en | ['en', 'en', 'en'] | True |
test_register_state_switch | (hass, mock_hub, regs, expected) | Run test for given config. | Run test for given config. | async def test_register_state_switch(hass, mock_hub, regs, expected):
"""Run test for given config."""
switch_name = "modbus_test_switch"
scan_interval = 5
entity_id, now, device = await setup_base_test(
switch_name,
hass,
mock_hub,
{
CONF_REGISTERS: [
... | [
"async",
"def",
"test_register_state_switch",
"(",
"hass",
",",
"mock_hub",
",",
"regs",
",",
"expected",
")",
":",
"switch_name",
"=",
"\"modbus_test_switch\"",
"scan_interval",
"=",
"5",
"entity_id",
",",
"now",
",",
"device",
"=",
"await",
"setup_base_test",
... | [
154,
0
] | [
185,
5
] | python | en | ['en', 'en', 'en'] | True |
mock_batch_timeout | (hass, monkeypatch) | Mock the event bus listener and the batch timeout for tests. | Mock the event bus listener and the batch timeout for tests. | def mock_batch_timeout(hass, monkeypatch):
"""Mock the event bus listener and the batch timeout for tests."""
hass.bus.listen = MagicMock()
monkeypatch.setattr(
f"{INFLUX_PATH}.InfluxThread.batch_timeout",
Mock(return_value=0),
) | [
"def",
"mock_batch_timeout",
"(",
"hass",
",",
"monkeypatch",
")",
":",
"hass",
".",
"bus",
".",
"listen",
"=",
"MagicMock",
"(",
")",
"monkeypatch",
".",
"setattr",
"(",
"f\"{INFLUX_PATH}.InfluxThread.batch_timeout\"",
",",
"Mock",
"(",
"return_value",
"=",
"0"... | [
39,
0
] | [
45,
5
] | python | en | ['en', 'en', 'en'] | True |
mock_client_fixture | (request) | Patch the InfluxDBClient object with mock for version under test. | Patch the InfluxDBClient object with mock for version under test. | def mock_client_fixture(request):
"""Patch the InfluxDBClient object with mock for version under test."""
if request.param == influxdb.API_VERSION_2:
client_target = f"{INFLUX_CLIENT_PATH}V2"
else:
client_target = INFLUX_CLIENT_PATH
with patch(client_target) as client:
yield cli... | [
"def",
"mock_client_fixture",
"(",
"request",
")",
":",
"if",
"request",
".",
"param",
"==",
"influxdb",
".",
"API_VERSION_2",
":",
"client_target",
"=",
"f\"{INFLUX_CLIENT_PATH}V2\"",
"else",
":",
"client_target",
"=",
"INFLUX_CLIENT_PATH",
"with",
"patch",
"(",
... | [
49,
0
] | [
57,
20
] | python | en | ['en', 'en', 'en'] | True |
get_mock_call_fixture | (request) | Get version specific lambda to make write API call mock. | Get version specific lambda to make write API call mock. | def get_mock_call_fixture(request):
"""Get version specific lambda to make write API call mock."""
def v2_call(body, precision):
data = {"bucket": DEFAULT_BUCKET, "record": body}
if precision is not None:
data["write_precision"] = precision
return call(**data)
if requ... | [
"def",
"get_mock_call_fixture",
"(",
"request",
")",
":",
"def",
"v2_call",
"(",
"body",
",",
"precision",
")",
":",
"data",
"=",
"{",
"\"bucket\"",
":",
"DEFAULT_BUCKET",
",",
"\"record\"",
":",
"body",
"}",
"if",
"precision",
"is",
"not",
"None",
":",
... | [
61,
0
] | [
75,
76
] | python | en | ['en', 'jv', 'en'] | True |
_get_write_api_mock_v1 | (mock_influx_client) | Return the write api mock for the V1 client. | Return the write api mock for the V1 client. | def _get_write_api_mock_v1(mock_influx_client):
"""Return the write api mock for the V1 client."""
return mock_influx_client.return_value.write_points | [
"def",
"_get_write_api_mock_v1",
"(",
"mock_influx_client",
")",
":",
"return",
"mock_influx_client",
".",
"return_value",
".",
"write_points"
] | [
78,
0
] | [
80,
55
] | python | en | ['en', 'no', 'en'] | True |
_get_write_api_mock_v2 | (mock_influx_client) | Return the write api mock for the V2 client. | Return the write api mock for the V2 client. | def _get_write_api_mock_v2(mock_influx_client):
"""Return the write api mock for the V2 client."""
return mock_influx_client.return_value.write_api.return_value.write | [
"def",
"_get_write_api_mock_v2",
"(",
"mock_influx_client",
")",
":",
"return",
"mock_influx_client",
".",
"return_value",
".",
"write_api",
".",
"return_value",
".",
"write"
] | [
83,
0
] | [
85,
71
] | python | en | ['en', 'no', 'en'] | True |
test_setup_config_full | (hass, mock_client, config_ext, get_write_api) | Test the setup with full configuration. | Test the setup with full configuration. | async def test_setup_config_full(hass, mock_client, config_ext, get_write_api):
"""Test the setup with full configuration."""
config = {
"influxdb": {
"host": "host",
"port": 123,
"database": "db",
"max_retries": 4,
"ssl": "False",
}
... | [
"async",
"def",
"test_setup_config_full",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"{",
"\"host\"",
":",
"\"host\"",
",",
"\"port\"",
":",
"123",
",",
"\"database\"",
":",
"\... | [
114,
0
] | [
131,
53
] | python | en | ['en', 'en', 'en'] | True |
test_setup_minimal_config | (hass, mock_client, config_ext, get_write_api) | Test the setup with minimal configuration and defaults. | Test the setup with minimal configuration and defaults. | async def test_setup_minimal_config(hass, mock_client, config_ext, get_write_api):
"""Test the setup with minimal configuration and defaults."""
config = {"influxdb": {}}
config["influxdb"].update(config_ext)
assert await async_setup_component(hass, influxdb.DOMAIN, config)
await hass.async_block_t... | [
"async",
"def",
"test_setup_minimal_config",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"{",
"}",
"}",
"config",
"[",
"\"influxdb\"",
"]",
".",
"update",
"(",
"config_ext",
")"... | [
142,
0
] | [
151,
53
] | python | en | ['en', 'en', 'en'] | True |
test_invalid_config | (hass, mock_client, config_ext, get_write_api) | Test the setup with invalid config or config options specified for wrong version. | Test the setup with invalid config or config options specified for wrong version. | async def test_invalid_config(hass, mock_client, config_ext, get_write_api):
"""Test the setup with invalid config or config options specified for wrong version."""
config = {"influxdb": {}}
config["influxdb"].update(config_ext)
assert not await async_setup_component(hass, influxdb.DOMAIN, config) | [
"async",
"def",
"test_invalid_config",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"{",
"}",
"}",
"config",
"[",
"\"influxdb\"",
"]",
".",
"update",
"(",
"config_ext",
")",
"a... | [
187,
0
] | [
192,
73
] | python | en | ['en', 'en', 'en'] | True |
_setup | (hass, mock_influx_client, config_ext, get_write_api) | Prepare client for next test and return event handler method. | Prepare client for next test and return event handler method. | async def _setup(hass, mock_influx_client, config_ext, get_write_api):
"""Prepare client for next test and return event handler method."""
config = {
"influxdb": {
"host": "host",
"exclude": {"entities": ["fake.excluded"], "domains": ["another_fake"]},
}
}
config[... | [
"async",
"def",
"_setup",
"(",
"hass",
",",
"mock_influx_client",
",",
"config_ext",
",",
"get_write_api",
")",
":",
"config",
"=",
"{",
"\"influxdb\"",
":",
"{",
"\"host\"",
":",
"\"host\"",
",",
"\"exclude\"",
":",
"{",
"\"entities\"",
":",
"[",
"\"fake.ex... | [
195,
0
] | [
209,
50
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener. | Test the event listener. | async def test_event_listener(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
# map of HA State to valid influxdb [state, value] fields
valid = {
"1": [None, 1],
... | [
"async",
"def",
"test_event_listener",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
"... | [
230,
0
] | [
295,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_no_units | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener for missing units. | Test the event listener for missing units. | async def test_event_listener_no_units(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener for missing units."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
for unit in (None, ""):
if unit:
attrs = {"unit_of_meas... | [
"async",
"def",
"test_event_listener_no_units",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_... | [
316,
0
] | [
349,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_inf | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with large or invalid numbers. | Test the event listener with large or invalid numbers. | async def test_event_listener_inf(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with large or invalid numbers."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
attrs = {"bignumstring": "9" * 999, "nonumstring": "nan"}
state ... | [
"async",
"def",
"test_event_listener_inf",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",... | [
370,
0
] | [
398,
53
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_states | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against ignored states. | Test the event listener against ignored states. | async def test_event_listener_states(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against ignored states."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
for state_state in (1, "unknown", "", "unavailable"):
state = Ma... | [
"async",
"def",
"test_event_listener_states",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_ap... | [
419,
0
] | [
451,
30
] | python | en | ['en', 'en', 'en'] | True |
execute_filter_test | (hass, tests, handler_method, write_api, get_mock_call) | Execute all tests for a given filtering test. | Execute all tests for a given filtering test. | def execute_filter_test(hass, tests, handler_method, write_api, get_mock_call):
"""Execute all tests for a given filtering test."""
for test in tests:
domain, entity_id = split_entity_id(test.id)
state = MagicMock(
state=1,
domain=domain,
entity_id=test.id,
... | [
"def",
"execute_filter_test",
"(",
"hass",
",",
"tests",
",",
"handler_method",
",",
"write_api",
",",
"get_mock_call",
")",
":",
"for",
"test",
"in",
"tests",
":",
"domain",
",",
"entity_id",
"=",
"split_entity_id",
"(",
"test",
".",
"id",
")",
"state",
"... | [
454,
0
] | [
482,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_denylist | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a denylist. | Test the event listener against a denylist. | async def test_event_listener_denylist(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a denylist."""
config = {"exclude": {"entities": ["fake.denylisted"]}, "include": {}}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, c... | [
"async",
"def",
"test_event_listener_denylist",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"exclude\"",
":",
"{",
"\"entities\"",
":",
"[",
"\"fake.denylisted\"",
"]",
"}",
",",... | [
503,
0
] | [
516,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_denylist_domain | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a domain denylist. | Test the event listener against a domain denylist. | async def test_event_listener_denylist_domain(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a domain denylist."""
config = {"exclude": {"domains": ["another_fake"]}, "include": {}}
config.update(config_ext)
handler_method = await _setup(hass, mock... | [
"async",
"def",
"test_event_listener_denylist_domain",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"exclude\"",
":",
"{",
"\"domains\"",
":",
"[",
"\"another_fake\"",
"]",
"}",
"... | [
537,
0
] | [
550,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_denylist_glob | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a glob denylist. | Test the event listener against a glob denylist. | async def test_event_listener_denylist_glob(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a glob denylist."""
config = {"exclude": {"entity_globs": ["*.excluded_*"]}, "include": {}}
config.update(config_ext)
handler_method = await _setup(hass, moc... | [
"async",
"def",
"test_event_listener_denylist_glob",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"exclude\"",
":",
"{",
"\"entity_globs\"",
":",
"[",
"\"*.excluded_*\"",
"]",
"}",
... | [
571,
0
] | [
584,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_allowlist | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against an allowlist. | Test the event listener against an allowlist. | async def test_event_listener_allowlist(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against an allowlist."""
config = {"include": {"entities": ["fake.included"]}, "exclude": {}}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, ... | [
"async",
"def",
"test_event_listener_allowlist",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"entities\"",
":",
"[",
"\"fake.included\"",
"]",
"}",
",",
... | [
605,
0
] | [
618,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_allowlist_domain | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a domain allowlist. | Test the event listener against a domain allowlist. | async def test_event_listener_allowlist_domain(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a domain allowlist."""
config = {"include": {"domains": ["fake"]}, "exclude": {}}
config.update(config_ext)
handler_method = await _setup(hass, mock_clien... | [
"async",
"def",
"test_event_listener_allowlist_domain",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"domains\"",
":",
"[",
"\"fake\"",
"]",
"}",
",",
"... | [
639,
0
] | [
652,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_allowlist_glob | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a glob allowlist. | Test the event listener against a glob allowlist. | async def test_event_listener_allowlist_glob(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a glob allowlist."""
config = {"include": {"entity_globs": ["*.included_*"]}, "exclude": {}}
config.update(config_ext)
handler_method = await _setup(hass, m... | [
"async",
"def",
"test_event_listener_allowlist_glob",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"entity_globs\"",
":",
"[",
"\"*.included_*\"",
"]",
"}",... | [
673,
0
] | [
686,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_filtered_allowlist | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against an allowlist filtered by denylist. | Test the event listener against an allowlist filtered by denylist. | async def test_event_listener_filtered_allowlist(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against an allowlist filtered by denylist."""
config = {
"include": {
"domains": ["fake"],
"entities": ["another_fake.included"],
... | [
"async",
"def",
"test_event_listener_filtered_allowlist",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"domains\"",
":",
"[",
"\"fake\"",
"]",
",",
"\"ent... | [
707,
0
] | [
736,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_filtered_denylist | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener against a domain/glob denylist with an entity id allowlist. | Test the event listener against a domain/glob denylist with an entity id allowlist. | async def test_event_listener_filtered_denylist(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener against a domain/glob denylist with an entity id allowlist."""
config = {
"include": {"entities": ["another_fake.included", "fake.excluded_pass"]},
"excl... | [
"async",
"def",
"test_event_listener_filtered_denylist",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"include\"",
":",
"{",
"\"entities\"",
":",
"[",
"\"another_fake.included\"",
","... | [
757,
0
] | [
776,
78
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_invalid_type | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener when an attribute has an invalid type. | Test the event listener when an attribute has an invalid type. | async def test_event_listener_invalid_type(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener when an attribute has an invalid type."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
# map of HA State to valid influxdb [state, value] ... | [
"async",
"def",
"test_event_listener_invalid_type",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_wr... | [
797,
0
] | [
850,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_default_measurement | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with a default measurement. | Test the event listener with a default measurement. | async def test_event_listener_default_measurement(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with a default measurement."""
config = {"default_measurement": "state"}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, config, get... | [
"async",
"def",
"test_event_listener_default_measurement",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"default_measurement\"",
":",
"\"state\"",
"}",
"config",
".",
"update",
"(",
... | [
871,
0
] | [
900,
53
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_unit_of_measurement_field | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener for unit of measurement field. | Test the event listener for unit of measurement field. | async def test_event_listener_unit_of_measurement_field(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener for unit of measurement field."""
config = {"override_measurement": "state"}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, c... | [
"async",
"def",
"test_event_listener_unit_of_measurement_field",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"override_measurement\"",
":",
"\"state\"",
"}",
"config",
".",
"update",
... | [
921,
0
] | [
951,
53
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_tags_attributes | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener when some attributes should be tags. | Test the event listener when some attributes should be tags. | async def test_event_listener_tags_attributes(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener when some attributes should be tags."""
config = {"tags_attributes": ["friendly_fake"]}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, ... | [
"async",
"def",
"test_event_listener_tags_attributes",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"tags_attributes\"",
":",
"[",
"\"friendly_fake\"",
"]",
"}",
"config",
".",
"upd... | [
972,
0
] | [
1006,
53
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_component_override_measurement | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with overridden measurements. | Test the event listener with overridden measurements. | async def test_event_listener_component_override_measurement(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with overridden measurements."""
config = {
"component_config": {
"sensor.fake_humidity": {"override_measurement": "humidity"}
}... | [
"async",
"def",
"test_event_listener_component_override_measurement",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"component_config\"",
":",
"{",
"\"sensor.fake_humidity\"",
":",
"{",
... | [
1027,
0
] | [
1072,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_component_measurement_attr | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with a different measurement_attr. | Test the event listener with a different measurement_attr. | async def test_event_listener_component_measurement_attr(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with a different measurement_attr."""
config = {
"measurement_attr": "domain__device_class",
"component_config": {
"sensor.fake_humi... | [
"async",
"def",
"test_event_listener_component_measurement_attr",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"measurement_attr\"",
":",
"\"domain__device_class\"",
",",
"\"component_confi... | [
1093,
0
] | [
1145,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_ignore_attributes | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with overridden measurements. | Test the event listener with overridden measurements. | async def test_event_listener_ignore_attributes(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with overridden measurements."""
config = {
"ignore_attributes": ["ignore"],
"component_config": {
"sensor.fake_humidity": {"ignore_attribute... | [
"async",
"def",
"test_event_listener_ignore_attributes",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"ignore_attributes\"",
":",
"[",
"\"ignore\"",
"]",
",",
"\"component_config\"",
... | [
1166,
0
] | [
1233,
30
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_ignore_attributes_overlapping_entities | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener with overridden measurements. | Test the event listener with overridden measurements. | async def test_event_listener_ignore_attributes_overlapping_entities(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener with overridden measurements."""
config = {
"component_config": {"sensor.fake": {"override_measurement": "units"}},
"component_confi... | [
"async",
"def",
"test_event_listener_ignore_attributes_overlapping_entities",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"component_config\"",
":",
"{",
"\"sensor.fake\"",
":",
"{",
"... | [
1254,
0
] | [
1287,
26
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_scheduled_write | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener retries after a write failure. | Test the event listener retries after a write failure. | async def test_event_listener_scheduled_write(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener retries after a write failure."""
config = {"max_retries": 1}
config.update(config_ext)
handler_method = await _setup(hass, mock_client, config, get_write_api)
... | [
"async",
"def",
"test_event_listener_scheduled_write",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"config",
"=",
"{",
"\"max_retries\"",
":",
"1",
"}",
"config",
".",
"update",
"(",
"config_ext",
")"... | [
1308,
0
] | [
1340,
36
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_backlog_full | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener drops old events when backlog gets full. | Test the event listener drops old events when backlog gets full. | async def test_event_listener_backlog_full(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener drops old events when backlog gets full."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
state = MagicMock(
state=1,
domai... | [
"async",
"def",
"test_event_listener_backlog_full",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_wr... | [
1361,
0
] | [
1388,
57
] | python | en | ['en', 'en', 'en'] | True |
test_event_listener_attribute_name_conflict | (
hass, mock_client, config_ext, get_write_api, get_mock_call
) | Test the event listener when an attribute conflicts with another field. | Test the event listener when an attribute conflicts with another field. | async def test_event_listener_attribute_name_conflict(
hass, mock_client, config_ext, get_write_api, get_mock_call
):
"""Test the event listener when an attribute conflicts with another field."""
handler_method = await _setup(hass, mock_client, config_ext, get_write_api)
attrs = {"value": "value_str"}
... | [
"async",
"def",
"test_event_listener_attribute_name_conflict",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
",",
"get_write_api",
",",
"get_mock_call",
")",
":",
"handler_method",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_client",
",",
"config_ext",
","... | [
1409,
0
] | [
1437,
53
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.