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
GarminConnectSensor.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._enabled_default
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_enabled_default" ]
[ 147, 4 ]
[ 149, 36 ]
python
en
['en', 'en', 'en']
True
GarminConnectSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 152, 4 ]
[ 154, 30 ]
python
en
['en', 'en', 'en']
True
GarminConnectSensor.device_class
(self)
Return the device class of the sensor.
Return the device class of the sensor.
def device_class(self): """Return the device class of the sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 157, 4 ]
[ 159, 33 ]
python
en
['en', 'en', 'en']
True
GarminConnectSensor.async_update
(self)
Update the data from Garmin Connect.
Update the data from Garmin Connect.
async def async_update(self): """Update the data from Garmin Connect.""" if not self.enabled: return await self._data.async_update() data = self._data.data if not data: _LOGGER.error("Didn't receive data from Garmin Connect") return if...
[ "async", "def", "async_update", "(", "self", ")", ":", "if", "not", "self", ".", "enabled", ":", "return", "await", "self", ".", "_data", ".", "async_update", "(", ")", "data", "=", "self", ".", "_data", ".", "data", "if", "not", "data", ":", "_LOGGE...
[ 161, 4 ]
[ 196, 9 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the PiFace Digital Input devices.
Set up the PiFace Digital Input devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the PiFace Digital Input devices.""" binary_sensors = [] ports = config.get(CONF_PORTS) for port, port_entity in ports.items(): name = port_entity.get(CONF_NAME) settle_time = port_entity[CONF_SETTLE_TIME] / 1...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "binary_sensors", "=", "[", "]", "ports", "=", "config", ".", "get", "(", "CONF_PORTS", ")", "for", "port", ",", "port_entity", "in", ...
[ 28, 0 ]
[ 42, 36 ]
python
en
['en', 'en', 'en']
True
RPiPFIOBinarySensor.__init__
(self, hass, port, name, settle_time, invert_logic)
Initialize the RPi binary sensor.
Initialize the RPi binary sensor.
def __init__(self, hass, port, name, settle_time, invert_logic): """Initialize the RPi binary sensor.""" self._port = port self._name = name or DEVICE_DEFAULT_NAME self._invert_logic = invert_logic self._state = None def read_pfio(port): """Read state from PF...
[ "def", "__init__", "(", "self", ",", "hass", ",", "port", ",", "name", ",", "settle_time", ",", "invert_logic", ")", ":", "self", ".", "_port", "=", "port", "self", ".", "_name", "=", "name", "or", "DEVICE_DEFAULT_NAME", "self", ".", "_invert_logic", "="...
[ 48, 4 ]
[ 60, 70 ]
python
en
['en', 'pt', 'en']
True
RPiPFIOBinarySensor.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 63, 4 ]
[ 65, 20 ]
python
en
['en', 'en', 'en']
True
RPiPFIOBinarySensor.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" ]
[ 68, 4 ]
[ 70, 25 ]
python
en
['en', 'mi', 'en']
True
RPiPFIOBinarySensor.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" ]
[ 73, 4 ]
[ 75, 48 ]
python
en
['en', 'en', 'en']
True
RPiPFIOBinarySensor.update
(self)
Update the PFIO state.
Update the PFIO state.
def update(self): """Update the PFIO state.""" self._state = rpi_pfio.read_input(self._port)
[ "def", "update", "(", "self", ")", ":", "self", ".", "_state", "=", "rpi_pfio", ".", "read_input", "(", "self", ".", "_port", ")" ]
[ 77, 4 ]
[ 79, 53 ]
python
en
['en', 'sn', 'en']
True
summation_worker
(group_name)
The main worker logic includes initialize proxy and handle sum jobs from the master. Args: group_name (str): Identifier for the group of all communication components.
The main worker logic includes initialize proxy and handle sum jobs from the master.
def summation_worker(group_name): """ The main worker logic includes initialize proxy and handle sum jobs from the master. Args: group_name (str): Identifier for the group of all communication components. """ proxy = Proxy(group_name=group_name, component_type="sum_worker"...
[ "def", "summation_worker", "(", "group_name", ")", ":", "proxy", "=", "Proxy", "(", "group_name", "=", "group_name", ",", "component_type", "=", "\"sum_worker\"", ",", "expected_peers", "=", "{", "\"master\"", ":", "1", "}", ")", "# Nonrecurring receive the messag...
[ 11, 0 ]
[ 28, 72 ]
python
en
['en', 'error', 'th']
False
multiplication_worker
(group_name)
The main worker logic includes initialize proxy and handle multiply jobs from the master. Args: group_name (str): Identifier for the group of all communication components.
The main worker logic includes initialize proxy and handle multiply jobs from the master.
def multiplication_worker(group_name): """ The main worker logic includes initialize proxy and handle multiply jobs from the master. Args: group_name (str): Identifier for the group of all communication components. """ proxy = Proxy(group_name=group_name, component_type="m...
[ "def", "multiplication_worker", "(", "group_name", ")", ":", "proxy", "=", "Proxy", "(", "group_name", "=", "group_name", ",", "component_type", "=", "\"multiply_worker\"", ",", "expected_peers", "=", "{", "\"master\"", ":", "1", "}", ")", "# Nonrecurring receive ...
[ 31, 0 ]
[ 48, 77 ]
python
en
['en', 'error', 'th']
False
master
(group_name: str, sum_worker_number: int, multiply_worker_number: int, is_immediate: bool = False)
The main master logic includes initialize proxy and allocate jobs to workers. Args: group_name (str): Identifier for the group of all communication components, sum_worker_number (int): The number of sum workers, multiply_worker_number (int): The number of multiply workers, is_i...
The main master logic includes initialize proxy and allocate jobs to workers.
def master(group_name: str, sum_worker_number: int, multiply_worker_number: int, is_immediate: bool = False): """ The main master logic includes initialize proxy and allocate jobs to workers. Args: group_name (str): Identifier for the group of all communication components, sum_worker_number...
[ "def", "master", "(", "group_name", ":", "str", ",", "sum_worker_number", ":", "int", ",", "multiply_worker_number", ":", "int", ",", "is_immediate", ":", "bool", "=", "False", ")", ":", "proxy", "=", "Proxy", "(", "group_name", "=", "group_name", ",", "co...
[ 51, 0 ]
[ 108, 53 ]
python
en
['en', 'error', 'th']
False
test_platform_manually_configured
(hass)
Test that we do not discover anything or try to set up a gateway.
Test that we do not discover anything or try to set up a gateway.
async def test_platform_manually_configured(hass): """Test that we do not discover anything or try to set up a gateway.""" assert ( await async_setup_component( hass, CLIMATE_DOMAIN, {"climate": {"platform": DECONZ_DOMAIN}} ) is True ) assert DECONZ_DOMAIN not in hass...
[ "async", "def", "test_platform_manually_configured", "(", "hass", ")", ":", "assert", "(", "await", "async_setup_component", "(", "hass", ",", "CLIMATE_DOMAIN", ",", "{", "\"climate\"", ":", "{", "\"platform\"", ":", "DECONZ_DOMAIN", "}", "}", ")", "is", "True",...
[ 58, 0 ]
[ 66, 41 ]
python
en
['en', 'en', 'en']
True
test_no_sensors
(hass)
Test that no sensors in deconz results in no climate entities.
Test that no sensors in deconz results in no climate entities.
async def test_no_sensors(hass): """Test that no sensors in deconz results in no climate entities.""" await setup_deconz_integration(hass) assert len(hass.states.async_all()) == 0
[ "async", "def", "test_no_sensors", "(", "hass", ")", ":", "await", "setup_deconz_integration", "(", "hass", ")", "assert", "len", "(", "hass", ".", "states", ".", "async_all", "(", ")", ")", "==", "0" ]
[ 69, 0 ]
[ 72, 44 ]
python
en
['en', 'en', 'en']
True
test_climate_devices
(hass)
Test successful creation of sensor entities.
Test successful creation of sensor entities.
async def test_climate_devices(hass): """Test successful creation of sensor entities.""" data = deepcopy(DECONZ_WEB_REQUEST) data["sensors"] = deepcopy(SENSORS) config_entry = await setup_deconz_integration(hass, get_state_response=data) gateway = get_gateway_from_config_entry(hass, config_entry) ...
[ "async", "def", "test_climate_devices", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"sensors\"", "]", "=", "deepcopy", "(", "SENSORS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "hass", ...
[ 75, 0 ]
[ 220, 44 ]
python
en
['en', 'en', 'en']
True
test_clip_climate_device
(hass)
Test successful creation of sensor entities.
Test successful creation of sensor entities.
async def test_clip_climate_device(hass): """Test successful creation of sensor entities.""" data = deepcopy(DECONZ_WEB_REQUEST) data["sensors"] = deepcopy(SENSORS) config_entry = await setup_deconz_integration( hass, options={CONF_ALLOW_CLIP_SENSOR: True}, get_state_response=dat...
[ "async", "def", "test_clip_climate_device", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"sensors\"", "]", "=", "deepcopy", "(", "SENSORS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "has...
[ 223, 0 ]
[ 257, 77 ]
python
en
['en', 'en', 'en']
True
test_verify_state_update
(hass)
Test that state update properly.
Test that state update properly.
async def test_verify_state_update(hass): """Test that state update properly.""" data = deepcopy(DECONZ_WEB_REQUEST) data["sensors"] = deepcopy(SENSORS) config_entry = await setup_deconz_integration(hass, get_state_response=data) gateway = get_gateway_from_config_entry(hass, config_entry) asser...
[ "async", "def", "test_verify_state_update", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"sensors\"", "]", "=", "deepcopy", "(", "SENSORS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "has...
[ 260, 0 ]
[ 280, 88 ]
python
en
['en', 'en', 'en']
True
test_add_new_climate_device
(hass)
Test that adding a new climate device works.
Test that adding a new climate device works.
async def test_add_new_climate_device(hass): """Test that adding a new climate device works.""" config_entry = await setup_deconz_integration(hass) gateway = get_gateway_from_config_entry(hass, config_entry) assert len(hass.states.async_all()) == 0 state_added_event = { "t": "event", ...
[ "async", "def", "test_add_new_climate_device", "(", "hass", ")", ":", "config_entry", "=", "await", "setup_deconz_integration", "(", "hass", ")", "gateway", "=", "get_gateway_from_config_entry", "(", "hass", ",", "config_entry", ")", "assert", "len", "(", "hass", ...
[ 283, 0 ]
[ 301, 76 ]
python
en
['en', 'en', 'en']
True
async_get_service
(hass, config, discovery_info=None)
Get the Prowl notification service.
Get the Prowl notification service.
async def async_get_service(hass, config, discovery_info=None): """Get the Prowl notification service.""" return ProwlNotificationService(hass, config[CONF_API_KEY])
[ "async", "def", "async_get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "return", "ProwlNotificationService", "(", "hass", ",", "config", "[", "CONF_API_KEY", "]", ")" ]
[ 24, 0 ]
[ 26, 63 ]
python
en
['en', 'en', 'en']
True
ProwlNotificationService.__init__
(self, hass, api_key)
Initialize the service.
Initialize the service.
def __init__(self, hass, api_key): """Initialize the service.""" self._hass = hass self._api_key = api_key
[ "def", "__init__", "(", "self", ",", "hass", ",", "api_key", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_api_key", "=", "api_key" ]
[ 32, 4 ]
[ 35, 31 ]
python
en
['en', 'en', 'en']
True
ProwlNotificationService.async_send_message
(self, message, **kwargs)
Send the message to the user.
Send the message to the user.
async def async_send_message(self, message, **kwargs): """Send the message to the user.""" response = None session = None url = f"{_RESOURCE}add" data = kwargs.get(ATTR_DATA) payload = { "apikey": self._api_key, "application": "Home-Assistant", ...
[ "async", "def", "async_send_message", "(", "self", ",", "message", ",", "*", "*", "kwargs", ")", ":", "response", "=", "None", "session", "=", "None", "url", "=", "f\"{_RESOURCE}add\"", "data", "=", "kwargs", ".", "get", "(", "ATTR_DATA", ")", "payload", ...
[ 37, 4 ]
[ 66, 63 ]
python
en
['en', 'en', 'en']
True
FlowHandler.__init__
(self)
Initialize flow.
Initialize flow.
def __init__(self): """Initialize flow.""" self._prefix = DEFAULT_PREFIX
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_prefix", "=", "DEFAULT_PREFIX" ]
[ 19, 4 ]
[ 21, 37 ]
python
en
['en', 'pl', 'en']
False
FlowHandler.async_step_mqtt
(self, discovery_info=None)
Handle a flow initialized by MQTT discovery.
Handle a flow initialized by MQTT discovery.
async def async_step_mqtt(self, discovery_info=None): """Handle a flow initialized by MQTT discovery.""" if self._async_in_progress() or self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") await self.async_set_unique_id(DOMAIN) # Validat...
[ "async", "def", "async_step_mqtt", "(", "self", ",", "discovery_info", "=", "None", ")", ":", "if", "self", ".", "_async_in_progress", "(", ")", "or", "self", ".", "_async_current_entries", "(", ")", ":", "return", "self", ".", "async_abort", "(", "reason", ...
[ 23, 4 ]
[ 41, 46 ]
python
en
['en', 'en', 'en']
True
FlowHandler.async_step_user
(self, user_input=None)
Handle a flow initialized by the user.
Handle a flow initialized by the user.
async def async_step_user(self, user_input=None): """Handle a flow initialized by the user.""" if self._async_current_entries(): return self.async_abort(reason="single_instance_allowed") if self.show_advanced_options: return await self.async_step_config() return ...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "self", ".", "_async_current_entries", "(", ")", ":", "return", "self", ".", "async_abort", "(", "reason", "=", "\"single_instance_allowed\"", ")", "if", "self", ...
[ 43, 4 ]
[ 50, 46 ]
python
en
['en', 'en', 'en']
True
FlowHandler.async_step_config
(self, user_input=None)
Confirm the setup.
Confirm the setup.
async def async_step_config(self, user_input=None): """Confirm the setup.""" errors = {} data = {CONF_DISCOVERY_PREFIX: self._prefix} if user_input is not None: bad_prefix = False prefix = user_input[CONF_DISCOVERY_PREFIX] if prefix.endswith("/#"): ...
[ "async", "def", "async_step_config", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "data", "=", "{", "CONF_DISCOVERY_PREFIX", ":", "self", ".", "_prefix", "}", "if", "user_input", "is", "not", "None", ":", "bad_prefix", ...
[ 52, 4 ]
[ 77, 9 ]
python
en
['en', 'pt', 'en']
True
FlowHandler.async_step_confirm
(self, user_input=None)
Confirm the setup.
Confirm the setup.
async def async_step_confirm(self, user_input=None): """Confirm the setup.""" data = {CONF_DISCOVERY_PREFIX: self._prefix} if user_input is not None: return self.async_create_entry(title="Tasmota", data=data) return self.async_show_form(step_id="confirm")
[ "async", "def", "async_step_confirm", "(", "self", ",", "user_input", "=", "None", ")", ":", "data", "=", "{", "CONF_DISCOVERY_PREFIX", ":", "self", ".", "_prefix", "}", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry...
[ 79, 4 ]
[ 87, 54 ]
python
en
['en', 'pt', 'en']
True
setup
(hass, config)
Set up the Datadog component.
Set up the Datadog component.
def setup(hass, config): """Set up the Datadog component.""" conf = config[DOMAIN] host = conf[CONF_HOST] port = conf[CONF_PORT] sample_rate = conf[CONF_RATE] prefix = conf[CONF_PREFIX] initialize(statsd_host=host, statsd_port=port) def logbook_entry_listener(event): """Listen...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "host", "=", "conf", "[", "CONF_HOST", "]", "port", "=", "conf", "[", "CONF_PORT", "]", "sample_rate", "=", "conf", "[", "CONF_RATE", "]", "prefix", "=",...
[ 43, 0 ]
[ 102, 15 ]
python
en
['en', 'da', 'en']
True
XLMRobertaTokenizer.build_inputs_with_special_tokens
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An XLM-RoBERTa sequence has the following format: - single sequence: ``<s> X </s>`` - pair of sequences: ``<s> A </s></s> B </s>`` Args: ...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An XLM-RoBERTa sequence has the following format:
def build_inputs_with_special_tokens( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An XLM-RoBERTa sequen...
[ "def", "build_inputs_with_special_tokens", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "if", "token_ids_1", ...
[ 162, 4 ]
[ 186, 64 ]
python
en
['en', 'error', 'th']
False
XLMRobertaTokenizer.get_special_tokens_mask
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False )
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_ids_1 (:obj:`List[int]`,...
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method.
def get_special_tokens_mask( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False ) -> List[int]: """ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens ...
[ "def", "get_special_tokens_mask", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ",", "already_has_special_tokens", ":", "bool", "=", "False", ")", "->", ...
[ 188, 4 ]
[ 217, 87 ]
python
en
['en', 'error', 'th']
False
XLMRobertaTokenizer.create_token_type_ids_from_sequences
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Create a mask from the two sequences passed to be used in a sequence-pair classification task. XLM-RoBERTa does not make use of token type ids, therefore a list of zeros is returned. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_ids_1 (:obj:`L...
Create a mask from the two sequences passed to be used in a sequence-pair classification task. XLM-RoBERTa does not make use of token type ids, therefore a list of zeros is returned.
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. XLM-RoBERTa does not make use of token type ids, therefor...
[ "def", "create_token_type_ids_from_sequences", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "sep", "=", "[",...
[ 219, 4 ]
[ 242, 75 ]
python
en
['en', 'error', 'th']
False
XLMRobertaTokenizer._convert_token_to_id
(self, token)
Converts a token (str) in an id using the vocab.
Converts a token (str) in an id using the vocab.
def _convert_token_to_id(self, token): """ Converts a token (str) in an id using the vocab. """ if token in self.fairseq_tokens_to_ids: return self.fairseq_tokens_to_ids[token] spm_id = self.sp_model.PieceToId(token) # Need to return unknown token if the SP model returned 0 ...
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ")", ":", "if", "token", "in", "self", ".", "fairseq_tokens_to_ids", ":", "return", "self", ".", "fairseq_tokens_to_ids", "[", "token", "]", "spm_id", "=", "self", ".", "sp_model", ".", "PieceToId", "...
[ 256, 4 ]
[ 263, 76 ]
python
en
['en', 'en', 'en']
True
XLMRobertaTokenizer._convert_id_to_token
(self, index)
Converts an index (integer) in a token (str) using the vocab.
Converts an index (integer) in a token (str) using the vocab.
def _convert_id_to_token(self, index): """Converts an index (integer) in a token (str) using the vocab.""" if index in self.fairseq_ids_to_tokens: return self.fairseq_ids_to_tokens[index] return self.sp_model.IdToPiece(index - self.fairseq_offset)
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ")", ":", "if", "index", "in", "self", ".", "fairseq_ids_to_tokens", ":", "return", "self", ".", "fairseq_ids_to_tokens", "[", "index", "]", "return", "self", ".", "sp_model", ".", "IdToPiece", "(", "...
[ 265, 4 ]
[ 269, 67 ]
python
en
['en', 'en', 'en']
True
XLMRobertaTokenizer.convert_tokens_to_string
(self, tokens)
Converts a sequence of tokens (strings for sub-words) in a single string.
Converts a sequence of tokens (strings for sub-words) in a single string.
def convert_tokens_to_string(self, tokens): """Converts a sequence of tokens (strings for sub-words) in a single string.""" out_string = "".join(tokens).replace(SPIECE_UNDERLINE, " ").strip() return out_string
[ "def", "convert_tokens_to_string", "(", "self", ",", "tokens", ")", ":", "out_string", "=", "\"\"", ".", "join", "(", "tokens", ")", ".", "replace", "(", "SPIECE_UNDERLINE", ",", "\" \"", ")", ".", "strip", "(", ")", "return", "out_string" ]
[ 271, 4 ]
[ 274, 25 ]
python
en
['en', 'en', 'en']
True
test_full_flow
(hass, aiohttp_client, aioclient_mock, current_request)
Check full flow.
Check full flow.
async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request): """Check full flow.""" assert await setup.async_setup_component( hass, "home_connect", { "home_connect": { CONF_CLIENT_ID: CLIENT_ID, CONF_CLIENT_SECRET: CLIENT_SE...
[ "async", "def", "test_full_flow", "(", "hass", ",", "aiohttp_client", ",", "aioclient_mock", ",", "current_request", ")", ":", "assert", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"home_connect\"", ",", "{", "\"home_connect\"", ":", "{", ...
[ 16, 0 ]
[ 64, 48 ]
python
en
['sv', 'no', 'en']
False
async_describe_on_off_states
( hass: HomeAssistantType, registry: GroupIntegrationRegistry )
Describe group on off states.
Describe group on off states.
def async_describe_on_off_states( hass: HomeAssistantType, registry: GroupIntegrationRegistry ) -> None: """Describe group on off states.""" registry.on_off_states({STATE_PROBLEM}, STATE_OK)
[ "def", "async_describe_on_off_states", "(", "hass", ":", "HomeAssistantType", ",", "registry", ":", "GroupIntegrationRegistry", ")", "->", "None", ":", "registry", ".", "on_off_states", "(", "{", "STATE_PROBLEM", "}", ",", "STATE_OK", ")" ]
[ 10, 0 ]
[ 14, 53 ]
python
en
['en', 'en', 'en']
True
async_attach_trigger
( hass, config, action, automation_info, *, platform_type="template" )
Listen for state changes based on configuration.
Listen for state changes based on configuration.
async def async_attach_trigger( hass, config, action, automation_info, *, platform_type="template" ): """Listen for state changes based on configuration.""" value_template = config.get(CONF_VALUE_TEMPLATE) value_template.hass = hass time_delta = config.get(CONF_FOR) template.attach(hass, time_de...
[ "async", "def", "async_attach_trigger", "(", "hass", ",", "config", ",", "action", ",", "automation_info", ",", "*", ",", "platform_type", "=", "\"template\"", ")", ":", "value_template", "=", "config", ".", "get", "(", "CONF_VALUE_TEMPLATE", ")", "value_templat...
[ 29, 0 ]
[ 116, 23 ]
python
en
['en', 'en', 'en']
True
zigpy_dev_basic
(zigpy_device_mock)
Zigpy device with just a basic cluster.
Zigpy device with just a basic cluster.
def zigpy_dev_basic(zigpy_device_mock): """Zigpy device with just a basic cluster.""" return zigpy_device_mock( { 1: { "in_clusters": [general.Basic.cluster_id], "out_clusters": [], "device_type": zha.DeviceType.ON_OFF_SWITCH, } ...
[ "def", "zigpy_dev_basic", "(", "zigpy_device_mock", ")", ":", "return", "zigpy_device_mock", "(", "{", "1", ":", "{", "\"in_clusters\"", ":", "[", "general", ".", "Basic", ".", "cluster_id", "]", ",", "\"out_clusters\"", ":", "[", "]", ",", "\"device_type\"", ...
[ 21, 0 ]
[ 31, 5 ]
python
en
['en', 'en', 'en']
True
zha_dev_basic
(hass, zha_device_restored, zigpy_dev_basic)
ZHA device with just a basic cluster.
ZHA device with just a basic cluster.
async def zha_dev_basic(hass, zha_device_restored, zigpy_dev_basic): """ZHA device with just a basic cluster.""" zha_device = await zha_device_restored(zigpy_dev_basic) return zha_device
[ "async", "def", "zha_dev_basic", "(", "hass", ",", "zha_device_restored", ",", "zigpy_dev_basic", ")", ":", "zha_device", "=", "await", "zha_device_restored", "(", "zigpy_dev_basic", ")", "return", "zha_device" ]
[ 35, 0 ]
[ 39, 21 ]
python
en
['en', 'en', 'en']
True
coordinator
(hass, zigpy_device_mock, zha_device_joined)
Test zha light platform.
Test zha light platform.
async def coordinator(hass, zigpy_device_mock, zha_device_joined): """Test zha light platform.""" zigpy_device = zigpy_device_mock( { 1: { "in_clusters": [], "out_clusters": [], "device_type": zha.DeviceType.COLOR_DIMMABLE_LIGHT, }...
[ "async", "def", "coordinator", "(", "hass", ",", "zigpy_device_mock", ",", "zha_device_joined", ")", ":", "zigpy_device", "=", "zigpy_device_mock", "(", "{", "1", ":", "{", "\"in_clusters\"", ":", "[", "]", ",", "\"out_clusters\"", ":", "[", "]", ",", "\"dev...
[ 43, 0 ]
[ 60, 21 ]
python
cs
['cs', 'lb', 'pl']
False
device_light_1
(hass, zigpy_device_mock, zha_device_joined)
Test zha light platform.
Test zha light platform.
async def device_light_1(hass, zigpy_device_mock, zha_device_joined): """Test zha light platform.""" zigpy_device = zigpy_device_mock( { 1: { "in_clusters": [ general.OnOff.cluster_id, general.LevelControl.cluster_id, ...
[ "async", "def", "device_light_1", "(", "hass", ",", "zigpy_device_mock", ",", "zha_device_joined", ")", ":", "zigpy_device", "=", "zigpy_device_mock", "(", "{", "1", ":", "{", "\"in_clusters\"", ":", "[", "general", ".", "OnOff", ".", "cluster_id", ",", "gener...
[ 64, 0 ]
[ 84, 21 ]
python
cs
['cs', 'lb', 'pl']
False
device_light_2
(hass, zigpy_device_mock, zha_device_joined)
Test zha light platform.
Test zha light platform.
async def device_light_2(hass, zigpy_device_mock, zha_device_joined): """Test zha light platform.""" zigpy_device = zigpy_device_mock( { 1: { "in_clusters": [ general.OnOff.cluster_id, general.LevelControl.cluster_id, ...
[ "async", "def", "device_light_2", "(", "hass", ",", "zigpy_device_mock", ",", "zha_device_joined", ")", ":", "zigpy_device", "=", "zigpy_device_mock", "(", "{", "1", ":", "{", "\"in_clusters\"", ":", "[", "general", ".", "OnOff", ".", "cluster_id", ",", "gener...
[ 88, 0 ]
[ 108, 21 ]
python
cs
['cs', 'lb', 'pl']
False
test_device_left
(hass, zigpy_dev_basic, zha_dev_basic)
Device leaving the network should become unavailable.
Device leaving the network should become unavailable.
async def test_device_left(hass, zigpy_dev_basic, zha_dev_basic): """Device leaving the network should become unavailable.""" assert zha_dev_basic.available is True get_zha_gateway(hass).device_left(zigpy_dev_basic) await hass.async_block_till_done() assert zha_dev_basic.available is False
[ "async", "def", "test_device_left", "(", "hass", ",", "zigpy_dev_basic", ",", "zha_dev_basic", ")", ":", "assert", "zha_dev_basic", ".", "available", "is", "True", "get_zha_gateway", "(", "hass", ")", ".", "device_left", "(", "zigpy_dev_basic", ")", "await", "ha...
[ 111, 0 ]
[ 118, 43 ]
python
en
['en', 'en', 'en']
True
test_gateway_group_methods
(hass, device_light_1, device_light_2, coordinator)
Test creating a group with 2 members.
Test creating a group with 2 members.
async def test_gateway_group_methods(hass, device_light_1, device_light_2, coordinator): """Test creating a group with 2 members.""" zha_gateway = get_zha_gateway(hass) assert zha_gateway is not None zha_gateway.coordinator_zha_device = coordinator coordinator._zha_gateway = zha_gateway device_l...
[ "async", "def", "test_gateway_group_methods", "(", "hass", ",", "device_light_1", ",", "device_light_2", ",", "coordinator", ")", ":", "zha_gateway", "=", "get_zha_gateway", "(", "hass", ")", "assert", "zha_gateway", "is", "not", "None", "zha_gateway", ".", "coord...
[ 121, 0 ]
[ 175, 62 ]
python
en
['en', 'en', 'en']
True
test_updating_device_store
(hass, zigpy_dev_basic, zha_dev_basic)
Test saving data after a delay.
Test saving data after a delay.
async def test_updating_device_store(hass, zigpy_dev_basic, zha_dev_basic): """Test saving data after a delay.""" zha_gateway = get_zha_gateway(hass) assert zha_gateway is not None await async_enable_traffic(hass, [zha_dev_basic]) assert zha_dev_basic.last_seen is not None entry = zha_gateway.z...
[ "async", "def", "test_updating_device_store", "(", "hass", ",", "zigpy_dev_basic", ",", "zha_dev_basic", ")", ":", "zha_gateway", "=", "get_zha_gateway", "(", "hass", ")", "assert", "zha_gateway", "is", "not", "None", "await", "async_enable_traffic", "(", "hass", ...
[ 178, 0 ]
[ 212, 39 ]
python
en
['en', 'en', 'en']
True
test_cleaning_up_storage
(hass, zigpy_dev_basic, zha_dev_basic, hass_storage)
Test cleaning up zha storage and remove stale devices.
Test cleaning up zha storage and remove stale devices.
async def test_cleaning_up_storage(hass, zigpy_dev_basic, zha_dev_basic, hass_storage): """Test cleaning up zha storage and remove stale devices.""" zha_gateway = get_zha_gateway(hass) assert zha_gateway is not None await async_enable_traffic(hass, [zha_dev_basic]) assert zha_dev_basic.last_seen is...
[ "async", "def", "test_cleaning_up_storage", "(", "hass", ",", "zigpy_dev_basic", ",", "zha_dev_basic", ",", "hass_storage", ")", ":", "zha_gateway", "=", "get_zha_gateway", "(", "hass", ")", "assert", "zha_gateway", "is", "not", "None", "await", "async_enable_traffi...
[ 215, 0 ]
[ 234, 61 ]
python
en
['en', 'en', 'en']
True
__liter_to_gallon
(liter: float)
Convert a volume measurement in Liter to Gallon.
Convert a volume measurement in Liter to Gallon.
def __liter_to_gallon(liter: float) -> float: """Convert a volume measurement in Liter to Gallon.""" return liter * 0.2642
[ "def", "__liter_to_gallon", "(", "liter", ":", "float", ")", "->", "float", ":", "return", "liter", "*", "0.2642" ]
[ 15, 0 ]
[ 17, 25 ]
python
en
['en', 'en', 'en']
True
__gallon_to_liter
(gallon: float)
Convert a volume measurement in Gallon to Liter.
Convert a volume measurement in Gallon to Liter.
def __gallon_to_liter(gallon: float) -> float: """Convert a volume measurement in Gallon to Liter.""" return gallon * 3.785
[ "def", "__gallon_to_liter", "(", "gallon", ":", "float", ")", "->", "float", ":", "return", "gallon", "*", "3.785" ]
[ 20, 0 ]
[ 22, 25 ]
python
en
['en', 'en', 'en']
True
convert
(volume: float, from_unit: str, to_unit: str)
Convert a temperature from one unit to another.
Convert a temperature from one unit to another.
def convert(volume: float, from_unit: str, to_unit: str) -> float: """Convert a temperature from one unit to another.""" if from_unit not in VALID_UNITS: raise ValueError(UNIT_NOT_RECOGNIZED_TEMPLATE.format(from_unit, VOLUME)) if to_unit not in VALID_UNITS: raise ValueError(UNIT_NOT_RECOGNIZ...
[ "def", "convert", "(", "volume", ":", "float", ",", "from_unit", ":", "str", ",", "to_unit", ":", "str", ")", "->", "float", ":", "if", "from_unit", "not", "in", "VALID_UNITS", ":", "raise", "ValueError", "(", "UNIT_NOT_RECOGNIZED_TEMPLATE", ".", "format", ...
[ 25, 0 ]
[ 44, 17 ]
python
en
['en', 'en', 'en']
True
test_extract_domain_configs
()
Test the extraction of domain configuration.
Test the extraction of domain configuration.
def test_extract_domain_configs(): """Test the extraction of domain configuration.""" config = { "zone": None, "zoner": None, "zone ": None, "zone Hallo": None, "zone 100": None, } assert {"zone", "zone Hallo", "zone 100"} == set( helpers.extract_domain_c...
[ "def", "test_extract_domain_configs", "(", ")", ":", "config", "=", "{", "\"zone\"", ":", "None", ",", "\"zoner\"", ":", "None", ",", "\"zone \"", ":", "None", ",", "\"zone Hallo\"", ":", "None", ",", "\"zone 100\"", ":", "None", ",", "}", "assert", "{", ...
[ 7, 0 ]
[ 19, 5 ]
python
en
['en', 'en', 'en']
True
test_config_per_platform
()
Test config per platform method.
Test config per platform method.
def test_config_per_platform(): """Test config per platform method.""" config = OrderedDict( [ ("zone", {"platform": "hello"}), ("zoner", None), ("zone Hallo", [1, {"platform": "hello 2"}]), ("zone 100", None), ] ) assert [ ("hello...
[ "def", "test_config_per_platform", "(", ")", ":", "config", "=", "OrderedDict", "(", "[", "(", "\"zone\"", ",", "{", "\"platform\"", ":", "\"hello\"", "}", ")", ",", "(", "\"zoner\"", ",", "None", ")", ",", "(", "\"zone Hallo\"", ",", "[", "1", ",", "{...
[ 22, 0 ]
[ 37, 58 ]
python
da
['no', 'da', 'it']
False
StarlineEntity.__init__
( self, account: StarlineAccount, device: StarlineDevice, key: str, name: str )
Initialize StarLine entity.
Initialize StarLine entity.
def __init__( self, account: StarlineAccount, device: StarlineDevice, key: str, name: str ): """Initialize StarLine entity.""" self._account = account self._device = device self._key = key self._name = name self._unsubscribe_api: Optional[Callable] = None
[ "def", "__init__", "(", "self", ",", "account", ":", "StarlineAccount", ",", "device", ":", "StarlineDevice", ",", "key", ":", "str", ",", "name", ":", "str", ")", ":", "self", ".", "_account", "=", "account", "self", ".", "_device", "=", "device", "se...
[ 11, 4 ]
[ 19, 56 ]
python
es
['es', 'pl', 'it']
False
StarlineEntity.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 22, 4 ]
[ 24, 20 ]
python
en
['en', 'en', 'en']
True
StarlineEntity.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._account.api.available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_account", ".", "api", ".", "available" ]
[ 27, 4 ]
[ 29, 42 ]
python
en
['en', 'en', 'en']
True
StarlineEntity.unique_id
(self)
Return the unique ID of the entity.
Return the unique ID of the entity.
def unique_id(self): """Return the unique ID of the entity.""" return f"starline-{self._key}-{self._device.device_id}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"starline-{self._key}-{self._device.device_id}\"" ]
[ 32, 4 ]
[ 34, 63 ]
python
en
['en', 'en', 'en']
True
StarlineEntity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return f"{self._device.name} {self._name}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._device.name} {self._name}\"" ]
[ 37, 4 ]
[ 39, 50 ]
python
en
['en', 'en', 'en']
True
StarlineEntity.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return self._account.device_info(self._device)
[ "def", "device_info", "(", "self", ")", ":", "return", "self", ".", "_account", ".", "device_info", "(", "self", ".", "_device", ")" ]
[ 42, 4 ]
[ 44, 54 ]
python
en
['en', 'en', 'en']
True
StarlineEntity.update
(self)
Read new state data.
Read new state data.
def update(self): """Read new state data.""" self.schedule_update_ha_state()
[ "def", "update", "(", "self", ")", ":", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 46, 4 ]
[ 48, 39 ]
python
en
['fr', 'en', 'en']
True
StarlineEntity.async_added_to_hass
(self)
Call when entity about to be added to Home Assistant.
Call when entity about to be added to Home Assistant.
async def async_added_to_hass(self): """Call when entity about to be added to Home Assistant.""" await super().async_added_to_hass() self._unsubscribe_api = self._account.api.add_update_listener(self.update)
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "_unsubscribe_api", "=", "self", ".", "_account", ".", "api", ".", "add_update_listener", "(", "self", ".", "update",...
[ 50, 4 ]
[ 53, 82 ]
python
en
['en', 'en', 'en']
True
StarlineEntity.async_will_remove_from_hass
(self)
Call when entity is being removed from Home Assistant.
Call when entity is being removed from Home Assistant.
async def async_will_remove_from_hass(self): """Call when entity is being removed from Home Assistant.""" await super().async_will_remove_from_hass() if self._unsubscribe_api is not None: self._unsubscribe_api() self._unsubscribe_api = None
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_will_remove_from_hass", "(", ")", "if", "self", ".", "_unsubscribe_api", "is", "not", "None", ":", "self", ".", "_unsubscribe_api", "(", ")", "self", ...
[ 55, 4 ]
[ 60, 40 ]
python
en
['en', 'en', 'en']
True
TRIGGER_SCHEMA
(value: Any)
Validate trigger.
Validate trigger.
def TRIGGER_SCHEMA(value: Any) -> dict: # pylint: disable=invalid-name """Validate trigger.""" if not isinstance(value, dict): raise vol.Invalid("Expected a dictionary") # We use this approach instead of vol.Any because # this gives better error messages. if CONF_ATTRIBUTE in value: ...
[ "def", "TRIGGER_SCHEMA", "(", "value", ":", "Any", ")", "->", "dict", ":", "# pylint: disable=invalid-name", "if", "not", "isinstance", "(", "value", ",", "dict", ")", ":", "raise", "vol", ".", "Invalid", "(", "\"Expected a dictionary\"", ")", "# We use this app...
[ 52, 0 ]
[ 62, 38 ]
python
en
['en', 'sv', 'en']
False
async_attach_trigger
( hass: HomeAssistant, config, action, automation_info, *, platform_type: str = "state", )
Listen for state changes based on configuration.
Listen for state changes based on configuration.
async def async_attach_trigger( hass: HomeAssistant, config, action, automation_info, *, platform_type: str = "state", ) -> CALLBACK_TYPE: """Listen for state changes based on configuration.""" entity_id = config.get(CONF_ENTITY_ID) from_state = config.get(CONF_FROM, MATCH_ALL) t...
[ "async", "def", "async_attach_trigger", "(", "hass", ":", "HomeAssistant", ",", "config", ",", "action", ",", "automation_info", ",", "*", ",", "platform_type", ":", "str", "=", "\"state\"", ",", ")", "->", "CALLBACK_TYPE", ":", "entity_id", "=", "config", "...
[ 65, 0 ]
[ 196, 23 ]
python
en
['en', 'en', 'en']
True
parse_annotation_mutable_layers
(code, lineno)
Parse the string of mutable layers in annotation. Return a list of AST Expr nodes code: annotation string (excluding '@')
Parse the string of mutable layers in annotation. Return a list of AST Expr nodes code: annotation string (excluding '
def parse_annotation_mutable_layers(code, lineno): """Parse the string of mutable layers in annotation. Return a list of AST Expr nodes code: annotation string (excluding '@') """ module = ast.parse(code) assert type(module) is ast.Module, 'internal error #1' assert len(module.body) == 1, 'A...
[ "def", "parse_annotation_mutable_layers", "(", "code", ",", "lineno", ")", ":", "module", "=", "ast", ".", "parse", "(", "code", ")", "assert", "type", "(", "module", ")", "is", "ast", ".", "Module", ",", "'internal error #1'", "assert", "len", "(", "modul...
[ 15, 0 ]
[ 87, 16 ]
python
en
['en', 'en', 'en']
True
parse_annotation
(code)
Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@')
Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '
def parse_annotation(code): """Parse an annotation string. Return an AST Expr node. code: annotation string (excluding '@') """ module = ast.parse(code) assert type(module) is ast.Module, 'internal error #1' assert len(module.body) == 1, 'Annotation contains more than one expression' ass...
[ "def", "parse_annotation", "(", "code", ")", ":", "module", "=", "ast", ".", "parse", "(", "code", ")", "assert", "type", "(", "module", ")", "is", "ast", ".", "Module", ",", "'internal error #1'", "assert", "len", "(", "module", ".", "body", ")", "=="...
[ 90, 0 ]
[ 99, 25 ]
python
en
['en', 'en', 'en']
True
parse_annotation_function
(code, func_name)
Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name
Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name
def parse_annotation_function(code, func_name): """Parse an annotation function. Return the value of `name` keyword argument and the AST Call node. func_name: expected function name """ expr = parse_annotation(code) call = expr.value assert type(call) is ast.Call, 'Annotation is not a functi...
[ "def", "parse_annotation_function", "(", "code", ",", "func_name", ")", ":", "expr", "=", "parse_annotation", "(", "code", ")", "call", "=", "expr", ".", "value", "assert", "type", "(", "call", ")", "is", "ast", ".", "Call", ",", "'Annotation is not a functi...
[ 102, 0 ]
[ 120, 21 ]
python
en
['en', 'en', 'en']
True
parse_nni_variable
(code)
Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string
Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string
def parse_nni_variable(code): """Parse `nni.variable` expression. Return the name argument and AST node of annotated expression. code: annotation string """ name, call = parse_annotation_function(code, 'variable') assert len(call.args) == 1, 'nni.variable contains more than one arguments' a...
[ "def", "parse_nni_variable", "(", "code", ")", ":", "name", ",", "call", "=", "parse_annotation_function", "(", "code", ",", "'variable'", ")", "assert", "len", "(", "call", ".", "args", ")", "==", "1", ",", "'nni.variable contains more than one arguments'", "ar...
[ 123, 0 ]
[ 143, 20 ]
python
en
['en', 'en', 'en']
True
parse_nni_function
(code)
Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string
Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string
def parse_nni_function(code): """Parse `nni.function_choice` expression. Return the AST node of annotated expression and a list of dumped function call expressions. code: annotation string """ name, call = parse_annotation_function(code, 'function_choice') funcs = [ast.dump(func, False) for func...
[ "def", "parse_nni_function", "(", "code", ")", ":", "name", ",", "call", "=", "parse_annotation_function", "(", "code", ",", "'function_choice'", ")", "funcs", "=", "[", "ast", ".", "dump", "(", "func", ",", "False", ")", "for", "func", "in", "call", "."...
[ 146, 0 ]
[ 158, 22 ]
python
en
['en', 'en', 'en']
True
convert_args_to_dict
(call, with_lambda=False)
Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary
Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary
def convert_args_to_dict(call, with_lambda=False): """Convert all args to a dict such that every key and value in the dict is the same as the value of the arg. Return the AST Call node with only one arg that is the dictionary """ keys, values = list(), list() for arg in call.args: if type(ar...
[ "def", "convert_args_to_dict", "(", "call", ",", "with_lambda", "=", "False", ")", ":", "keys", ",", "values", "=", "list", "(", ")", ",", "list", "(", ")", "for", "arg", "in", "call", ".", "args", ":", "if", "type", "(", "arg", ")", "in", "[", "...
[ 161, 0 ]
[ 179, 15 ]
python
en
['en', 'en', 'en']
True
make_lambda
(call)
Wrap an AST Call node to lambda expression node. call: ast.Call node
Wrap an AST Call node to lambda expression node. call: ast.Call node
def make_lambda(call): """Wrap an AST Call node to lambda expression node. call: ast.Call node """ empty_args = ast.arguments(args=[], vararg=None, kwarg=None, defaults=[]) return ast.Lambda(args=empty_args, body=call)
[ "def", "make_lambda", "(", "call", ")", ":", "empty_args", "=", "ast", ".", "arguments", "(", "args", "=", "[", "]", ",", "vararg", "=", "None", ",", "kwarg", "=", "None", ",", "defaults", "=", "[", "]", ")", "return", "ast", ".", "Lambda", "(", ...
[ 182, 0 ]
[ 187, 49 ]
python
en
['en', 'lb', 'en']
True
test_variable_equal
(node1, node2)
Test whether two variables are the same.
Test whether two variables are the same.
def test_variable_equal(node1, node2): """Test whether two variables are the same.""" if type(node1) is not type(node2): return False if isinstance(node1, ast.AST): for k, v in vars(node1).items(): if k in ('lineno', 'col_offset', 'ctx', 'end_lineno', 'end_col_offset'): ...
[ "def", "test_variable_equal", "(", "node1", ",", "node2", ")", ":", "if", "type", "(", "node1", ")", "is", "not", "type", "(", "node2", ")", ":", "return", "False", "if", "isinstance", "(", "node1", ",", "ast", ".", "AST", ")", ":", "for", "k", ","...
[ 190, 0 ]
[ 206, 25 ]
python
en
['en', 'en', 'en']
True
replace_variable_node
(node, annotation)
Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string
Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string
def replace_variable_node(node, annotation): """Replace a node annotated by `nni.variable`. node: the AST node to replace annotation: annotation string """ assert type(node) is ast.Assign, 'nni.variable is not annotating assignment expression' assert len(node.targets) == 1, 'Annotated assignment...
[ "def", "replace_variable_node", "(", "node", ",", "annotation", ")", ":", "assert", "type", "(", "node", ")", "is", "ast", ".", "Assign", ",", "'nni.variable is not annotating assignment expression'", "assert", "len", "(", "node", ".", "targets", ")", "==", "1",...
[ 209, 0 ]
[ 219, 15 ]
python
en
['en', 'en', 'en']
True
replace_function_node
(node, annotation)
Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string
Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string
def replace_function_node(node, annotation): """Replace a node annotated by `nni.function_choice`. node: the AST node to replace annotation: annotation string """ target, funcs = parse_nni_function(annotation) FuncReplacer(funcs, target).visit(node) return node
[ "def", "replace_function_node", "(", "node", ",", "annotation", ")", ":", "target", ",", "funcs", "=", "parse_nni_function", "(", "annotation", ")", "FuncReplacer", "(", "funcs", ",", "target", ")", ".", "visit", "(", "node", ")", "return", "node" ]
[ 222, 0 ]
[ 229, 15 ]
python
en
['en', 'en', 'en']
True
parse
(code, para, module)
Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str)
Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str)
def parse(code, para, module): """Annotate user code. Return annotated code (str) if annotation detected; return None if not. code: original user code (str) """ global para_cfg global prefix_name para_cfg = para prefix_name = module try: ast_tree = ast.parse(code) except ...
[ "def", "parse", "(", "code", ",", "para", ",", "module", ")", ":", "global", "para_cfg", "global", "prefix_name", "para_cfg", "=", "para", "prefix_name", "=", "module", "try", ":", "ast_tree", "=", "ast", ".", "parse", "(", "code", ")", "except", "Except...
[ 330, 0 ]
[ 353, 36 ]
python
en
['en', 'en', 'en']
True
FuncReplacer.__init__
(self, funcs, target)
Constructor. funcs: list of dumped function call expressions to replace target: use this AST node to replace matching expressions
Constructor. funcs: list of dumped function call expressions to replace target: use this AST node to replace matching expressions
def __init__(self, funcs, target): """Constructor. funcs: list of dumped function call expressions to replace target: use this AST node to replace matching expressions """ self.funcs = set(funcs) self.target = target
[ "def", "__init__", "(", "self", ",", "funcs", ",", "target", ")", ":", "self", ".", "funcs", "=", "set", "(", "funcs", ")", "self", ".", "target", "=", "target" ]
[ 235, 4 ]
[ 241, 28 ]
python
en
['en', 'en', 'en']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the ViaggiaTreno platform.
Set up the ViaggiaTreno platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the ViaggiaTreno platform.""" train_id = config.get(CONF_TRAIN_ID) station_id = config.get(CONF_STATION_ID) name = config.get(CONF_NAME) if not name: name = DEFAULT_NAME.format(train_id) asyn...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "train_id", "=", "config", ".", "get", "(", "CONF_TRAIN_ID", ")", "station_id", "=", "config", ".", "get", "(", "CONF...
[ 58, 0 ]
[ 65, 72 ]
python
en
['en', 'pt', 'en']
True
async_http_request
(hass, uri)
Perform actual request.
Perform actual request.
async def async_http_request(hass, uri): """Perform actual request.""" try: session = hass.helpers.aiohttp_client.async_get_clientsession(hass) with async_timeout.timeout(REQUEST_TIMEOUT): req = await session.get(uri) if req.status != HTTP_OK: return {"error": req...
[ "async", "def", "async_http_request", "(", "hass", ",", "uri", ")", ":", "try", ":", "session", "=", "hass", ".", "helpers", ".", "aiohttp_client", ".", "async_get_clientsession", "(", "hass", ")", "with", "async_timeout", ".", "timeout", "(", "REQUEST_TIMEOUT...
[ 68, 0 ]
[ 81, 78 ]
python
en
['en', 'la', 'en']
True
ViaggiaTrenoSensor.__init__
(self, train_id, station_id, name)
Initialize the sensor.
Initialize the sensor.
def __init__(self, train_id, station_id, name): """Initialize the sensor.""" self._state = None self._attributes = {} self._unit = "" self._icon = ICON self._station_id = station_id self._name = name self.uri = VIAGGIATRENO_ENDPOINT.format( st...
[ "def", "__init__", "(", "self", ",", "train_id", ",", "station_id", ",", "name", ")", ":", "self", ".", "_state", "=", "None", "self", ".", "_attributes", "=", "{", "}", "self", ".", "_unit", "=", "\"\"", "self", ".", "_icon", "=", "ICON", "self", ...
[ 87, 4 ]
[ 98, 9 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.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" ]
[ 101, 4 ]
[ 103, 25 ]
python
en
['en', 'mi', 'en']
True
ViaggiaTrenoSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 106, 4 ]
[ 108, 26 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 111, 4 ]
[ 113, 25 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 116, 4 ]
[ 118, 25 ]
python
en
['en', 'la', 'en']
True
ViaggiaTrenoSensor.device_state_attributes
(self)
Return extra attributes.
Return extra attributes.
def device_state_attributes(self): """Return extra attributes.""" self._attributes[ATTR_ATTRIBUTION] = ATTRIBUTION return self._attributes
[ "def", "device_state_attributes", "(", "self", ")", ":", "self", ".", "_attributes", "[", "ATTR_ATTRIBUTION", "]", "=", "ATTRIBUTION", "return", "self", ".", "_attributes" ]
[ 121, 4 ]
[ 124, 31 ]
python
en
['es', 'la', 'en']
False
ViaggiaTrenoSensor.has_departed
(data)
Check if the train has actually departed.
Check if the train has actually departed.
def has_departed(data): """Check if the train has actually departed.""" try: first_station = data["fermate"][0] if data["oraUltimoRilevamento"] or first_station["effettiva"]: return True except ValueError: _LOGGER.error("Cannot fetch first stat...
[ "def", "has_departed", "(", "data", ")", ":", "try", ":", "first_station", "=", "data", "[", "\"fermate\"", "]", "[", "0", "]", "if", "data", "[", "\"oraUltimoRilevamento\"", "]", "or", "first_station", "[", "\"effettiva\"", "]", ":", "return", "True", "ex...
[ 127, 4 ]
[ 135, 20 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.has_arrived
(data)
Check if the train has already arrived.
Check if the train has already arrived.
def has_arrived(data): """Check if the train has already arrived.""" last_station = data["fermate"][-1] if not last_station["effettiva"]: return False return True
[ "def", "has_arrived", "(", "data", ")", ":", "last_station", "=", "data", "[", "\"fermate\"", "]", "[", "-", "1", "]", "if", "not", "last_station", "[", "\"effettiva\"", "]", ":", "return", "False", "return", "True" ]
[ 138, 4 ]
[ 143, 19 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.is_cancelled
(data)
Check if the train is cancelled.
Check if the train is cancelled.
def is_cancelled(data): """Check if the train is cancelled.""" if data["tipoTreno"] == "ST" and data["provvedimento"] == 1: return True return False
[ "def", "is_cancelled", "(", "data", ")", ":", "if", "data", "[", "\"tipoTreno\"", "]", "==", "\"ST\"", "and", "data", "[", "\"provvedimento\"", "]", "==", "1", ":", "return", "True", "return", "False" ]
[ 146, 4 ]
[ 150, 20 ]
python
en
['en', 'en', 'en']
True
ViaggiaTrenoSensor.async_update
(self)
Update state.
Update state.
async def async_update(self): """Update state.""" uri = self.uri res = await async_http_request(self.hass, uri) if res.get("error", ""): if res["error"] == 204: self._state = NO_INFORMATION_STRING self._unit = "" else: ...
[ "async", "def", "async_update", "(", "self", ")", ":", "uri", "=", "self", ".", "uri", "res", "=", "await", "async_http_request", "(", "self", ".", "hass", ",", "uri", ")", "if", "res", ".", "get", "(", "\"error\"", ",", "\"\"", ")", ":", "if", "re...
[ 152, 4 ]
[ 180, 33 ]
python
en
['en', 'co', 'en']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Proliphix thermostats.
Set up the Proliphix thermostats.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Proliphix thermostats.""" username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) host = config.get(CONF_HOST) pdp = proliphix.PDP(host, username, password) pdp.update() add_entities([Proli...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "username", "=", "config", ".", "get", "(", "CONF_USERNAME", ")", "password", "=", "config", ".", "get", "(", "CONF_PASSWORD", ")", "hos...
[ 36, 0 ]
[ 45, 50 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.__init__
(self, pdp)
Initialize the thermostat.
Initialize the thermostat.
def __init__(self, pdp): """Initialize the thermostat.""" self._pdp = pdp self._name = None
[ "def", "__init__", "(", "self", ",", "pdp", ")", ":", "self", ".", "_pdp", "=", "pdp", "self", ".", "_name", "=", "None" ]
[ 51, 4 ]
[ 54, 25 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" return SUPPORT_TARGET_TEMPERATURE
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_TARGET_TEMPERATURE" ]
[ 57, 4 ]
[ 59, 41 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.should_poll
(self)
Set up polling needed for thermostat.
Set up polling needed for thermostat.
def should_poll(self): """Set up polling needed for thermostat.""" return True
[ "def", "should_poll", "(", "self", ")", ":", "return", "True" ]
[ 62, 4 ]
[ 64, 19 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.update
(self)
Update the data from the thermostat.
Update the data from the thermostat.
def update(self): """Update the data from the thermostat.""" self._pdp.update() self._name = self._pdp.name
[ "def", "update", "(", "self", ")", ":", "self", ".", "_pdp", ".", "update", "(", ")", "self", ".", "_name", "=", "self", ".", "_pdp", ".", "name" ]
[ 66, 4 ]
[ 69, 35 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.name
(self)
Return the name of the thermostat.
Return the name of the thermostat.
def name(self): """Return the name of the thermostat.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 72, 4 ]
[ 74, 25 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.precision
(self)
Return the precision of the system. Proliphix temperature values are passed back and forth in the API as tenths of degrees F (i.e. 690 for 69 degrees).
Return the precision of the system.
def precision(self): """Return the precision of the system. Proliphix temperature values are passed back and forth in the API as tenths of degrees F (i.e. 690 for 69 degrees). """ return PRECISION_TENTHS
[ "def", "precision", "(", "self", ")", ":", "return", "PRECISION_TENTHS" ]
[ 77, 4 ]
[ 83, 31 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.device_state_attributes
(self)
Return the device specific state attributes.
Return the device specific state attributes.
def device_state_attributes(self): """Return the device specific state attributes.""" return {ATTR_FAN: self._pdp.fan_state}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_FAN", ":", "self", ".", "_pdp", ".", "fan_state", "}" ]
[ 86, 4 ]
[ 88, 46 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_FAHRENHEIT
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_FAHRENHEIT" ]
[ 91, 4 ]
[ 93, 30 ]
python
en
['en', 'la', 'en']
True
ProliphixThermostat.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._pdp.cur_temp
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_pdp", ".", "cur_temp" ]
[ 96, 4 ]
[ 98, 33 ]
python
en
['en', 'la', 'en']
True
ProliphixThermostat.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" return self._pdp.setback
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_pdp", ".", "setback" ]
[ 101, 4 ]
[ 103, 32 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.hvac_action
(self)
Return the current state of the thermostat.
Return the current state of the thermostat.
def hvac_action(self): """Return the current state of the thermostat.""" state = self._pdp.hvac_state if state == 1: return CURRENT_HVAC_OFF if state in (3, 4, 5): return CURRENT_HVAC_HEAT if state in (6, 7): return CURRENT_HVAC_COOL re...
[ "def", "hvac_action", "(", "self", ")", ":", "state", "=", "self", ".", "_pdp", ".", "hvac_state", "if", "state", "==", "1", ":", "return", "CURRENT_HVAC_OFF", "if", "state", "in", "(", "3", ",", "4", ",", "5", ")", ":", "return", "CURRENT_HVAC_HEAT", ...
[ 106, 4 ]
[ 115, 32 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.hvac_mode
(self)
Return the current state of the thermostat.
Return the current state of the thermostat.
def hvac_mode(self): """Return the current state of the thermostat.""" if self._pdp.is_heating: return HVAC_MODE_HEAT if self._pdp.is_cooling: return HVAC_MODE_COOL return HVAC_MODE_OFF
[ "def", "hvac_mode", "(", "self", ")", ":", "if", "self", ".", "_pdp", ".", "is_heating", ":", "return", "HVAC_MODE_HEAT", "if", "self", ".", "_pdp", ".", "is_cooling", ":", "return", "HVAC_MODE_COOL", "return", "HVAC_MODE_OFF" ]
[ 118, 4 ]
[ 124, 28 ]
python
en
['en', 'en', 'en']
True
ProliphixThermostat.hvac_modes
(self)
Return available HVAC modes.
Return available HVAC modes.
def hvac_modes(self): """Return available HVAC modes.""" return []
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "[", "]" ]
[ 127, 4 ]
[ 129, 17 ]
python
en
['fr', 'hi-Latn', 'en']
False