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_convert_same_unit | () | Test conversion from any unit to same unit. | Test conversion from any unit to same unit. | def test_convert_same_unit():
"""Test conversion from any unit to same unit."""
assert pressure_util.convert(2, PRESSURE_PA, PRESSURE_PA) == 2
assert pressure_util.convert(3, PRESSURE_HPA, PRESSURE_HPA) == 3
assert pressure_util.convert(4, PRESSURE_MBAR, PRESSURE_MBAR) == 4
assert pressure_util.conv... | [
"def",
"test_convert_same_unit",
"(",
")",
":",
"assert",
"pressure_util",
".",
"convert",
"(",
"2",
",",
"PRESSURE_PA",
",",
"PRESSURE_PA",
")",
"==",
"2",
"assert",
"pressure_util",
".",
"convert",
"(",
"3",
",",
"PRESSURE_HPA",
",",
"PRESSURE_HPA",
")",
"... | [
16,
0
] | [
21,
70
] | python | en | ['en', 'en', 'en'] | True |
test_convert_invalid_unit | () | Test exception is thrown for invalid units. | Test exception is thrown for invalid units. | def test_convert_invalid_unit():
"""Test exception is thrown for invalid units."""
with pytest.raises(ValueError):
pressure_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)
with pytest.raises(ValueError):
pressure_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL) | [
"def",
"test_convert_invalid_unit",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
")",
":",
"pressure_util",
".",
"convert",
"(",
"5",
",",
"INVALID_SYMBOL",
",",
"VALID_SYMBOL",
")",
"with",
"pytest",
".",
"raises",
"(",
"ValueError",
"... | [
24,
0
] | [
30,
62
] | python | en | ['en', 'en', 'en'] | True |
test_convert_nonnumeric_value | () | Test exception is thrown for nonnumeric type. | Test exception is thrown for nonnumeric type. | def test_convert_nonnumeric_value():
"""Test exception is thrown for nonnumeric type."""
with pytest.raises(TypeError):
pressure_util.convert("a", PRESSURE_HPA, PRESSURE_INHG) | [
"def",
"test_convert_nonnumeric_value",
"(",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"TypeError",
")",
":",
"pressure_util",
".",
"convert",
"(",
"\"a\"",
",",
"PRESSURE_HPA",
",",
"PRESSURE_INHG",
")"
] | [
33,
0
] | [
36,
63
] | python | en | ['en', 'en', 'en'] | True |
test_convert_from_hpascals | () | Test conversion from hPA to other units. | Test conversion from hPA to other units. | def test_convert_from_hpascals():
"""Test conversion from hPA to other units."""
hpascals = 1000
assert pressure_util.convert(hpascals, PRESSURE_HPA, PRESSURE_PSI) == pytest.approx(
14.5037743897
)
assert pressure_util.convert(
hpascals, PRESSURE_HPA, PRESSURE_INHG
) == pytest.ap... | [
"def",
"test_convert_from_hpascals",
"(",
")",
":",
"hpascals",
"=",
"1000",
"assert",
"pressure_util",
".",
"convert",
"(",
"hpascals",
",",
"PRESSURE_HPA",
",",
"PRESSURE_PSI",
")",
"==",
"pytest",
".",
"approx",
"(",
"14.5037743897",
")",
"assert",
"pressure_... | [
39,
0
] | [
53,
28
] | python | en | ['en', 'en', 'en'] | True |
test_convert_from_inhg | () | Test conversion from inHg to other units. | Test conversion from inHg to other units. | def test_convert_from_inhg():
"""Test conversion from inHg to other units."""
inhg = 30
assert pressure_util.convert(inhg, PRESSURE_INHG, PRESSURE_PSI) == pytest.approx(
14.7346266155
)
assert pressure_util.convert(inhg, PRESSURE_INHG, PRESSURE_HPA) == pytest.approx(
1015.9167
)
... | [
"def",
"test_convert_from_inhg",
"(",
")",
":",
"inhg",
"=",
"30",
"assert",
"pressure_util",
".",
"convert",
"(",
"inhg",
",",
"PRESSURE_INHG",
",",
"PRESSURE_PSI",
")",
"==",
"pytest",
".",
"approx",
"(",
"14.7346266155",
")",
"assert",
"pressure_util",
".",... | [
56,
0
] | [
70,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the Ness Alarm alarm control panel devices. | Set up the Ness Alarm alarm control panel devices. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the Ness Alarm alarm control panel devices."""
if discovery_info is None:
return
device = NessAlarmPanel(hass.data[DATA_NESS], "Alarm Panel")
async_add_entities([device]) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"device",
"=",
"NessAlarmPanel",
"(",
"hass",
".",
"data",
"[",
... | [
27,
0
] | [
33,
32
] | python | en | ['en', 'en', 'en'] | True |
NessAlarmPanel.__init__ | (self, client, name) | Initialize the alarm panel. | Initialize the alarm panel. | def __init__(self, client, name):
"""Initialize the alarm panel."""
self._client = client
self._name = name
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"client",
",",
"name",
")",
":",
"self",
".",
"_client",
"=",
"client",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state",
"=",
"None"
] | [
39,
4
] | [
43,
26
] | python | en | ['en', 'en', 'en'] | True |
NessAlarmPanel.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, SIGNAL_ARMING_STATE_CHANGED, self._handle_arming_state_change
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"SIGNAL_ARMING_STATE_CHANGED",
",",
"self",
".",
"_handle_arming_state_change",
")",
")"
] | [
45,
4
] | [
51,
9
] | python | en | ['en', 'no', 'en'] | False |
NessAlarmPanel.name | (self) | Return the name of the device. | Return the name of the device. | def name(self):
"""Return the name of the device."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
54,
4
] | [
56,
25
] | python | en | ['en', 'en', 'en'] | True |
NessAlarmPanel.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
59,
4
] | [
61,
20
] | python | en | ['en', 'en', 'en'] | True |
NessAlarmPanel.code_format | (self) | Return the regex for code format or None if no code is required. | Return the regex for code format or None if no code is required. | def code_format(self):
"""Return the regex for code format or None if no code is required."""
return alarm.FORMAT_NUMBER | [
"def",
"code_format",
"(",
"self",
")",
":",
"return",
"alarm",
".",
"FORMAT_NUMBER"
] | [
64,
4
] | [
66,
34
] | python | en | ['en', 'en', 'en'] | True |
NessAlarmPanel.state | (self) | Return the state of the device. | Return the state of the device. | def state(self):
"""Return the state of the device."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
69,
4
] | [
71,
26
] | python | en | ['en', 'en', 'en'] | True |
NessAlarmPanel.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 | SUPPORT_ALARM_TRIGGER | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_ALARM_ARM_HOME",
"|",
"SUPPORT_ALARM_ARM_AWAY",
"|",
"SUPPORT_ALARM_TRIGGER"
] | [
74,
4
] | [
76,
86
] | python | en | ['en', 'en', 'en'] | True |
NessAlarmPanel.async_alarm_disarm | (self, code=None) | Send disarm command. | Send disarm command. | async def async_alarm_disarm(self, code=None):
"""Send disarm command."""
await self._client.disarm(code) | [
"async",
"def",
"async_alarm_disarm",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_client",
".",
"disarm",
"(",
"code",
")"
] | [
78,
4
] | [
80,
39
] | python | en | ['en', 'pt', 'en'] | True |
NessAlarmPanel.async_alarm_arm_away | (self, code=None) | Send arm away command. | Send arm away command. | async def async_alarm_arm_away(self, code=None):
"""Send arm away command."""
await self._client.arm_away(code) | [
"async",
"def",
"async_alarm_arm_away",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_client",
".",
"arm_away",
"(",
"code",
")"
] | [
82,
4
] | [
84,
41
] | python | en | ['en', 'en', 'en'] | True |
NessAlarmPanel.async_alarm_arm_home | (self, code=None) | Send arm home command. | Send arm home command. | async def async_alarm_arm_home(self, code=None):
"""Send arm home command."""
await self._client.arm_home(code) | [
"async",
"def",
"async_alarm_arm_home",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_client",
".",
"arm_home",
"(",
"code",
")"
] | [
86,
4
] | [
88,
41
] | python | en | ['en', 'pt', 'en'] | True |
NessAlarmPanel.async_alarm_trigger | (self, code=None) | Send trigger/panic command. | Send trigger/panic command. | async def async_alarm_trigger(self, code=None):
"""Send trigger/panic command."""
await self._client.panic(code) | [
"async",
"def",
"async_alarm_trigger",
"(",
"self",
",",
"code",
"=",
"None",
")",
":",
"await",
"self",
".",
"_client",
".",
"panic",
"(",
"code",
")"
] | [
90,
4
] | [
92,
38
] | python | en | ['en', 'zh', 'en'] | True |
NessAlarmPanel._handle_arming_state_change | (self, arming_state) | Handle arming state update. | Handle arming state update. | def _handle_arming_state_change(self, arming_state):
"""Handle arming state update."""
if arming_state == ArmingState.UNKNOWN:
self._state = None
elif arming_state == ArmingState.DISARMED:
self._state = STATE_ALARM_DISARMED
elif arming_state == ArmingState.ARMING... | [
"def",
"_handle_arming_state_change",
"(",
"self",
",",
"arming_state",
")",
":",
"if",
"arming_state",
"==",
"ArmingState",
".",
"UNKNOWN",
":",
"self",
".",
"_state",
"=",
"None",
"elif",
"arming_state",
"==",
"ArmingState",
".",
"DISARMED",
":",
"self",
"."... | [
95,
4
] | [
115,
35
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) | Set up the Genius Hub sensor entities. | Set up the Genius Hub sensor entities. | async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
) -> None:
"""Set up the Genius Hub sensor entities."""
if discovery_info is None:
return
broker = hass.data[DOMAIN]["broker"]
switches = [
GeniusBinarySensor(broker... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
"->",
"None",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"broker",... | [
9,
0
] | [
24,
56
] | python | en | ['en', 'et', 'en'] | True |
GeniusBinarySensor.__init__ | (self, broker, device, state_attr) | Initialize the binary sensor. | Initialize the binary sensor. | def __init__(self, broker, device, state_attr) -> None:
"""Initialize the binary sensor."""
super().__init__(broker, device)
self._state_attr = state_attr
if device.type[:21] == "Dual Channel Receiver":
self._name = f"{device.type[:21]} {device.id}"
else:
... | [
"def",
"__init__",
"(",
"self",
",",
"broker",
",",
"device",
",",
"state_attr",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"broker",
",",
"device",
")",
"self",
".",
"_state_attr",
"=",
"state_attr",
"if",
"device",
".",
"type",
... | [
30,
4
] | [
39,
53
] | python | en | ['en', 'haw', 'en'] | True |
GeniusBinarySensor.is_on | (self) | Return the status of the sensor. | Return the status of the sensor. | def is_on(self) -> bool:
"""Return the status of the sensor."""
return self._device.data["state"][self._state_attr] | [
"def",
"is_on",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_device",
".",
"data",
"[",
"\"state\"",
"]",
"[",
"self",
".",
"_state_attr",
"]"
] | [
42,
4
] | [
44,
59
] | python | en | ['en', 'id', 'en'] | True |
GaussianProcess_QuasiPeriodicActivity_Common.convert_val2gp | (self, input_pams) |
:param input_pam: dictonary with the 'physically meaningful' parameters of the GP kernel
:return: dictonary with the parameters to be fed to 'george'
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
create a new Class with different transformation... |
:param input_pam: dictonary with the 'physically meaningful' parameters of the GP kernel
:return: dictonary with the parameters to be fed to 'george'
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
create a new Class with different transformation... | def convert_val2gp(self, input_pams):
"""
:param input_pam: dictonary with the 'physically meaningful' parameters of the GP kernel
:return: dictonary with the parameters to be fed to 'george'
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
... | [
"def",
"convert_val2gp",
"(",
"self",
",",
"input_pams",
")",
":",
"output_pams",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"n_pams",
",",
"dtype",
"=",
"np",
".",
"double",
")",
"\"\"\" You must check _george_ documentation (and possibily do a lot of testing) to kno... | [
58,
4
] | [
77,
26
] | python | en | ['en', 'error', 'th'] | False |
GaussianProcess_QuasiPeriodicActivity_Common.convert_gp2val | (self, input_pams) |
:param input_pam: dictonary with the parameters to be fed to 'george'
:return: dictonary with the 'physically meaningful' parameters of the GP kernel
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
create a new Class with different transformation... |
:param input_pam: dictonary with the parameters to be fed to 'george'
:return: dictonary with the 'physically meaningful' parameters of the GP kernel
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
create a new Class with different transformation... | def convert_gp2val(self, input_pams):
"""
:param input_pam: dictonary with the parameters to be fed to 'george'
:return: dictonary with the 'physically meaningful' parameters of the GP kernel
WARNING: this subroutine is HIGHLY specific of your choice of the kernel! I reccomend to
... | [
"def",
"convert_gp2val",
"(",
"self",
",",
"input_pams",
")",
":",
"return",
"{",
"'Hamp'",
":",
"np",
".",
"exp",
"(",
"input_pams",
"[",
"self",
".",
"gp_pams_index",
"[",
"'Hamp'",
"]",
"]",
"/",
"2.0",
")",
",",
"'Pdec'",
":",
"np",
".",
"exp",
... | [
79,
4
] | [
92,
9
] | python | en | ['en', 'error', 'th'] | False |
GaussianProcess_QuasiPeriodicActivity_Common.define_kernel | (self, dataset) | Kernel initialized with fake values... don't worry, they'll be overwritten soon | Kernel initialized with fake values... don't worry, they'll be overwritten soon | def define_kernel(self, dataset):
gp_pams = np.ones(self.n_pams)
""" Kernel initialized with fake values... don't worry, they'll be overwritten soon"""
kernel = np.exp(gp_pams[0]) * \
george.kernels.ExpSquaredKernel(metric=np.exp(gp_pams[1])) * \
geor... | [
"def",
"define_kernel",
"(",
"self",
",",
"dataset",
")",
":",
"gp_pams",
"=",
"np",
".",
"ones",
"(",
"self",
".",
"n_pams",
")",
"kernel",
"=",
"np",
".",
"exp",
"(",
"gp_pams",
"[",
"0",
"]",
")",
"*",
"george",
".",
"kernels",
".",
"ExpSquaredK... | [
103,
4
] | [
138,
14
] | python | en | ['en', 'en', 'en'] | True |
GaussianProcess_QuasiPeriodicActivity_Common.lnlk_compute | (self) | 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to {\tt george} input parameters
| 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to {\tt george} input parameters
| def lnlk_compute(self):
""" 2 steps:
1) theta parameters must be converted in physical units (e.g. from logarithmic to linear spaces)
2) physical values must be converted to {\tt george} input parameters
"""
self.gp.set_parameter_vector(self.internal_gp_pams)
self.... | [
"def",
"lnlk_compute",
"(",
"self",
")",
":",
"self",
".",
"gp",
".",
"set_parameter_vector",
"(",
"self",
".",
"internal_gp_pams",
")",
"self",
".",
"gp",
".",
"compute",
"(",
"self",
".",
"internal_dataset",
"[",
"'x0'",
"]",
",",
"self",
".",
"interna... | [
151,
4
] | [
159,
78
] | python | en | ['en', 'sk', 'en'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up the ONVIF camera video stream. | Set up the ONVIF camera video stream. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up the ONVIF camera video stream."""
platform = entity_platform.current_platform.get()
# Create PTZ service
platform.async_register_entity_service(
SERVICE_PTZ,
{
vol.Optional(ATTR_PAN): vol.In([DIR_... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"platform",
"=",
"entity_platform",
".",
"current_platform",
".",
"get",
"(",
")",
"# Create PTZ service",
"platform",
".",
"async_register_entity_service",
"("... | [
42,
0
] | [
69,
15
] | python | en | ['en', 'pt', 'en'] | True |
ONVIFCameraEntity.__init__ | (self, device, profile) | Initialize ONVIF camera entity. | Initialize ONVIF camera entity. | def __init__(self, device, profile):
"""Initialize ONVIF camera entity."""
ONVIFBaseEntity.__init__(self, device, profile)
Camera.__init__(self)
self.stream_options[CONF_RTSP_TRANSPORT] = device.config_entry.options.get(
CONF_RTSP_TRANSPORT
)
self._basic_auth ... | [
"def",
"__init__",
"(",
"self",
",",
"device",
",",
"profile",
")",
":",
"ONVIFBaseEntity",
".",
"__init__",
"(",
"self",
",",
"device",
",",
"profile",
")",
"Camera",
".",
"__init__",
"(",
"self",
")",
"self",
".",
"stream_options",
"[",
"CONF_RTSP_TRANSP... | [
75,
4
] | [
86,
31
] | python | es | ['es', 'pl', 'it'] | False |
ONVIFCameraEntity.supported_features | (self) | Return supported features. | Return supported features. | def supported_features(self) -> int:
"""Return supported features."""
return SUPPORT_STREAM | [
"def",
"supported_features",
"(",
"self",
")",
"->",
"int",
":",
"return",
"SUPPORT_STREAM"
] | [
89,
4
] | [
91,
29
] | python | en | ['en', 'en', 'en'] | True |
ONVIFCameraEntity.name | (self) | Return the name of this camera. | Return the name of this camera. | def name(self) -> str:
"""Return the name of this camera."""
return f"{self.device.name} - {self.profile.name}" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self.device.name} - {self.profile.name}\""
] | [
94,
4
] | [
96,
58
] | python | en | ['en', 'en', 'en'] | True |
ONVIFCameraEntity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
if self.profile.index:
return f"{self.device.info.mac or self.device.info.serial_number}_{self.profile.index}"
return self.device.info.mac or self.device.info.serial_number | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"profile",
".",
"index",
":",
"return",
"f\"{self.device.info.mac or self.device.info.serial_number}_{self.profile.index}\"",
"return",
"self",
".",
"device",
".",
"info",
".",
"mac",
"or",
... | [
99,
4
] | [
103,
69
] | python | ca | ['fr', 'ca', 'en'] | False |
ONVIFCameraEntity.entity_registry_enabled_default | (self) | Return if the entity should be enabled when first added to the entity registry. | Return if the entity should be enabled when first added to the entity registry. | def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return self.device.max_resolution == self.profile.video.resolution.width | [
"def",
"entity_registry_enabled_default",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"device",
".",
"max_resolution",
"==",
"self",
".",
"profile",
".",
"video",
".",
"resolution",
".",
"width"
] | [
106,
4
] | [
108,
80
] | python | en | ['en', 'en', 'en'] | True |
ONVIFCameraEntity.stream_source | (self) | Return the stream source. | Return the stream source. | async def stream_source(self):
"""Return the stream source."""
return self._stream_uri | [
"async",
"def",
"stream_source",
"(",
"self",
")",
":",
"return",
"self",
".",
"_stream_uri"
] | [
110,
4
] | [
112,
31
] | python | en | ['en', 'ig', 'en'] | True |
ONVIFCameraEntity.async_camera_image | (self) | Return a still image response from the camera. | Return a still image response from the camera. | async def async_camera_image(self):
"""Return a still image response from the camera."""
image = None
if self.device.capabilities.snapshot:
try:
image = await self.device.device.get_snapshot(
self.profile.token, self._basic_auth
)
... | [
"async",
"def",
"async_camera_image",
"(",
"self",
")",
":",
"image",
"=",
"None",
"if",
"self",
".",
"device",
".",
"capabilities",
".",
"snapshot",
":",
"try",
":",
"image",
"=",
"await",
"self",
".",
"device",
".",
"device",
".",
"get_snapshot",
"(",
... | [
114,
4
] | [
142,
20
] | python | en | ['en', 'en', 'en'] | True |
ONVIFCameraEntity.handle_async_mjpeg_stream | (self, request) | Generate an HTTP MJPEG stream from the camera. | Generate an HTTP MJPEG stream from the camera. | async def handle_async_mjpeg_stream(self, request):
"""Generate an HTTP MJPEG stream from the camera."""
LOGGER.debug("Handling mjpeg stream from camera '%s'", self.device.name)
ffmpeg_manager = self.hass.data[DATA_FFMPEG]
stream = CameraMjpeg(ffmpeg_manager.binary, loop=self.hass.loop)... | [
"async",
"def",
"handle_async_mjpeg_stream",
"(",
"self",
",",
"request",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Handling mjpeg stream from camera '%s'\"",
",",
"self",
".",
"device",
".",
"name",
")",
"ffmpeg_manager",
"=",
"self",
".",
"hass",
".",
"data",
... | [
144,
4
] | [
165,
32
] | python | en | ['en', 'en', 'en'] | True |
ONVIFCameraEntity.async_added_to_hass | (self) | Run when entity about to be added to hass. | Run when entity about to be added to hass. | async def async_added_to_hass(self):
"""Run when entity about to be added to hass."""
uri_no_auth = await self.device.async_get_stream_uri(self.profile)
self._stream_uri = uri_no_auth.replace(
"rtsp://", f"rtsp://{self.device.username}:{self.device.password}@", 1
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"uri_no_auth",
"=",
"await",
"self",
".",
"device",
".",
"async_get_stream_uri",
"(",
"self",
".",
"profile",
")",
"self",
".",
"_stream_uri",
"=",
"uri_no_auth",
".",
"replace",
"(",
"\"rtsp://\"",... | [
167,
4
] | [
172,
9
] | python | en | ['en', 'en', 'en'] | True |
ONVIFCameraEntity.async_perform_ptz | (
self,
distance,
speed,
move_mode,
continuous_duration,
preset,
pan=None,
tilt=None,
zoom=None,
) | Perform a PTZ action on the camera. | Perform a PTZ action on the camera. | async def async_perform_ptz(
self,
distance,
speed,
move_mode,
continuous_duration,
preset,
pan=None,
tilt=None,
zoom=None,
) -> None:
"""Perform a PTZ action on the camera."""
await self.device.async_perform_ptz(
se... | [
"async",
"def",
"async_perform_ptz",
"(",
"self",
",",
"distance",
",",
"speed",
",",
"move_mode",
",",
"continuous_duration",
",",
"preset",
",",
"pan",
"=",
"None",
",",
"tilt",
"=",
"None",
",",
"zoom",
"=",
"None",
",",
")",
"->",
"None",
":",
"awa... | [
174,
4
] | [
196,
9
] | python | en | ['en', 'en', 'en'] | True |
train | (args, train_dataset, model, tokenizer, criterion) | Train the model | Train the model | def train(args, train_dataset, model, tokenizer, criterion):
""" Train the model """
if args.local_rank in [-1, 0]:
tb_writer = SummaryWriter()
args.train_batch_size = args.per_gpu_train_batch_size * max(1, args.n_gpu)
train_sampler = RandomSampler(train_dataset) if args.local_rank == -1 else D... | [
"def",
"train",
"(",
"args",
",",
"train_dataset",
",",
"model",
",",
"tokenizer",
",",
"criterion",
")",
":",
"if",
"args",
".",
"local_rank",
"in",
"[",
"-",
"1",
",",
"0",
"]",
":",
"tb_writer",
"=",
"SummaryWriter",
"(",
")",
"args",
".",
"train_... | [
65,
0
] | [
231,
45
] | python | en | ['en', 'it', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the kaiterra temperature and humidity sensor. | Set up the kaiterra temperature and humidity sensor. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the kaiterra temperature and humidity sensor."""
if discovery_info is None:
return
api = hass.data[DOMAIN]
name = discovery_info[CONF_NAME]
device_id = discovery_info[CONF_DEVICE_ID]
async_... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"api",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"name",
"... | [
13,
0
] | [
24,
5
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.__init__ | (self, api, name, device_id, sensor) | Initialize the sensor. | Initialize the sensor. | def __init__(self, api, name, device_id, sensor):
"""Initialize the sensor."""
self._api = api
self._name = f'{name} {sensor["name"]}'
self._device_id = device_id
self._kind = sensor["name"].lower()
self._property = sensor["prop"]
self._device_class = sensor["devi... | [
"def",
"__init__",
"(",
"self",
",",
"api",
",",
"name",
",",
"device_id",
",",
"sensor",
")",
":",
"self",
".",
"_api",
"=",
"api",
"self",
".",
"_name",
"=",
"f'{name} {sensor[\"name\"]}'",
"self",
".",
"_device_id",
"=",
"device_id",
"self",
".",
"_ki... | [
30,
4
] | [
37,
51
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor._sensor | (self) | Return the sensor data. | Return the sensor data. | def _sensor(self):
"""Return the sensor data."""
return self._api.data.get(self._device_id, {}).get(self._property, {}) | [
"def",
"_sensor",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"self",
".",
"_device_id",
",",
"{",
"}",
")",
".",
"get",
"(",
"self",
".",
"_property",
",",
"{",
"}",
")"
] | [
40,
4
] | [
42,
78
] | python | en | ['en', 'no', 'en'] | True |
KaiterraSensor.should_poll | (self) | Return that the sensor should not be polled. | Return that the sensor should not be polled. | def should_poll(self):
"""Return that the sensor should not be polled."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
45,
4
] | [
47,
20
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.available | (self) | Return the availability of the sensor. | Return the availability of the sensor. | def available(self):
"""Return the availability of the sensor."""
return self._api.data.get(self._device_id) is not None | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"self",
".",
"_api",
".",
"data",
".",
"get",
"(",
"self",
".",
"_device_id",
")",
"is",
"not",
"None"
] | [
50,
4
] | [
52,
62
] | python | en | ['en', 'ga', 'en'] | True |
KaiterraSensor.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
55,
4
] | [
57,
33
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
60,
4
] | [
62,
25
] | python | en | ['en', 'ig', 'en'] | True |
KaiterraSensor.state | (self) | Return the state. | Return the state. | def state(self):
"""Return the state."""
return self._sensor.get("value") | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sensor",
".",
"get",
"(",
"\"value\"",
")"
] | [
65,
4
] | [
67,
40
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.unique_id | (self) | Return the sensor's unique id. | Return the sensor's unique id. | def unique_id(self):
"""Return the sensor's unique id."""
return f"{self._device_id}_{self._kind}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f\"{self._device_id}_{self._kind}\""
] | [
70,
4
] | [
72,
48
] | python | en | ['en', 'ca', 'en'] | True |
KaiterraSensor.unit_of_measurement | (self) | Return the unit the value is expressed in. | Return the unit the value is expressed in. | def unit_of_measurement(self):
"""Return the unit the value is expressed in."""
if not self._sensor.get("units"):
return None
value = self._sensor["units"].value
if value == "F":
return TEMP_FAHRENHEIT
if value == "C":
return TEMP_CELSIUS
... | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_sensor",
".",
"get",
"(",
"\"units\"",
")",
":",
"return",
"None",
"value",
"=",
"self",
".",
"_sensor",
"[",
"\"units\"",
"]",
".",
"value",
"if",
"value",
"==",
"\"F\"",... | [
75,
4
] | [
86,
20
] | python | en | ['en', 'en', 'en'] | True |
KaiterraSensor.async_added_to_hass | (self) | Register callback. | Register callback. | async def async_added_to_hass(self):
"""Register callback."""
self.async_on_remove(
async_dispatcher_connect(
self.hass, DISPATCHER_KAITERRA, self.async_write_ha_state
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"DISPATCHER_KAITERRA",
",",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
88,
4
] | [
94,
9
] | python | en | ['en', 'no', 'en'] | False |
setup_platform | (hass, config, add_devices, discovery_info=None) | Nissan Leaf switch platform setup. | Nissan Leaf switch platform setup. | def setup_platform(hass, config, add_devices, discovery_info=None):
"""Nissan Leaf switch platform setup."""
if discovery_info is None:
return
devices = []
for vin, datastore in hass.data[DATA_LEAF].items():
_LOGGER.debug("Adding switch for vin=%s", vin)
devices.append(LeafClima... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_devices",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"devices",
"=",
"[",
"]",
"for",
"vin",
",",
"datastore",
"in",
"hass",
".",
"data... | [
10,
0
] | [
20,
30
] | python | en | ['en', 'da', 'en'] | True |
LeafClimateSwitch.name | (self) | Switch name. | Switch name. | def name(self):
"""Switch name."""
return f"{self.car.leaf.nickname} Climate Control" | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f\"{self.car.leaf.nickname} Climate Control\""
] | [
27,
4
] | [
29,
58
] | python | en | ['en', 'en', 'en'] | False |
LeafClimateSwitch.log_registration | (self) | Log registration. | Log registration. | def log_registration(self):
"""Log registration."""
_LOGGER.debug(
"Registered LeafClimateSwitch integration with Home Assistant for VIN %s",
self.car.leaf.vin,
) | [
"def",
"log_registration",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Registered LeafClimateSwitch integration with Home Assistant for VIN %s\"",
",",
"self",
".",
"car",
".",
"leaf",
".",
"vin",
",",
")"
] | [
31,
4
] | [
36,
9
] | python | da | ['da', 'da', 'en'] | False |
LeafClimateSwitch.device_state_attributes | (self) | Return climate control attributes. | Return climate control attributes. | def device_state_attributes(self):
"""Return climate control attributes."""
attrs = super().device_state_attributes
attrs["updated_on"] = self.car.last_climate_response
return attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attrs",
"=",
"super",
"(",
")",
".",
"device_state_attributes",
"attrs",
"[",
"\"updated_on\"",
"]",
"=",
"self",
".",
"car",
".",
"last_climate_response",
"return",
"attrs"
] | [
39,
4
] | [
43,
20
] | python | en | ['en', 'en', 'en'] | True |
LeafClimateSwitch.is_on | (self) | Return true if climate control is on. | Return true if climate control is on. | def is_on(self):
"""Return true if climate control is on."""
return self.car.data[DATA_CLIMATE] | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"car",
".",
"data",
"[",
"DATA_CLIMATE",
"]"
] | [
46,
4
] | [
48,
42
] | python | en | ['en', 'en', 'en'] | True |
LeafClimateSwitch.async_turn_on | (self, **kwargs) | Turn on climate control. | Turn on climate control. | async def async_turn_on(self, **kwargs):
"""Turn on climate control."""
if await self.car.async_set_climate(True):
self.car.data[DATA_CLIMATE] = True | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"await",
"self",
".",
"car",
".",
"async_set_climate",
"(",
"True",
")",
":",
"self",
".",
"car",
".",
"data",
"[",
"DATA_CLIMATE",
"]",
"=",
"True"
] | [
50,
4
] | [
53,
46
] | python | en | ['en', 'en', 'en'] | True |
LeafClimateSwitch.async_turn_off | (self, **kwargs) | Turn off climate control. | Turn off climate control. | async def async_turn_off(self, **kwargs):
"""Turn off climate control."""
if await self.car.async_set_climate(False):
self.car.data[DATA_CLIMATE] = False | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"await",
"self",
".",
"car",
".",
"async_set_climate",
"(",
"False",
")",
":",
"self",
".",
"car",
".",
"data",
"[",
"DATA_CLIMATE",
"]",
"=",
"False"
] | [
55,
4
] | [
58,
47
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (hass, entry, async_add_entities) | Set up the hunter douglas shades. | Set up the hunter douglas shades. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the hunter douglas shades."""
pv_data = hass.data[DOMAIN][entry.entry_id]
room_data = pv_data[PV_ROOM_DATA]
shade_data = pv_data[PV_SHADE_DATA]
pv_request = pv_data[PV_API]
coordinator = pv_data[COORDINATOR]
device_info... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"pv_data",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"room_data",
"=",
"pv_data",
"[",
"PV_ROOM_DATA",
"]",
"shade_... | [
50,
0
] | [
84,
32
] | python | en | ['en', 'fil', 'en'] | True |
hd_position_to_hass | (hd_position) | Convert hunter douglas position to hass position. | Convert hunter douglas position to hass position. | def hd_position_to_hass(hd_position):
"""Convert hunter douglas position to hass position."""
return round((hd_position / MAX_POSITION) * 100) | [
"def",
"hd_position_to_hass",
"(",
"hd_position",
")",
":",
"return",
"round",
"(",
"(",
"hd_position",
"/",
"MAX_POSITION",
")",
"*",
"100",
")"
] | [
87,
0
] | [
89,
52
] | python | en | ['en', 'en', 'en'] | True |
hass_position_to_hd | (hass_positon) | Convert hass position to hunter douglas position. | Convert hass position to hunter douglas position. | def hass_position_to_hd(hass_positon):
"""Convert hass position to hunter douglas position."""
return int(hass_positon / 100 * MAX_POSITION) | [
"def",
"hass_position_to_hd",
"(",
"hass_positon",
")",
":",
"return",
"int",
"(",
"hass_positon",
"/",
"100",
"*",
"MAX_POSITION",
")"
] | [
92,
0
] | [
94,
49
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.__init__ | (self, shade, name, room_data, coordinator, device_info) | Initialize the shade. | Initialize the shade. | def __init__(self, shade, name, room_data, coordinator, device_info):
"""Initialize the shade."""
room_id = shade.raw_data.get(ROOM_ID_IN_SHADE)
super().__init__(coordinator, device_info, shade, name)
self._shade = shade
self._device_info = device_info
self._is_opening = ... | [
"def",
"__init__",
"(",
"self",
",",
"shade",
",",
"name",
",",
"room_data",
",",
"coordinator",
",",
"device_info",
")",
":",
"room_id",
"=",
"shade",
".",
"raw_data",
".",
"get",
"(",
"ROOM_ID_IN_SHADE",
")",
"super",
"(",
")",
".",
"__init__",
"(",
... | [
100,
4
] | [
111,
51
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
return {STATE_ATTRIBUTE_ROOM_NAME: self._room_name} | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"{",
"STATE_ATTRIBUTE_ROOM_NAME",
":",
"self",
".",
"_room_name",
"}"
] | [
114,
4
] | [
116,
59
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
if self._device_info[DEVICE_MODEL] != LEGACY_DEVICE_MODEL:
supported_features |= SUPPORT_STOP
return supported_features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"supported_features",
"=",
"SUPPORT_OPEN",
"|",
"SUPPORT_CLOSE",
"|",
"SUPPORT_SET_POSITION",
"if",
"self",
".",
"_device_info",
"[",
"DEVICE_MODEL",
"]",
"!=",
"LEGACY_DEVICE_MODEL",
":",
"supported_features",
"|=",... | [
119,
4
] | [
124,
33
] | python | en | ['da', 'en', 'en'] | True |
PowerViewShade.is_closed | (self) | Return if the cover is closed. | Return if the cover is closed. | def is_closed(self):
"""Return if the cover is closed."""
return self._current_cover_position == MIN_POSITION | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_current_cover_position",
"==",
"MIN_POSITION"
] | [
127,
4
] | [
129,
59
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.is_opening | (self) | Return if the cover is opening. | Return if the cover is opening. | def is_opening(self):
"""Return if the cover is opening."""
return self._is_opening | [
"def",
"is_opening",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_opening"
] | [
132,
4
] | [
134,
31
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.is_closing | (self) | Return if the cover is closing. | Return if the cover is closing. | def is_closing(self):
"""Return if the cover is closing."""
return self._is_closing | [
"def",
"is_closing",
"(",
"self",
")",
":",
"return",
"self",
".",
"_is_closing"
] | [
137,
4
] | [
139,
31
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.current_cover_position | (self) | Return the current position of cover. | Return the current position of cover. | def current_cover_position(self):
"""Return the current position of cover."""
return hd_position_to_hass(self._current_cover_position) | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"return",
"hd_position_to_hass",
"(",
"self",
".",
"_current_cover_position",
")"
] | [
142,
4
] | [
144,
64
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.device_class | (self) | Return device class. | Return device class. | def device_class(self):
"""Return device class."""
return DEVICE_CLASS_SHADE | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_SHADE"
] | [
147,
4
] | [
149,
33
] | python | en | ['es', 'zh', 'en'] | False |
PowerViewShade.name | (self) | Return the name of the shade. | Return the name of the shade. | def name(self):
"""Return the name of the shade."""
return self._shade_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_shade_name"
] | [
152,
4
] | [
154,
31
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.async_close_cover | (self, **kwargs) | Close the cover. | Close the cover. | async def async_close_cover(self, **kwargs):
"""Close the cover."""
await self._async_move(0) | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_async_move",
"(",
"0",
")"
] | [
156,
4
] | [
158,
33
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.async_open_cover | (self, **kwargs) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs):
"""Open the cover."""
await self._async_move(100) | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_async_move",
"(",
"100",
")"
] | [
160,
4
] | [
162,
35
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.async_stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover(self, **kwargs):
"""Stop the cover."""
# Cancel any previous updates
self._async_cancel_scheduled_transition_update()
self._async_update_from_command(await self._shade.stop())
await self._async_force_refresh_state() | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Cancel any previous updates",
"self",
".",
"_async_cancel_scheduled_transition_update",
"(",
")",
"self",
".",
"_async_update_from_command",
"(",
"await",
"self",
".",
"_shade",
"... | [
164,
4
] | [
169,
47
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.async_set_cover_position | (self, **kwargs) | Move the shade to a specific position. | Move the shade to a specific position. | async def async_set_cover_position(self, **kwargs):
"""Move the shade to a specific position."""
if ATTR_POSITION not in kwargs:
return
await self._async_move(kwargs[ATTR_POSITION]) | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ATTR_POSITION",
"not",
"in",
"kwargs",
":",
"return",
"await",
"self",
".",
"_async_move",
"(",
"kwargs",
"[",
"ATTR_POSITION",
"]",
")"
] | [
171,
4
] | [
175,
53
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade._async_move | (self, target_hass_position) | Move the shade to a position. | Move the shade to a position. | async def _async_move(self, target_hass_position):
"""Move the shade to a position."""
current_hass_position = hd_position_to_hass(self._current_cover_position)
steps_to_move = abs(current_hass_position - target_hass_position)
if not steps_to_move:
return
self._async_... | [
"async",
"def",
"_async_move",
"(",
"self",
",",
"target_hass_position",
")",
":",
"current_hass_position",
"=",
"hd_position_to_hass",
"(",
"self",
".",
"_current_cover_position",
")",
"steps_to_move",
"=",
"abs",
"(",
"current_hass_position",
"-",
"target_hass_positio... | [
177,
4
] | [
198,
35
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade._async_update_from_command | (self, raw_data) | Update the shade state after a command. | Update the shade state after a command. | def _async_update_from_command(self, raw_data):
"""Update the shade state after a command."""
if not raw_data or SHADE_RESPONSE not in raw_data:
return
self._async_process_new_shade_data(raw_data[SHADE_RESPONSE]) | [
"def",
"_async_update_from_command",
"(",
"self",
",",
"raw_data",
")",
":",
"if",
"not",
"raw_data",
"or",
"SHADE_RESPONSE",
"not",
"in",
"raw_data",
":",
"return",
"self",
".",
"_async_process_new_shade_data",
"(",
"raw_data",
"[",
"SHADE_RESPONSE",
"]",
")"
] | [
201,
4
] | [
205,
68
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade._async_process_new_shade_data | (self, data) | Process new data from an update. | Process new data from an update. | def _async_process_new_shade_data(self, data):
"""Process new data from an update."""
self._shade.raw_data = data
self._async_update_current_cover_position() | [
"def",
"_async_process_new_shade_data",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_shade",
".",
"raw_data",
"=",
"data",
"self",
".",
"_async_update_current_cover_position",
"(",
")"
] | [
208,
4
] | [
211,
51
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade._async_update_current_cover_position | (self) | Update the current cover position from the data. | Update the current cover position from the data. | def _async_update_current_cover_position(self):
"""Update the current cover position from the data."""
_LOGGER.debug("Raw data update: %s", self._shade.raw_data)
position_data = self._shade.raw_data.get(ATTR_POSITION_DATA, {})
if ATTR_POSITION1 in position_data:
self._current... | [
"def",
"_async_update_current_cover_position",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Raw data update: %s\"",
",",
"self",
".",
"_shade",
".",
"raw_data",
")",
"position_data",
"=",
"self",
".",
"_shade",
".",
"raw_data",
".",
"get",
"(",
"ATT... | [
214,
4
] | [
221,
32
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade._async_cancel_scheduled_transition_update | (self) | Cancel any previous updates. | Cancel any previous updates. | def _async_cancel_scheduled_transition_update(self):
"""Cancel any previous updates."""
if not self._scheduled_transition_update:
return
self._scheduled_transition_update()
self._scheduled_transition_update = None | [
"def",
"_async_cancel_scheduled_transition_update",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_scheduled_transition_update",
":",
"return",
"self",
".",
"_scheduled_transition_update",
"(",
")",
"self",
".",
"_scheduled_transition_update",
"=",
"None"
] | [
224,
4
] | [
229,
48
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade._async_complete_schedule_update | (self, _) | Update status of the cover. | Update status of the cover. | async def _async_complete_schedule_update(self, _):
"""Update status of the cover."""
_LOGGER.debug("Processing scheduled update for %s", self.name)
self._scheduled_transition_update = None
await self._async_force_refresh_state() | [
"async",
"def",
"_async_complete_schedule_update",
"(",
"self",
",",
"_",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Processing scheduled update for %s\"",
",",
"self",
".",
"name",
")",
"self",
".",
"_scheduled_transition_update",
"=",
"None",
"await",
"self",
".... | [
257,
4
] | [
261,
47
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade._async_force_refresh_state | (self) | Refresh the cover state and force the device cache to be bypassed. | Refresh the cover state and force the device cache to be bypassed. | async def _async_force_refresh_state(self):
"""Refresh the cover state and force the device cache to be bypassed."""
await self._shade.refresh()
self._async_update_current_cover_position()
self.async_write_ha_state() | [
"async",
"def",
"_async_force_refresh_state",
"(",
"self",
")",
":",
"await",
"self",
".",
"_shade",
".",
"refresh",
"(",
")",
"self",
".",
"_async_update_current_cover_position",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
263,
4
] | [
267,
35
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade.async_added_to_hass | (self) | When entity is added to hass. | When entity is added to hass. | async def async_added_to_hass(self):
"""When entity is added to hass."""
self._async_update_current_cover_position()
self.async_on_remove(
self.coordinator.async_add_listener(self._async_update_shade_from_group)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_async_update_current_cover_position",
"(",
")",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"coordinator",
".",
"async_add_listener",
"(",
"self",
".",
"_async_update_shade_from_group",... | [
269,
4
] | [
274,
9
] | python | en | ['en', 'en', 'en'] | True |
PowerViewShade._async_update_shade_from_group | (self) | Update with new data from the coordinator. | Update with new data from the coordinator. | def _async_update_shade_from_group(self):
"""Update with new data from the coordinator."""
if self._scheduled_transition_update:
# If a transition in in progress
# the data will be wrong
return
self._async_process_new_shade_data(self.coordinator.data[self._sha... | [
"def",
"_async_update_shade_from_group",
"(",
"self",
")",
":",
"if",
"self",
".",
"_scheduled_transition_update",
":",
"# If a transition in in progress",
"# the data will be wrong",
"return",
"self",
".",
"_async_process_new_shade_data",
"(",
"self",
".",
"coordinator",
"... | [
277,
4
] | [
284,
35
] | python | en | ['en', 'en', 'en'] | True |
test_browse_media | (hass, hass_ws_client, mock_plex_server, mock_websocket) | Test getting Plex clients from plex.tv. | Test getting Plex clients from plex.tv. | async def test_browse_media(hass, hass_ws_client, mock_plex_server, mock_websocket):
"""Test getting Plex clients from plex.tv."""
websocket_client = await hass_ws_client(hass)
trigger_plex_update(mock_websocket)
await hass.async_block_till_done()
media_players = hass.states.async_entity_ids("medi... | [
"async",
"def",
"test_browse_media",
"(",
"hass",
",",
"hass_ws_client",
",",
"mock_plex_server",
",",
"mock_websocket",
")",
":",
"websocket_client",
"=",
"await",
"hass_ws_client",
"(",
"hass",
")",
"trigger_plex_update",
"(",
"mock_websocket",
")",
"await",
"hass... | [
13,
0
] | [
193,
45
] | python | en | ['en', 'mt', 'en'] | True |
_convert_name | (name: str) |
Convert the names using separator '.' to valid variable name in code
|
Convert the names using separator '.' to valid variable name in code
| def _convert_name(name: str) -> str:
"""
Convert the names using separator '.' to valid variable name in code
"""
return name.replace('.', '__') | [
"def",
"_convert_name",
"(",
"name",
":",
"str",
")",
"->",
"str",
":",
"return",
"name",
".",
"replace",
"(",
"'.'",
",",
"'__'",
")"
] | [
10,
0
] | [
14,
34
] | python | en | ['en', 'error', 'th'] | False |
PyTorchOperation.to_forward_code | (self, field: str, output: str, inputs: List[str], inputs_value: List[Any] = None) |
Parameters
----------
field : str
the name of member submodule
output : str
the output name (lvalue) of this line of code
inputs : List[str]
variables used in this line of code
inputs_value : List[Any]
some variables are ac... |
Parameters
----------
field : str
the name of member submodule
output : str
the output name (lvalue) of this line of code
inputs : List[str]
variables used in this line of code
inputs_value : List[Any]
some variables are ac... | def to_forward_code(self, field: str, output: str, inputs: List[str], inputs_value: List[Any] = None) -> str:
"""
Parameters
----------
field : str
the name of member submodule
output : str
the output name (lvalue) of this line of code
inputs : Lis... | [
"def",
"to_forward_code",
"(",
"self",
",",
"field",
":",
"str",
",",
"output",
":",
"str",
",",
"inputs",
":",
"List",
"[",
"str",
"]",
",",
"inputs_value",
":",
"List",
"[",
"Any",
"]",
"=",
"None",
")",
"->",
"str",
":",
"if",
"self",
".",
"ty... | [
136,
4
] | [
158,
100
] | python | en | ['en', 'error', 'th'] | False |
get_scanner | (_hass, config) | Validate the configuration and return a Keenetic NDMS2 scanner. | Validate the configuration and return a Keenetic NDMS2 scanner. | def get_scanner(_hass, config):
"""Validate the configuration and return a Keenetic NDMS2 scanner."""
scanner = KeeneticNDMS2DeviceScanner(config[DOMAIN])
return scanner if scanner.success_init else None | [
"def",
"get_scanner",
"(",
"_hass",
",",
"config",
")",
":",
"scanner",
"=",
"KeeneticNDMS2DeviceScanner",
"(",
"config",
"[",
"DOMAIN",
"]",
")",
"return",
"scanner",
"if",
"scanner",
".",
"success_init",
"else",
"None"
] | [
36,
0
] | [
40,
52
] | python | en | ['en', 'en', 'en'] | True |
KeeneticNDMS2DeviceScanner.__init__ | (self, config) | Initialize the scanner. | Initialize the scanner. | def __init__(self, config):
"""Initialize the scanner."""
self.last_results = []
self._interface = config[CONF_INTERFACE]
self._client = Client(
TelnetConnection(
config.get(CONF_HOST),
config.get(CONF_PORT),
config.get(CONF_... | [
"def",
"__init__",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"last_results",
"=",
"[",
"]",
"self",
".",
"_interface",
"=",
"config",
"[",
"CONF_INTERFACE",
"]",
"self",
".",
"_client",
"=",
"Client",
"(",
"TelnetConnection",
"(",
"config",
".",... | [
46,
4
] | [
63,
43
] | python | en | ['en', 'en', 'en'] | True |
KeeneticNDMS2DeviceScanner.scan_devices | (self) | Scan for new devices and return a list with found device IDs. | Scan for new devices and return a list with found device IDs. | def scan_devices(self):
"""Scan for new devices and return a list with found device IDs."""
self._update_info()
return [device.mac for device in self.last_results] | [
"def",
"scan_devices",
"(",
"self",
")",
":",
"self",
".",
"_update_info",
"(",
")",
"return",
"[",
"device",
".",
"mac",
"for",
"device",
"in",
"self",
".",
"last_results",
"]"
] | [
65,
4
] | [
69,
59
] | python | en | ['en', 'en', 'en'] | True |
KeeneticNDMS2DeviceScanner.get_device_name | (self, device) | Return the name of the given device or None if we don't know. | Return the name of the given device or None if we don't know. | def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
name = next(
(result.name for result in self.last_results if result.mac == device), None
)
return name | [
"def",
"get_device_name",
"(",
"self",
",",
"device",
")",
":",
"name",
"=",
"next",
"(",
"(",
"result",
".",
"name",
"for",
"result",
"in",
"self",
".",
"last_results",
"if",
"result",
".",
"mac",
"==",
"device",
")",
",",
"None",
")",
"return",
"na... | [
71,
4
] | [
76,
19
] | python | en | ['en', 'en', 'en'] | True |
KeeneticNDMS2DeviceScanner.get_extra_attributes | (self, device) | Return the IP of the given device. | Return the IP of the given device. | def get_extra_attributes(self, device):
"""Return the IP of the given device."""
attributes = next(
({"ip": result.ip} for result in self.last_results if result.mac == device),
{},
)
return attributes | [
"def",
"get_extra_attributes",
"(",
"self",
",",
"device",
")",
":",
"attributes",
"=",
"next",
"(",
"(",
"{",
"\"ip\"",
":",
"result",
".",
"ip",
"}",
"for",
"result",
"in",
"self",
".",
"last_results",
"if",
"result",
".",
"mac",
"==",
"device",
")",... | [
78,
4
] | [
84,
25
] | python | en | ['en', 'en', 'en'] | True |
KeeneticNDMS2DeviceScanner._update_info | (self) | Get ARP from keenetic router. | Get ARP from keenetic router. | def _update_info(self):
"""Get ARP from keenetic router."""
_LOGGER.debug("Fetching devices from router...")
try:
self.last_results = [
dev
for dev in self._client.get_devices()
if dev.interface == self._interface
]
... | [
"def",
"_update_info",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Fetching devices from router...\"",
")",
"try",
":",
"self",
".",
"last_results",
"=",
"[",
"dev",
"for",
"dev",
"in",
"self",
".",
"_client",
".",
"get_devices",
"(",
")",
"if"... | [
86,
4
] | [
101,
24
] | python | en | ['en', 'en', 'en'] | True |
mock_async_subprocess | () | Get a Popen mock back. | Get a Popen mock back. | def mock_async_subprocess():
"""Get a Popen mock back."""
async_popen = MagicMock()
async def communicate(input=None):
"""Communicate mock."""
fixture = bytes(load_fixture("alpr_stdout.txt"), "utf-8")
return (fixture, None)
async_popen.communicate = communicate
return async... | [
"def",
"mock_async_subprocess",
"(",
")",
":",
"async_popen",
"=",
"MagicMock",
"(",
")",
"async",
"def",
"communicate",
"(",
"input",
"=",
"None",
")",
":",
"\"\"\"Communicate mock.\"\"\"",
"fixture",
"=",
"bytes",
"(",
"load_fixture",
"(",
"\"alpr_stdout.txt\"",... | [
11,
0
] | [
21,
22
] | python | en | ['en', 'da', 'en'] | True |
TestOpenAlprLocalSetup.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant() | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")"
] | [
27,
4
] | [
29,
45
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprLocalSetup.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
31,
4
] | [
33,
24
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprLocalSetup.test_setup_platform | (self) | Set up platform with one entity. | Set up platform with one entity. | def test_setup_platform(self):
"""Set up platform with one entity."""
config = {
ip.DOMAIN: {
"platform": "openalpr_local",
"source": {"entity_id": "camera.demo_camera"},
"region": "eu",
},
"camera": {"platform": "demo"}... | [
"def",
"test_setup_platform",
"(",
"self",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_local\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
"}",
",",
"\"region\"",
":",
"\"eu\"... | [
35,
4
] | [
50,
76
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprLocalSetup.test_setup_platform_name | (self) | Set up platform with one entity and set name. | Set up platform with one entity and set name. | def test_setup_platform_name(self):
"""Set up platform with one entity and set name."""
config = {
ip.DOMAIN: {
"platform": "openalpr_local",
"source": {"entity_id": "camera.demo_camera", "name": "test local"},
"region": "eu",
},
... | [
"def",
"test_setup_platform_name",
"(",
"self",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_local\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
",",
"\"name\"",
":",
"\"test loc... | [
52,
4
] | [
67,
66
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprLocalSetup.test_setup_platform_without_region | (self) | Set up platform with one entity without region. | Set up platform with one entity without region. | def test_setup_platform_without_region(self):
"""Set up platform with one entity without region."""
config = {
ip.DOMAIN: {
"platform": "openalpr_local",
"source": {"entity_id": "camera.demo_camera"},
},
"camera": {"platform": "demo"},
... | [
"def",
"test_setup_platform_without_region",
"(",
"self",
")",
":",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_local\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\"camera.demo_camera\"",
"}",
",",
"}",
",",
"... | [
69,
4
] | [
81,
39
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprLocal.setup_method | (self) | Set up things to be run when tests are started. | Set up things to be run when tests are started. | def setup_method(self):
"""Set up things to be run when tests are started."""
self.hass = get_test_home_assistant()
config = {
ip.DOMAIN: {
"platform": "openalpr_local",
"source": {"entity_id": "camera.demo_camera", "name": "test local"},
... | [
"def",
"setup_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"config",
"=",
"{",
"ip",
".",
"DOMAIN",
":",
"{",
"\"platform\"",
":",
"\"openalpr_local\"",
",",
"\"source\"",
":",
"{",
"\"entity_id\"",
":",
"\... | [
87,
4
] | [
118,
77
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprLocal.teardown_method | (self) | Stop everything that was started. | Stop everything that was started. | def teardown_method(self):
"""Stop everything that was started."""
self.hass.stop() | [
"def",
"teardown_method",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
120,
4
] | [
122,
24
] | python | en | ['en', 'en', 'en'] | True |
TestOpenAlprLocal.test_openalpr_process_image | (self, popen_mock, aioclient_mock) | Set up and scan a picture and test plates from event. | Set up and scan a picture and test plates from event. | def test_openalpr_process_image(self, popen_mock, aioclient_mock):
"""Set up and scan a picture and test plates from event."""
aioclient_mock.get(self.url, content=b"image")
common.scan(self.hass, entity_id="image_processing.test_local")
self.hass.block_till_done()
state = self... | [
"def",
"test_openalpr_process_image",
"(",
"self",
",",
"popen_mock",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"get",
"(",
"self",
".",
"url",
",",
"content",
"=",
"b\"image\"",
")",
"common",
".",
"scan",
"(",
"self",
".",
"hass",
",",
"ent... | [
125,
4
] | [
147,
74
] | python | en | ['en', 'en', 'en'] | True |
FileSynchronizer.copy_files_to_node | (
local_path: str,
remote_dir: str,
node_username: str,
node_hostname: str,
node_ssh_port: int
) | Copy local files to node, automatically create folder if not exist.
Args:
local_path (str): path of the local file.
remote_dir (str): dir for remote files.
node_username (str): username of the vm.
node_hostname (str): hostname of the vm.
node_ssh_port... | Copy local files to node, automatically create folder if not exist. | def copy_files_to_node(
local_path: str,
remote_dir: str,
node_username: str,
node_hostname: str,
node_ssh_port: int
) -> None:
"""Copy local files to node, automatically create folder if not exist.
Args:
local_path (str): path of the local file.
... | [
"def",
"copy_files_to_node",
"(",
"local_path",
":",
"str",
",",
"remote_dir",
":",
"str",
",",
"node_username",
":",
"str",
",",
"node_hostname",
":",
"str",
",",
"node_ssh_port",
":",
"int",
")",
"->",
"None",
":",
"source_path",
"=",
"PathConvertor",
".",... | [
23,
4
] | [
81,
60
] | python | en | ['en', 'en', 'en'] | True |
FileSynchronizer.copy_files_from_node | (
local_dir: str,
remote_path: str,
node_username: str,
node_hostname: str,
node_ssh_port: int
) | Copy node files to local, automatically create folder if not exist.
Args:
local_dir (str): dir for local files.
remote_path (str): path of the remote file.
node_username (str): username of the vm.
node_hostname (str): hostname of the vm.
node_ssh_port... | Copy node files to local, automatically create folder if not exist. | def copy_files_from_node(
local_dir: str,
remote_path: str,
node_username: str,
node_hostname: str,
node_ssh_port: int
) -> None:
"""Copy node files to local, automatically create folder if not exist.
Args:
local_dir (str): dir for local files.
... | [
"def",
"copy_files_from_node",
"(",
"local_dir",
":",
"str",
",",
"remote_path",
":",
"str",
",",
"node_username",
":",
"str",
",",
"node_hostname",
":",
"str",
",",
"node_ssh_port",
":",
"int",
")",
"->",
"None",
":",
"source_path",
"=",
"PathConvertor",
".... | [
84,
4
] | [
138,
60
] | 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.