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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
BloomSkySensor.update | (self) | Request an update from the BloomSky API. | Request an update from the BloomSky API. | def update(self):
"""Request an update from the BloomSky API."""
self._bloomsky.refresh_devices()
self._state = self._bloomsky.devices[self._device_id]["Data"][self._sensor_name] | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_bloomsky",
".",
"refresh_devices",
"(",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_bloomsky",
".",
"devices",
"[",
"self",
".",
"_device_id",
"]",
"[",
"\"Data\"",
"]",
"[",
"self",
".",
"_s... | [
70,
4
] | [
74,
88
] | python | en | ['en', 'en', 'en'] | True |
async_get_conditions | (
hass: HomeAssistant, device_id: str
) | List device conditions for Climate devices. | List device conditions for Climate devices. | async def async_get_conditions(
hass: HomeAssistant, device_id: str
) -> List[Dict[str, str]]:
"""List device conditions for Climate devices."""
registry = await entity_registry.async_get_registry(hass)
conditions = []
# Get all the integrations entities for this device
for entry in entity_regi... | [
"async",
"def",
"async_get_conditions",
"(",
"hass",
":",
"HomeAssistant",
",",
"device_id",
":",
"str",
")",
"->",
"List",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"registry",
"=",
"await",
"entity_registry",
".",
"async_get_registry",
"(",
"ha... | [
42,
0
] | [
80,
21
] | python | en | ['fr', 'en', 'en'] | True |
async_condition_from_config | (
config: ConfigType, config_validation: bool
) | Create a function to test a device condition. | Create a function to test a device condition. | def async_condition_from_config(
config: ConfigType, config_validation: bool
) -> condition.ConditionCheckerType:
"""Create a function to test a device condition."""
if config_validation:
config = CONDITION_SCHEMA(config)
if config[CONF_TYPE] == "is_hvac_mode":
attribute = const.ATTR_HV... | [
"def",
"async_condition_from_config",
"(",
"config",
":",
"ConfigType",
",",
"config_validation",
":",
"bool",
")",
"->",
"condition",
".",
"ConditionCheckerType",
":",
"if",
"config_validation",
":",
"config",
"=",
"CONDITION_SCHEMA",
"(",
"config",
")",
"if",
"c... | [
84,
0
] | [
101,
24
] | python | en | ['en', 'en', 'en'] | True |
async_get_condition_capabilities | (hass, config) | List condition capabilities. | List condition capabilities. | async def async_get_condition_capabilities(hass, config):
"""List condition capabilities."""
state = hass.states.get(config[CONF_ENTITY_ID])
condition_type = config[CONF_TYPE]
fields = {}
if condition_type == "is_hvac_mode":
hvac_modes = state.attributes[const.ATTR_HVAC_MODES] if state els... | [
"async",
"def",
"async_get_condition_capabilities",
"(",
"hass",
",",
"config",
")",
":",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"config",
"[",
"CONF_ENTITY_ID",
"]",
")",
"condition_type",
"=",
"config",
"[",
"CONF_TYPE",
"]",
"fields",
"=",
... | [
104,
0
] | [
123,
47
] | python | en | ['ro', 'sr', 'en'] | False |
_async_create_entities | (hass, config) | Create the Template Lights. | Create the Template Lights. | async def _async_create_entities(hass, config):
"""Create the Template Lights."""
lights = []
for device, device_config in config[CONF_LIGHTS].items():
friendly_name = device_config.get(CONF_FRIENDLY_NAME, device)
state_template = device_config.get(CONF_VALUE_TEMPLATE)
icon_templat... | [
"async",
"def",
"_async_create_entities",
"(",
"hass",
",",
"config",
")",
":",
"lights",
"=",
"[",
"]",
"for",
"device",
",",
"device_config",
"in",
"config",
"[",
"CONF_LIGHTS",
"]",
".",
"items",
"(",
")",
":",
"friendly_name",
"=",
"device_config",
"."... | [
83,
0
] | [
134,
17
] | python | en | ['en', 'en', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the template lights. | Set up the template lights. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the template lights."""
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
async_add_entities(await _async_create_entities(hass, config)) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"await",
"async_setup_reload_service",
"(",
"hass",
",",
"DOMAIN",
",",
"PLATFORMS",
")",
"async_add_entities",
"(",
"await... | [
137,
0
] | [
141,
66
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate.__init__ | (
self,
hass,
device_id,
friendly_name,
state_template,
icon_template,
entity_picture_template,
availability_template,
on_action,
off_action,
level_action,
level_template,
temperature_action,
temperature_temp... | Initialize the light. | Initialize the light. | def __init__(
self,
hass,
device_id,
friendly_name,
state_template,
icon_template,
entity_picture_template,
availability_template,
on_action,
off_action,
level_action,
level_template,
temperature_action,
temp... | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"device_id",
",",
"friendly_name",
",",
"state_template",
",",
"icon_template",
",",
"entity_picture_template",
",",
"availability_template",
",",
"on_action",
",",
"off_action",
",",
"level_action",
",",
"level_temp... | [
147,
4
] | [
208,
35
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate.brightness | (self) | Return the brightness of the light. | Return the brightness of the light. | def brightness(self):
"""Return the brightness of the light."""
return self._brightness | [
"def",
"brightness",
"(",
"self",
")",
":",
"return",
"self",
".",
"_brightness"
] | [
211,
4
] | [
213,
31
] | python | en | ['en', 'no', 'en'] | True |
LightTemplate.color_temp | (self) | Return the CT color value in mireds. | Return the CT color value in mireds. | def color_temp(self):
"""Return the CT color value in mireds."""
return self._temperature | [
"def",
"color_temp",
"(",
"self",
")",
":",
"return",
"self",
".",
"_temperature"
] | [
216,
4
] | [
218,
32
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate.white_value | (self) | Return the white value. | Return the white value. | def white_value(self):
"""Return the white value."""
return self._white_value | [
"def",
"white_value",
"(",
"self",
")",
":",
"return",
"self",
".",
"_white_value"
] | [
221,
4
] | [
223,
32
] | python | en | ['en', 'no', 'en'] | True |
LightTemplate.hs_color | (self) | Return the hue and saturation color value [float, float]. | Return the hue and saturation color value [float, float]. | def hs_color(self):
"""Return the hue and saturation color value [float, float]."""
return self._color | [
"def",
"hs_color",
"(",
"self",
")",
":",
"return",
"self",
".",
"_color"
] | [
226,
4
] | [
228,
26
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate.name | (self) | Return the display name of this light. | Return the display name of this light. | def name(self):
"""Return the display name of this light."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
231,
4
] | [
233,
25
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate.unique_id | (self) | Return the unique id of this light. | Return the unique id of this light. | def unique_id(self):
"""Return the unique id of this light."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
236,
4
] | [
238,
30
] | python | en | ['en', 'la', 'en'] | True |
LightTemplate.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
supported_features = 0
if self._level_script is not None:
supported_features |= SUPPORT_BRIGHTNESS
if self._temperature_script is not None:
supported_features |= SUPPORT_COLOR_TEMP
if self._color... | [
"def",
"supported_features",
"(",
"self",
")",
":",
"supported_features",
"=",
"0",
"if",
"self",
".",
"_level_script",
"is",
"not",
"None",
":",
"supported_features",
"|=",
"SUPPORT_BRIGHTNESS",
"if",
"self",
".",
"_temperature_script",
"is",
"not",
"None",
":"... | [
241,
4
] | [
252,
33
] | python | en | ['da', 'en', 'en'] | True |
LightTemplate.is_on | (self) | Return true if device is on. | Return true if device is on. | def is_on(self):
"""Return true if device is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
255,
4
] | [
257,
26
] | python | en | ['en', 'fy', 'en'] | True |
LightTemplate.async_added_to_hass | (self) | Register callbacks. | Register callbacks. | async def async_added_to_hass(self):
"""Register callbacks."""
if self._template:
self.add_template_attribute(
"_state", self._template, None, self._update_state
)
if self._level_template:
self.add_template_attribute(
"_brightn... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"if",
"self",
".",
"_template",
":",
"self",
".",
"add_template_attribute",
"(",
"\"_state\"",
",",
"self",
".",
"_template",
",",
"None",
",",
"self",
".",
"_update_state",
")",
"if",
"self",
"... | [
259,
4
] | [
298,
43
] | python | en | ['en', 'no', 'en'] | False |
LightTemplate.async_turn_on | (self, **kwargs) | Turn the light on. | Turn the light on. | async def async_turn_on(self, **kwargs):
"""Turn the light on."""
optimistic_set = False
# set optimistic states
if self._template is None:
self._state = True
optimistic_set = True
if self._level_template is None and ATTR_BRIGHTNESS in kwargs:
... | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"optimistic_set",
"=",
"False",
"# set optimistic states",
"if",
"self",
".",
"_template",
"is",
"None",
":",
"self",
".",
"_state",
"=",
"True",
"optimistic_set",
"=",
"True",
... | [
300,
4
] | [
352,
39
] | python | en | ['en', 'et', 'en'] | True |
LightTemplate.async_turn_off | (self, **kwargs) | Turn the light off. | Turn the light off. | async def async_turn_off(self, **kwargs):
"""Turn the light off."""
await self._off_script.async_run(context=self._context)
if self._template is None:
self._state = False
self.async_write_ha_state() | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_off_script",
".",
"async_run",
"(",
"context",
"=",
"self",
".",
"_context",
")",
"if",
"self",
".",
"_template",
"is",
"None",
":",
"self",
".",
... | [
354,
4
] | [
359,
39
] | python | en | ['en', 'zh', 'en'] | True |
LightTemplate._update_brightness | (self, brightness) | Update the brightness from the template. | Update the brightness from the template. | def _update_brightness(self, brightness):
"""Update the brightness from the template."""
try:
if brightness in ("None", ""):
self._brightness = None
return
if 0 <= int(brightness) <= 255:
self._brightness = int(brightness)
... | [
"def",
"_update_brightness",
"(",
"self",
",",
"brightness",
")",
":",
"try",
":",
"if",
"brightness",
"in",
"(",
"\"None\"",
",",
"\"\"",
")",
":",
"self",
".",
"_brightness",
"=",
"None",
"return",
"if",
"0",
"<=",
"int",
"(",
"brightness",
")",
"<="... | [
362,
4
] | [
380,
35
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate._update_white_value | (self, white_value) | Update the white value from the template. | Update the white value from the template. | def _update_white_value(self, white_value):
"""Update the white value from the template."""
try:
if white_value in ("None", ""):
self._white_value = None
return
if 0 <= int(white_value) <= 255:
self._white_value = int(white_value)
... | [
"def",
"_update_white_value",
"(",
"self",
",",
"white_value",
")",
":",
"try",
":",
"if",
"white_value",
"in",
"(",
"\"None\"",
",",
"\"\"",
")",
":",
"self",
".",
"_white_value",
"=",
"None",
"return",
"if",
"0",
"<=",
"int",
"(",
"white_value",
")",
... | [
383,
4
] | [
401,
36
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate._update_state | (self, result) | Update the state from the template. | Update the state from the template. | def _update_state(self, result):
"""Update the state from the template."""
if isinstance(result, TemplateError):
# This behavior is legacy
self._state = False
if not self._availability_template:
self._available = True
return
if is... | [
"def",
"_update_state",
"(",
"self",
",",
"result",
")",
":",
"if",
"isinstance",
"(",
"result",
",",
"TemplateError",
")",
":",
"# This behavior is legacy",
"self",
".",
"_state",
"=",
"False",
"if",
"not",
"self",
".",
"_availability_template",
":",
"self",
... | [
404,
4
] | [
428,
26
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate._update_temperature | (self, render) | Update the temperature from the template. | Update the temperature from the template. | def _update_temperature(self, render):
"""Update the temperature from the template."""
try:
if render in ("None", ""):
self._temperature = None
return
temperature = int(render)
if self.min_mireds <= temperature <= self.max_mireds:
... | [
"def",
"_update_temperature",
"(",
"self",
",",
"render",
")",
":",
"try",
":",
"if",
"render",
"in",
"(",
"\"None\"",
",",
"\"\"",
")",
":",
"self",
".",
"_temperature",
"=",
"None",
"return",
"temperature",
"=",
"int",
"(",
"render",
")",
"if",
"self... | [
431,
4
] | [
453,
36
] | python | en | ['en', 'en', 'en'] | True |
LightTemplate._update_color | (self, render) | Update the hs_color from the template. | Update the hs_color from the template. | def _update_color(self, render):
"""Update the hs_color from the template."""
h_str = s_str = None
if isinstance(render, str):
if render in ("None", ""):
self._color = None
return
h_str, s_str = map(
float, render.replace("(... | [
"def",
"_update_color",
"(",
"self",
",",
"render",
")",
":",
"h_str",
"=",
"s_str",
"=",
"None",
"if",
"isinstance",
"(",
"render",
",",
"str",
")",
":",
"if",
"render",
"in",
"(",
"\"None\"",
",",
"\"\"",
")",
":",
"self",
".",
"_color",
"=",
"No... | [
456,
4
] | [
485,
30
] | python | en | ['en', 'en', 'en'] | True |
CTCTrainer.training_step | (self, model: nn.Module, inputs: Dict[str, Union[torch.Tensor, Any]]) |
Perform a training step on a batch of inputs.
Subclass and override to inject custom behavior.
Args:
model (:obj:`nn.Module`):
The model to train.
inputs (:obj:`Dict[str, Union[torch.Tensor, Any]]`):
The inputs and targets of the model.
... |
Perform a training step on a batch of inputs. | def training_step(self, model: nn.Module, inputs: Dict[str, Union[torch.Tensor, Any]]) -> torch.Tensor:
"""
Perform a training step on a batch of inputs.
Subclass and override to inject custom behavior.
Args:
model (:obj:`nn.Module`):
The model to train.
... | [
"def",
"training_step",
"(",
"self",
",",
"model",
":",
"nn",
".",
"Module",
",",
"inputs",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"torch",
".",
"Tensor",
",",
"Any",
"]",
"]",
")",
"->",
"torch",
".",
"Tensor",
":",
"model",
".",
"train",
"... | [
205,
4
] | [
254,
28
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the configured Numato USB GPIO binary sensor ports. | Set up the configured Numato USB GPIO binary sensor ports. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the configured Numato USB GPIO binary sensor ports."""
if discovery_info is None:
return
def read_gpio(device_id, port, level):
"""Send signal to entity to have it update state."""
dispatcher_send(hass, N... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"def",
"read_gpio",
"(",
"device_id",
",",
"port",
",",
"level",
")",
":",
"\"\"\"S... | [
26,
0
] | [
68,
38
] | python | en | ['en', 'hr', 'en'] | True |
NumatoGpioBinarySensor.__init__ | (self, name, device_id, port, invert_logic, api) | Initialize the Numato GPIO based binary sensor object. | Initialize the Numato GPIO based binary sensor object. | def __init__(self, name, device_id, port, invert_logic, api):
"""Initialize the Numato GPIO based binary sensor object."""
self._name = name or DEVICE_DEFAULT_NAME
self._device_id = device_id
self._port = port
self._invert_logic = invert_logic
self._state = None
s... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"device_id",
",",
"port",
",",
"invert_logic",
",",
"api",
")",
":",
"self",
".",
"_name",
"=",
"name",
"or",
"DEVICE_DEFAULT_NAME",
"self",
".",
"_device_id",
"=",
"device_id",
"self",
".",
"_port",
"=",... | [
74,
4
] | [
81,
23
] | python | en | ['en', 'pl', 'en'] | True |
NumatoGpioBinarySensor.async_added_to_hass | (self) | Connect state update callback. | Connect state update callback. | async def async_added_to_hass(self):
"""Connect state update callback."""
self.async_on_remove(
async_dispatcher_connect(
self.hass,
NUMATO_SIGNAL.format(self._device_id, self._port),
self._async_update_state,
)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"NUMATO_SIGNAL",
".",
"format",
"(",
"self",
".",
"_device_id",
",",
"self",
".",
"_port",
")",
",",... | [
83,
4
] | [
91,
9
] | python | en | ['en', 'en', 'en'] | True |
NumatoGpioBinarySensor._async_update_state | (self, level) | Update entity state. | Update entity state. | def _async_update_state(self, level):
"""Update entity state."""
self._state = level
self.async_write_ha_state() | [
"def",
"_async_update_state",
"(",
"self",
",",
"level",
")",
":",
"self",
".",
"_state",
"=",
"level",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
94,
4
] | [
97,
35
] | python | en | ['en', 'en', 'en'] | True |
NumatoGpioBinarySensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
100,
4
] | [
102,
20
] | python | en | ['en', 'en', 'en'] | True |
NumatoGpioBinarySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
105,
4
] | [
107,
25
] | python | en | ['en', 'mi', 'en'] | True |
NumatoGpioBinarySensor.is_on | (self) | Return the state of the entity. | Return the state of the entity. | def is_on(self):
"""Return the state of the entity."""
return self._state != self._invert_logic | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state",
"!=",
"self",
".",
"_invert_logic"
] | [
110,
4
] | [
112,
48
] | python | en | ['en', 'en', 'en'] | True |
NumatoGpioBinarySensor.update | (self) | Update the GPIO state. | Update the GPIO state. | def update(self):
"""Update the GPIO state."""
try:
self._state = self._api.read_input(self._device_id, self._port)
except NumatoGpioError as err:
self._state = None
_LOGGER.error(
"Failed to update Numato device %s port %s: %s",
... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_state",
"=",
"self",
".",
"_api",
".",
"read_input",
"(",
"self",
".",
"_device_id",
",",
"self",
".",
"_port",
")",
"except",
"NumatoGpioError",
"as",
"err",
":",
"self",
".",
"_stat... | [
114,
4
] | [
125,
13
] | python | en | ['en', 'it', 'en'] | True |
ChannelPruningEnv._action_wall | (self, action) |
Limit the action generated by DDPG for this layer by two constraints:
1. The total flops must meet the flops reduce target.
For example: the original flops of entire model is 1000, target flops ratio is 0.5, target flops
is 1000*0.5 = 500. The reduced flops of other layers is 400,... |
Limit the action generated by DDPG for this layer by two constraints:
1. The total flops must meet the flops reduce target.
For example: the original flops of entire model is 1000, target flops ratio is 0.5, target flops
is 1000*0.5 = 500. The reduced flops of other layers is 400,... | def _action_wall(self, action):
"""
Limit the action generated by DDPG for this layer by two constraints:
1. The total flops must meet the flops reduce target.
For example: the original flops of entire model is 1000, target flops ratio is 0.5, target flops
is 1000*0.5 = 500... | [
"def",
"_action_wall",
"(",
"self",
",",
"action",
")",
":",
"assert",
"len",
"(",
"self",
".",
"strategy",
")",
"==",
"self",
".",
"cur_ind",
"action",
"=",
"float",
"(",
"action",
")",
"action",
"=",
"np",
".",
"clip",
"(",
"action",
",",
"0",
",... | [
279,
4
] | [
319,
21
] | python | en | ['en', 'error', 'th'] | False |
ChannelPruningEnv._build_index | (self) |
Build following information/data for later pruning:
self.prunable_idx: layer indices for pruable layers, the index values are the index
of list(self.model.modules()). Pruable layers are pointwise Conv2d layers and Linear
layers.
self.prunable_ops: prunable modules
... |
Build following information/data for later pruning:
self.prunable_idx: layer indices for pruable layers, the index values are the index
of list(self.model.modules()). Pruable layers are pointwise Conv2d layers and Linear
layers.
self.prunable_ops: prunable modules
... | def _build_index(self):
"""
Build following information/data for later pruning:
self.prunable_idx: layer indices for pruable layers, the index values are the index
of list(self.model.modules()). Pruable layers are pointwise Conv2d layers and Linear
layers.
self.pr... | [
"def",
"_build_index",
"(",
"self",
")",
":",
"self",
".",
"prunable_idx",
"=",
"[",
"]",
"self",
".",
"prunable_ops",
"=",
"[",
"]",
"self",
".",
"layer_type_dict",
"=",
"{",
"}",
"self",
".",
"strategy_dict",
"=",
"{",
"}",
"self",
".",
"buffer_dict"... | [
340,
4
] | [
414,
30
] | python | en | ['en', 'error', 'th'] | False |
test_websocket_api | (hass, aiohttp_client, hass_access_token, legacy_auth) | Test API streams. | Test API streams. | async def test_websocket_api(hass, aiohttp_client, hass_access_token, legacy_auth):
"""Test API streams."""
await async_setup_component(
hass, "sensor", {"sensor": {"platform": "websocket_api"}}
)
await hass.async_block_till_done()
client = await aiohttp_client(hass.http.app)
ws = await... | [
"async",
"def",
"test_websocket_api",
"(",
"hass",
",",
"aiohttp_client",
",",
"hass_access_token",
",",
"legacy_auth",
")",
":",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"sensor\"",
",",
"{",
"\"sensor\"",
":",
"{",
"\"platform\"",
":",
"\"websocket_... | [
9,
0
] | [
37,
29
] | python | en | ['en', 'sk', 'en'] | True |
test_report_state | (hass, aioclient_mock) | Test proactive state reports. | Test proactive state reports. | async def test_report_state(hass, aioclient_mock):
"""Test proactive state reports."""
aioclient_mock.post(TEST_URL, text="", status=202)
hass.states.async_set(
"binary_sensor.test_contact",
"on",
{"friendly_name": "Test Contact Sensor", "device_class": "door"},
)
await sta... | [
"async",
"def",
"test_report_state",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"TEST_URL",
",",
"text",
"=",
"\"\"",
",",
"status",
"=",
"202",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"binary_sensor.test_c... | [
6,
0
] | [
37,
87
] | python | en | ['en', 'en', 'en'] | True |
test_report_state_instance | (hass, aioclient_mock) | Test proactive state reports with instance. | Test proactive state reports with instance. | async def test_report_state_instance(hass, aioclient_mock):
"""Test proactive state reports with instance."""
aioclient_mock.post(TEST_URL, text="", status=202)
hass.states.async_set(
"fan.test_fan",
"off",
{
"friendly_name": "Test fan",
"supported_features":... | [
"async",
"def",
"test_report_state_instance",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"TEST_URL",
",",
"text",
"=",
"\"\"",
",",
"status",
"=",
"202",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"fan.test_fa... | [
40,
0
] | [
87,
73
] | python | en | ['en', 'en', 'en'] | True |
test_send_add_or_update_message | (hass, aioclient_mock) | Test sending an AddOrUpdateReport message. | Test sending an AddOrUpdateReport message. | async def test_send_add_or_update_message(hass, aioclient_mock):
"""Test sending an AddOrUpdateReport message."""
aioclient_mock.post(TEST_URL, text="")
hass.states.async_set(
"binary_sensor.test_contact",
"on",
{"friendly_name": "Test Contact Sensor", "device_class": "door"},
)... | [
"async",
"def",
"test_send_add_or_update_message",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"TEST_URL",
",",
"text",
"=",
"\"\"",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"binary_sensor.test_contact\"",
",",
"... | [
90,
0
] | [
114,
5
] | python | en | ['en', 'lb', 'en'] | True |
test_send_delete_message | (hass, aioclient_mock) | Test sending an AddOrUpdateReport message. | Test sending an AddOrUpdateReport message. | async def test_send_delete_message(hass, aioclient_mock):
"""Test sending an AddOrUpdateReport message."""
aioclient_mock.post(TEST_URL, json={"data": "is irrelevant"})
hass.states.async_set(
"binary_sensor.test_contact",
"on",
{"friendly_name": "Test Contact Sensor", "device_class"... | [
"async",
"def",
"test_send_delete_message",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"TEST_URL",
",",
"json",
"=",
"{",
"\"data\"",
":",
"\"is irrelevant\"",
"}",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"... | [
117,
0
] | [
141,
5
] | python | en | ['en', 'lb', 'en'] | True |
test_doorbell_event | (hass, aioclient_mock) | Test doorbell press reports. | Test doorbell press reports. | async def test_doorbell_event(hass, aioclient_mock):
"""Test doorbell press reports."""
aioclient_mock.post(TEST_URL, text="", status=202)
hass.states.async_set(
"binary_sensor.test_doorbell",
"off",
{"friendly_name": "Test Doorbell Sensor", "device_class": "occupancy"},
)
... | [
"async",
"def",
"test_doorbell_event",
"(",
"hass",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"TEST_URL",
",",
"text",
"=",
"\"\"",
",",
"status",
"=",
"202",
")",
"hass",
".",
"states",
".",
"async_set",
"(",
"\"binary_sensor.test... | [
144,
0
] | [
172,
88
] | python | en | ['en', 'nl', 'en'] | True |
_async_has_devices | (hass) | Return if there are devices that can be discovered. | Return if there are devices that can be discovered. | async def _async_has_devices(hass):
"""Return if there are devices that can be discovered."""
return await hass.async_add_executor_job(pysonos.discover) | [
"async",
"def",
"_async_has_devices",
"(",
"hass",
")",
":",
"return",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"pysonos",
".",
"discover",
")"
] | [
9,
0
] | [
11,
62
] | python | en | ['en', 'en', 'en'] | True |
write_msg | (msg: Dict) | Write out the message in Line delimited JSON. | Write out the message in Line delimited JSON. | def write_msg(msg: Dict):
"""Write out the message in Line delimited JSON."""
msg = json.dumps(msg) + "\n"
sys.stdout.write(msg)
sys.stdout.flush() | [
"def",
"write_msg",
"(",
"msg",
":",
"Dict",
")",
":",
"msg",
"=",
"json",
".",
"dumps",
"(",
"msg",
")",
"+",
"\"\\n\"",
"sys",
".",
"stdout",
".",
"write",
"(",
"msg",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
")"
] | [
90,
0
] | [
94,
22
] | python | en | ['en', 'en', 'en'] | True |
read_msg | () | Read Line delimited JSON from stdin. | Read Line delimited JSON from stdin. | def read_msg() -> Optional[Dict]:
"""Read Line delimited JSON from stdin. """
msg = json.loads(sys.stdin.readline().strip())
if "terminate" in (msg.get("type"), msg.get("event")):
# terminate message received
return None
if msg.get("event") not in ("download", "upload"):
logger... | [
"def",
"read_msg",
"(",
")",
"->",
"Optional",
"[",
"Dict",
"]",
":",
"msg",
"=",
"json",
".",
"loads",
"(",
"sys",
".",
"stdin",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
")",
"if",
"\"terminate\"",
"in",
"(",
"msg",
".",
"get",
"(",
... | [
97,
0
] | [
109,
14
] | python | en | ['en', 'fy', 'en'] | True |
MixedOp.__init__ | (self, mutable, latency) |
Parameters
----------
mutable : LayerChoice
A LayerChoice in user model
latency : List
performance cost for each op in mutable
|
Parameters
----------
mutable : LayerChoice
A LayerChoice in user model
latency : List
performance cost for each op in mutable
| def __init__(self, mutable, latency):
"""
Parameters
----------
mutable : LayerChoice
A LayerChoice in user model
latency : List
performance cost for each op in mutable
"""
super(MixedOp, self).__init__()
self.latency = latency
... | [
"def",
"__init__",
"(",
"self",
",",
"mutable",
",",
"latency",
")",
":",
"super",
"(",
"MixedOp",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"latency",
"=",
"latency",
"n_choices",
"=",
"len",
"(",
"mutable",
")",
"self",
".",
"path_a... | [
20,
4
] | [
36,
30
] | python | en | ['en', 'error', 'th'] | False |
MixedOp.get_path_alpha | (self) | Return the architecture parameter. | Return the architecture parameter. | def get_path_alpha(self):
"""Return the architecture parameter."""
return self.path_alpha | [
"def",
"get_path_alpha",
"(",
"self",
")",
":",
"return",
"self",
".",
"path_alpha"
] | [
38,
4
] | [
40,
30
] | python | en | ['en', 'en', 'en'] | True |
MixedOp.get_weighted_latency | (self) | Return the weighted perf_cost of current mutable. | Return the weighted perf_cost of current mutable. | def get_weighted_latency(self):
"""Return the weighted perf_cost of current mutable."""
soft_masks = self.probs_over_ops()
weighted_latency = sum(m * l for m, l in zip(soft_masks, self.latency))
return weighted_latency | [
"def",
"get_weighted_latency",
"(",
"self",
")",
":",
"soft_masks",
"=",
"self",
".",
"probs_over_ops",
"(",
")",
"weighted_latency",
"=",
"sum",
"(",
"m",
"*",
"l",
"for",
"m",
",",
"l",
"in",
"zip",
"(",
"soft_masks",
",",
"self",
".",
"latency",
")"... | [
42,
4
] | [
46,
31
] | python | en | ['en', 'en', 'en'] | True |
MixedOp.set_temperature | (self, temperature) |
Set the annealed temperature for gumbel softmax.
Parameters
----------
temperature : float
The annealed temperature for gumbel softmax
|
Set the annealed temperature for gumbel softmax. | def set_temperature(self, temperature):
"""
Set the annealed temperature for gumbel softmax.
Parameters
----------
temperature : float
The annealed temperature for gumbel softmax
"""
self.temperature = temperature | [
"def",
"set_temperature",
"(",
"self",
",",
"temperature",
")",
":",
"self",
".",
"temperature",
"=",
"temperature"
] | [
48,
4
] | [
57,
38
] | python | en | ['en', 'error', 'th'] | False |
MixedOp.to_requires_grad | (self) | Enable gradient calculation. | Enable gradient calculation. | def to_requires_grad(self):
"""Enable gradient calculation."""
self.path_alpha.requires_grad = True | [
"def",
"to_requires_grad",
"(",
"self",
")",
":",
"self",
".",
"path_alpha",
".",
"requires_grad",
"=",
"True"
] | [
59,
4
] | [
61,
44
] | python | en | ['nl', 'en', 'en'] | True |
MixedOp.to_disable_grad | (self) | Disable gradient calculation. | Disable gradient calculation. | def to_disable_grad(self):
"""Disable gradient calculation."""
self.path_alpha.requires_grad = False | [
"def",
"to_disable_grad",
"(",
"self",
")",
":",
"self",
".",
"path_alpha",
".",
"requires_grad",
"=",
"False"
] | [
63,
4
] | [
65,
45
] | python | en | ['nl', 'en', 'en'] | True |
MixedOp.probs_over_ops | (self) | Apply gumbel softmax to generate probability distribution. | Apply gumbel softmax to generate probability distribution. | def probs_over_ops(self):
"""Apply gumbel softmax to generate probability distribution."""
return F.gumbel_softmax(self.path_alpha, self.temperature) | [
"def",
"probs_over_ops",
"(",
"self",
")",
":",
"return",
"F",
".",
"gumbel_softmax",
"(",
"self",
".",
"path_alpha",
",",
"self",
".",
"temperature",
")"
] | [
67,
4
] | [
69,
66
] | python | en | ['en', 'en', 'en'] | True |
MixedOp.forward | (self, mutable, x) |
Define forward of LayerChoice.
Parameters
----------
mutable : LayerChoice
this layer's mutable
x : tensor
inputs of this layer, only support one input
Returns
-------
output: tensor
output of this layer
|
Define forward of LayerChoice. | def forward(self, mutable, x):
"""
Define forward of LayerChoice.
Parameters
----------
mutable : LayerChoice
this layer's mutable
x : tensor
inputs of this layer, only support one input
Returns
-------
output: tensor
... | [
"def",
"forward",
"(",
"self",
",",
"mutable",
",",
"x",
")",
":",
"candidate_ops",
"=",
"list",
"(",
"mutable",
")",
"soft_masks",
"=",
"self",
".",
"probs_over_ops",
"(",
")",
"output",
"=",
"sum",
"(",
"m",
"*",
"op",
"(",
"x",
")",
"for",
"m",
... | [
71,
4
] | [
91,
21
] | python | en | ['en', 'error', 'th'] | False |
MixedOp.chosen_index | (self) |
choose the op with max prob
Returns
-------
int
index of the chosen one
|
choose the op with max prob | def chosen_index(self):
"""
choose the op with max prob
Returns
-------
int
index of the chosen one
"""
alphas = self.path_alpha.data.detach().cpu().numpy()
index = int(np.argmax(alphas))
return index | [
"def",
"chosen_index",
"(",
"self",
")",
":",
"alphas",
"=",
"self",
".",
"path_alpha",
".",
"data",
".",
"detach",
"(",
")",
".",
"cpu",
"(",
")",
".",
"numpy",
"(",
")",
"index",
"=",
"int",
"(",
"np",
".",
"argmax",
"(",
"alphas",
")",
")",
... | [
94,
4
] | [
105,
20
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.__init__ | (self, model, lookup_table) |
Init a MixedOp instance for each mutable i.e., LayerChoice.
And register the instantiated MixedOp in corresponding LayerChoice.
If does not register it in LayerChoice, DataParallel does'nt work then,
for architecture weights are not included in the DataParallel model.
When Mixed... |
Init a MixedOp instance for each mutable i.e., LayerChoice.
And register the instantiated MixedOp in corresponding LayerChoice.
If does not register it in LayerChoice, DataParallel does'nt work then,
for architecture weights are not included in the DataParallel model.
When Mixed... | def __init__(self, model, lookup_table):
"""
Init a MixedOp instance for each mutable i.e., LayerChoice.
And register the instantiated MixedOp in corresponding LayerChoice.
If does not register it in LayerChoice, DataParallel does'nt work then,
for architecture weights are not in... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"lookup_table",
")",
":",
"super",
"(",
"FBNetMutator",
",",
"self",
")",
".",
"__init__",
"(",
"model",
")",
"self",
".",
"mutable_list",
"=",
"[",
"]",
"# Collect the op names of the candidate ops within each ... | [
115,
4
] | [
158,
65
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.on_forward_layer_choice | (self, mutable, *args, **kwargs) |
Callback of layer choice forward. This function defines the forward
logic of the input mutable. So mutable is only interface, its real
implementation is defined in mutator.
Parameters
----------
mutable: LayerChoice
forward logic of this input mutable
... |
Callback of layer choice forward. This function defines the forward
logic of the input mutable. So mutable is only interface, its real
implementation is defined in mutator. | def on_forward_layer_choice(self, mutable, *args, **kwargs):
"""
Callback of layer choice forward. This function defines the forward
logic of the input mutable. So mutable is only interface, its real
implementation is defined in mutator.
Parameters
----------
mut... | [
"def",
"on_forward_layer_choice",
"(",
"self",
",",
"mutable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# FIXME: return mask, to be consistent with other algorithms",
"idx",
"=",
"mutable",
".",
"registered_module",
".",
"chosen_index",
"return",
"mutable... | [
160,
4
] | [
184,
71
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.num_arch_params | (self) |
The number of mutables, i.e., LayerChoice
Returns
-------
int
the number of LayerChoice in user model
|
The number of mutables, i.e., LayerChoice | def num_arch_params(self):
"""
The number of mutables, i.e., LayerChoice
Returns
-------
int
the number of LayerChoice in user model
"""
return len(self.mutable_list) | [
"def",
"num_arch_params",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"mutable_list",
")"
] | [
186,
4
] | [
195,
37
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.get_architecture_parameters | (self) |
Get all the architecture parameters.
yield
-----
PyTorch Parameter
Return path_alpha of the traversed mutable
|
Get all the architecture parameters. | def get_architecture_parameters(self):
"""
Get all the architecture parameters.
yield
-----
PyTorch Parameter
Return path_alpha of the traversed mutable
"""
for mutable in self.undedup_mutables:
yield mutable.registered_module.get_path_alp... | [
"def",
"get_architecture_parameters",
"(",
"self",
")",
":",
"for",
"mutable",
"in",
"self",
".",
"undedup_mutables",
":",
"yield",
"mutable",
".",
"registered_module",
".",
"get_path_alpha",
"(",
")"
] | [
197,
4
] | [
207,
60
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.get_weighted_latency | (self) |
Get the latency weighted by gumbel softmax coefficients.
yield
-----
Tuple
Return the weighted_latency of the traversed mutable
|
Get the latency weighted by gumbel softmax coefficients. | def get_weighted_latency(self):
"""
Get the latency weighted by gumbel softmax coefficients.
yield
-----
Tuple
Return the weighted_latency of the traversed mutable
"""
for mutable in self.undedup_mutables:
yield mutable.registered_module.g... | [
"def",
"get_weighted_latency",
"(",
"self",
")",
":",
"for",
"mutable",
"in",
"self",
".",
"undedup_mutables",
":",
"yield",
"mutable",
".",
"registered_module",
".",
"get_weighted_latency",
"(",
")"
] | [
209,
4
] | [
219,
66
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.set_temperature | (self, temperature) |
Set the annealed temperature of the op for gumbel softmax.
Parameters
----------
temperature : float
The annealed temperature for gumbel softmax
|
Set the annealed temperature of the op for gumbel softmax. | def set_temperature(self, temperature):
"""
Set the annealed temperature of the op for gumbel softmax.
Parameters
----------
temperature : float
The annealed temperature for gumbel softmax
"""
for mutable in self.undedup_mutables:
mutable.... | [
"def",
"set_temperature",
"(",
"self",
",",
"temperature",
")",
":",
"for",
"mutable",
"in",
"self",
".",
"undedup_mutables",
":",
"mutable",
".",
"registered_module",
".",
"set_temperature",
"(",
"temperature",
")"
] | [
221,
4
] | [
231,
66
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.arch_requires_grad | (self) |
Make architecture weights require gradient
|
Make architecture weights require gradient
| def arch_requires_grad(self):
"""
Make architecture weights require gradient
"""
for mutable in self.undedup_mutables:
mutable.registered_module.to_requires_grad() | [
"def",
"arch_requires_grad",
"(",
"self",
")",
":",
"for",
"mutable",
"in",
"self",
".",
"undedup_mutables",
":",
"mutable",
".",
"registered_module",
".",
"to_requires_grad",
"(",
")"
] | [
233,
4
] | [
238,
56
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.arch_disable_grad | (self) |
Disable gradient of architecture weights, i.e., does not
calculate gradient for them.
|
Disable gradient of architecture weights, i.e., does not
calculate gradient for them.
| def arch_disable_grad(self):
"""
Disable gradient of architecture weights, i.e., does not
calculate gradient for them.
"""
for mutable in self.undedup_mutables:
mutable.registered_module.to_disable_grad() | [
"def",
"arch_disable_grad",
"(",
"self",
")",
":",
"for",
"mutable",
"in",
"self",
".",
"undedup_mutables",
":",
"mutable",
".",
"registered_module",
".",
"to_disable_grad",
"(",
")"
] | [
240,
4
] | [
246,
55
] | python | en | ['en', 'error', 'th'] | False |
FBNetMutator.sample_final | (self) |
Generate the final chosen architecture.
Returns
-------
dict
the choice of each mutable, i.e., LayerChoice
|
Generate the final chosen architecture. | def sample_final(self):
"""
Generate the final chosen architecture.
Returns
-------
dict
the choice of each mutable, i.e., LayerChoice
"""
result = dict()
for mutable in self.undedup_mutables:
assert isinstance(mutable, LayerChoice... | [
"def",
"sample_final",
"(",
"self",
")",
":",
"result",
"=",
"dict",
"(",
")",
"for",
"mutable",
"in",
"self",
".",
"undedup_mutables",
":",
"assert",
"isinstance",
"(",
"mutable",
",",
"LayerChoice",
")",
"index",
"=",
"mutable",
".",
"registered_module",
... | [
248,
4
] | [
267,
21
] | python | en | ['en', 'error', 'th'] | False |
_make_causal_mask | (input_ids_shape: tf.TensorShape, past_key_values_length: int = 0) |
Make causal mask used for bi-directional self-attention.
|
Make causal mask used for bi-directional self-attention.
| def _make_causal_mask(input_ids_shape: tf.TensorShape, past_key_values_length: int = 0):
"""
Make causal mask used for bi-directional self-attention.
"""
bsz, tgt_len = input_ids_shape
mask = tf.ones((tgt_len, tgt_len)) * LARGE_NEGATIVE
mask_cond = tf.range(shape_list(mask)[-1])
mask = tf.w... | [
"def",
"_make_causal_mask",
"(",
"input_ids_shape",
":",
"tf",
".",
"TensorShape",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"tgt_len",
"=",
"input_ids_shape",
"mask",
"=",
"tf",
".",
"ones",
"(",
"(",
"tgt_len",
",",
"tgt_... | [
86,
0
] | [
99,
58
] | python | en | ['en', 'error', 'th'] | False |
_expand_mask | (mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0) |
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
| def _expand_mask(mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0):
"""
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
"""
src_len = shape_list(mask)[1]
tgt_len = tgt_len if tgt_len is not None else src_len
one_cst = tf.consta... | [
"def",
"_expand_mask",
"(",
"mask",
":",
"tf",
".",
"Tensor",
",",
"tgt_len",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"src_len",
"=",
"shape_list",
"(",
"mask",
")",
"[",
"1",
"]",... | [
103,
0
] | [
113,
53
] | python | en | ['en', 'error', 'th'] | False |
TFBlenderbotLearnedPositionalEmbedding.call | (self, input_shape: tf.TensorShape, past_key_values_length: int = 0) | Input is expected to be of size [bsz x seqlen]. | Input is expected to be of size [bsz x seqlen]. | def call(self, input_shape: tf.TensorShape, past_key_values_length: int = 0):
"""Input is expected to be of size [bsz x seqlen]."""
bsz, seq_len = input_shape[:2]
positions = tf.range(past_key_values_length, seq_len + past_key_values_length, delta=1, name="range")
return super().call(po... | [
"def",
"call",
"(",
"self",
",",
"input_shape",
":",
"tf",
".",
"TensorShape",
",",
"past_key_values_length",
":",
"int",
"=",
"0",
")",
":",
"bsz",
",",
"seq_len",
"=",
"input_shape",
"[",
":",
"2",
"]",
"positions",
"=",
"tf",
".",
"range",
"(",
"p... | [
124,
4
] | [
129,
38
] | python | en | ['en', 'en', 'en'] | True |
TFBlenderbotAttention.call | (
self,
hidden_states: tf.Tensor,
key_value_states: Optional[tf.Tensor] = None,
past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None,
attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
training=False,
) | Input shape: Batch x Time x Channel | Input shape: Batch x Time x Channel | def call(
self,
hidden_states: tf.Tensor,
key_value_states: Optional[tf.Tensor] = None,
past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None,
attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
training=False,
) -> Tupl... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
":",
"tf",
".",
"Tensor",
",",
"key_value_states",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"past_key_value",
":",
"Optional",
"[",
"Tuple",
"[",
"Tuple",
"[",
"tf",
".",
"Tenso... | [
163,
4
] | [
279,
56
] | python | en | ['en', 'pl', 'en'] | True |
TFBlenderbotEncoderLayer.call | (self, hidden_states: tf.Tensor, attention_mask: tf.Tensor, layer_head_mask: tf.Tensor, training=False) |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
laye... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
laye... | def call(self, hidden_states: tf.Tensor, attention_mask: tf.Tensor, layer_head_mask: tf.Tensor, training=False):
"""
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
":",
"tf",
".",
"Tensor",
",",
"attention_mask",
":",
"tf",
".",
"Tensor",
",",
"layer_head_mask",
":",
"tf",
".",
"Tensor",
",",
"training",
"=",
"False",
")",
":",
"residual",
"=",
"hidden_states",
"hid... | [
298,
4
] | [
333,
47
] | python | en | ['en', 'error', 'th'] | False |
TFBlenderbotDecoderLayer.call | (
self,
hidden_states,
attention_mask: Optional[tf.Tensor] = None,
encoder_hidden_states: Optional[tf.Tensor] = None,
encoder_attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
encoder_layer_head_mask: Optional[tf.Tensor] = No... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
enco... |
Args:
hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)`
attention_mask (:obj:`tf.Tensor`): attention mask of size
`(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values.
enco... | def call(
self,
hidden_states,
attention_mask: Optional[tf.Tensor] = None,
encoder_hidden_states: Optional[tf.Tensor] = None,
encoder_attention_mask: Optional[tf.Tensor] = None,
layer_head_mask: Optional[tf.Tensor] = None,
encoder_layer_head_mask: Optional[tf.Tens... | [
"def",
"call",
"(",
"self",
",",
"hidden_states",
",",
"attention_mask",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_hidden_states",
":",
"Optional",
"[",
"tf",
".",
"Tensor",
"]",
"=",
"None",
",",
"encoder_attention_mask",
... | [
365,
4
] | [
440,
9
] | python | en | ['en', 'error', 'th'] | False |
mock_client_fixture | () | Mock the azure event hub producer client. | Mock the azure event hub producer client. | def mock_client_fixture():
"""Mock the azure event hub producer client."""
with patch(f"{PRODUCER_PATH}.send_batch") as mock_send_batch, patch(
f"{PRODUCER_PATH}.close"
) as mock_close, patch(f"{PRODUCER_PATH}.__init__", return_value=None) as mock_init:
yield (
mock_init,
... | [
"def",
"mock_client_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"f\"{PRODUCER_PATH}.send_batch\"",
")",
"as",
"mock_send_batch",
",",
"patch",
"(",
"f\"{PRODUCER_PATH}.close\"",
")",
"as",
"mock_close",
",",
"patch",
"(",
"f\"{PRODUCER_PATH}.__init__\"",
",",
"retu... | [
30,
0
] | [
39,
9
] | python | en | ['en', 'en', 'en'] | True |
mock_batch_fixture | () | Mock batch creator and return mocked batch object. | Mock batch creator and return mocked batch object. | def mock_batch_fixture():
"""Mock batch creator and return mocked batch object."""
mock_batch = MagicMock()
with patch(f"{PRODUCER_PATH}.create_batch", return_value=mock_batch):
yield mock_batch | [
"def",
"mock_batch_fixture",
"(",
")",
":",
"mock_batch",
"=",
"MagicMock",
"(",
")",
"with",
"patch",
"(",
"f\"{PRODUCER_PATH}.create_batch\"",
",",
"return_value",
"=",
"mock_batch",
")",
":",
"yield",
"mock_batch"
] | [
43,
0
] | [
47,
24
] | python | en | ['en', 'cy', 'en'] | True |
mock_policy_fixture | () | Mock azure shared key credential. | Mock azure shared key credential. | def mock_policy_fixture():
"""Mock azure shared key credential."""
with patch(f"{AZURE_EVENT_HUB_PATH}.EventHubSharedKeyCredential") as policy:
yield policy | [
"def",
"mock_policy_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"f\"{AZURE_EVENT_HUB_PATH}.EventHubSharedKeyCredential\"",
")",
"as",
"policy",
":",
"yield",
"policy"
] | [
51,
0
] | [
54,
20
] | python | da | ['eu', 'da', 'en'] | False |
mock_event_data_fixture | () | Mock the azure event data component. | Mock the azure event data component. | def mock_event_data_fixture():
"""Mock the azure event data component."""
with patch(f"{AZURE_EVENT_HUB_PATH}.EventData") as event_data:
yield event_data | [
"def",
"mock_event_data_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"f\"{AZURE_EVENT_HUB_PATH}.EventData\"",
")",
"as",
"event_data",
":",
"yield",
"event_data"
] | [
58,
0
] | [
61,
24
] | python | en | ['en', 'en', 'en'] | True |
mock_call_later_fixture | () | Mock async_call_later to allow queue processing on demand. | Mock async_call_later to allow queue processing on demand. | def mock_call_later_fixture():
"""Mock async_call_later to allow queue processing on demand."""
with patch(f"{AZURE_EVENT_HUB_PATH}.async_call_later") as mock_call_later:
yield mock_call_later | [
"def",
"mock_call_later_fixture",
"(",
")",
":",
"with",
"patch",
"(",
"f\"{AZURE_EVENT_HUB_PATH}.async_call_later\"",
")",
"as",
"mock_call_later",
":",
"yield",
"mock_call_later"
] | [
65,
0
] | [
68,
29
] | python | en | ['en', 'en', 'en'] | True |
test_minimal_config | (hass) | Test the minimal config and defaults of component. | Test the minimal config and defaults of component. | async def test_minimal_config(hass):
"""Test the minimal config and defaults of component."""
config = {azure_event_hub.DOMAIN: MIN_CONFIG}
assert await async_setup_component(hass, azure_event_hub.DOMAIN, config) | [
"async",
"def",
"test_minimal_config",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"azure_event_hub",
".",
"DOMAIN",
":",
"MIN_CONFIG",
"}",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"azure_event_hub",
".",
"DOMAIN",
",",
"config",
")"
] | [
71,
0
] | [
74,
76
] | python | en | ['en', 'en', 'en'] | True |
test_full_config | (hass) | Test the full config of component. | Test the full config of component. | async def test_full_config(hass):
"""Test the full config of component."""
config = {
azure_event_hub.DOMAIN: {
"send_interval": 10,
"max_delay": 10,
"filter": {
"include_domains": ["light"],
"include_entity_globs": ["sensor.included_*"... | [
"async",
"def",
"test_full_config",
"(",
"hass",
")",
":",
"config",
"=",
"{",
"azure_event_hub",
".",
"DOMAIN",
":",
"{",
"\"send_interval\"",
":",
"10",
",",
"\"max_delay\"",
":",
"10",
",",
"\"filter\"",
":",
"{",
"\"include_domains\"",
":",
"[",
"\"light... | [
77,
0
] | [
94,
76
] | python | en | ['en', 'en', 'en'] | True |
_setup | (hass, mock_call_later, filter_config) | Shared set up for filtering tests. | Shared set up for filtering tests. | async def _setup(hass, mock_call_later, filter_config):
"""Shared set up for filtering tests."""
config = {azure_event_hub.DOMAIN: {"filter": filter_config}}
config[azure_event_hub.DOMAIN].update(MIN_CONFIG)
assert await async_setup_component(hass, azure_event_hub.DOMAIN, config)
await hass.async_b... | [
"async",
"def",
"_setup",
"(",
"hass",
",",
"mock_call_later",
",",
"filter_config",
")",
":",
"config",
"=",
"{",
"azure_event_hub",
".",
"DOMAIN",
":",
"{",
"\"filter\"",
":",
"filter_config",
"}",
"}",
"config",
"[",
"azure_event_hub",
".",
"DOMAIN",
"]",... | [
97,
0
] | [
105,
42
] | python | en | ['en', 'da', 'en'] | True |
_run_filter_tests | (hass, tests, process_queue, mock_batch) | Run a series of filter tests on azure event hub. | Run a series of filter tests on azure event hub. | async def _run_filter_tests(hass, tests, process_queue, mock_batch):
"""Run a series of filter tests on azure event hub."""
for test in tests:
hass.states.async_set(test.id, STATE_ON)
await hass.async_block_till_done()
await process_queue(None)
if test.should_pass:
m... | [
"async",
"def",
"_run_filter_tests",
"(",
"hass",
",",
"tests",
",",
"process_queue",
",",
"mock_batch",
")",
":",
"for",
"test",
"in",
"tests",
":",
"hass",
".",
"states",
".",
"async_set",
"(",
"test",
".",
"id",
",",
"STATE_ON",
")",
"await",
"hass",
... | [
108,
0
] | [
119,
46
] | python | en | ['en', 'en', 'en'] | True |
test_allowlist | (hass, mock_batch, mock_call_later) | Test an allowlist only config. | Test an allowlist only config. | async def test_allowlist(hass, mock_batch, mock_call_later):
"""Test an allowlist only config."""
process_queue = await _setup(
hass,
mock_call_later,
{
"include_domains": ["light"],
"include_entity_globs": ["sensor.included_*"],
"include_entities": ["... | [
"async",
"def",
"test_allowlist",
"(",
"hass",
",",
"mock_batch",
",",
"mock_call_later",
")",
":",
"process_queue",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_call_later",
",",
"{",
"\"include_domains\"",
":",
"[",
"\"light\"",
"]",
",",
"\"include_entity_... | [
122,
0
] | [
143,
67
] | python | en | ['en', 'lb', 'en'] | True |
test_denylist | (hass, mock_batch, mock_call_later) | Test a denylist only config. | Test a denylist only config. | async def test_denylist(hass, mock_batch, mock_call_later):
"""Test a denylist only config."""
process_queue = await _setup(
hass,
mock_call_later,
{
"exclude_domains": ["climate"],
"exclude_entity_globs": ["sensor.excluded_*"],
"exclude_entities": ["b... | [
"async",
"def",
"test_denylist",
"(",
"hass",
",",
"mock_batch",
",",
"mock_call_later",
")",
":",
"process_queue",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_call_later",
",",
"{",
"\"exclude_domains\"",
":",
"[",
"\"climate\"",
"]",
",",
"\"exclude_entity... | [
146,
0
] | [
167,
67
] | python | en | ['en', 'en', 'en'] | True |
test_filtered_allowlist | (hass, mock_batch, mock_call_later) | Test an allowlist config with a filtering denylist. | Test an allowlist config with a filtering denylist. | async def test_filtered_allowlist(hass, mock_batch, mock_call_later):
"""Test an allowlist config with a filtering denylist."""
process_queue = await _setup(
hass,
mock_call_later,
{
"include_domains": ["light"],
"include_entity_globs": ["*.included_*"],
... | [
"async",
"def",
"test_filtered_allowlist",
"(",
"hass",
",",
"mock_batch",
",",
"mock_call_later",
")",
":",
"process_queue",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_call_later",
",",
"{",
"\"include_domains\"",
":",
"[",
"\"light\"",
"]",
",",
"\"includ... | [
170,
0
] | [
192,
67
] | python | en | ['en', 'en', 'en'] | True |
test_filtered_denylist | (hass, mock_batch, mock_call_later) | Test a denylist config with a filtering allowlist. | Test a denylist config with a filtering allowlist. | async def test_filtered_denylist(hass, mock_batch, mock_call_later):
"""Test a denylist config with a filtering allowlist."""
process_queue = await _setup(
hass,
mock_call_later,
{
"include_entities": ["climate.included", "sensor.excluded_test"],
"exclude_domains"... | [
"async",
"def",
"test_filtered_denylist",
"(",
"hass",
",",
"mock_batch",
",",
"mock_call_later",
")",
":",
"process_queue",
"=",
"await",
"_setup",
"(",
"hass",
",",
"mock_call_later",
",",
"{",
"\"include_entities\"",
":",
"[",
"\"climate.included\"",
",",
"\"se... | [
195,
0
] | [
217,
67
] | python | en | ['en', 'en', 'en'] | True |
test_switch | (
hass: HomeAssistant, vera_component_factory: ComponentFactory
) | Test function. | Test function. | async def test_switch(
hass: HomeAssistant, vera_component_factory: ComponentFactory
) -> None:
"""Test function."""
vera_device = MagicMock(spec=pv.VeraSwitch) # type: pv.VeraSwitch
vera_device.device_id = 1
vera_device.vera_device_id = vera_device.device_id
vera_device.name = "dev1"
vera_... | [
"async",
"def",
"test_switch",
"(",
"hass",
":",
"HomeAssistant",
",",
"vera_component_factory",
":",
"ComponentFactory",
")",
"->",
"None",
":",
"vera_device",
"=",
"MagicMock",
"(",
"spec",
"=",
"pv",
".",
"VeraSwitch",
")",
"# type: pv.VeraSwitch",
"vera_device... | [
10,
0
] | [
54,
52
] | python | en | ['en', 'en', 'en'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Demo Calendar platform. | Set up the Demo Calendar platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Demo Calendar platform."""
calendar_data_future = DemoGoogleCalendarDataFuture()
calendar_data_current = DemoGoogleCalendarDataCurrent()
add_entities(
[
DemoGoogleCalendar(hass, calendar_data_future, "... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"calendar_data_future",
"=",
"DemoGoogleCalendarDataFuture",
"(",
")",
"calendar_data_current",
"=",
"DemoGoogleCalendarDataCurrent",
"(",
")",
"add... | [
7,
0
] | [
16,
5
] | python | en | ['en', 'pt', 'en'] | True |
DemoGoogleCalendarData.async_get_events | (self, hass, start_date, end_date) | Get all events in a specific time frame. | Get all events in a specific time frame. | async def async_get_events(self, hass, start_date, end_date):
"""Get all events in a specific time frame."""
event = copy.copy(self.event)
event["title"] = event["summary"]
event["start"] = get_date(event["start"]).isoformat()
event["end"] = get_date(event["end"]).isoformat()
... | [
"async",
"def",
"async_get_events",
"(",
"self",
",",
"hass",
",",
"start_date",
",",
"end_date",
")",
":",
"event",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"event",
")",
"event",
"[",
"\"title\"",
"]",
"=",
"event",
"[",
"\"summary\"",
"]",
"event... | [
24,
4
] | [
30,
22
] | python | en | ['en', 'en', 'en'] | True |
DemoGoogleCalendarDataFuture.__init__ | (self) | Set the event to a future event. | Set the event to a future event. | def __init__(self):
"""Set the event to a future event."""
one_hour_from_now = dt_util.now() + dt_util.dt.timedelta(minutes=30)
self.event = {
"start": {"dateTime": one_hour_from_now.isoformat()},
"end": {
"dateTime": (
one_hour_from_no... | [
"def",
"__init__",
"(",
"self",
")",
":",
"one_hour_from_now",
"=",
"dt_util",
".",
"now",
"(",
")",
"+",
"dt_util",
".",
"dt",
".",
"timedelta",
"(",
"minutes",
"=",
"30",
")",
"self",
".",
"event",
"=",
"{",
"\"start\"",
":",
"{",
"\"dateTime\"",
"... | [
36,
4
] | [
47,
9
] | python | en | ['en', 'en', 'en'] | True |
DemoGoogleCalendarDataCurrent.__init__ | (self) | Set the event data. | Set the event data. | def __init__(self):
"""Set the event data."""
middle_of_event = dt_util.now() - dt_util.dt.timedelta(minutes=30)
self.event = {
"start": {"dateTime": middle_of_event.isoformat()},
"end": {
"dateTime": (
middle_of_event + dt_util.dt.time... | [
"def",
"__init__",
"(",
"self",
")",
":",
"middle_of_event",
"=",
"dt_util",
".",
"now",
"(",
")",
"-",
"dt_util",
".",
"dt",
".",
"timedelta",
"(",
"minutes",
"=",
"30",
")",
"self",
".",
"event",
"=",
"{",
"\"start\"",
":",
"{",
"\"dateTime\"",
":"... | [
53,
4
] | [
64,
9
] | python | en | ['en', 'en', 'en'] | True |
DemoGoogleCalendar.__init__ | (self, hass, calendar_data, name) | Initialize demo calendar. | Initialize demo calendar. | def __init__(self, hass, calendar_data, name):
"""Initialize demo calendar."""
self.data = calendar_data
self._name = name | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"calendar_data",
",",
"name",
")",
":",
"self",
".",
"data",
"=",
"calendar_data",
"self",
".",
"_name",
"=",
"name"
] | [
70,
4
] | [
73,
25
] | python | es | ['es', 'pt', 'it'] | False |
DemoGoogleCalendar.event | (self) | Return the next upcoming event. | Return the next upcoming event. | def event(self):
"""Return the next upcoming event."""
return self.data.event | [
"def",
"event",
"(",
"self",
")",
":",
"return",
"self",
".",
"data",
".",
"event"
] | [
76,
4
] | [
78,
30
] | python | en | ['en', 'en', 'en'] | True |
DemoGoogleCalendar.name | (self) | Return the name of the entity. | Return the name of the entity. | def name(self):
"""Return the name of the entity."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
81,
4
] | [
83,
25
] | python | en | ['en', 'en', 'en'] | True |
DemoGoogleCalendar.async_get_events | (self, hass, start_date, end_date) | Return calendar events within a datetime range. | Return calendar events within a datetime range. | async def async_get_events(self, hass, start_date, end_date):
"""Return calendar events within a datetime range."""
return await self.data.async_get_events(hass, start_date, end_date) | [
"async",
"def",
"async_get_events",
"(",
"self",
",",
"hass",
",",
"start_date",
",",
"end_date",
")",
":",
"return",
"await",
"self",
".",
"data",
".",
"async_get_events",
"(",
"hass",
",",
"start_date",
",",
"end_date",
")"
] | [
85,
4
] | [
87,
75
] | python | en | ['en', 'en', 'en'] | True |
async_process_devices | (hass, manager) | Assign devices to proper component. | Assign devices to proper component. | async def async_process_devices(hass, manager):
"""Assign devices to proper component."""
devices = {}
devices[VS_SWITCHES] = []
devices[VS_FANS] = []
await hass.async_add_executor_job(manager.update)
if manager.fans:
devices[VS_FANS].extend(manager.fans)
_LOGGER.info("%d VeSyn... | [
"async",
"def",
"async_process_devices",
"(",
"hass",
",",
"manager",
")",
":",
"devices",
"=",
"{",
"}",
"devices",
"[",
"VS_SWITCHES",
"]",
"=",
"[",
"]",
"devices",
"[",
"VS_FANS",
"]",
"=",
"[",
"]",
"await",
"hass",
".",
"async_add_executor_job",
"(... | [
10,
0
] | [
32,
18
] | python | en | ['en', 'en', 'en'] | True |
VeSyncDevice.__init__ | (self, device) | Initialize the VeSync device. | Initialize the VeSync device. | def __init__(self, device):
"""Initialize the VeSync device."""
self.device = device | [
"def",
"__init__",
"(",
"self",
",",
"device",
")",
":",
"self",
".",
"device",
"=",
"device"
] | [
38,
4
] | [
40,
28
] | python | en | ['en', 'cs', 'en'] | True |
VeSyncDevice.unique_id | (self) | Return the ID of this device. | Return the ID of this device. | def unique_id(self):
"""Return the ID of this device."""
if isinstance(self.device.sub_device_no, int):
return "{}{}".format(self.device.cid, str(self.device.sub_device_no))
return self.device.cid | [
"def",
"unique_id",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"device",
".",
"sub_device_no",
",",
"int",
")",
":",
"return",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"device",
".",
"cid",
",",
"str",
"(",
"self",
".",
"device"... | [
43,
4
] | [
47,
30
] | python | en | ['en', 'en', 'en'] | True |
VeSyncDevice.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.device.device_name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"device",
".",
"device_name"
] | [
50,
4
] | [
52,
38
] | python | en | ['en', 'en', 'en'] | True |
VeSyncDevice.is_on | (self) | Return True if device is on. | Return True if device is on. | def is_on(self):
"""Return True if device is on."""
return self.device.device_status == "on" | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"device",
".",
"device_status",
"==",
"\"on\""
] | [
55,
4
] | [
57,
48
] | python | en | ['en', 'fy', 'en'] | True |
VeSyncDevice.available | (self) | Return True if device is available. | Return True if device is available. | def available(self) -> bool:
"""Return True if device is available."""
return self.device.connection_status == "online" | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"device",
".",
"connection_status",
"==",
"\"online\""
] | [
60,
4
] | [
62,
56
] | python | en | ['en', 'en', 'en'] | True |
VeSyncDevice.turn_off | (self, **kwargs) | Turn the device off. | Turn the device off. | def turn_off(self, **kwargs):
"""Turn the device off."""
self.device.turn_off() | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"device",
".",
"turn_off",
"(",
")"
] | [
64,
4
] | [
66,
30
] | python | en | ['en', 'en', 'en'] | True |
VeSyncDevice.update | (self) | Update vesync device. | Update vesync device. | def update(self):
"""Update vesync device."""
self.device.update() | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"device",
".",
"update",
"(",
")"
] | [
68,
4
] | [
70,
28
] | python | cs | ['fr', 'cs', 'tr'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up tuya sensors dynamically through tuya discovery. | Set up tuya sensors dynamically through tuya discovery. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up tuya sensors dynamically through tuya discovery."""
platform = config_entry.data[CONF_PLATFORM]
async def async_discover_sensor(dev_ids):
"""Discover and add a discovered tuya sensor."""
if not dev_ids:
... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"platform",
"=",
"config_entry",
".",
"data",
"[",
"CONF_PLATFORM",
"]",
"async",
"def",
"async_discover_sensor",
"(",
"dev_ids",
")",
":",
"\"\"\"Discover ... | [
13,
0
] | [
35,
44
] | python | en | ['en', 'zu', 'en'] | True |
_setup_entities | (hass, dev_ids, platform) | Set up Tuya Scene. | Set up Tuya Scene. | def _setup_entities(hass, dev_ids, platform):
"""Set up Tuya Scene."""
tuya = hass.data[DOMAIN][TUYA_DATA]
entities = []
for dev_id in dev_ids:
device = tuya.get_device_by_id(dev_id)
if device is None:
continue
entities.append(TuyaScene(device, platform))
return e... | [
"def",
"_setup_entities",
"(",
"hass",
",",
"dev_ids",
",",
"platform",
")",
":",
"tuya",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"TUYA_DATA",
"]",
"entities",
"=",
"[",
"]",
"for",
"dev_id",
"in",
"dev_ids",
":",
"device",
"=",
"tuya",
".... | [
38,
0
] | [
47,
19
] | python | en | ['en', 'hr', 'en'] | True |
TuyaScene.__init__ | (self, tuya, platform) | Init Tuya scene. | Init Tuya scene. | def __init__(self, tuya, platform):
"""Init Tuya scene."""
super().__init__(tuya, platform)
self.entity_id = ENTITY_ID_FORMAT.format(tuya.object_id()) | [
"def",
"__init__",
"(",
"self",
",",
"tuya",
",",
"platform",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"tuya",
",",
"platform",
")",
"self",
".",
"entity_id",
"=",
"ENTITY_ID_FORMAT",
".",
"format",
"(",
"tuya",
".",
"object_id",
"(",
")",
... | [
53,
4
] | [
56,
66
] | python | en | ['en', 'sw', 'it'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.