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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test_setup | (hass: HomeAssistantType, fritz: Mock) | Test setup of platform. | Test setup of platform. | async def test_setup(hass: HomeAssistantType, fritz: Mock):
"""Test setup of platform."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
state = hass.states.get(ENTITY_ID)
assert state
assert state.attributes[ATTR_BATTE... | [
"async",
"def",
"test_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
"await",
"setu... | [
55,
0
] | [
79,
40
] | python | en | ['en', 'da', 'en'] | True |
test_target_temperature_on | (hass: HomeAssistantType, fritz: Mock) | Test turn device on. | Test turn device on. | async def test_target_temperature_on(hass: HomeAssistantType, fritz: Mock):
"""Test turn device on."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
device.target_temperature = 127.0
await setup_fritzbox(hass, MOCK_CONFIG)
state = hass.states.get(ENTITY_ID)
a... | [
"async",
"def",
"test_target_temperature_on",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
... | [
82,
0
] | [
91,
51
] | python | en | ['es', 'en', 'en'] | True |
test_target_temperature_off | (hass: HomeAssistantType, fritz: Mock) | Test turn device on. | Test turn device on. | async def test_target_temperature_off(hass: HomeAssistantType, fritz: Mock):
"""Test turn device on."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
device.target_temperature = 126.5
await setup_fritzbox(hass, MOCK_CONFIG)
state = hass.states.get(ENTITY_ID)
... | [
"async",
"def",
"test_target_temperature_off",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
... | [
94,
0
] | [
103,
50
] | python | en | ['es', 'en', 'en'] | True |
test_update | (hass: HomeAssistantType, fritz: Mock) | Test update with error. | Test update with error. | async def test_update(hass: HomeAssistantType, fritz: Mock):
"""Test update with error."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
state = hass.states.get(ENTITY_ID)
assert state
assert state.attributes[ATTR_CURR... | [
"async",
"def",
"test_update",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
"await",
"set... | [
106,
0
] | [
131,
51
] | python | en | ['en', 'de', 'en'] | True |
test_update_error | (hass: HomeAssistantType, fritz: Mock) | Test update with error. | Test update with error. | async def test_update_error(hass: HomeAssistantType, fritz: Mock):
"""Test update with error."""
device = FritzDeviceClimateMock()
device.update.side_effect = HTTPError("Boom")
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert device.update.call_count ==... | [
"async",
"def",
"test_update_error",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"device",
".",
"update",
".",
"side_effect",
"=",
"HTTPError",
"(",
"\"Boom\"",
")",
"fritz",
... | [
134,
0
] | [
149,
40
] | python | en | ['en', 'de', 'en'] | True |
test_set_temperature_temperature | (hass: HomeAssistantType, fritz: Mock) | Test setting temperature by temperature. | Test setting temperature by temperature. | async def test_set_temperature_temperature(hass: HomeAssistantType, fritz: Mock):
"""Test setting temperature by temperature."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert await hass.services.async_call(
DOMA... | [
"async",
"def",
"test_set_temperature_temperature",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"... | [
152,
0
] | [
165,
70
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_mode_off | (hass: HomeAssistantType, fritz: Mock) | Test setting temperature by mode. | Test setting temperature by mode. | async def test_set_temperature_mode_off(hass: HomeAssistantType, fritz: Mock):
"""Test setting temperature by mode."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert await hass.services.async_call(
DOMAIN,
... | [
"async",
"def",
"test_set_temperature_mode_off",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",... | [
168,
0
] | [
185,
68
] | python | en | ['en', 'en', 'en'] | True |
test_set_temperature_mode_heat | (hass: HomeAssistantType, fritz: Mock) | Test setting temperature by mode. | Test setting temperature by mode. | async def test_set_temperature_mode_heat(hass: HomeAssistantType, fritz: Mock):
"""Test setting temperature by mode."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert await hass.services.async_call(
DOMAIN,
... | [
"async",
"def",
"test_set_temperature_mode_heat",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]"... | [
188,
0
] | [
205,
69
] | python | en | ['en', 'en', 'en'] | True |
test_set_hvac_mode_off | (hass: HomeAssistantType, fritz: Mock) | Test setting hvac mode. | Test setting hvac mode. | async def test_set_hvac_mode_off(hass: HomeAssistantType, fritz: Mock):
"""Test setting hvac mode."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert await hass.services.async_call(
DOMAIN,
SERVICE_SET_HVA... | [
"async",
"def",
"test_set_hvac_mode_off",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
"awa... | [
208,
0
] | [
221,
68
] | python | en | ['en', 'sq', 'ru'] | False |
test_set_hvac_mode_heat | (hass: HomeAssistantType, fritz: Mock) | Test setting hvac mode. | Test setting hvac mode. | async def test_set_hvac_mode_heat(hass: HomeAssistantType, fritz: Mock):
"""Test setting hvac mode."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert await hass.services.async_call(
DOMAIN,
SERVICE_SET_HV... | [
"async",
"def",
"test_set_hvac_mode_heat",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
"aw... | [
224,
0
] | [
237,
69
] | python | en | ['en', 'sq', 'ru'] | False |
test_set_preset_mode_comfort | (hass: HomeAssistantType, fritz: Mock) | Test setting preset mode. | Test setting preset mode. | async def test_set_preset_mode_comfort(hass: HomeAssistantType, fritz: Mock):
"""Test setting preset mode."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert await hass.services.async_call(
DOMAIN,
SERVICE... | [
"async",
"def",
"test_set_preset_mode_comfort",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
... | [
240,
0
] | [
253,
69
] | python | en | ['en', 'ko', 'en'] | True |
test_set_preset_mode_eco | (hass: HomeAssistantType, fritz: Mock) | Test setting preset mode. | Test setting preset mode. | async def test_set_preset_mode_eco(hass: HomeAssistantType, fritz: Mock):
"""Test setting preset mode."""
device = FritzDeviceClimateMock()
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
assert await hass.services.async_call(
DOMAIN,
SERVICE_SET... | [
"async",
"def",
"test_set_preset_mode_eco",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"fritz",
"(",
")",
".",
"get_devices",
".",
"return_value",
"=",
"[",
"device",
"]",
"a... | [
256,
0
] | [
269,
69
] | python | en | ['en', 'ko', 'en'] | True |
test_preset_mode_update | (hass: HomeAssistantType, fritz: Mock) | Test preset mode. | Test preset mode. | async def test_preset_mode_update(hass: HomeAssistantType, fritz: Mock):
"""Test preset mode."""
device = FritzDeviceClimateMock()
device.comfort_temperature = 98
device.eco_temperature = 99
fritz().get_devices.return_value = [device]
await setup_fritzbox(hass, MOCK_CONFIG)
state = hass.sta... | [
"async",
"def",
"test_preset_mode_update",
"(",
"hass",
":",
"HomeAssistantType",
",",
"fritz",
":",
"Mock",
")",
":",
"device",
"=",
"FritzDeviceClimateMock",
"(",
")",
"device",
".",
"comfort_temperature",
"=",
"98",
"device",
".",
"eco_temperature",
"=",
"99"... | [
272,
0
] | [
305,
59
] | python | de | ['de', 'ko', 'it'] | False |
_key2bin | (s) | Convert a key into a string of binary digits | Convert a key into a string of binary digits | def _key2bin(s):
"Convert a key into a string of binary digits"
kl=[bord(x) for x in s]
kl=[binary[x>>4]+binary[x&15] for x in kl]
return ''.join(kl) | [
"def",
"_key2bin",
"(",
"s",
")",
":",
"kl",
"=",
"[",
"bord",
"(",
"x",
")",
"for",
"x",
"in",
"s",
"]",
"kl",
"=",
"[",
"binary",
"[",
"x",
">>",
"4",
"]",
"+",
"binary",
"[",
"x",
"&",
"15",
"]",
"for",
"x",
"in",
"kl",
"]",
"return",
... | [
49,
0
] | [
53,
22
] | python | en | ['en', 'en', 'en'] | True |
_extract | (key, start, length) | Extract a bitstring(2.x)/bytestring(2.x) from a string of binary digits, and return its
numeric value. | Extract a bitstring(2.x)/bytestring(2.x) from a string of binary digits, and return its
numeric value. | def _extract(key, start, length):
"""Extract a bitstring(2.x)/bytestring(2.x) from a string of binary digits, and return its
numeric value."""
k=key[start:start+length]
return reduce(lambda x,y: x*2+ord(y)-48, k, 0) | [
"def",
"_extract",
"(",
"key",
",",
"start",
",",
"length",
")",
":",
"k",
"=",
"key",
"[",
"start",
":",
"start",
"+",
"length",
"]",
"return",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
"*",
"2",
"+",
"ord",
"(",
"y",
")",
"-",
"48",... | [
55,
0
] | [
59,
50
] | python | en | ['en', 'en', 'en'] | True |
key_to_english | (key) | key_to_english(key:string(2.x)/bytes(3.x)) : string
Transform an arbitrary key into a string containing English words.
The key length must be a multiple of 8.
| key_to_english(key:string(2.x)/bytes(3.x)) : string
Transform an arbitrary key into a string containing English words.
The key length must be a multiple of 8.
| def key_to_english (key):
"""key_to_english(key:string(2.x)/bytes(3.x)) : string
Transform an arbitrary key into a string containing English words.
The key length must be a multiple of 8.
"""
english=''
for index in range(0, len(key), 8): # Loop over 8-byte subkeys
subkey=key[index:index... | [
"def",
"key_to_english",
"(",
"key",
")",
":",
"english",
"=",
"''",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"key",
")",
",",
"8",
")",
":",
"# Loop over 8-byte subkeys",
"subkey",
"=",
"key",
"[",
"index",
":",
"index",
"+",
"8",
... | [
61,
0
] | [
77,
23
] | python | en | ['it', 'ru-Latn', 'en'] | False |
english_to_key | (s) | english_to_key(string):string(2.x)/bytes(2.x)
Transform a string into a corresponding key.
The string must contain words separated by whitespace; the number
of words must be a multiple of 6.
| english_to_key(string):string(2.x)/bytes(2.x)
Transform a string into a corresponding key.
The string must contain words separated by whitespace; the number
of words must be a multiple of 6.
| def english_to_key (s):
"""english_to_key(string):string(2.x)/bytes(2.x)
Transform a string into a corresponding key.
The string must contain words separated by whitespace; the number
of words must be a multiple of 6.
"""
L=s.upper().split() ; key=b''
for index in range(0, len(L), 6):
... | [
"def",
"english_to_key",
"(",
"s",
")",
":",
"L",
"=",
"s",
".",
"upper",
"(",
")",
".",
"split",
"(",
")",
"key",
"=",
"b''",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"L",
")",
",",
"6",
")",
":",
"sublist",
"=",
"L",
"[",... | [
79,
0
] | [
112,
14
] | python | en | ['it', 'ru-Latn', 'en'] | False |
Dataset.__init__ | (self, X, y) | Reads source and target sequences from txt files. | Reads source and target sequences from txt files. | def __init__(self, X, y):
"""Reads source and target sequences from txt files."""
self.X = X
self.y = y | [
"def",
"__init__",
"(",
"self",
",",
"X",
",",
"y",
")",
":",
"self",
".",
"X",
"=",
"X",
"self",
".",
"y",
"=",
"y"
] | [
84,
4
] | [
87,
18
] | python | en | ['en', 'en', 'en'] | True |
Dataset.__getitem__ | (self, index) | Returns one data pair (source and target). | Returns one data pair (source and target). | def __getitem__(self, index):
"""Returns one data pair (source and target)."""
data = {}
data["X"] = self.X[index]
data["y"] = self.y[index]
return data | [
"def",
"__getitem__",
"(",
"self",
",",
"index",
")",
":",
"data",
"=",
"{",
"}",
"data",
"[",
"\"X\"",
"]",
"=",
"self",
".",
"X",
"[",
"index",
"]",
"data",
"[",
"\"y\"",
"]",
"=",
"self",
".",
"y",
"[",
"index",
"]",
"return",
"data"
] | [
92,
4
] | [
97,
19
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities
) | Set up the HomematicIP alrm control panel from a config entry. | Set up the HomematicIP alrm control panel from a config entry. | async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities
) -> None:
"""Set up the HomematicIP alrm control panel from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]
async_add_entities([HomematicipAlarmControlPanelEntity(hap)]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config_entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
"->",
"None",
":",
"hap",
"=",
"hass",
".",
"data",
"[",
"HMIPC_DOMAIN",
"]",
"[",
"config_entry",
".",
"unique... | [
29,
0
] | [
34,
65
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.__init__ | (self, hap: HomematicipHAP) | Initialize the alarm control panel. | Initialize the alarm control panel. | def __init__(self, hap: HomematicipHAP) -> None:
"""Initialize the alarm control panel."""
self._home = hap.home
_LOGGER.info("Setting up %s", self.name) | [
"def",
"__init__",
"(",
"self",
",",
"hap",
":",
"HomematicipHAP",
")",
"->",
"None",
":",
"self",
".",
"_home",
"=",
"hap",
".",
"home",
"_LOGGER",
".",
"info",
"(",
"\"Setting up %s\"",
",",
"self",
".",
"name",
")"
] | [
40,
4
] | [
43,
48
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.device_info | (self) | Return device specific attributes. | Return device specific attributes. | def device_info(self) -> Dict[str, Any]:
"""Return device specific attributes."""
return {
"identifiers": {(HMIPC_DOMAIN, f"ACP {self._home.id}")},
"name": self.name,
"manufacturer": "eQ-3",
"model": CONST_ALARM_CONTROL_PANEL_NAME,
"via_device"... | [
"def",
"device_info",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"HMIPC_DOMAIN",
",",
"f\"ACP {self._home.id}\"",
")",
"}",
",",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"manufac... | [
46,
4
] | [
54,
9
] | python | en | ['fr', 'it', 'en'] | False |
HomematicipAlarmControlPanelEntity.state | (self) | Return the state of the alarm control panel. | Return the state of the alarm control panel. | def state(self) -> str:
"""Return the state of the alarm control panel."""
# check for triggered alarm
if self._security_and_alarm.alarmActive:
return STATE_ALARM_TRIGGERED
activation_state = self._home.get_security_zones_activation()
# check arm_away
if acti... | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"# check for triggered alarm",
"if",
"self",
".",
"_security_and_alarm",
".",
"alarmActive",
":",
"return",
"STATE_ALARM_TRIGGERED",
"activation_state",
"=",
"self",
".",
"_home",
".",
"get_security_zones_activation"... | [
57,
4
] | [
71,
35
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.supported_features | (self) | Return the list of supported features. | Return the list of supported features. | def supported_features(self) -> int:
"""Return the list of supported features."""
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_ALARM_ARM_HOME",
"|",
"SUPPORT_ALARM_ARM_AWAY"
] | [
78,
4
] | [
80,
62
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.async_alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | async def async_alarm_disarm(self, code=None) -> None:
"""Send disarm command."""
await self._home.set_security_zones_activation(False, False) | [
"async",
"def",
"async_alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
"->",
"None",
":",
"await",
"self",
".",
"_home",
".",
"set_security_zones_activation",
"(",
"False",
",",
"False",
")"
] | [
82,
4
] | [
84,
68
] | python | en | ['en', 'pt', 'en'] | True |
HomematicipAlarmControlPanelEntity.async_alarm_arm_home | (self, code=None) | Send arm home command. | Send arm home command. | async def async_alarm_arm_home(self, code=None) -> None:
"""Send arm home command."""
await self._home.set_security_zones_activation(False, True) | [
"async",
"def",
"async_alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
"->",
"None",
":",
"await",
"self",
".",
"_home",
".",
"set_security_zones_activation",
"(",
"False",
",",
"True",
")"
] | [
86,
4
] | [
88,
67
] | python | en | ['en', 'pt', 'en'] | True |
HomematicipAlarmControlPanelEntity.async_alarm_arm_away | (self, code=None) | Send arm away command. | Send arm away command. | async def async_alarm_arm_away(self, code=None) -> None:
"""Send arm away command."""
await self._home.set_security_zones_activation(True, True) | [
"async",
"def",
"async_alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
"->",
"None",
":",
"await",
"self",
".",
"_home",
".",
"set_security_zones_activation",
"(",
"True",
",",
"True",
")"
] | [
90,
4
] | [
92,
66
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self) -> None:
"""Register callbacks."""
self._home.on_update(self._async_device_changed) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_home",
".",
"on_update",
"(",
"self",
".",
"_async_device_changed",
")"
] | [
94,
4
] | [
96,
56
] | python | en | ['en', 'no', 'en'] | False |
HomematicipAlarmControlPanelEntity._async_device_changed | (self, *args, **kwargs) | Handle entity state changes. | Handle entity state changes. | def _async_device_changed(self, *args, **kwargs) -> None:
"""Handle entity state changes."""
# Don't update disabled entities
if self.enabled:
_LOGGER.debug("Event %s (%s)", self.name, CONST_ALARM_CONTROL_PANEL_NAME)
self.async_write_ha_state()
else:
_... | [
"def",
"_async_device_changed",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"->",
"None",
":",
"# Don't update disabled entities",
"if",
"self",
".",
"enabled",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Event %s (%s)\"",
",",
"self",
".",
"name"... | [
99,
4
] | [
109,
13
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.name | (self) | Return the name of the generic entity. | Return the name of the generic entity. | def name(self) -> str:
"""Return the name of the generic entity."""
name = CONST_ALARM_CONTROL_PANEL_NAME
if self._home.name:
name = f"{self._home.name} {name}"
return name | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"name",
"=",
"CONST_ALARM_CONTROL_PANEL_NAME",
"if",
"self",
".",
"_home",
".",
"name",
":",
"name",
"=",
"f\"{self._home.name} {name}\"",
"return",
"name"
] | [
112,
4
] | [
117,
19
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self) -> bool:
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"False"
] | [
120,
4
] | [
122,
20
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.available | (self) | Return if alarm control panel is available. | Return if alarm control panel is available. | def available(self) -> bool:
"""Return if alarm control panel is available."""
return self._home.connected | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_home",
".",
"connected"
] | [
125,
4
] | [
127,
35
] | python | en | ['en', 'en', 'en'] | True |
HomematicipAlarmControlPanelEntity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self.__class__.__name__}_{self._home.id}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self.__class__.__name__}_{self._home.id}\""
] | [
130,
4
] | [
132,
59
] | python | ca | ['fr', 'ca', 'en'] | False |
create_server | () | create server | create server | def create_server():
"""create server"""
return HTTPServer(('127.0.0.1', 3000), SimpleHTTPRequestHandler) | [
"def",
"create_server",
"(",
")",
":",
"return",
"HTTPServer",
"(",
"(",
"'127.0.0.1'",
",",
"3000",
")",
",",
"SimpleHTTPRequestHandler",
")"
] | [
110,
0
] | [
112,
68
] | python | en | ['en', 'bs', 'en'] | False |
run_forever | () | keep server running forever | keep server running forever | def run_forever():
"""keep server running forever"""
server = create_server()
try:
print('Starting server on port 3000')
server.serve_forever()
except KeyboardInterrupt:
server.shutdown()
server.server_close() | [
"def",
"run_forever",
"(",
")",
":",
"server",
"=",
"create_server",
"(",
")",
"try",
":",
"print",
"(",
"'Starting server on port 3000'",
")",
"server",
".",
"serve_forever",
"(",
")",
"except",
"KeyboardInterrupt",
":",
"server",
".",
"shutdown",
"(",
")",
... | [
115,
0
] | [
124,
29
] | python | en | ['en', 'no', 'en'] | True |
SimpleHTTPRequestHandler.do_GET | (self) | handle GET routes | handle GET routes | def do_GET(self):
"""handle GET routes"""
parsed_path = urlparse(self.path)
parsed_qs = parse_qs(parsed_path.query)
if parsed_path.path == '/':
#set header
self.send_response(200)
self.send_header('Content-Type', 'text/html')
self.end_head... | [
"def",
"do_GET",
"(",
"self",
")",
":",
"parsed_path",
"=",
"urlparse",
"(",
"self",
".",
"path",
")",
"parsed_qs",
"=",
"parse_qs",
"(",
"parsed_path",
".",
"query",
")",
"if",
"parsed_path",
".",
"path",
"==",
"'/'",
":",
"#set header",
"self",
".",
... | [
8,
4
] | [
79,
42
] | python | en | ['fr', 'en', 'en'] | True |
SimpleHTTPRequestHandler.do_POST | (self) | handle POST routes | handle POST routes | def do_POST(self):
"""handle POST routes"""
parsed_path = urlparse(self.path)
if parsed_path.path == '/cow':
try:
content_length = int(self.headers['Content-Length'])
body = json.loads(self.rfile.read(content_length).decode('utf8'))
except... | [
"def",
"do_POST",
"(",
"self",
")",
":",
"parsed_path",
"=",
"urlparse",
"(",
"self",
".",
"path",
")",
"if",
"parsed_path",
".",
"path",
"==",
"'/cow'",
":",
"try",
":",
"content_length",
"=",
"int",
"(",
"self",
".",
"headers",
"[",
"'Content-Length'",... | [
81,
4
] | [
107,
42
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the Lutron Caseta scene platform.
Adds scenes from the Caseta bridge associated with the config_entry as
scene entities.
| Set up the Lutron Caseta scene platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the Lutron Caseta scene platform.
Adds scenes from the Caseta bridge associated with the config_entry as
scene entities.
"""
entities = []
bridge = hass.data[CASETA_DOMAIN][config_entry.entry_id]
scenes = bridge... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"entities",
"=",
"[",
"]",
"bridge",
"=",
"hass",
".",
"data",
"[",
"CASETA_DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"scenes",
"=",
... | [
8,
0
] | [
23,
38
] | python | en | ['en', 'hr', 'en'] | True |
LutronCasetaScene.__init__ | (self, scene, bridge) | Initialize the Lutron Caseta scene. | Initialize the Lutron Caseta scene. | def __init__(self, scene, bridge):
"""Initialize the Lutron Caseta scene."""
self._scene_name = scene["name"]
self._scene_id = scene["scene_id"]
self._bridge = bridge | [
"def",
"__init__",
"(",
"self",
",",
"scene",
",",
"bridge",
")",
":",
"self",
".",
"_scene_name",
"=",
"scene",
"[",
"\"name\"",
"]",
"self",
".",
"_scene_id",
"=",
"scene",
"[",
"\"scene_id\"",
"]",
"self",
".",
"_bridge",
"=",
"bridge"
] | [
29,
4
] | [
33,
29
] | python | en | ['en', 'ro', 'en'] | True |
LutronCasetaScene.name | (self) | Return the name of the scene. | Return the name of the scene. | def name(self):
"""Return the name of the scene."""
return self._scene_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_scene_name"
] | [
36,
4
] | [
38,
31
] | python | en | ['en', 'ig', 'en'] | True |
LutronCasetaScene.async_activate | (self, **kwargs: Any) | Activate the scene. | Activate the scene. | async def async_activate(self, **kwargs: Any) -> None:
"""Activate the scene."""
await self._bridge.activate_scene(self._scene_id) | [
"async",
"def",
"async_activate",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_bridge",
".",
"activate_scene",
"(",
"self",
".",
"_scene_id",
")"
] | [
40,
4
] | [
42,
57
] | python | en | ['en', 'it', 'en'] | True |
test_create_doorbell | (hass) | Test creation of a doorbell. | Test creation of a doorbell. | async def test_create_doorbell(hass):
"""Test creation of a doorbell."""
doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.json")
await _create_august_with_devices(hass, [doorbell_one])
sensor_k98gidt45gul_name_battery = hass.states.get(
"sensor.k98gidt45gul_name_battery"
... | [
"async",
"def",
"test_create_doorbell",
"(",
"hass",
")",
":",
"doorbell_one",
"=",
"await",
"_mock_doorbell_from_fixture",
"(",
"hass",
",",
"\"get_doorbell.json\"",
")",
"await",
"_create_august_with_devices",
"(",
"hass",
",",
"[",
"doorbell_one",
"]",
")",
"sens... | [
13,
0
] | [
24,
5
] | python | en | ['en', 'lb', 'en'] | True |
test_create_doorbell_offline | (hass) | Test creation of a doorbell that is offline. | Test creation of a doorbell that is offline. | async def test_create_doorbell_offline(hass):
"""Test creation of a doorbell that is offline."""
doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.offline.json")
await _create_august_with_devices(hass, [doorbell_one])
entity_registry = await hass.helpers.entity_registry.async_get_regi... | [
"async",
"def",
"test_create_doorbell_offline",
"(",
"hass",
")",
":",
"doorbell_one",
"=",
"await",
"_mock_doorbell_from_fixture",
"(",
"hass",
",",
"\"get_doorbell.offline.json\"",
")",
"await",
"_create_august_with_devices",
"(",
"hass",
",",
"[",
"doorbell_one",
"]"... | [
27,
0
] | [
39,
53
] | python | en | ['en', 'nl', 'en'] | True |
test_create_doorbell_hardwired | (hass) | Test creation of a doorbell that is hardwired without a battery. | Test creation of a doorbell that is hardwired without a battery. | async def test_create_doorbell_hardwired(hass):
"""Test creation of a doorbell that is hardwired without a battery."""
doorbell_one = await _mock_doorbell_from_fixture(
hass, "get_doorbell.nobattery.json"
)
await _create_august_with_devices(hass, [doorbell_one])
sensor_tmt100_name_battery =... | [
"async",
"def",
"test_create_doorbell_hardwired",
"(",
"hass",
")",
":",
"doorbell_one",
"=",
"await",
"_mock_doorbell_from_fixture",
"(",
"hass",
",",
"\"get_doorbell.nobattery.json\"",
")",
"await",
"_create_august_with_devices",
"(",
"hass",
",",
"[",
"doorbell_one",
... | [
42,
0
] | [
50,
45
] | python | en | ['en', 'en', 'en'] | True |
test_create_lock_with_linked_keypad | (hass) | Test creation of a lock with a linked keypad that both have a battery. | Test creation of a lock with a linked keypad that both have a battery. | async def test_create_lock_with_linked_keypad(hass):
"""Test creation of a lock with a linked keypad that both have a battery."""
lock_one = await _mock_lock_from_fixture(hass, "get_lock.doorsense_init.json")
await _create_august_with_devices(hass, [lock_one])
entity_registry = await hass.helpers.entity... | [
"async",
"def",
"test_create_lock_with_linked_keypad",
"(",
"hass",
")",
":",
"lock_one",
"=",
"await",
"_mock_lock_from_fixture",
"(",
"hass",
",",
"\"get_lock.doorsense_init.json\"",
")",
"await",
"_create_august_with_devices",
"(",
"hass",
",",
"[",
"lock_one",
"]",
... | [
53,
0
] | [
80,
78
] | python | en | ['en', 'en', 'en'] | True |
test_create_lock_with_low_battery_linked_keypad | (hass) | Test creation of a lock with a linked keypad that both have a battery. | Test creation of a lock with a linked keypad that both have a battery. | async def test_create_lock_with_low_battery_linked_keypad(hass):
"""Test creation of a lock with a linked keypad that both have a battery."""
lock_one = await _mock_lock_from_fixture(hass, "get_lock.low_keypad_battery.json")
await _create_august_with_devices(hass, [lock_one])
entity_registry = await has... | [
"async",
"def",
"test_create_lock_with_low_battery_linked_keypad",
"(",
"hass",
")",
":",
"lock_one",
"=",
"await",
"_mock_lock_from_fixture",
"(",
"hass",
",",
"\"get_lock.low_keypad_battery.json\"",
")",
"await",
"_create_august_with_devices",
"(",
"hass",
",",
"[",
"lo... | [
83,
0
] | [
123,
5
] | python | en | ['en', 'en', 'en'] | True |
test_lock_operator_bluetooth | (hass) | Test operation of a lock with doorsense and bridge. | Test operation of a lock with doorsense and bridge. | async def test_lock_operator_bluetooth(hass):
"""Test operation of a lock with doorsense and bridge."""
lock_one = await _mock_doorsense_enabled_august_lock_detail(hass)
activities = await _mock_activities_from_fixture(
hass, "get_activity.lock_from_bluetooth.json"
)
await _create_august_wi... | [
"async",
"def",
"test_lock_operator_bluetooth",
"(",
"hass",
")",
":",
"lock_one",
"=",
"await",
"_mock_doorsense_enabled_august_lock_detail",
"(",
"hass",
")",
"activities",
"=",
"await",
"_mock_activities_from_fixture",
"(",
"hass",
",",
"\"get_activity.lock_from_bluetoot... | [
126,
0
] | [
167,
5
] | python | en | ['en', 'en', 'en'] | True |
test_lock_operator_keypad | (hass) | Test operation of a lock with doorsense and bridge. | Test operation of a lock with doorsense and bridge. | async def test_lock_operator_keypad(hass):
"""Test operation of a lock with doorsense and bridge."""
lock_one = await _mock_doorsense_enabled_august_lock_detail(hass)
activities = await _mock_activities_from_fixture(
hass, "get_activity.lock_from_keypad.json"
)
await _create_august_with_dev... | [
"async",
"def",
"test_lock_operator_keypad",
"(",
"hass",
")",
":",
"lock_one",
"=",
"await",
"_mock_doorsense_enabled_august_lock_detail",
"(",
"hass",
")",
"activities",
"=",
"await",
"_mock_activities_from_fixture",
"(",
"hass",
",",
"\"get_activity.lock_from_keypad.json... | [
170,
0
] | [
211,
5
] | python | en | ['en', 'en', 'en'] | True |
test_lock_operator_remote | (hass) | Test operation of a lock with doorsense and bridge. | Test operation of a lock with doorsense and bridge. | async def test_lock_operator_remote(hass):
"""Test operation of a lock with doorsense and bridge."""
lock_one = await _mock_doorsense_enabled_august_lock_detail(hass)
activities = await _mock_activities_from_fixture(hass, "get_activity.lock.json")
await _create_august_with_devices(hass, [lock_one], act... | [
"async",
"def",
"test_lock_operator_remote",
"(",
"hass",
")",
":",
"lock_one",
"=",
"await",
"_mock_doorsense_enabled_august_lock_detail",
"(",
"hass",
")",
"activities",
"=",
"await",
"_mock_activities_from_fixture",
"(",
"hass",
",",
"\"get_activity.lock.json\"",
")",
... | [
214,
0
] | [
253,
5
] | python | en | ['en', 'en', 'en'] | True |
test_lock_operator_autorelock | (hass) | Test operation of a lock with doorsense and bridge. | Test operation of a lock with doorsense and bridge. | async def test_lock_operator_autorelock(hass):
"""Test operation of a lock with doorsense and bridge."""
lock_one = await _mock_doorsense_enabled_august_lock_detail(hass)
activities = await _mock_activities_from_fixture(
hass, "get_activity.lock_from_autorelock.json"
)
await _create_august_... | [
"async",
"def",
"test_lock_operator_autorelock",
"(",
"hass",
")",
":",
"lock_one",
"=",
"await",
"_mock_doorsense_enabled_august_lock_detail",
"(",
"hass",
")",
"activities",
"=",
"await",
"_mock_activities_from_fixture",
"(",
"hass",
",",
"\"get_activity.lock_from_autorel... | [
256,
0
] | [
297,
5
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, base_config) | Set up the Fibaro Component. | Set up the Fibaro Component. | def setup(hass, base_config):
"""Set up the Fibaro Component."""
gateways = base_config[DOMAIN][CONF_GATEWAYS]
hass.data[FIBARO_CONTROLLERS] = {}
def stop_fibaro(event):
"""Stop Fibaro Thread."""
_LOGGER.info("Shutting down Fibaro connection")
for controller in hass.data[FIBARO_... | [
"def",
"setup",
"(",
"hass",
",",
"base_config",
")",
":",
"gateways",
"=",
"base_config",
"[",
"DOMAIN",
"]",
"[",
"CONF_GATEWAYS",
"]",
"hass",
".",
"data",
"[",
"FIBARO_CONTROLLERS",
"]",
"=",
"{",
"}",
"def",
"stop_fibaro",
"(",
"event",
")",
":",
... | [
355,
0
] | [
387,
16
] | python | en | ['en', 'ca', 'en'] | True |
FibaroController.__init__ | (self, config) | Initialize the Fibaro controller. | Initialize the Fibaro controller. | def __init__(self, config):
"""Initialize the Fibaro controller."""
self._client = FibaroClient(
config[CONF_URL], config[CONF_USERNAME], config[CONF_PASSWORD]
)
self._scene_map = None
# Whether to import devices from plugins
self._import_plugins = config[CON... | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_client",
"=",
"FibaroClient",
"(",
"config",
"[",
"CONF_URL",
"]",
",",
"config",
"[",
"CONF_USERNAME",
"]",
",",
"config",
"[",
"CONF_PASSWORD",
"]",
")",
"self",
".",
"_scene_map",... | [
113,
4
] | [
129,
30
] | python | en | ['en', 'en', 'en'] | True |
FibaroController.connect | (self) | Start the communication with the Fibaro controller. | Start the communication with the Fibaro controller. | def connect(self):
"""Start the communication with the Fibaro controller."""
try:
login = self._client.login.get()
info = self._client.info.get()
self.hub_serial = slugify(info.serialNumber)
except AssertionError:
_LOGGER.error("Can't connect to Fi... | [
"def",
"connect",
"(",
"self",
")",
":",
"try",
":",
"login",
"=",
"self",
".",
"_client",
".",
"login",
".",
"get",
"(",
")",
"info",
"=",
"self",
".",
"_client",
".",
"info",
".",
"get",
"(",
")",
"self",
".",
"hub_serial",
"=",
"slugify",
"(",... | [
131,
4
] | [
149,
19
] | python | en | ['en', 'en', 'en'] | True |
FibaroController.enable_state_handler | (self) | Start StateHandler thread for monitoring updates. | Start StateHandler thread for monitoring updates. | def enable_state_handler(self):
"""Start StateHandler thread for monitoring updates."""
self._state_handler = StateHandler(self._client, self._on_state_change) | [
"def",
"enable_state_handler",
"(",
"self",
")",
":",
"self",
".",
"_state_handler",
"=",
"StateHandler",
"(",
"self",
".",
"_client",
",",
"self",
".",
"_on_state_change",
")"
] | [
151,
4
] | [
153,
79
] | python | en | ['en', 'no', 'en'] | True |
FibaroController.disable_state_handler | (self) | Stop StateHandler thread used for monitoring updates. | Stop StateHandler thread used for monitoring updates. | def disable_state_handler(self):
"""Stop StateHandler thread used for monitoring updates."""
self._state_handler.stop()
self._state_handler = None | [
"def",
"disable_state_handler",
"(",
"self",
")",
":",
"self",
".",
"_state_handler",
".",
"stop",
"(",
")",
"self",
".",
"_state_handler",
"=",
"None"
] | [
155,
4
] | [
158,
34
] | python | en | ['en', 'en', 'en'] | True |
FibaroController._on_state_change | (self, state) | Handle change report received from the HomeCenter. | Handle change report received from the HomeCenter. | def _on_state_change(self, state):
"""Handle change report received from the HomeCenter."""
callback_set = set()
for change in state.get("changes", []):
try:
dev_id = change.pop("id")
if dev_id not in self._device_map:
continue
... | [
"def",
"_on_state_change",
"(",
"self",
",",
"state",
")",
":",
"callback_set",
"=",
"set",
"(",
")",
"for",
"change",
"in",
"state",
".",
"get",
"(",
"\"changes\"",
",",
"[",
"]",
")",
":",
"try",
":",
"dev_id",
"=",
"change",
".",
"pop",
"(",
"\"... | [
160,
4
] | [
188,
35
] | python | en | ['en', 'en', 'en'] | True |
FibaroController.register | (self, device_id, callback) | Register device with a callback for updates. | Register device with a callback for updates. | def register(self, device_id, callback):
"""Register device with a callback for updates."""
self._callbacks[device_id] = callback | [
"def",
"register",
"(",
"self",
",",
"device_id",
",",
"callback",
")",
":",
"self",
".",
"_callbacks",
"[",
"device_id",
"]",
"=",
"callback"
] | [
190,
4
] | [
192,
45
] | python | en | ['en', 'en', 'en'] | True |
FibaroController.get_children | (self, device_id) | Get a list of child devices. | Get a list of child devices. | def get_children(self, device_id):
"""Get a list of child devices."""
return [
device
for device in self._device_map.values()
if device.parentId == device_id
] | [
"def",
"get_children",
"(",
"self",
",",
"device_id",
")",
":",
"return",
"[",
"device",
"for",
"device",
"in",
"self",
".",
"_device_map",
".",
"values",
"(",
")",
"if",
"device",
".",
"parentId",
"==",
"device_id",
"]"
] | [
194,
4
] | [
200,
9
] | python | en | ['en', 'en', 'en'] | True |
FibaroController.get_children2 | (self, device_id, endpoint_id) | Get a list of child devices for the same endpoint. | Get a list of child devices for the same endpoint. | def get_children2(self, device_id, endpoint_id):
"""Get a list of child devices for the same endpoint."""
return [
device
for device in self._device_map.values()
if device.parentId == device_id
and (
"endPointId" not in device.properties
... | [
"def",
"get_children2",
"(",
"self",
",",
"device_id",
",",
"endpoint_id",
")",
":",
"return",
"[",
"device",
"for",
"device",
"in",
"self",
".",
"_device_map",
".",
"values",
"(",
")",
"if",
"device",
".",
"parentId",
"==",
"device_id",
"and",
"(",
"\"e... | [
202,
4
] | [
212,
9
] | python | en | ['en', 'en', 'en'] | True |
FibaroController.get_siblings | (self, device) | Get the siblings of a device. | Get the siblings of a device. | def get_siblings(self, device):
"""Get the siblings of a device."""
if "endPointId" in device.properties:
return self.get_children2(
self._device_map[device.id].parentId,
self._device_map[device.id].properties.endPointId,
)
return self.get_... | [
"def",
"get_siblings",
"(",
"self",
",",
"device",
")",
":",
"if",
"\"endPointId\"",
"in",
"device",
".",
"properties",
":",
"return",
"self",
".",
"get_children2",
"(",
"self",
".",
"_device_map",
"[",
"device",
".",
"id",
"]",
".",
"parentId",
",",
"se... | [
214,
4
] | [
221,
70
] | python | en | ['en', 'en', 'en'] | True |
FibaroController._map_device_to_type | (device) | Map device to HA device type. | Map device to HA device type. | def _map_device_to_type(device):
"""Map device to HA device type."""
# Use our lookup table to identify device type
device_type = None
if "type" in device:
device_type = FIBARO_TYPEMAP.get(device.type)
if device_type is None and "baseType" in device:
devic... | [
"def",
"_map_device_to_type",
"(",
"device",
")",
":",
"# Use our lookup table to identify device type",
"device_type",
"=",
"None",
"if",
"\"type\"",
"in",
"device",
":",
"device_type",
"=",
"FIBARO_TYPEMAP",
".",
"get",
"(",
"device",
".",
"type",
")",
"if",
"de... | [
224,
4
] | [
252,
26
] | python | en | ['en', 'en', 'en'] | True |
FibaroController._read_devices | (self) | Read and process the device list. | Read and process the device list. | def _read_devices(self):
"""Read and process the device list."""
devices = self._client.devices.list()
self._device_map = {}
self.fibaro_devices = defaultdict(list)
last_climate_parent = None
last_endpoint = None
for device in devices:
try:
... | [
"def",
"_read_devices",
"(",
"self",
")",
":",
"devices",
"=",
"self",
".",
"_client",
".",
"devices",
".",
"list",
"(",
")",
"self",
".",
"_device_map",
"=",
"{",
"}",
"self",
".",
"fibaro_devices",
"=",
"defaultdict",
"(",
"list",
")",
"last_climate_pa... | [
275,
4
] | [
352,
20
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.__init__ | (self, fibaro_device) | Initialize the device. | Initialize the device. | def __init__(self, fibaro_device):
"""Initialize the device."""
self.fibaro_device = fibaro_device
self.controller = fibaro_device.fibaro_controller
self._name = fibaro_device.friendly_name
self.ha_id = fibaro_device.ha_id | [
"def",
"__init__",
"(",
"self",
",",
"fibaro_device",
")",
":",
"self",
".",
"fibaro_device",
"=",
"fibaro_device",
"self",
".",
"controller",
"=",
"fibaro_device",
".",
"fibaro_controller",
"self",
".",
"_name",
"=",
"fibaro_device",
".",
"friendly_name",
"self... | [
393,
4
] | [
398,
40
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.async_added_to_hass | (self) | Call when entity is added to hass. | Call when entity is added to hass. | async def async_added_to_hass(self):
"""Call when entity is added to hass."""
self.controller.register(self.fibaro_device.id, self._update_callback) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"controller",
".",
"register",
"(",
"self",
".",
"fibaro_device",
".",
"id",
",",
"self",
".",
"_update_callback",
")"
] | [
400,
4
] | [
402,
78
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice._update_callback | (self) | Update the state. | Update the state. | def _update_callback(self):
"""Update the state."""
self.schedule_update_ha_state(True) | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"schedule_update_ha_state",
"(",
"True",
")"
] | [
404,
4
] | [
406,
43
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.level | (self) | Get the level of Fibaro device. | Get the level of Fibaro device. | def level(self):
"""Get the level of Fibaro device."""
if "value" in self.fibaro_device.properties:
return self.fibaro_device.properties.value
return None | [
"def",
"level",
"(",
"self",
")",
":",
"if",
"\"value\"",
"in",
"self",
".",
"fibaro_device",
".",
"properties",
":",
"return",
"self",
".",
"fibaro_device",
".",
"properties",
".",
"value",
"return",
"None"
] | [
409,
4
] | [
413,
19
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.level2 | (self) | Get the tilt level of Fibaro device. | Get the tilt level of Fibaro device. | def level2(self):
"""Get the tilt level of Fibaro device."""
if "value2" in self.fibaro_device.properties:
return self.fibaro_device.properties.value2
return None | [
"def",
"level2",
"(",
"self",
")",
":",
"if",
"\"value2\"",
"in",
"self",
".",
"fibaro_device",
".",
"properties",
":",
"return",
"self",
".",
"fibaro_device",
".",
"properties",
".",
"value2",
"return",
"None"
] | [
416,
4
] | [
420,
19
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.dont_know_message | (self, action) | Make a warning in case we don't know how to perform an action. | Make a warning in case we don't know how to perform an action. | def dont_know_message(self, action):
"""Make a warning in case we don't know how to perform an action."""
_LOGGER.warning(
"Not sure how to setValue: %s (available actions: %s)",
str(self.ha_id),
str(self.fibaro_device.actions),
) | [
"def",
"dont_know_message",
"(",
"self",
",",
"action",
")",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Not sure how to setValue: %s (available actions: %s)\"",
",",
"str",
"(",
"self",
".",
"ha_id",
")",
",",
"str",
"(",
"self",
".",
"fibaro_device",
".",
"actions... | [
422,
4
] | [
428,
9
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.set_level | (self, level) | Set the level of Fibaro device. | Set the level of Fibaro device. | def set_level(self, level):
"""Set the level of Fibaro device."""
self.action("setValue", level)
if "value" in self.fibaro_device.properties:
self.fibaro_device.properties.value = level
if "brightness" in self.fibaro_device.properties:
self.fibaro_device.propertie... | [
"def",
"set_level",
"(",
"self",
",",
"level",
")",
":",
"self",
".",
"action",
"(",
"\"setValue\"",
",",
"level",
")",
"if",
"\"value\"",
"in",
"self",
".",
"fibaro_device",
".",
"properties",
":",
"self",
".",
"fibaro_device",
".",
"properties",
".",
"... | [
430,
4
] | [
436,
60
] | python | en | ['en', 'sr', 'en'] | True |
FibaroDevice.set_level2 | (self, level) | Set the level2 of Fibaro device. | Set the level2 of Fibaro device. | def set_level2(self, level):
"""Set the level2 of Fibaro device."""
self.action("setValue2", level)
if "value2" in self.fibaro_device.properties:
self.fibaro_device.properties.value2 = level | [
"def",
"set_level2",
"(",
"self",
",",
"level",
")",
":",
"self",
".",
"action",
"(",
"\"setValue2\"",
",",
"level",
")",
"if",
"\"value2\"",
"in",
"self",
".",
"fibaro_device",
".",
"properties",
":",
"self",
".",
"fibaro_device",
".",
"properties",
".",
... | [
438,
4
] | [
442,
56
] | python | en | ['en', 'sr', 'en'] | True |
FibaroDevice.call_turn_on | (self) | Turn on the Fibaro device. | Turn on the Fibaro device. | def call_turn_on(self):
"""Turn on the Fibaro device."""
self.action("turnOn") | [
"def",
"call_turn_on",
"(",
"self",
")",
":",
"self",
".",
"action",
"(",
"\"turnOn\"",
")"
] | [
444,
4
] | [
446,
29
] | python | en | ['en', 'yo', 'en'] | True |
FibaroDevice.call_turn_off | (self) | Turn off the Fibaro device. | Turn off the Fibaro device. | def call_turn_off(self):
"""Turn off the Fibaro device."""
self.action("turnOff") | [
"def",
"call_turn_off",
"(",
"self",
")",
":",
"self",
".",
"action",
"(",
"\"turnOff\"",
")"
] | [
448,
4
] | [
450,
30
] | python | en | ['en', 'yo', 'en'] | True |
FibaroDevice.call_set_color | (self, red, green, blue, white) | Set the color of Fibaro device. | Set the color of Fibaro device. | def call_set_color(self, red, green, blue, white):
"""Set the color of Fibaro device."""
red = int(max(0, min(255, red)))
green = int(max(0, min(255, green)))
blue = int(max(0, min(255, blue)))
white = int(max(0, min(255, white)))
color_str = f"{red},{green},{blue},{white... | [
"def",
"call_set_color",
"(",
"self",
",",
"red",
",",
"green",
",",
"blue",
",",
"white",
")",
":",
"red",
"=",
"int",
"(",
"max",
"(",
"0",
",",
"min",
"(",
"255",
",",
"red",
")",
")",
")",
"green",
"=",
"int",
"(",
"max",
"(",
"0",
",",
... | [
452,
4
] | [
460,
76
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.action | (self, cmd, *args) | Perform an action on the Fibaro HC. | Perform an action on the Fibaro HC. | def action(self, cmd, *args):
"""Perform an action on the Fibaro HC."""
if cmd in self.fibaro_device.actions:
getattr(self.fibaro_device, cmd)(*args)
_LOGGER.debug("-> %s.%s%s called", str(self.ha_id), str(cmd), str(args))
else:
self.dont_know_message(cmd) | [
"def",
"action",
"(",
"self",
",",
"cmd",
",",
"*",
"args",
")",
":",
"if",
"cmd",
"in",
"self",
".",
"fibaro_device",
".",
"actions",
":",
"getattr",
"(",
"self",
".",
"fibaro_device",
",",
"cmd",
")",
"(",
"*",
"args",
")",
"_LOGGER",
".",
"debug... | [
462,
4
] | [
468,
39
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.current_power_w | (self) | Return the current power usage in W. | Return the current power usage in W. | def current_power_w(self):
"""Return the current power usage in W."""
if "power" in self.fibaro_device.properties:
power = self.fibaro_device.properties.power
if power:
return convert(power, float, 0.0)
else:
return None | [
"def",
"current_power_w",
"(",
"self",
")",
":",
"if",
"\"power\"",
"in",
"self",
".",
"fibaro_device",
".",
"properties",
":",
"power",
"=",
"self",
".",
"fibaro_device",
".",
"properties",
".",
"power",
"if",
"power",
":",
"return",
"convert",
"(",
"powe... | [
471,
4
] | [
478,
23
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.current_binary_state | (self) | Return the current binary state. | Return the current binary state. | def current_binary_state(self):
"""Return the current binary state."""
if self.fibaro_device.properties.value == "false":
return False
if (
self.fibaro_device.properties.value == "true"
or int(self.fibaro_device.properties.value) > 0
):
ret... | [
"def",
"current_binary_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"fibaro_device",
".",
"properties",
".",
"value",
"==",
"\"false\"",
":",
"return",
"False",
"if",
"(",
"self",
".",
"fibaro_device",
".",
"properties",
".",
"value",
"==",
"\"true\"",
... | [
481,
4
] | [
490,
20
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return self.fibaro_device.unique_id_str | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"fibaro_device",
".",
"unique_id_str"
] | [
493,
4
] | [
495,
47
] | python | ca | ['fr', 'ca', 'en'] | False |
FibaroDevice.name | (self) | Return the name of the device. | Return the name of the device. | def name(self) -> Optional[str]:
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"self",
".",
"_name"
] | [
498,
4
] | [
500,
25
] | python | en | ['en', 'en', 'en'] | True |
FibaroDevice.should_poll | (self) | Get polling requirement from fibaro device. | Get polling requirement from fibaro device. | def should_poll(self):
"""Get polling requirement from fibaro device."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
503,
4
] | [
505,
20
] | python | en | ['eo', 'en', 'en'] | True |
FibaroDevice.device_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def device_state_attributes(self):
"""Return the state attributes of the device."""
attr = {"fibaro_id": self.fibaro_device.id}
try:
if "battery" in self.fibaro_device.interfaces:
attr[ATTR_BATTERY_LEVEL] = int(
self.fibaro_device.properties.batte... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"\"fibaro_id\"",
":",
"self",
".",
"fibaro_device",
".",
"id",
"}",
"try",
":",
"if",
"\"battery\"",
"in",
"self",
".",
"fibaro_device",
".",
"interfaces",
":",
"attr",
"[",
"ATTR_B... | [
508,
4
] | [
530,
19
] | python | en | ['en', 'en', 'en'] | True |
test_humidifier | (hass, hk_driver, events) | Test if humidifier accessory and HA are updated accordingly. | Test if humidifier accessory and HA are updated accordingly. | async def test_humidifier(hass, hk_driver, events):
"""Test if humidifier accessory and HA are updated accordingly."""
entity_id = "humidifier.test"
hass.states.async_set(entity_id, STATE_OFF)
await hass.async_block_till_done()
acc = HumidifierDehumidifier(
hass, hk_driver, "HumidifierDehum... | [
"async",
"def",
"test_humidifier",
"(",
"hass",
",",
"hk_driver",
",",
"events",
")",
":",
"entity_id",
"=",
"\"humidifier.test\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_OFF",
")",
"await",
"hass",
".",
"async_block_till_done",
... | [
45,
0
] | [
121,
88
] | python | en | ['en', 'en', 'en'] | True |
test_dehumidifier | (hass, hk_driver, events) | Test if dehumidifier accessory and HA are updated accordingly. | Test if dehumidifier accessory and HA are updated accordingly. | async def test_dehumidifier(hass, hk_driver, events):
"""Test if dehumidifier accessory and HA are updated accordingly."""
entity_id = "humidifier.test"
hass.states.async_set(
entity_id, STATE_OFF, {ATTR_DEVICE_CLASS: DEVICE_CLASS_DEHUMIDIFIER}
)
await hass.async_block_till_done()
acc =... | [
"async",
"def",
"test_dehumidifier",
"(",
"hass",
",",
"hk_driver",
",",
"events",
")",
":",
"entity_id",
"=",
"\"humidifier.test\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_OFF",
",",
"{",
"ATTR_DEVICE_CLASS",
":",
"DEVICE_CLASS_D... | [
124,
0
] | [
204,
5
] | python | en | ['en', 'en', 'en'] | True |
test_hygrostat_power_state | (hass, hk_driver, events) | Test if accessory and HA are updated accordingly. | Test if accessory and HA are updated accordingly. | async def test_hygrostat_power_state(hass, hk_driver, events):
"""Test if accessory and HA are updated accordingly."""
entity_id = "humidifier.test"
hass.states.async_set(
entity_id,
STATE_ON,
{ATTR_HUMIDITY: 43},
)
await hass.async_block_till_done()
acc = HumidifierDehu... | [
"async",
"def",
"test_hygrostat_power_state",
"(",
"hass",
",",
"hk_driver",
",",
"events",
")",
":",
"entity_id",
"=",
"\"humidifier.test\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_ON",
",",
"{",
"ATTR_HUMIDITY",
":",
"43",
"}"... | [
207,
0
] | [
284,
55
] | python | en | ['en', 'en', 'en'] | True |
test_hygrostat_get_humidity_range | (hass, hk_driver) | Test if humidity range is evaluated correctly. | Test if humidity range is evaluated correctly. | async def test_hygrostat_get_humidity_range(hass, hk_driver):
"""Test if humidity range is evaluated correctly."""
entity_id = "humidifier.test"
hass.states.async_set(
entity_id, STATE_OFF, {ATTR_MIN_HUMIDITY: 40, ATTR_MAX_HUMIDITY: 45}
)
await hass.async_block_till_done()
acc = Humidif... | [
"async",
"def",
"test_hygrostat_get_humidity_range",
"(",
"hass",
",",
"hk_driver",
")",
":",
"entity_id",
"=",
"\"humidifier.test\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_OFF",
",",
"{",
"ATTR_MIN_HUMIDITY",
":",
"40",
",",
"AT... | [
287,
0
] | [
304,
68
] | python | en | ['en', 'zu', 'en'] | True |
test_humidifier_with_linked_humidity_sensor | (hass, hk_driver) | Test a humidifier with a linked humidity sensor can update. | Test a humidifier with a linked humidity sensor can update. | async def test_humidifier_with_linked_humidity_sensor(hass, hk_driver):
"""Test a humidifier with a linked humidity sensor can update."""
humidity_sensor_entity_id = "sensor.bedroom_humidity"
hass.states.async_set(
humidity_sensor_entity_id,
"42.0",
{
ATTR_DEVICE_CLASS: ... | [
"async",
"def",
"test_humidifier_with_linked_humidity_sensor",
"(",
"hass",
",",
"hk_driver",
")",
":",
"humidity_sensor_entity_id",
"=",
"\"sensor.bedroom_humidity\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"humidity_sensor_entity_id",
",",
"\"42.0\"",
",",
"{",
... | [
307,
0
] | [
366,
50
] | python | en | ['en', 'en', 'en'] | True |
test_humidifier_with_a_missing_linked_humidity_sensor | (hass, hk_driver) | Test a humidifier with a configured linked motion sensor that is missing. | Test a humidifier with a configured linked motion sensor that is missing. | async def test_humidifier_with_a_missing_linked_humidity_sensor(hass, hk_driver):
"""Test a humidifier with a configured linked motion sensor that is missing."""
humidity_sensor_entity_id = "sensor.bedroom_humidity"
entity_id = "humidifier.test"
hass.states.async_set(entity_id, STATE_OFF)
await has... | [
"async",
"def",
"test_humidifier_with_a_missing_linked_humidity_sensor",
"(",
"hass",
",",
"hk_driver",
")",
":",
"humidity_sensor_entity_id",
"=",
"\"sensor.bedroom_humidity\"",
"entity_id",
"=",
"\"humidifier.test\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_... | [
369,
0
] | [
389,
47
] | python | en | ['en', 'en', 'en'] | True |
test_humidifier_as_dehumidifier | (hass, hk_driver, events, caplog) | Test an invalid char_target_humidifier_dehumidifier from HomeKit. | Test an invalid char_target_humidifier_dehumidifier from HomeKit. | async def test_humidifier_as_dehumidifier(hass, hk_driver, events, caplog):
"""Test an invalid char_target_humidifier_dehumidifier from HomeKit."""
entity_id = "humidifier.test"
hass.states.async_set(entity_id, STATE_OFF)
await hass.async_block_till_done()
acc = HumidifierDehumidifier(
hass... | [
"async",
"def",
"test_humidifier_as_dehumidifier",
"(",
"hass",
",",
"hk_driver",
",",
"events",
",",
"caplog",
")",
":",
"entity_id",
"=",
"\"humidifier.test\"",
"hass",
".",
"states",
".",
"async_set",
"(",
"entity_id",
",",
"STATE_OFF",
")",
"await",
"hass",
... | [
392,
0
] | [
428,
27
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up the Genius Hub water_heater entities. | Set up the Genius Hub water_heater entities. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) -> None:
"""Set up the Genius Hub water_heater entities."""
if discovery_info is None:
return
broker = hass.data[DOMAIN]["broker"]
async_add_entities(
[
... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
"->",
"None",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"broker",... | [
33,
0
] | [
48,
5
] | python | en | ['en', 'af', 'en'] | True |
GeniusWaterHeater.__init__ | (self, broker, zone) | Initialize the water_heater device. | Initialize the water_heater device. | def __init__(self, broker, zone) -> None:
"""Initialize the water_heater device."""
super().__init__(broker, zone)
self._max_temp = 80.0
self._min_temp = 30.0
self._supported_features = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE | [
"def",
"__init__",
"(",
"self",
",",
"broker",
",",
"zone",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"broker",
",",
"zone",
")",
"self",
".",
"_max_temp",
"=",
"80.0",
"self",
".",
"_min_temp",
"=",
"30.0",
"self",
".",
"_su... | [
54,
4
] | [
60,
86
] | python | en | ['en', 'en', 'en'] | True |
GeniusWaterHeater.operation_list | (self) | Return the list of available operation modes. | Return the list of available operation modes. | def operation_list(self) -> List[str]:
"""Return the list of available operation modes."""
return list(HA_OPMODE_TO_GH) | [
"def",
"operation_list",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"list",
"(",
"HA_OPMODE_TO_GH",
")"
] | [
63,
4
] | [
65,
36
] | python | en | ['en', 'en', 'en'] | True |
GeniusWaterHeater.current_operation | (self) | Return the current operation mode. | Return the current operation mode. | def current_operation(self) -> str:
"""Return the current operation mode."""
return GH_STATE_TO_HA[self._zone.data["mode"]] | [
"def",
"current_operation",
"(",
"self",
")",
"->",
"str",
":",
"return",
"GH_STATE_TO_HA",
"[",
"self",
".",
"_zone",
".",
"data",
"[",
"\"mode\"",
"]",
"]"
] | [
68,
4
] | [
70,
54
] | python | en | ['en', 'en', 'en'] | True |
GeniusWaterHeater.async_set_operation_mode | (self, operation_mode) | Set a new operation mode for this boiler. | Set a new operation mode for this boiler. | async def async_set_operation_mode(self, operation_mode) -> None:
"""Set a new operation mode for this boiler."""
await self._zone.set_mode(HA_OPMODE_TO_GH[operation_mode]) | [
"async",
"def",
"async_set_operation_mode",
"(",
"self",
",",
"operation_mode",
")",
"->",
"None",
":",
"await",
"self",
".",
"_zone",
".",
"set_mode",
"(",
"HA_OPMODE_TO_GH",
"[",
"operation_mode",
"]",
")"
] | [
72,
4
] | [
74,
66
] | python | en | ['en', 'en', 'en'] | True |
conv2d | (x_input, w_matrix) | conv2d returns a 2d convolution layer with full stride. | conv2d returns a 2d convolution layer with full stride. | def conv2d(x_input, w_matrix):
"""conv2d returns a 2d convolution layer with full stride."""
return tf.nn.conv2d(x_input, w_matrix, strides=[1, 1, 1, 1], padding='SAME') | [
"def",
"conv2d",
"(",
"x_input",
",",
"w_matrix",
")",
":",
"return",
"tf",
".",
"nn",
".",
"conv2d",
"(",
"x_input",
",",
"w_matrix",
",",
"strides",
"=",
"[",
"1",
",",
"1",
",",
"1",
",",
"1",
"]",
",",
"padding",
"=",
"'SAME'",
")"
] | [
124,
0
] | [
126,
80
] | python | en | ['en', 'en', 'en'] | True |
max_pool | (x_input, pool_size) | max_pool downsamples a feature map by 2X. | max_pool downsamples a feature map by 2X. | def max_pool(x_input, pool_size):
"""max_pool downsamples a feature map by 2X."""
return tf.nn.max_pool(x_input, ksize=[1, pool_size, pool_size, 1],
strides=[1, pool_size, pool_size, 1], padding='SAME') | [
"def",
"max_pool",
"(",
"x_input",
",",
"pool_size",
")",
":",
"return",
"tf",
".",
"nn",
".",
"max_pool",
"(",
"x_input",
",",
"ksize",
"=",
"[",
"1",
",",
"pool_size",
",",
"pool_size",
",",
"1",
"]",
",",
"strides",
"=",
"[",
"1",
",",
"pool_siz... | [
129,
0
] | [
132,
79
] | python | en | ['en', 'en', 'en'] | True |
weight_variable | (shape) | weight_variable generates a weight variable of a given shape. | weight_variable generates a weight variable of a given shape. | def weight_variable(shape):
"""weight_variable generates a weight variable of a given shape."""
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial) | [
"def",
"weight_variable",
"(",
"shape",
")",
":",
"initial",
"=",
"tf",
".",
"truncated_normal",
"(",
"shape",
",",
"stddev",
"=",
"0.1",
")",
"return",
"tf",
".",
"Variable",
"(",
"initial",
")"
] | [
135,
0
] | [
138,
31
] | python | en | ['en', 'en', 'en'] | True |
bias_variable | (shape) | bias_variable generates a bias variable of a given shape. | bias_variable generates a bias variable of a given shape. | def bias_variable(shape):
"""bias_variable generates a bias variable of a given shape."""
initial = tf.constant(0.1, shape=shape)
return tf.Variable(initial) | [
"def",
"bias_variable",
"(",
"shape",
")",
":",
"initial",
"=",
"tf",
".",
"constant",
"(",
"0.1",
",",
"shape",
"=",
"shape",
")",
"return",
"tf",
".",
"Variable",
"(",
"initial",
")"
] | [
141,
0
] | [
144,
31
] | 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",... | [
146,
0
] | [
153,
48
] | python | en | ['en', 'en', 'en'] | True |
main | (params) |
Main function, build mnist network, run and send result to NNI.
|
Main function, build mnist network, run and send result to NNI.
| def main(params):
'''
Main function, build mnist network, run and send result to NNI.
'''
# Import data
mnist = download_mnist_retry(params['data_dir'])
print('Mnist download data done.')
logger.debug('Mnist download data done.')
# Create the model
# Build the graph for the deep net... | [
"def",
"main",
"(",
"params",
")",
":",
"# Import data",
"mnist",
"=",
"download_mnist_retry",
"(",
"params",
"[",
"'data_dir'",
"]",
")",
"print",
"(",
"'Mnist download data done.'",
")",
"logger",
".",
"debug",
"(",
"'Mnist download data done.'",
")",
"# Create ... | [
155,
0
] | [
208,
47
] | python | en | ['en', 'error', 'th'] | False |
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("--dropout_rate", type=float, default=0.5, help="dropout rate")
parser.add_... | [
"def",
"get_params",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"--data_dir\"",
",",
"type",
"=",
"str",
",",
"default",
"=",
"'/tmp/tensorflow/mnist/input_data'",
",",
"help",
"=",
"\"data ... | [
210,
0
] | [
225,
15
] | python | en | ['en', 'en', 'en'] | True |
MnistNetwork.build_network | (self) |
Building network for mnist
|
Building network for mnist
| def build_network(self):
'''
Building network for mnist
'''
# Reshape to use within a convolutional neural net.
# Last dimension is for "features" - there is only one here, since images are
# grayscale -- it would be 3 for an RGB image, 4 for RGBA, etc.
with tf.n... | [
"def",
"build_network",
"(",
"self",
")",
":",
"# Reshape to use within a convolutional neural net.",
"# Last dimension is for \"features\" - there is only one here, since images are",
"# grayscale -- it would be 3 for an RGB image, 4 for RGBA, etc.",
"with",
"tf",
".",
"name_scope",
"(",
... | [
47,
4
] | [
121,
56
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.