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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
EvolutionTunerTestCase.test_json2space | (self) | test for json2space
| test for json2space
| def test_json2space(self):
"""test for json2space
"""
json_search_space = {
"optimizer": {
"_type": "choice",
"_value": ["Adam", "SGD"]
},
"learning_rate": {
"_type": "choice",
"_value": [0.0001, ... | [
"def",
"test_json2space",
"(",
"self",
")",
":",
"json_search_space",
"=",
"{",
"\"optimizer\"",
":",
"{",
"\"_type\"",
":",
"\"choice\"",
",",
"\"_value\"",
":",
"[",
"\"Adam\"",
",",
"\"SGD\"",
"]",
"}",
",",
"\"learning_rate\"",
":",
"{",
"\"_type\"",
":"... | [
15,
4
] | [
30,
74
] | python | en | ['en', 'en', 'en'] | True |
EvolutionTunerTestCase.test_json2parameter | (self) | test for json2parameter
| test for json2parameter
| def test_json2parameter(self):
"""test for json2parameter
"""
json_search_space = {
"optimizer":{
"_type":"choice","_value":["Adam", "SGD"]
},
"learning_rate":{
"_type":"choice",
"_value":[0.0001, 0.001, 0.002, 0... | [
"def",
"test_json2parameter",
"(",
"self",
")",
":",
"json_search_space",
"=",
"{",
"\"optimizer\"",
":",
"{",
"\"_type\"",
":",
"\"choice\"",
",",
"\"_value\"",
":",
"[",
"\"Adam\"",
",",
"\"SGD\"",
"]",
"}",
",",
"\"learning_rate\"",
":",
"{",
"\"_type\"",
... | [
32,
4
] | [
53,
108
] | python | en | ['en', 'da', 'en'] | True |
AudioResampleReader.__init__ | (self, sample_factor: float) |
Resampl
:param sample_factor:
|
Resampl
:param sample_factor:
| def __init__(self, sample_factor: float):
"""
Resampl
:param sample_factor:
"""
self.sample_factor = sample_factor | [
"def",
"__init__",
"(",
"self",
",",
"sample_factor",
":",
"float",
")",
":",
"self",
".",
"sample_factor",
"=",
"sample_factor"
] | [
36,
4
] | [
41,
42
] | python | en | ['en', 'error', 'th'] | False |
AudioResampleReader.transform | (self, wav) | Do an FFT-based resample of the wav
:param wav:
:return:
| Do an FFT-based resample of the wav | def transform(self, wav):
"""Do an FFT-based resample of the wav
:param wav:
:return:
"""
num = int(len(wav) * self.sample_factor)
resample = scipy.signal.resample(wav, num)
return resample.astype(dtype=np.float32) | [
"def",
"transform",
"(",
"self",
",",
"wav",
")",
":",
"num",
"=",
"int",
"(",
"len",
"(",
"wav",
")",
"*",
"self",
".",
"sample_factor",
")",
"resample",
"=",
"scipy",
".",
"signal",
".",
"resample",
"(",
"wav",
",",
"num",
")",
"return",
"resampl... | [
43,
4
] | [
51,
48
] | python | en | ['en', 'en', 'en'] | True |
AudioTextLetterDataset.process_sample | (self, file) | Read in a line and turn it into an entry. FIXME, get from anywhere
The entries will get collated by the data loader
:param file:
:return:
| Read in a line and turn it into an entry. FIXME, get from anywhere | def process_sample(self, file):
"""Read in a line and turn it into an entry. FIXME, get from anywhere
The entries will get collated by the data loader
:param file:
:return:
"""
return self.reader.read(file) | [
"def",
"process_sample",
"(",
"self",
",",
"file",
")",
":",
"return",
"self",
".",
"reader",
".",
"read",
"(",
"file",
")"
] | [
295,
4
] | [
303,
37
] | python | en | ['en', 'en', 'en'] | True |
AudioFileDataset.process_sample | (self, file, len) | Read in a line and turn it into an entry. FIXME, get from anywhere
The entries will get collated by the data loader
:param file:
:return:
| Read in a line and turn it into an entry. FIXME, get from anywhere | def process_sample(self, file, len):
"""Read in a line and turn it into an entry. FIXME, get from anywhere
The entries will get collated by the data loader
:param file:
:return:
"""
return self.reader.read(file, len) | [
"def",
"process_sample",
"(",
"self",
",",
"file",
",",
"len",
")",
":",
"return",
"self",
".",
"reader",
".",
"read",
"(",
"file",
",",
"len",
")"
] | [
398,
4
] | [
406,
42
] | python | en | ['en', 'en', 'en'] | True |
client_fixture | () | Patch of client library for tests. | Patch of client library for tests. | def client_fixture():
"""Patch of client library for tests."""
with patch(
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR",
autospec=True,
) as mock_client_class, patch(
"homeassistant.components.denonavr.receiver.denonavr.discover"
):
mock_client_class.ret... | [
"def",
"client_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.denonavr.receiver.denonavr.DenonAVR\"",
",",
"autospec",
"=",
"True",
",",
")",
"as",
"mock_client_class",
",",
"patch",
"(",
"\"homeassistant.components.denonavr.receiver.denonavr.disco... | [
35,
0
] | [
52,
44
] | python | en | ['en', 'en', 'en'] | True |
setup_denonavr | (hass) | Initialize media_player for tests. | Initialize media_player for tests. | async def setup_denonavr(hass):
"""Initialize media_player for tests."""
entry_data = {
CONF_HOST: TEST_HOST,
CONF_MAC: TEST_MAC,
CONF_MODEL: TEST_MODEL,
CONF_TYPE: TEST_RECEIVER_TYPE,
CONF_MANUFACTURER: TEST_MANUFACTURER,
CONF_SERIAL_NUMBER: TEST_SERIALNUMBER,
... | [
"async",
"def",
"setup_denonavr",
"(",
"hass",
")",
":",
"entry_data",
"=",
"{",
"CONF_HOST",
":",
"TEST_HOST",
",",
"CONF_MAC",
":",
"TEST_MAC",
",",
"CONF_MODEL",
":",
"TEST_MODEL",
",",
"CONF_TYPE",
":",
"TEST_RECEIVER_TYPE",
",",
"CONF_MANUFACTURER",
":",
... | [
55,
0
] | [
80,
34
] | python | en | ['da', 'en', 'en'] | True |
test_get_command | (hass, client) | Test generic command functionality. | Test generic command functionality. | async def test_get_command(hass, client):
"""Test generic command functionality."""
await setup_denonavr(hass)
data = {
ATTR_ENTITY_ID: ENTITY_ID,
ATTR_COMMAND: "test_command",
}
await hass.services.async_call(DOMAIN, SERVICE_GET_COMMAND, data)
await hass.async_block_till_done()... | [
"async",
"def",
"test_get_command",
"(",
"hass",
",",
"client",
")",
":",
"await",
"setup_denonavr",
"(",
"hass",
")",
"data",
"=",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_ID",
",",
"ATTR_COMMAND",
":",
"\"test_command\"",
",",
"}",
"await",
"hass",
".",
"servic... | [
83,
0
] | [
94,
62
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up device automation. | Set up device automation. | async def async_setup(hass, config):
"""Set up device automation."""
hass.components.websocket_api.async_register_command(
websocket_device_automation_list_actions
)
hass.components.websocket_api.async_register_command(
websocket_device_automation_list_conditions
)
hass.component... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"hass",
".",
"components",
".",
"websocket_api",
".",
"async_register_command",
"(",
"websocket_device_automation_list_actions",
")",
"hass",
".",
"components",
".",
"websocket_api",
".",
"async_re... | [
48,
0
] | [
68,
15
] | python | cs | ['fr', 'cs', 'en'] | False |
async_get_device_automation_platform | (
hass: HomeAssistant, domain: str, automation_type: str
) | Load device automation platform for integration.
Throws InvalidDeviceAutomationConfig if the integration is not found or does not support device automation.
| Load device automation platform for integration. | async def async_get_device_automation_platform(
hass: HomeAssistant, domain: str, automation_type: str
) -> ModuleType:
"""Load device automation platform for integration.
Throws InvalidDeviceAutomationConfig if the integration is not found or does not support device automation.
"""
platform_name =... | [
"async",
"def",
"async_get_device_automation_platform",
"(",
"hass",
":",
"HomeAssistant",
",",
"domain",
":",
"str",
",",
"automation_type",
":",
"str",
")",
"->",
"ModuleType",
":",
"platform_name",
"=",
"TYPES",
"[",
"automation_type",
"]",
"[",
"0",
"]",
"... | [
71,
0
] | [
91,
19
] | python | da | ['es', 'da', 'en'] | False |
_async_get_device_automations_from_domain | (
hass, domain, automation_type, device_id
) | List device automations. | List device automations. | async def _async_get_device_automations_from_domain(
hass, domain, automation_type, device_id
):
"""List device automations."""
try:
platform = await async_get_device_automation_platform(
hass, domain, automation_type
)
except InvalidDeviceAutomationConfig:
return Non... | [
"async",
"def",
"_async_get_device_automations_from_domain",
"(",
"hass",
",",
"domain",
",",
"automation_type",
",",
"device_id",
")",
":",
"try",
":",
"platform",
"=",
"await",
"async_get_device_automation_platform",
"(",
"hass",
",",
"domain",
",",
"automation_type... | [
94,
0
] | [
107,
66
] | python | en | ['fr', 'en', 'en'] | True |
_async_get_device_automations | (hass, automation_type, device_id) | List device automations. | List device automations. | async def _async_get_device_automations(hass, automation_type, device_id):
"""List device automations."""
device_registry, entity_registry = await asyncio.gather(
hass.helpers.device_registry.async_get_registry(),
hass.helpers.entity_registry.async_get_registry(),
)
domains = set()
... | [
"async",
"def",
"_async_get_device_automations",
"(",
"hass",
",",
"automation_type",
",",
"device_id",
")",
":",
"device_registry",
",",
"entity_registry",
"=",
"await",
"asyncio",
".",
"gather",
"(",
"hass",
".",
"helpers",
".",
"device_registry",
".",
"async_ge... | [
110,
0
] | [
144,
22
] | python | en | ['fr', 'en', 'en'] | True |
_async_get_device_automation_capabilities | (hass, automation_type, automation) | List device automations. | List device automations. | async def _async_get_device_automation_capabilities(hass, automation_type, automation):
"""List device automations."""
try:
platform = await async_get_device_automation_platform(
hass, automation[CONF_DOMAIN], automation_type
)
except InvalidDeviceAutomationConfig:
return... | [
"async",
"def",
"_async_get_device_automation_capabilities",
"(",
"hass",
",",
"automation_type",
",",
"automation",
")",
":",
"try",
":",
"platform",
"=",
"await",
"async_get_device_automation_platform",
"(",
"hass",
",",
"automation",
"[",
"CONF_DOMAIN",
"]",
",",
... | [
147,
0
] | [
177,
23
] | python | en | ['fr', 'en', 'en'] | True |
handle_device_errors | (func) | Handle device automation errors. | Handle device automation errors. | def handle_device_errors(func):
"""Handle device automation errors."""
@wraps(func)
async def with_error_handling(hass, connection, msg):
try:
await func(hass, connection, msg)
except DeviceNotFound:
connection.send_error(
msg["id"], websocket_api.con... | [
"def",
"handle_device_errors",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"async",
"def",
"with_error_handling",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"try",
":",
"await",
"func",
"(",
"hass",
",",
"connection",
",",
"msg",
... | [
180,
0
] | [
192,
30
] | python | en | ['fr', 'en', 'en'] | True |
websocket_device_automation_list_actions | (hass, connection, msg) | Handle request for device actions. | Handle request for device actions. | async def websocket_device_automation_list_actions(hass, connection, msg):
"""Handle request for device actions."""
device_id = msg["device_id"]
actions = await _async_get_device_automations(hass, "action", device_id)
connection.send_result(msg["id"], actions) | [
"async",
"def",
"websocket_device_automation_list_actions",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"device_id",
"=",
"msg",
"[",
"\"device_id\"",
"]",
"actions",
"=",
"await",
"_async_get_device_automations",
"(",
"hass",
",",
"\"action\"",
",",
"de... | [
203,
0
] | [
207,
46
] | python | en | ['da', 'en', 'en'] | True |
websocket_device_automation_list_conditions | (hass, connection, msg) | Handle request for device conditions. | Handle request for device conditions. | async def websocket_device_automation_list_conditions(hass, connection, msg):
"""Handle request for device conditions."""
device_id = msg["device_id"]
conditions = await _async_get_device_automations(hass, "condition", device_id)
connection.send_result(msg["id"], conditions) | [
"async",
"def",
"websocket_device_automation_list_conditions",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"device_id",
"=",
"msg",
"[",
"\"device_id\"",
"]",
"conditions",
"=",
"await",
"_async_get_device_automations",
"(",
"hass",
",",
"\"condition\"",
"... | [
218,
0
] | [
222,
49
] | python | en | ['da', 'en', 'en'] | True |
websocket_device_automation_list_triggers | (hass, connection, msg) | Handle request for device triggers. | Handle request for device triggers. | async def websocket_device_automation_list_triggers(hass, connection, msg):
"""Handle request for device triggers."""
device_id = msg["device_id"]
triggers = await _async_get_device_automations(hass, "trigger", device_id)
connection.send_result(msg["id"], triggers) | [
"async",
"def",
"websocket_device_automation_list_triggers",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"device_id",
"=",
"msg",
"[",
"\"device_id\"",
"]",
"triggers",
"=",
"await",
"_async_get_device_automations",
"(",
"hass",
",",
"\"trigger\"",
",",
... | [
233,
0
] | [
237,
47
] | python | en | ['da', 'en', 'en'] | True |
websocket_device_automation_get_action_capabilities | (hass, connection, msg) | Handle request for device action capabilities. | Handle request for device action capabilities. | async def websocket_device_automation_get_action_capabilities(hass, connection, msg):
"""Handle request for device action capabilities."""
action = msg["action"]
capabilities = await _async_get_device_automation_capabilities(
hass, "action", action
)
connection.send_result(msg["id"], capabil... | [
"async",
"def",
"websocket_device_automation_get_action_capabilities",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"action",
"=",
"msg",
"[",
"\"action\"",
"]",
"capabilities",
"=",
"await",
"_async_get_device_automation_capabilities",
"(",
"hass",
",",
"\"a... | [
248,
0
] | [
254,
51
] | python | en | ['ro', 'en', 'en'] | True |
websocket_device_automation_get_condition_capabilities | (hass, connection, msg) | Handle request for device condition capabilities. | Handle request for device condition capabilities. | async def websocket_device_automation_get_condition_capabilities(hass, connection, msg):
"""Handle request for device condition capabilities."""
condition = msg["condition"]
capabilities = await _async_get_device_automation_capabilities(
hass, "condition", condition
)
connection.send_result(... | [
"async",
"def",
"websocket_device_automation_get_condition_capabilities",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"condition",
"=",
"msg",
"[",
"\"condition\"",
"]",
"capabilities",
"=",
"await",
"_async_get_device_automation_capabilities",
"(",
"hass",
",... | [
265,
0
] | [
271,
51
] | python | en | ['ro', 'en', 'en'] | True |
websocket_device_automation_get_trigger_capabilities | (hass, connection, msg) | Handle request for device trigger capabilities. | Handle request for device trigger capabilities. | async def websocket_device_automation_get_trigger_capabilities(hass, connection, msg):
"""Handle request for device trigger capabilities."""
trigger = msg["trigger"]
capabilities = await _async_get_device_automation_capabilities(
hass, "trigger", trigger
)
connection.send_result(msg["id"], c... | [
"async",
"def",
"websocket_device_automation_get_trigger_capabilities",
"(",
"hass",
",",
"connection",
",",
"msg",
")",
":",
"trigger",
"=",
"msg",
"[",
"\"trigger\"",
"]",
"capabilities",
"=",
"await",
"_async_get_device_automation_capabilities",
"(",
"hass",
",",
"... | [
282,
0
] | [
288,
51
] | python | en | ['da', 'en', 'en'] | True |
async_setup_entity_json | (
hass, config: ConfigType, async_add_entities, config_entry, discovery_data
) | Set up a MQTT JSON Light. | Set up a MQTT JSON Light. | async def async_setup_entity_json(
hass, config: ConfigType, async_add_entities, config_entry, discovery_data
):
"""Set up a MQTT JSON Light."""
async_add_entities([MqttLightJson(config, config_entry, discovery_data)]) | [
"async",
"def",
"async_setup_entity_json",
"(",
"hass",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"config_entry",
",",
"discovery_data",
")",
":",
"async_add_entities",
"(",
"[",
"MqttLightJson",
"(",
"config",
",",
"config_entry",
",",
"di... | [
126,
0
] | [
130,
77
] | python | en | ['en', 'lb', 'en'] | True |
MqttLightJson.__init__ | (self, config, config_entry, discovery_data) | Initialize MQTT JSON light. | Initialize MQTT JSON light. | def __init__(self, config, config_entry, discovery_data):
"""Initialize MQTT JSON light."""
self._state = False
self._sub_state = None
self._supported_features = 0
self._topic = None
self._optimistic = False
self._brightness = None
self._color_temp = None... | [
"def",
"__init__",
"(",
"self",
",",
"config",
",",
"config_entry",
",",
"discovery_data",
")",
":",
"self",
".",
"_state",
"=",
"False",
"self",
".",
"_sub_state",
"=",
"None",
"self",
".",
"_supported_features",
"=",
"0",
"self",
".",
"_topic",
"=",
"N... | [
143,
4
] | [
167,
72
] | python | en | ['en', 'lb', 'it'] | False |
MqttLightJson.async_added_to_hass | (self) | Subscribe to MQTT events. | Subscribe to MQTT events. | async def async_added_to_hass(self):
"""Subscribe to MQTT events."""
await super().async_added_to_hass()
await self._subscribe_topics() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"await",
"self",
".",
"_subscribe_topics",
"(",
")"
] | [
169,
4
] | [
172,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.discovery_update | (self, discovery_payload) | Handle updated discovery message. | Handle updated discovery message. | async def discovery_update(self, discovery_payload):
"""Handle updated discovery message."""
config = PLATFORM_SCHEMA_JSON(discovery_payload)
self._setup_from_config(config)
await self.attributes_discovery_update(config)
await self.availability_discovery_update(config)
aw... | [
"async",
"def",
"discovery_update",
"(",
"self",
",",
"discovery_payload",
")",
":",
"config",
"=",
"PLATFORM_SCHEMA_JSON",
"(",
"discovery_payload",
")",
"self",
".",
"_setup_from_config",
"(",
"config",
")",
"await",
"self",
".",
"attributes_discovery_update",
"("... | [
174,
4
] | [
182,
35
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson._setup_from_config | (self, config) | (Re)Setup the entity. | (Re)Setup the entity. | def _setup_from_config(self, config):
"""(Re)Setup the entity."""
self._config = config
self._topic = {
key: config.get(key) for key in (CONF_STATE_TOPIC, CONF_COMMAND_TOPIC)
}
optimistic = config[CONF_OPTIMISTIC]
self._optimistic = optimistic or self._topic[... | [
"def",
"_setup_from_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_config",
"=",
"config",
"self",
".",
"_topic",
"=",
"{",
"key",
":",
"config",
".",
"get",
"(",
"key",
")",
"for",
"key",
"in",
"(",
"CONF_STATE_TOPIC",
",",
"CONF_COMMAN... | [
184,
4
] | [
206,
69
] | python | en | ['en', 'haw', 'en'] | True |
MqttLightJson._subscribe_topics | (self) | (Re)Subscribe to topics. | (Re)Subscribe to topics. | async def _subscribe_topics(self):
"""(Re)Subscribe to topics."""
last_state = await self.async_get_last_state()
@callback
@log_messages(self.hass, self.entity_id)
def state_received(msg):
"""Handle new MQTT messages."""
values = json.loads(msg.payload)
... | [
"async",
"def",
"_subscribe_topics",
"(",
"self",
")",
":",
"last_state",
"=",
"await",
"self",
".",
"async_get_last_state",
"(",
")",
"@",
"callback",
"@",
"log_messages",
"(",
"self",
".",
"hass",
",",
"self",
".",
"entity_id",
")",
"def",
"state_received"... | [
208,
4
] | [
315,
79
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.async_will_remove_from_hass | (self) | Unsubscribe when removed. | Unsubscribe when removed. | async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
self._sub_state = await subscription.async_unsubscribe_topics(
self.hass, self._sub_state
)
await MqttAttributes.async_will_remove_from_hass(self)
await MqttAvailability.async_will_remove_fro... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"self",
".",
"_sub_state",
"=",
"await",
"subscription",
".",
"async_unsubscribe_topics",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_sub_state",
")",
"await",
"MqttAttributes",
".",
"async_... | [
317,
4
] | [
324,
67
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.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."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
327,
4
] | [
329,
31
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.color_temp | (self) | Return the color temperature in mired. | Return the color temperature in mired. | def color_temp(self):
"""Return the color temperature in mired."""
return self._color_temp | [
"def",
"color_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"_color_temp"
] | [
332,
4
] | [
334,
31
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.min_mireds | (self) | Return the coldest color_temp that this light supports. | Return the coldest color_temp that this light supports. | def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
return self._config.get(CONF_MIN_MIREDS, super().min_mireds) | [
"def",
"min_mireds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_MIN_MIREDS",
",",
"super",
"(",
")",
".",
"min_mireds",
")"
] | [
337,
4
] | [
339,
68
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.max_mireds | (self) | Return the warmest color_temp that this light supports. | Return the warmest color_temp that this light supports. | def max_mireds(self):
"""Return the warmest color_temp that this light supports."""
return self._config.get(CONF_MAX_MIREDS, super().max_mireds) | [
"def",
"max_mireds",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_MAX_MIREDS",
",",
"super",
"(",
")",
".",
"max_mireds",
")"
] | [
342,
4
] | [
344,
68
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.effect | (self) | Return the current effect. | Return the current effect. | def effect(self):
"""Return the current effect."""
return self._effect | [
"def",
"effect",
"(",
"self",
")",
":",
"return",
"self",
".",
"_effect"
] | [
347,
4
] | [
349,
27
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.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 self._config.get(CONF_EFFECT_LIST) | [
"def",
"effect_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
".",
"get",
"(",
"CONF_EFFECT_LIST",
")"
] | [
352,
4
] | [
354,
49
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.hs_color | (self) | Return the hs color value. | Return the hs color value. | def hs_color(self):
"""Return the hs color value."""
return self._hs | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"self",
".",
"_hs"
] | [
357,
4
] | [
359,
23
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.white_value | (self) | Return the white property. | Return the white property. | def white_value(self):
"""Return the white property."""
return self._white_value | [
"def",
"white_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_white_value"
] | [
362,
4
] | [
364,
32
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.should_poll | (self) | No polling needed for a MQTT light. | No polling needed for a MQTT light. | def should_poll(self):
"""No polling needed for a MQTT light."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
367,
4
] | [
369,
20
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.name | (self) | Return the name of the device if any. | Return the name of the device if any. | def name(self):
"""Return the name of the device if any."""
return self._config[CONF_NAME] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_config",
"[",
"CONF_NAME",
"]"
] | [
372,
4
] | [
374,
38
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
377,
4
] | [
379,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
MqttLightJson.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
382,
4
] | [
384,
26
] | python | en | ['en', 'fy', 'en'] | True |
MqttLightJson.assumed_state | (self) | Return true if we do optimistic updates. | Return true if we do optimistic updates. | def assumed_state(self):
"""Return true if we do optimistic updates."""
return self._optimistic | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_optimistic"
] | [
387,
4
] | [
389,
31
] | python | en | ['pt', 'la', 'en'] | False |
MqttLightJson.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return self._supported_features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_supported_features"
] | [
392,
4
] | [
394,
39
] | python | en | ['da', 'en', 'en'] | True |
MqttLightJson.async_turn_on | (self, **kwargs) | Turn the device on.
This method is a coroutine.
| Turn the device on. | async def async_turn_on(self, **kwargs):
"""Turn the device on.
This method is a coroutine.
"""
should_update = False
message = {"state": "ON"}
if ATTR_HS_COLOR in kwargs and (
self._config[CONF_HS] or self._config[CONF_RGB] or self._config[CONF_XY]
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"should_update",
"=",
"False",
"message",
"=",
"{",
"\"state\"",
":",
"\"ON\"",
"}",
"if",
"ATTR_HS_COLOR",
"in",
"kwargs",
"and",
"(",
"self",
".",
"_config",
"[",
"CONF_HS... | [
396,
4
] | [
495,
39
] | python | en | ['en', 'en', 'en'] | True |
MqttLightJson.async_turn_off | (self, **kwargs) | Turn the device off.
This method is a coroutine.
| Turn the device off. | async def async_turn_off(self, **kwargs):
"""Turn the device off.
This method is a coroutine.
"""
message = {"state": "OFF"}
if ATTR_TRANSITION in kwargs:
message["transition"] = kwargs[ATTR_TRANSITION]
mqtt.async_publish(
self.hass,
... | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"message",
"=",
"{",
"\"state\"",
":",
"\"OFF\"",
"}",
"if",
"ATTR_TRANSITION",
"in",
"kwargs",
":",
"message",
"[",
"\"transition\"",
"]",
"=",
"kwargs",
"[",
"ATTR_TRANSITI... | [
497,
4
] | [
518,
39
] | python | en | ['en', 'en', 'en'] | True |
test_async_match_state | () | Test async_match_state helper. | Test async_match_state helper. | def test_async_match_state():
"""Test async_match_state helper."""
state1 = State("light.kitchen", "on")
state2 = State("switch.kitchen", "on")
state = intent.async_match_state(None, "kitch", [state1, state2])
assert state is state1 | [
"def",
"test_async_match_state",
"(",
")",
":",
"state1",
"=",
"State",
"(",
"\"light.kitchen\"",
",",
"\"on\"",
")",
"state2",
"=",
"State",
"(",
"\"switch.kitchen\"",
",",
"\"on\"",
")",
"state",
"=",
"intent",
".",
"async_match_state",
"(",
"None",
",",
"... | [
17,
0
] | [
23,
26
] | python | en | ['en', 'cy', 'en'] | True |
test_async_validate_slots | () | Test async_validate_slots of IntentHandler. | Test async_validate_slots of IntentHandler. | def test_async_validate_slots():
"""Test async_validate_slots of IntentHandler."""
handler1 = MockIntentHandler({vol.Required("name"): cv.string})
with pytest.raises(vol.error.MultipleInvalid):
handler1.async_validate_slots({})
with pytest.raises(vol.error.MultipleInvalid):
handler1.asy... | [
"def",
"test_async_validate_slots",
"(",
")",
":",
"handler1",
"=",
"MockIntentHandler",
"(",
"{",
"vol",
".",
"Required",
"(",
"\"name\"",
")",
":",
"cv",
".",
"string",
"}",
")",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"error",
".",
"Multiple... | [
26,
0
] | [
39,
5
] | python | en | ['en', 'en', 'en'] | True |
MockIntentHandler.__init__ | (self, slot_schema) | Initialize the mock handler. | Initialize the mock handler. | def __init__(self, slot_schema):
"""Initialize the mock handler."""
self.slot_schema = slot_schema | [
"def",
"__init__",
"(",
"self",
",",
"slot_schema",
")",
":",
"self",
".",
"slot_schema",
"=",
"slot_schema"
] | [
12,
4
] | [
14,
38
] | python | en | ['en', 'en', 'en'] | True |
Wav2Vec2CTCTokenizer.word_delimiter_token | (self) |
:obj:`str`: Word delimiter token. Log an error if used while not having been set.
|
:obj:`str`: Word delimiter token. Log an error if used while not having been set.
| def word_delimiter_token(self) -> str:
"""
:obj:`str`: Word delimiter token. Log an error if used while not having been set.
"""
if self._word_delimiter_token is None and self.verbose:
logger.error("Using word_delimiter_token, but it is not set yet.")
return None
... | [
"def",
"word_delimiter_token",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_word_delimiter_token",
"is",
"None",
"and",
"self",
".",
"verbose",
":",
"logger",
".",
"error",
"(",
"\"Using word_delimiter_token, but it is not set yet.\"",
")",
"return",
"... | [
145,
4
] | [
152,
46
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2CTCTokenizer.word_delimiter_token_id | (self) |
:obj:`Optional[int]`: Id of the word_delimiter_token in the vocabulary. Returns :obj:`None` if the token has
not been set.
|
:obj:`Optional[int]`: Id of the word_delimiter_token in the vocabulary. Returns :obj:`None` if the token has
not been set.
| def word_delimiter_token_id(self) -> Optional[int]:
"""
:obj:`Optional[int]`: Id of the word_delimiter_token in the vocabulary. Returns :obj:`None` if the token has
not been set.
"""
if self._word_delimiter_token is None:
return None
return self.convert_tokens... | [
"def",
"word_delimiter_token_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"self",
".",
"_word_delimiter_token",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"convert_tokens_to_ids",
"(",
"self",
".",
"word_delimiter_token",... | [
155,
4
] | [
162,
68
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2CTCTokenizer._tokenize | (self, text, **kwargs) |
Converts a string in a sequence of tokens (string), using the tokenizer.
|
Converts a string in a sequence of tokens (string), using the tokenizer.
| def _tokenize(self, text, **kwargs):
"""
Converts a string in a sequence of tokens (string), using the tokenizer.
"""
if self.do_lower_case:
text = text.upper()
return list(text.replace(" ", self.word_delimiter_token)) | [
"def",
"_tokenize",
"(",
"self",
",",
"text",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"do_lower_case",
":",
"text",
"=",
"text",
".",
"upper",
"(",
")",
"return",
"list",
"(",
"text",
".",
"replace",
"(",
"\" \"",
",",
"self",
".",
... | [
179,
4
] | [
186,
65
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2CTCTokenizer._convert_token_to_id | (self, token: str) | Converts a token (str) in an index (integer) using the vocab. | Converts a token (str) in an index (integer) using the vocab. | def _convert_token_to_id(self, token: str) -> int:
"""Converts a token (str) in an index (integer) using the vocab."""
return self.encoder.get(token, self.encoder.get(self.unk_token)) | [
"def",
"_convert_token_to_id",
"(",
"self",
",",
"token",
":",
"str",
")",
"->",
"int",
":",
"return",
"self",
".",
"encoder",
".",
"get",
"(",
"token",
",",
"self",
".",
"encoder",
".",
"get",
"(",
"self",
".",
"unk_token",
")",
")"
] | [
188,
4
] | [
190,
72
] | python | en | ['en', 'en', 'en'] | True |
Wav2Vec2CTCTokenizer._convert_id_to_token | (self, index: int) | Converts an index (integer) in a token (str) using the vocab. | Converts an index (integer) in a token (str) using the vocab. | def _convert_id_to_token(self, index: int) -> str:
"""Converts an index (integer) in a token (str) using the vocab."""
result = self.decoder.get(index, self.unk_token)
return result | [
"def",
"_convert_id_to_token",
"(",
"self",
",",
"index",
":",
"int",
")",
"->",
"str",
":",
"result",
"=",
"self",
".",
"decoder",
".",
"get",
"(",
"index",
",",
"self",
".",
"unk_token",
")",
"return",
"result"
] | [
192,
4
] | [
195,
21
] | python | en | ['en', 'en', 'en'] | True |
Wav2Vec2CTCTokenizer.convert_tokens_to_string | (
self, tokens: List[str], group_tokens: bool = True, spaces_between_special_tokens: bool = False
) |
Converts a connectionist-temporal-classification (CTC) output tokens into a single string.
|
Converts a connectionist-temporal-classification (CTC) output tokens into a single string.
| def convert_tokens_to_string(
self, tokens: List[str], group_tokens: bool = True, spaces_between_special_tokens: bool = False
) -> str:
"""
Converts a connectionist-temporal-classification (CTC) output tokens into a single string.
"""
# group same tokens into non-repeating to... | [
"def",
"convert_tokens_to_string",
"(",
"self",
",",
"tokens",
":",
"List",
"[",
"str",
"]",
",",
"group_tokens",
":",
"bool",
"=",
"True",
",",
"spaces_between_special_tokens",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"# group same tokens into non-repe... | [
197,
4
] | [
222,
21
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2CTCTokenizer._decode | (
self,
token_ids: List[int],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
group_tokens: bool = True,
spaces_between_special_tokens: bool = False,
) |
special _decode function is needed for Wav2Vec2Tokenizer because added tokens should be treated exactly the
same as tokens of the base vocabulary and therefore the function `convert_tokens_to_string` has to be called on
the whole token list and not individually on added tokens
|
special _decode function is needed for Wav2Vec2Tokenizer because added tokens should be treated exactly the
same as tokens of the base vocabulary and therefore the function `convert_tokens_to_string` has to be called on
the whole token list and not individually on added tokens
| def _decode(
self,
token_ids: List[int],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
group_tokens: bool = True,
spaces_between_special_tokens: bool = False,
) -> str:
"""
special _decode function is needed for Wav2Vec2... | [
"def",
"_decode",
"(",
"self",
",",
"token_ids",
":",
"List",
"[",
"int",
"]",
",",
"skip_special_tokens",
":",
"bool",
"=",
"False",
",",
"clean_up_tokenization_spaces",
":",
"bool",
"=",
"True",
",",
"group_tokens",
":",
"bool",
"=",
"True",
",",
"spaces... | [
229,
4
] | [
258,
23
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2Tokenizer.word_delimiter_token | (self) |
:obj:`str`: Padding token. Log an error if used while not having been set.
|
:obj:`str`: Padding token. Log an error if used while not having been set.
| def word_delimiter_token(self) -> str:
"""
:obj:`str`: Padding token. Log an error if used while not having been set.
"""
if self._word_delimiter_token is None and self.verbose:
logger.error("Using word_delimiter_token, but it is not set yet.")
return None
... | [
"def",
"word_delimiter_token",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_word_delimiter_token",
"is",
"None",
"and",
"self",
".",
"verbose",
":",
"logger",
".",
"error",
"(",
"\"Using word_delimiter_token, but it is not set yet.\"",
")",
"return",
"... | [
371,
4
] | [
378,
46
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2Tokenizer.word_delimiter_token_id | (self) |
:obj:`Optional[int]`: Id of the word_delimiter_token in the vocabulary. Returns :obj:`None` if the token has
not been set.
|
:obj:`Optional[int]`: Id of the word_delimiter_token in the vocabulary. Returns :obj:`None` if the token has
not been set.
| def word_delimiter_token_id(self) -> Optional[int]:
"""
:obj:`Optional[int]`: Id of the word_delimiter_token in the vocabulary. Returns :obj:`None` if the token has
not been set.
"""
if self._word_delimiter_token is None:
return None
return self.convert_tokens... | [
"def",
"word_delimiter_token_id",
"(",
"self",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"self",
".",
"_word_delimiter_token",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"convert_tokens_to_ids",
"(",
"self",
".",
"word_delimiter_token",... | [
381,
4
] | [
388,
68
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2Tokenizer.__call__ | (
self,
raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],
padding: Union[bool, str, PaddingStrategy] = False,
max_length: Optional[int] = None,
pad_to_multiple_of: Optional[int] = None,
return_tensors: Optional[Union[str, TensorType]] = None... |
Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences.
Args:
raw_speech (:obj:`np.ndarray`, :obj:`List[float]`, :obj:`List[np.ndarray]`, :obj:`List[List[float]]`):
The sequence or batch of sequences to be... |
Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences. | def __call__(
self,
raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],
padding: Union[bool, str, PaddingStrategy] = False,
max_length: Optional[int] = None,
pad_to_multiple_of: Optional[int] = None,
return_tensors: Optional[Union[str, TensorT... | [
"def",
"__call__",
"(",
"self",
",",
"raw_speech",
":",
"Union",
"[",
"np",
".",
"ndarray",
",",
"List",
"[",
"float",
"]",
",",
"List",
"[",
"np",
".",
"ndarray",
"]",
",",
"List",
"[",
"List",
"[",
"float",
"]",
"]",
"]",
",",
"padding",
":",
... | [
399,
4
] | [
451,
28
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2Tokenizer._convert_token_to_id | (self, token: str) | Converts a token (str) in an index (integer) using the vocab. | Converts a token (str) in an index (integer) using the vocab. | def _convert_token_to_id(self, token: str) -> int:
"""Converts a token (str) in an index (integer) using the vocab."""
return self.encoder.get(token, self.encoder.get(self.unk_token)) | [
"def",
"_convert_token_to_id",
"(",
"self",
",",
"token",
":",
"str",
")",
"->",
"int",
":",
"return",
"self",
".",
"encoder",
".",
"get",
"(",
"token",
",",
"self",
".",
"encoder",
".",
"get",
"(",
"self",
".",
"unk_token",
")",
")"
] | [
460,
4
] | [
462,
72
] | python | en | ['en', 'en', 'en'] | True |
Wav2Vec2Tokenizer._convert_id_to_token | (self, index: int) | Converts an index (integer) in a token (str) using the vocab. | Converts an index (integer) in a token (str) using the vocab. | def _convert_id_to_token(self, index: int) -> str:
"""Converts an index (integer) in a token (str) using the vocab."""
result = self.decoder.get(index, self.unk_token)
return result | [
"def",
"_convert_id_to_token",
"(",
"self",
",",
"index",
":",
"int",
")",
"->",
"str",
":",
"result",
"=",
"self",
".",
"decoder",
".",
"get",
"(",
"index",
",",
"self",
".",
"unk_token",
")",
"return",
"result"
] | [
464,
4
] | [
467,
21
] | python | en | ['en', 'en', 'en'] | True |
Wav2Vec2Tokenizer.convert_tokens_to_string | (self, tokens: List[str]) |
Converts a connectionist-temporal-classification (CTC) output tokens into a single string.
|
Converts a connectionist-temporal-classification (CTC) output tokens into a single string.
| def convert_tokens_to_string(self, tokens: List[str]) -> str:
"""
Converts a connectionist-temporal-classification (CTC) output tokens into a single string.
"""
# group same tokens into non-repeating tokens in CTC style decoding
grouped_tokens = [token_group[0] for token_group in... | [
"def",
"convert_tokens_to_string",
"(",
"self",
",",
"tokens",
":",
"List",
"[",
"str",
"]",
")",
"->",
"str",
":",
"# group same tokens into non-repeating tokens in CTC style decoding",
"grouped_tokens",
"=",
"[",
"token_group",
"[",
"0",
"]",
"for",
"token_group",
... | [
469,
4
] | [
484,
21
] | python | en | ['en', 'error', 'th'] | False |
Wav2Vec2Tokenizer._decode | (
self,
token_ids: List[int],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
**kwargs
) |
special _decode function is needed for Wav2Vec2Tokenizer because added tokens should be treated exactly the
same as tokens of the base vocabulary and therefore the function `convert_tokens_to_string` has to be called on
the whole token list and not individually on added tokens
|
special _decode function is needed for Wav2Vec2Tokenizer because added tokens should be treated exactly the
same as tokens of the base vocabulary and therefore the function `convert_tokens_to_string` has to be called on
the whole token list and not individually on added tokens
| def _decode(
self,
token_ids: List[int],
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: bool = True,
**kwargs
) -> str:
"""
special _decode function is needed for Wav2Vec2Tokenizer because added tokens should be treated exactly the
sa... | [
"def",
"_decode",
"(",
"self",
",",
"token_ids",
":",
"List",
"[",
"int",
"]",
",",
"skip_special_tokens",
":",
"bool",
"=",
"False",
",",
"clean_up_tokenization_spaces",
":",
"bool",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
"->",
"str",
":",
"filtered... | [
486,
4
] | [
512,
23
] | python | en | ['en', 'error', 'th'] | False |
setup | (hass, config) | Set up the w800rf32 component. | Set up the w800rf32 component. | def setup(hass, config):
"""Set up the w800rf32 component."""
# Declare the Handle event
def handle_receive(event):
"""Handle received messages from w800rf32 gateway."""
# Log event
if not event.device:
return
_LOGGER.debug("Receive W800rf32 event in handle_recei... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"# Declare the Handle event",
"def",
"handle_receive",
"(",
"event",
")",
":",
"\"\"\"Handle received messages from w800rf32 gateway.\"\"\"",
"# Log event",
"if",
"not",
"event",
".",
"device",
":",
"return",
"_LOG... | [
26,
0
] | [
59,
15
] | python | en | ['en', 'en', 'en'] | True |
get_key_fingerprint | () | Get identifier for CloudWatch agent's key. | Get identifier for CloudWatch agent's key. | def get_key_fingerprint():
"""Get identifier for CloudWatch agent's key."""
keys = gnupg.GPG().list_keys(keys='Amazon CloudWatch Agent')
for key in keys:
if "Amazon CloudWatch Agent" in key.get("uids"):
return key.get("fingerprint")
sys.exit("Unable to get CloudWatch Agent's public k... | [
"def",
"get_key_fingerprint",
"(",
")",
":",
"keys",
"=",
"gnupg",
".",
"GPG",
"(",
")",
".",
"list_keys",
"(",
"keys",
"=",
"'Amazon CloudWatch Agent'",
")",
"for",
"key",
"in",
"keys",
":",
"if",
"\"Amazon CloudWatch Agent\"",
"in",
"key",
".",
"get",
"(... | [
11,
0
] | [
17,
72
] | python | en | ['en', 'en', 'en'] | True |
main | () | Run the script. | Run the script. | def main():
"""Run the script."""
fingerprint = get_key_fingerprint()
if fingerprint != EXPECTED_FINGERPRINT:
sys.exit(
'Observed fingerprint of cloudwatch agent public key ({observed}) '
'does not match expected fingerprint ({expected}).'
.format(observed=fingerp... | [
"def",
"main",
"(",
")",
":",
"fingerprint",
"=",
"get_key_fingerprint",
"(",
")",
"if",
"fingerprint",
"!=",
"EXPECTED_FINGERPRINT",
":",
"sys",
".",
"exit",
"(",
"'Observed fingerprint of cloudwatch agent public key ({observed}) '",
"'does not match expected fingerprint ({e... | [
20,
0
] | [
28,
9
] | python | en | ['en', 'co', 'en'] | True |
mock_cases | () | Mock coronavirus cases. | Mock coronavirus cases. | def mock_cases():
"""Mock coronavirus cases."""
with patch(
"coronavirus.get_cases",
return_value=[
Mock(country="Netherlands", confirmed=10, recovered=8, deaths=1, current=1),
Mock(country="Germany", confirmed=1, recovered=0, deaths=0, current=0),
Mock(
... | [
"def",
"mock_cases",
"(",
")",
":",
"with",
"patch",
"(",
"\"coronavirus.get_cases\"",
",",
"return_value",
"=",
"[",
"Mock",
"(",
"country",
"=",
"\"Netherlands\"",
",",
"confirmed",
"=",
"10",
",",
"recovered",
"=",
"8",
",",
"deaths",
"=",
"1",
",",
"... | [
8,
0
] | [
24,
28
] | python | en | ['en', 'fi', 'en'] | True |
setup_component | (hass) | Initialize components. | Initialize components. | async def setup_component(hass):
"""Initialize components."""
assert await async_setup_component(
hass, remote.DOMAIN, {"remote": {"platform": "demo"}}
)
await hass.async_block_till_done() | [
"async",
"def",
"setup_component",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"remote",
".",
"DOMAIN",
",",
"{",
"\"remote\"",
":",
"{",
"\"platform\"",
":",
"\"demo\"",
"}",
"}",
")",
"await",
"hass",
".",
"async_... | [
19,
0
] | [
24,
38
] | python | en | ['de', 'en', 'en'] | False |
test_methods | (hass) | Test if services call the entity methods as expected. | Test if services call the entity methods as expected. | async def test_methods(hass):
"""Test if services call the entity methods as expected."""
await hass.services.async_call(
remote.DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: ENTITY_ID}
)
await hass.async_block_till_done()
state = hass.states.get(ENTITY_ID)
assert state.state == STATE_ON
... | [
"async",
"def",
"test_methods",
"(",
"hass",
")",
":",
"await",
"hass",
".",
"services",
".",
"async_call",
"(",
"remote",
".",
"DOMAIN",
",",
"SERVICE_TURN_ON",
",",
"{",
"ATTR_ENTITY_ID",
":",
"ENTITY_ID",
"}",
")",
"await",
"hass",
".",
"async_block_till_... | [
27,
0
] | [
62,
5
] | python | en | ['en', 'en', 'en'] | True |
download_mnist_retry | (data_dir, max_num_retries=20) | Try to download mnist dataset and avoid errors | Try to download mnist dataset and avoid errors | def download_mnist_retry(data_dir, max_num_retries=20):
"""Try to download mnist dataset and avoid errors"""
for _ in range(max_num_retries):
try:
return input_data.read_data_sets(data_dir, one_hot=True)
except tf.errors.AlreadyExistsError:
time.sleep(1)
raise Excepti... | [
"def",
"download_mnist_retry",
"(",
"data_dir",
",",
"max_num_retries",
"=",
"20",
")",
":",
"for",
"_",
"in",
"range",
"(",
"max_num_retries",
")",
":",
"try",
":",
"return",
"input_data",
".",
"read_data_sets",
"(",
"data_dir",
",",
"one_hot",
"=",
"True",... | [
92,
0
] | [
99,
48
] | python | en | ['en', 'en', 'en'] | True |
get_params | () | Get parameters from command line | Get parameters from command line | def get_params():
''' Get parameters from command line '''
parser = argparse.ArgumentParser()
parser.add_argument("--data_dir", type=str, default='/tmp/tensorflow/mnist/input_data', help="data directory")
parser.add_argument("--batch_num", type=int, default=1000)
parser.add_argument("--batch_size", ... | [
"def",
"get_params",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"--data_dir\"",
",",
"type",
"=",
"str",
",",
"default",
"=",
"'/tmp/tensorflow/mnist/input_data'",
",",
"help",
"=",
"\"data ... | [
134,
0
] | [
141,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Ring binary sensors from a config entry. | Set up the Ring binary sensors from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Ring binary sensors from a config entry."""
ring = hass.data[DOMAIN][config_entry.entry_id]["api"]
devices = hass.data[DOMAIN][config_entry.entry_id]["devices"]
sensors = []
for device_type in ("doorbots", "authoriz... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"ring",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"\"api\"",
"]",
"devices",
"=",
"hass",
".",
... | [
24,
0
] | [
41,
31
] | python | en | ['en', 'en', 'en'] | True |
RingBinarySensor.__init__ | (self, config_entry_id, ring, device, sensor_type) | Initialize a sensor for Ring device. | Initialize a sensor for Ring device. | def __init__(self, config_entry_id, ring, device, sensor_type):
"""Initialize a sensor for Ring device."""
super().__init__(config_entry_id, device)
self._ring = ring
self._sensor_type = sensor_type
self._name = "{} {}".format(self._device.name, SENSOR_TYPES.get(sensor_type)[0])
... | [
"def",
"__init__",
"(",
"self",
",",
"config_entry_id",
",",
"ring",
",",
"device",
",",
"sensor_type",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"config_entry_id",
",",
"device",
")",
"self",
".",
"_ring",
"=",
"ring",
"self",
".",
"_sensor_typ... | [
49,
4
] | [
58,
28
] | python | en | ['en', 'en', 'en'] | True |
RingBinarySensor.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
await super().async_added_to_hass()
self.ring_objects["dings_data"].async_add_listener(self._dings_update_callback)
self._dings_update_callback() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"ring_objects",
"[",
"\"dings_data\"",
"]",
".",
"async_add_listener",
"(",
"self",
".",
"_dings_update_callback",
")",
... | [
60,
4
] | [
64,
37
] | python | en | ['en', 'no', 'en'] | False |
RingBinarySensor.async_will_remove_from_hass | (self) | Disconnect callbacks. | Disconnect callbacks. | async def async_will_remove_from_hass(self):
"""Disconnect callbacks."""
await super().async_will_remove_from_hass()
self.ring_objects["dings_data"].async_remove_listener(
self._dings_update_callback
) | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"super",
"(",
")",
".",
"async_will_remove_from_hass",
"(",
")",
"self",
".",
"ring_objects",
"[",
"\"dings_data\"",
"]",
".",
"async_remove_listener",
"(",
"self",
".",
"_dings_update_... | [
66,
4
] | [
71,
9
] | python | en | ['en', 'ja', 'en'] | False |
RingBinarySensor._dings_update_callback | (self) | Call update method. | Call update method. | def _dings_update_callback(self):
"""Call update method."""
self._update_alert()
self.async_write_ha_state() | [
"def",
"_dings_update_callback",
"(",
"self",
")",
":",
"self",
".",
"_update_alert",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
74,
4
] | [
77,
35
] | python | en | ['en', 'sn', 'en'] | True |
RingBinarySensor._update_alert | (self) | Update active alert. | Update active alert. | def _update_alert(self):
"""Update active alert."""
self._active_alert = next(
(
alert
for alert in self._ring.active_alerts()
if alert["kind"] == self._sensor_type
and alert["doorbot_id"] == self._device.id
),
... | [
"def",
"_update_alert",
"(",
"self",
")",
":",
"self",
".",
"_active_alert",
"=",
"next",
"(",
"(",
"alert",
"for",
"alert",
"in",
"self",
".",
"_ring",
".",
"active_alerts",
"(",
")",
"if",
"alert",
"[",
"\"kind\"",
"]",
"==",
"self",
".",
"_sensor_ty... | [
80,
4
] | [
90,
9
] | python | en | ['ro', 'nl', 'en'] | False |
RingBinarySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
93,
4
] | [
95,
25
] | python | en | ['en', 'mi', 'en'] | True |
RingBinarySensor.is_on | (self) | Return True if the binary sensor is on. | Return True if the binary sensor is on. | def is_on(self):
"""Return True if the binary sensor is on."""
return self._active_alert is not None | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_active_alert",
"is",
"not",
"None"
] | [
98,
4
] | [
100,
45
] | python | en | ['en', 'fy', 'en'] | True |
RingBinarySensor.device_class | (self) | Return the class of the binary sensor. | Return the class of the binary sensor. | def device_class(self):
"""Return the class of the binary sensor."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
103,
4
] | [
105,
33
] | python | en | ['en', 'tg', 'en'] | True |
RingBinarySensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
108,
4
] | [
110,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
RingBinarySensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attrs = super().device_state_attributes
if self._active_alert is None:
return attrs
attrs["state"] = self._active_alert["state"]
attrs["expires_at"] = datetime.fromtimestamp(
self._act... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"super",
"(",
")",
".",
"device_state_attributes",
"if",
"self",
".",
"_active_alert",
"is",
"None",
":",
"return",
"attrs",
"attrs",
"[",
"\"state\"",
"]",
"=",
"self",
".",
"_active_ale... | [
113,
4
] | [
125,
20
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Sense binary sensor. | Set up the Sense binary sensor. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Sense binary sensor."""
data = hass.data[DOMAIN][config_entry.entry_id][SENSE_DATA]
sense_devices_data = hass.data[DOMAIN][config_entry.entry_id][SENSE_DEVICES_DATA]
sense_monitor_id = data.sense_monitor_id
sense_dev... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"SENSE_DATA",
"]",
"sense_devices_data",
"=",
"h... | [
22,
0
] | [
39,
31
] | python | en | ['en', 'st', 'en'] | True |
sense_to_mdi | (sense_icon) | Convert sense icon to mdi icon. | Convert sense icon to mdi icon. | def sense_to_mdi(sense_icon):
"""Convert sense icon to mdi icon."""
return "mdi:{}".format(MDI_ICONS.get(sense_icon, "power-plug")) | [
"def",
"sense_to_mdi",
"(",
"sense_icon",
")",
":",
"return",
"\"mdi:{}\"",
".",
"format",
"(",
"MDI_ICONS",
".",
"get",
"(",
"sense_icon",
",",
"\"power-plug\"",
")",
")"
] | [
58,
0
] | [
60,
67
] | python | el-Latn | ['en', 'el-Latn', 'pt'] | False |
SenseDevice.__init__ | (self, sense_devices_data, device, sense_monitor_id) | Initialize the Sense binary sensor. | Initialize the Sense binary sensor. | def __init__(self, sense_devices_data, device, sense_monitor_id):
"""Initialize the Sense binary sensor."""
self._name = device["name"]
self._id = device["id"]
self._sense_monitor_id = sense_monitor_id
self._unique_id = f"{sense_monitor_id}-{self._id}"
self._icon = sense_... | [
"def",
"__init__",
"(",
"self",
",",
"sense_devices_data",
",",
"device",
",",
"sense_monitor_id",
")",
":",
"self",
".",
"_name",
"=",
"device",
"[",
"\"name\"",
"]",
"self",
".",
"_id",
"=",
"device",
"[",
"\"id\"",
"]",
"self",
".",
"_sense_monitor_id",... | [
66,
4
] | [
75,
31
] | python | en | ['en', 'pt', 'en'] | True |
SenseDevice.is_on | (self) | Return true if the binary sensor is on. | Return true if the binary sensor is on. | def is_on(self):
"""Return true if the binary sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
78,
4
] | [
80,
26
] | python | en | ['en', 'fy', 'en'] | True |
SenseDevice.available | (self) | Return the availability of the binary sensor. | Return the availability of the binary sensor. | def available(self):
"""Return the availability of the binary sensor."""
return self._available | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_available"
] | [
83,
4
] | [
85,
30
] | python | en | ['en', 'ga', 'en'] | True |
SenseDevice.name | (self) | Return the name of the binary sensor. | Return the name of the binary sensor. | def name(self):
"""Return the name of the binary sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
88,
4
] | [
90,
25
] | python | en | ['en', 'mi', 'en'] | True |
SenseDevice.unique_id | (self) | Return the unique id of the binary sensor. | Return the unique id of the binary sensor. | def unique_id(self):
"""Return the unique id of the binary sensor."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
93,
4
] | [
95,
30
] | python | en | ['en', 'it', 'en'] | True |
SenseDevice.old_unique_id | (self) | Return the old not so unique id of the binary sensor. | Return the old not so unique id of the binary sensor. | def old_unique_id(self):
"""Return the old not so unique id of the binary sensor."""
return self._id | [
"def",
"old_unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_id"
] | [
98,
4
] | [
100,
23
] | python | en | ['en', 'en', 'en'] | True |
SenseDevice.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {ATTR_ATTRIBUTION: ATTRIBUTION} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"ATTR_ATTRIBUTION",
":",
"ATTRIBUTION",
"}"
] | [
103,
4
] | [
105,
46
] | python | en | ['en', 'en', 'en'] | True |
SenseDevice.icon | (self) | Return the icon of the binary sensor. | Return the icon of the binary sensor. | def icon(self):
"""Return the icon of the binary sensor."""
return self._icon | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"self",
".",
"_icon"
] | [
108,
4
] | [
110,
25
] | python | en | ['en', 'en', 'en'] | True |
SenseDevice.device_class | (self) | Return the device class of the binary sensor. | Return the device class of the binary sensor. | def device_class(self):
"""Return the device class of the binary sensor."""
return DEVICE_CLASS_POWER | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_POWER"
] | [
113,
4
] | [
115,
33
] | python | en | ['en', 'tg', 'en'] | True |
SenseDevice.should_poll | (self) | Return the deviceshould not poll for updates. | Return the deviceshould not poll for updates. | def should_poll(self):
"""Return the deviceshould not poll for updates."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
118,
4
] | [
120,
20
] | python | en | ['en', 'en', 'en'] | True |
SenseDevice.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
f"{SENSE_DEVICE_UPDATE}-{self._sense_monitor_id}",
self._async_update_from_data,
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"f\"{SENSE_DEVICE_UPDATE}-{self._sense_monitor_id}\"",
",",
"self",
".",
"_async_update_from_data",
",",
")",
... | [
122,
4
] | [
130,
9
] | python | en | ['en', 'no', 'en'] | False |
SenseDevice._async_update_from_data | (self) | Get the latest data, update state. Must not do I/O. | Get the latest data, update state. Must not do I/O. | def _async_update_from_data(self):
"""Get the latest data, update state. Must not do I/O."""
new_state = bool(self._sense_devices_data.get_device_by_id(self._id))
if self._available and self._state == new_state:
return
self._available = True
self._state = new_state
... | [
"def",
"_async_update_from_data",
"(",
"self",
")",
":",
"new_state",
"=",
"bool",
"(",
"self",
".",
"_sense_devices_data",
".",
"get_device_by_id",
"(",
"self",
".",
"_id",
")",
")",
"if",
"self",
".",
"_available",
"and",
"self",
".",
"_state",
"==",
"ne... | [
133,
4
] | [
140,
35
] | python | en | ['en', 'en', 'en'] | True |
UtilsTestCase.test_split_index_normal | (self) | test for normal search space
| test for normal search space
| def test_split_index_normal(self):
"""test for normal search space
"""
normal__params_with_index = {
"dropout_rate": {
"_index" : 1,
"_value" : 0.9
},
"hidden_size": {
"_index" : 1,
"_value" : 512... | [
"def",
"test_split_index_normal",
"(",
"self",
")",
":",
"normal__params_with_index",
"=",
"{",
"\"dropout_rate\"",
":",
"{",
"\"_index\"",
":",
"1",
",",
"\"_value\"",
":",
"0.9",
"}",
",",
"\"hidden_size\"",
":",
"{",
"\"_index\"",
":",
"1",
",",
"\"_value\"... | [
10,
4
] | [
29,
48
] | python | en | ['en', 'en', 'en'] | True |
UtilsTestCase.test_split_index_nested | (self) | test for nested search space
| test for nested search space
| def test_split_index_nested(self):
"""test for nested search space
"""
nested_params_with_index = {
"layer0": {
"_name": "Avg_pool",
"pooling_size":{
"_index" : 1,
"_value" : 2
}
},
... | [
"def",
"test_split_index_nested",
"(",
"self",
")",
":",
"nested_params_with_index",
"=",
"{",
"\"layer0\"",
":",
"{",
"\"_name\"",
":",
"\"Avg_pool\"",
",",
"\"pooling_size\"",
":",
"{",
"\"_index\"",
":",
"1",
",",
"\"_value\"",
":",
"2",
"}",
"}",
",",
"\... | [
31,
4
] | [
83,
47
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Track states and offer events for locks. | Track states and offer events for locks. | async def async_setup(hass, config):
"""Track states and offer events for locks."""
component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
)
await component.async_setup(config)
component.async_register_entity_service(
SERVICE_UNLOCK, LOCK_SERVICE_SCHE... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"component",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"EntityComponent",
"(",
"_LOGGER",
",",
"DOMAIN",
",",
"hass",
",",
"SCAN_INTERVAL",
")",
"await",
"component",
".",
"asy... | [
46,
0
] | [
64,
15
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry) | Set up a config entry. | Set up a config entry. | async def async_setup_entry(hass, entry):
"""Set up a config entry."""
return await hass.data[DOMAIN].async_setup_entry(entry) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
")",
":",
"return",
"await",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"async_setup_entry",
"(",
"entry",
")"
] | [
67,
0
] | [
69,
59
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass, entry) | Unload a config entry. | Unload a config entry. | async def async_unload_entry(hass, entry):
"""Unload a config entry."""
return await hass.data[DOMAIN].async_unload_entry(entry) | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
",",
"entry",
")",
":",
"return",
"await",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"async_unload_entry",
"(",
"entry",
")"
] | [
72,
0
] | [
74,
60
] | python | en | ['en', 'es', 'en'] | True |
LockEntity.changed_by | (self) | Last change triggered by. | Last change triggered by. | def changed_by(self):
"""Last change triggered by."""
return None | [
"def",
"changed_by",
"(",
"self",
")",
":",
"return",
"None"
] | [
81,
4
] | [
83,
19
] | 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.