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
SpeedTestDataCoordinator.async_set_options
(self)
Set options for entry.
Set options for entry.
async def async_set_options(self): """Set options for entry.""" if not self.config_entry.options: data = {**self.config_entry.data} options = { CONF_SCAN_INTERVAL: data.pop(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL), CONF_MANUAL: data.pop(CONF_MANU...
[ "async", "def", "async_set_options", "(", "self", ")", ":", "if", "not", "self", ".", "config_entry", ".", "options", ":", "data", "=", "{", "*", "*", "self", ".", "config_entry", ".", "data", "}", "options", "=", "{", "CONF_SCAN_INTERVAL", ":", "data", ...
[ 177, 4 ]
[ 188, 13 ]
python
en
['en', 'en', 'en']
True
SpeedTestDataCoordinator.async_setup
(self)
Set up SpeedTest.
Set up SpeedTest.
async def async_setup(self): """Set up SpeedTest.""" try: self.api = await self.hass.async_add_executor_job(speedtest.Speedtest) except speedtest.ConfigRetrievalError as err: raise ConfigEntryNotReady from err async def request_update(call): """Reques...
[ "async", "def", "async_setup", "(", "self", ")", ":", "try", ":", "self", ".", "api", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "speedtest", ".", "Speedtest", ")", "except", "speedtest", ".", "ConfigRetrievalError", "as", "err", ...
[ 190, 4 ]
[ 209, 9 ]
python
en
['en', 'de', 'en']
True
SpeedTestDataCoordinator.async_unload
(self)
Unload the coordinator.
Unload the coordinator.
def async_unload(self): """Unload the coordinator.""" if not self._unsub_update_listener: return self._unsub_update_listener() self._unsub_update_listener = None
[ "def", "async_unload", "(", "self", ")", ":", "if", "not", "self", ".", "_unsub_update_listener", ":", "return", "self", ".", "_unsub_update_listener", "(", ")", "self", ".", "_unsub_update_listener", "=", "None" ]
[ 212, 4 ]
[ 217, 42 ]
python
en
['en', 'nl', 'en']
True
GlobalOrderProportion.parse
(self, conf: dict, total_container: int, max_tick: int, start_tick: int = 0)
Parse specified configuration, and generate order proportion. Args: conf (dict): Configuration to parse. total_container (int): Total containers in this environment. max_tick (int): Max tick to generate. start_tick (int): Start tick to generate. Returns:...
Parse specified configuration, and generate order proportion.
def parse(self, conf: dict, total_container: int, max_tick: int, start_tick: int = 0) -> np.ndarray: """Parse specified configuration, and generate order proportion. Args: conf (dict): Configuration to parse. total_container (int): Total containers in this environment. ...
[ "def", "parse", "(", "self", ",", "conf", ":", "dict", ",", "total_container", ":", "int", ",", "max_tick", ":", "int", ",", "start_tick", ":", "int", "=", "0", ")", "->", "np", ".", "ndarray", ":", "durations", ":", "int", "=", "max_tick", "-", "s...
[ 15, 4 ]
[ 67, 31 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Lutron Caseta binary_sensor platform. Adds occupancy groups from the Caseta bridge associated with the config_entry as binary_sensor entities.
Set up the Lutron Caseta binary_sensor platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Lutron Caseta binary_sensor platform. Adds occupancy groups from the Caseta bridge associated with the config_entry as binary_sensor entities. """ entities = [] bridge = hass.data[CASETA_DOMAIN][config_entry.ent...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "]", "bridge", "=", "hass", ".", "data", "[", "CASETA_DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "occupancy_groups",...
[ 11, 0 ]
[ 26, 38 ]
python
en
['en', 'pt', 'en']
True
LutronOccupancySensor.device_class
(self)
Flag supported features.
Flag supported features.
def device_class(self): """Flag supported features.""" return DEVICE_CLASS_OCCUPANCY
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_OCCUPANCY" ]
[ 33, 4 ]
[ 35, 37 ]
python
en
['da', 'en', 'en']
True
LutronOccupancySensor.is_on
(self)
Return the brightness of the light.
Return the brightness of the light.
def is_on(self): """Return the brightness of the light.""" return self._device["status"] == OCCUPANCY_GROUP_OCCUPIED
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_device", "[", "\"status\"", "]", "==", "OCCUPANCY_GROUP_OCCUPIED" ]
[ 38, 4 ]
[ 40, 65 ]
python
en
['en', 'no', 'en']
True
LutronOccupancySensor.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self): """Register callbacks.""" self._smartbridge.add_occupancy_subscriber( self.device_id, self.async_write_ha_state )
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_smartbridge", ".", "add_occupancy_subscriber", "(", "self", ".", "device_id", ",", "self", ".", "async_write_ha_state", ")" ]
[ 42, 4 ]
[ 46, 9 ]
python
en
['en', 'no', 'en']
False
LutronOccupancySensor.device_id
(self)
Return the device ID used for calling pylutron_caseta.
Return the device ID used for calling pylutron_caseta.
def device_id(self): """Return the device ID used for calling pylutron_caseta.""" return self._device["occupancy_group_id"]
[ "def", "device_id", "(", "self", ")", ":", "return", "self", ".", "_device", "[", "\"occupancy_group_id\"", "]" ]
[ 49, 4 ]
[ 51, 49 ]
python
en
['en', 'sm', 'en']
True
LutronOccupancySensor.unique_id
(self)
Return a unique identifier.
Return a unique identifier.
def unique_id(self): """Return a unique identifier.""" return f"occupancygroup_{self.device_id}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"occupancygroup_{self.device_id}\"" ]
[ 54, 4 ]
[ 56, 49 ]
python
fr
['fr', 'fr', 'en']
True
LutronOccupancySensor.device_info
(self)
Return the device info. Sensor entities are aggregated from one or more physical sensors by each room. Therefore, there shouldn't be devices related to any sensor entities.
Return the device info.
def device_info(self): """Return the device info. Sensor entities are aggregated from one or more physical sensors by each room. Therefore, there shouldn't be devices related to any sensor entities. """ return None
[ "def", "device_info", "(", "self", ")", ":", "return", "None" ]
[ 59, 4 ]
[ 66, 19 ]
python
en
['en', 'en', 'en']
True
LutronOccupancySensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return {"device_id": self.device_id}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"device_id\"", ":", "self", ".", "device_id", "}" ]
[ 69, 4 ]
[ 71, 44 ]
python
en
['en', 'en', 'en']
True
VirtualMachine.get_income_till_now
(self, cur_tick: int)
Get the VM's income which contains income from [creation_tick, current_tick).
Get the VM's income which contains income from [creation_tick, current_tick).
def get_income_till_now(self, cur_tick: int): """Get the VM's income which contains income from [creation_tick, current_tick). """ return self.unit_price * (cur_tick - self.creation_tick)
[ "def", "get_income_till_now", "(", "self", ",", "cur_tick", ":", "int", ")", ":", "return", "self", ".", "unit_price", "*", "(", "cur_tick", "-", "self", ".", "creation_tick", ")" ]
[ 57, 4 ]
[ 59, 64 ]
python
en
['en', 'en', 'en']
True
VirtualMachine.add_utilization
(self, cpu_utilization: float)
VM CPU utilization list. In the cpu_readings_file, all CPU utilization of all VMs are sorted by the timestamp, indexed by the VM ID. At each tick, we only read the CPU utilization at specific timestamp (tick). Hence, this function is designed to append the CPU utilization to the end of the corr...
VM CPU utilization list.
def add_utilization(self, cpu_utilization: float): """VM CPU utilization list. In the cpu_readings_file, all CPU utilization of all VMs are sorted by the timestamp, indexed by the VM ID. At each tick, we only read the CPU utilization at specific timestamp (tick). Hence, this function is...
[ "def", "add_utilization", "(", "self", ",", "cpu_utilization", ":", "float", ")", ":", "# If cpu_utilization is smaller than 0, it means the missing data in the cpu readings file.", "# TODO: We use the last utilization, it could be further refined to use average or others.", "if", "cpu_uti...
[ 75, 4 ]
[ 88, 60 ]
python
de
['es', 'de', 'en']
False
VirtualMachine.get_historical_utilization_series
(self, cur_tick: int)
Only expose the CPU utilization series before the current tick.
Only expose the CPU utilization series before the current tick.
def get_historical_utilization_series(self, cur_tick: int) -> List[float]: """"Only expose the CPU utilization series before the current tick.""" return self._utilization_series[:cur_tick - self.creation_tick + 1]
[ "def", "get_historical_utilization_series", "(", "self", ",", "cur_tick", ":", "int", ")", "->", "List", "[", "float", "]", ":", "return", "self", ".", "_utilization_series", "[", ":", "cur_tick", "-", "self", ".", "creation_tick", "+", "1", "]" ]
[ 90, 4 ]
[ 92, 75 ]
python
en
['en', 'en', 'en']
True
async_attach_trigger
( hass: HomeAssistant, config: ConfigType, action: AutomationActionType, automation_info: dict, )
Listen for state changes based on configuration.
Listen for state changes based on configuration.
async def async_attach_trigger( hass: HomeAssistant, config: ConfigType, action: AutomationActionType, automation_info: dict, ) -> CALLBACK_TYPE: """Listen for state changes based on configuration.""" return await toggle_entity.async_attach_trigger( hass, config, action, automation_info ...
[ "async", "def", "async_attach_trigger", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ",", "action", ":", "AutomationActionType", ",", "automation_info", ":", "dict", ",", ")", "->", "CALLBACK_TYPE", ":", "return", "await", "toggle_entity", ...
[ 18, 0 ]
[ 27, 5 ]
python
en
['en', 'en', 'en']
True
async_get_triggers
(hass: HomeAssistant, device_id: str)
List device triggers.
List device triggers.
async def async_get_triggers(hass: HomeAssistant, device_id: str) -> List[dict]: """List device triggers.""" return await toggle_entity.async_get_triggers(hass, device_id, DOMAIN)
[ "async", "def", "async_get_triggers", "(", "hass", ":", "HomeAssistant", ",", "device_id", ":", "str", ")", "->", "List", "[", "dict", "]", ":", "return", "await", "toggle_entity", ".", "async_get_triggers", "(", "hass", ",", "device_id", ",", "DOMAIN", ")" ...
[ 30, 0 ]
[ 32, 74 ]
python
en
['fr', 'en', 'en']
True
async_get_trigger_capabilities
(hass: HomeAssistant, config: dict)
List trigger capabilities.
List trigger capabilities.
async def async_get_trigger_capabilities(hass: HomeAssistant, config: dict) -> dict: """List trigger capabilities.""" return await toggle_entity.async_get_trigger_capabilities(hass, config)
[ "async", "def", "async_get_trigger_capabilities", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", "->", "dict", ":", "return", "await", "toggle_entity", ".", "async_get_trigger_capabilities", "(", "hass", ",", "config", ")" ]
[ 35, 0 ]
[ 37, 75 ]
python
en
['en', 'la', 'en']
True
test_record_stream
(hass, hass_client)
Test record stream. Purposefully not mocking anything here to test full integration with the stream component.
Test record stream.
async def test_record_stream(hass, hass_client): """ Test record stream. Purposefully not mocking anything here to test full integration with the stream component. """ await async_setup_component(hass, "stream", {"stream": {}}) with patch("homeassistant.components.stream.recorder.recorder_...
[ "async", "def", "test_record_stream", "(", "hass", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "with", "patch", "(", "\"homeassistant.components.stream.recorder.re...
[ 18, 0 ]
[ 42, 27 ]
python
en
['en', 'error', 'th']
False
test_recorder_timeout
(hass, hass_client)
Test recorder timeout.
Test recorder timeout.
async def test_recorder_timeout(hass, hass_client): """Test recorder timeout.""" await async_setup_component(hass, "stream", {"stream": {}}) with patch( "homeassistant.components.stream.recorder.RecorderOutput.cleanup" ) as mock_cleanup: # Setup demo track source = generate_h264...
[ "async", "def", "test_recorder_timeout", "(", "hass", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "with", "patch", "(", "\"homeassistant.components.stream.recorder...
[ 46, 0 ]
[ 66, 34 ]
python
en
['da', 'en', 'en']
True
test_recorder_save
()
Test recorder save.
Test recorder save.
async def test_recorder_save(): """Test recorder save.""" # Setup source = generate_h264_video() output = BytesIO() output.name = "test.mp4" # Run recorder_save_worker(output, [Segment(1, source, 4)], "mp4") # Assert assert output.getvalue()
[ "async", "def", "test_recorder_save", "(", ")", ":", "# Setup", "source", "=", "generate_h264_video", "(", ")", "output", "=", "BytesIO", "(", ")", "output", ".", "name", "=", "\"test.mp4\"", "# Run", "recorder_save_worker", "(", "output", ",", "[", "Segment",...
[ 70, 0 ]
[ 81, 28 ]
python
en
['en', 'en', 'en']
True
test_record_stream_audio
(hass, hass_client)
Test treatment of different audio inputs. Record stream output should have an audio channel when input has a valid codec and audio packets and no audio channel otherwise.
Test treatment of different audio inputs.
async def test_record_stream_audio(hass, hass_client): """ Test treatment of different audio inputs. Record stream output should have an audio channel when input has a valid codec and audio packets and no audio channel otherwise. """ await async_setup_component(hass, "stream", {"stream": {}}) ...
[ "async", "def", "test_record_stream_audio", "(", "hass", ",", "hass_client", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "for", "a_codec", ",", "expected_audio_streams", "in", "("...
[ 85, 0 ]
[ 119, 25 ]
python
en
['en', 'error', 'th']
False
utcnow
(request)
Freeze time at a known point.
Freeze time at a known point.
def utcnow(request): """Freeze time at a known point.""" now = dt_util.utcnow() start_dt = datetime.datetime(now.year + 1, 1, 1, 0, 0, 0, tzinfo=now.tzinfo) with mock.patch("homeassistant.util.dt.utcnow") as dt_utcnow: dt_utcnow.return_value = start_dt yield dt_utcnow
[ "def", "utcnow", "(", "request", ")", ":", "now", "=", "dt_util", ".", "utcnow", "(", ")", "start_dt", "=", "datetime", ".", "datetime", "(", "now", ".", "year", "+", "1", ",", "1", ",", "1", ",", "0", ",", "0", ",", "0", ",", "tzinfo", "=", ...
[ 14, 0 ]
[ 20, 23 ]
python
en
['en', 'en', 'en']
True
controller
(hass)
Replace aiohomekit.Controller with an instance of aiohomekit.testing.FakeController.
Replace aiohomekit.Controller with an instance of aiohomekit.testing.FakeController.
def controller(hass): """Replace aiohomekit.Controller with an instance of aiohomekit.testing.FakeController.""" instance = FakeController() with tests.async_mock.patch("aiohomekit.Controller", return_value=instance): yield instance
[ "def", "controller", "(", "hass", ")", ":", "instance", "=", "FakeController", "(", ")", "with", "tests", ".", "async_mock", ".", "patch", "(", "\"aiohomekit.Controller\"", ",", "return_value", "=", "instance", ")", ":", "yield", "instance" ]
[ 24, 0 ]
[ 28, 22 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities )
Set up the Firmata sensors.
Set up the Firmata sensors.
async def async_setup_entry( hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up the Firmata sensors.""" new_entities = [] board = hass.data[DOMAIN][config_entry.entry_id] for sensor in board.sensors: pin = sensor[CONF_PIN] pin_mode = sensor[CONF_...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "new_entities", "=", "[", "]", "board", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "...
[ 16, 0 ]
[ 41, 40 ]
python
en
['en', 'bg', 'en']
True
FirmataSensor.async_added_to_hass
(self)
Set up a sensor.
Set up a sensor.
async def async_added_to_hass(self) -> None: """Set up a sensor.""" await self._api.start_pin(self.async_write_ha_state)
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_api", ".", "start_pin", "(", "self", ".", "async_write_ha_state", ")" ]
[ 47, 4 ]
[ 49, 60 ]
python
en
['en', 'ca', 'en']
True
FirmataSensor.async_will_remove_from_hass
(self)
Stop reporting a sensor.
Stop reporting a sensor.
async def async_will_remove_from_hass(self) -> None: """Stop reporting a sensor.""" await self._api.stop_pin()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "await", "self", ".", "_api", ".", "stop_pin", "(", ")" ]
[ 51, 4 ]
[ 53, 34 ]
python
en
['en', 'id', 'en']
True
FirmataSensor.state
(self)
Return sensor state.
Return sensor state.
def state(self) -> int: """Return sensor state.""" return self._api.state
[ "def", "state", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_api", ".", "state" ]
[ 56, 4 ]
[ 58, 30 ]
python
en
['en', 'bs', 'en']
True
Seq2SeqTrainer.create_optimizer_and_scheduler
(self, num_training_steps: int)
Setup the optimizer and the learning rate scheduler. We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the Trainer's init through :obj:`optimizers`, or subclass and override this method in a subclass.
Setup the optimizer and the learning rate scheduler.
def create_optimizer_and_scheduler(self, num_training_steps: int): """ Setup the optimizer and the learning rate scheduler. We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the Trainer's init through :obj:`optimizers`, or subcla...
[ "def", "create_optimizer_and_scheduler", "(", "self", ",", "num_training_steps", ":", "int", ")", ":", "if", "self", ".", "optimizer", "is", "None", ":", "no_decay", "=", "[", "\"bias\"", ",", "\"LayerNorm.weight\"", "]", "optimizer_grouped_parameters", "=", "[", ...
[ 87, 4 ]
[ 129, 100 ]
python
en
['en', 'error', 'th']
False
Seq2SeqTrainer.prediction_step
( self, model: nn.Module, inputs: Dict[str, Union[torch.Tensor, Any]], prediction_loss_only: bool, ignore_keys: Optional[List[str]] = None, )
Perform an evaluation step on :obj:`model` using obj:`inputs`. Subclass and override to inject custom behavior. Args: model (:obj:`nn.Module`): The model to evaluate. inputs (:obj:`Dict[str, Union[torch.Tensor, Any]]`): The inputs and ta...
Perform an evaluation step on :obj:`model` using obj:`inputs`.
def prediction_step( self, model: nn.Module, inputs: Dict[str, Union[torch.Tensor, Any]], prediction_loss_only: bool, ignore_keys: Optional[List[str]] = None, ) -> Tuple[Optional[float], Optional[torch.Tensor], Optional[torch.Tensor]]: """ Perform an evaluatio...
[ "def", "prediction_step", "(", "self", ",", "model", ":", "nn", ".", "Module", ",", "inputs", ":", "Dict", "[", "str", ",", "Union", "[", "torch", ".", "Tensor", ",", "Any", "]", "]", ",", "prediction_loss_only", ":", "bool", ",", "ignore_keys", ":", ...
[ 182, 4 ]
[ 242, 37 ]
python
en
['en', 'error', 'th']
False
M2M100Tokenizer._convert_id_to_token
(self, index: int)
Converts an index (integer) in a token (str) using the decoder.
Converts an index (integer) in a token (str) using the decoder.
def _convert_id_to_token(self, index: int) -> str: """Converts an index (integer) in a token (str) using the decoder.""" if index in self.id_to_lang_token: return self.id_to_lang_token[index] return self.decoder.get(index, self.unk_token)
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ":", "int", ")", "->", "str", ":", "if", "index", "in", "self", ".", "id_to_lang_token", ":", "return", "self", ".", "id_to_lang_token", "[", "index", "]", "return", "self", ".", "decoder", ".", "...
[ 178, 4 ]
[ 182, 54 ]
python
en
['en', 'en', 'en']
True
M2M100Tokenizer.convert_tokens_to_string
(self, tokens: List[str])
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: List[str]) -> str: """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", ":", "List", "[", "str", "]", ")", "->", "str", ":", "out_string", "=", "\"\"", ".", "join", "(", "tokens", ")", ".", "replace", "(", "SPIECE_UNDERLINE", ",", "\" \"", ")", ".", "strip", "(...
[ 184, 4 ]
[ 187, 25 ]
python
en
['en', 'en', 'en']
True
M2M100Tokenizer.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", ")", "->", ...
[ 189, 4 ]
[ 219, 94 ]
python
en
['en', 'error', 'th']
False
M2M100Tokenizer.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 MBART sequence has the following format, where ``X`` represents the sequence: - ``input_ids`` (for encoder) ``X [eos, src_lang_code]`` - ``decoder_i...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An MBART sequence has the following format, where ``X`` represents the sequence:
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 MBART sequence has...
[ "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", ...
[ 221, 4 ]
[ 246, 82 ]
python
en
['en', 'error', 'th']
False
M2M100Tokenizer.as_target_tokenizer
(self)
Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to sequence-to-sequence models that need a slightly different processing for the labels.
Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to sequence-to-sequence models that need a slightly different processing for the labels.
def as_target_tokenizer(self): """ Temporarily sets the tokenizer for encoding the targets. Useful for tokenizer associated to sequence-to-sequence models that need a slightly different processing for the labels. """ self.set_tgt_lang_special_tokens(self.tgt_lang) yield ...
[ "def", "as_target_tokenizer", "(", "self", ")", ":", "self", ".", "set_tgt_lang_special_tokens", "(", "self", ".", "tgt_lang", ")", "yield", "self", ".", "set_src_lang_special_tokens", "(", "self", ".", "src_lang", ")" ]
[ 293, 4 ]
[ 300, 55 ]
python
en
['en', 'error', 'th']
False
M2M100Tokenizer.set_src_lang_special_tokens
(self, src_lang: str)
Reset the special tokens to the source lang setting. No prefix and suffix=[eos, src_lang_code].
Reset the special tokens to the source lang setting. No prefix and suffix=[eos, src_lang_code].
def set_src_lang_special_tokens(self, src_lang: str) -> None: """Reset the special tokens to the source lang setting. No prefix and suffix=[eos, src_lang_code].""" lang_token = self.get_lang_token(src_lang) self.cur_lang_id = self.lang_token_to_id[lang_token] self.prefix_tokens = [self.c...
[ "def", "set_src_lang_special_tokens", "(", "self", ",", "src_lang", ":", "str", ")", "->", "None", ":", "lang_token", "=", "self", ".", "get_lang_token", "(", "src_lang", ")", "self", ".", "cur_lang_id", "=", "self", ".", "lang_token_to_id", "[", "lang_token",...
[ 302, 4 ]
[ 307, 48 ]
python
en
['en', 'en', 'en']
True
M2M100Tokenizer.set_tgt_lang_special_tokens
(self, tgt_lang: str)
Reset the special tokens to the target language setting. No prefix and suffix=[eos, tgt_lang_code].
Reset the special tokens to the target language setting. No prefix and suffix=[eos, tgt_lang_code].
def set_tgt_lang_special_tokens(self, tgt_lang: str) -> None: """Reset the special tokens to the target language setting. No prefix and suffix=[eos, tgt_lang_code].""" lang_token = self.get_lang_token(tgt_lang) self.cur_lang_id = self.lang_token_to_id[lang_token] self.prefix_tokens = [se...
[ "def", "set_tgt_lang_special_tokens", "(", "self", ",", "tgt_lang", ":", "str", ")", "->", "None", ":", "lang_token", "=", "self", ".", "get_lang_token", "(", "tgt_lang", ")", "self", ".", "cur_lang_id", "=", "self", ".", "lang_token_to_id", "[", "lang_token",...
[ 309, 4 ]
[ 314, 48 ]
python
en
['en', 'en', 'en']
True
convert_prophetnet_checkpoint_to_pytorch
(prophetnet_checkpoint_path: str, pytorch_dump_folder_path: str)
Copy/paste/tweak prohpetnet's weights to our prophetnet structure.
Copy/paste/tweak prohpetnet's weights to our prophetnet structure.
def convert_prophetnet_checkpoint_to_pytorch(prophetnet_checkpoint_path: str, pytorch_dump_folder_path: str): """ Copy/paste/tweak prohpetnet's weights to our prophetnet structure. """ if "xprophetnet" in prophetnet_checkpoint_path: prophet_old = XLMProphetNetForConditionalGenerationOld.from_pre...
[ "def", "convert_prophetnet_checkpoint_to_pytorch", "(", "prophetnet_checkpoint_path", ":", "str", ",", "pytorch_dump_folder_path", ":", "str", ")", ":", "if", "\"xprophetnet\"", "in", "prophetnet_checkpoint_path", ":", "prophet_old", "=", "XLMProphetNetForConditionalGenerationO...
[ 37, 0 ]
[ 146, 53 ]
python
en
['en', 'error', 'th']
False
decode_block_str
(block_str)
Decode block definition string Gets a list of block arg (dicts) through a string notation of arguments. E.g. ir_r2_k3_s2_e1_i32_o16_se0.25_noskip All args can exist in any order with the exception of the leading string which is assumed to indicate the block type. leading string - block type ( ...
Decode block definition string Gets a list of block arg (dicts) through a string notation of arguments. E.g. ir_r2_k3_s2_e1_i32_o16_se0.25_noskip All args can exist in any order with the exception of the leading string which is assumed to indicate the block type. leading string - block type ( ...
def decode_block_str(block_str): """ Decode block definition string Gets a list of block arg (dicts) through a string notation of arguments. E.g. ir_r2_k3_s2_e1_i32_o16_se0.25_noskip All args can exist in any order with the exception of the leading string which is assumed to indicate the block type....
[ "def", "decode_block_str", "(", "block_str", ")", ":", "assert", "isinstance", "(", "block_str", ",", "str", ")", "ops", "=", "block_str", ".", "split", "(", "'_'", ")", "block_type", "=", "ops", "[", "0", "]", "# take the block type off the front", "ops", "...
[ 57, 0 ]
[ 158, 33 ]
python
de
['nl', 'de', 'en']
False
scale_stage_depth
( stack_args, repeats, depth_multiplier=1.0, depth_trunc='ceil')
Per-stage depth scaling Scales the block repeats in each stage. This depth scaling impl maintains compatibility with the EfficientNet scaling method, while allowing sensible scaling for other models that may have multiple block arg definitions in each stage.
Per-stage depth scaling Scales the block repeats in each stage. This depth scaling impl maintains compatibility with the EfficientNet scaling method, while allowing sensible scaling for other models that may have multiple block arg definitions in each stage.
def scale_stage_depth( stack_args, repeats, depth_multiplier=1.0, depth_trunc='ceil'): """ Per-stage depth scaling Scales the block repeats in each stage. This depth scaling impl maintains compatibility with the EfficientNet scaling method, while allowing sensible scaling...
[ "def", "scale_stage_depth", "(", "stack_args", ",", "repeats", ",", "depth_multiplier", "=", "1.0", ",", "depth_trunc", "=", "'ceil'", ")", ":", "# We scale the total repeat count for each stage, there may be multiple", "# block arg defs per stage so we need to sum.", "num_repeat...
[ 161, 0 ]
[ 203, 20 ]
python
en
['fr', 'en', 'en']
True
init_weight_goog
(m, n='', fix_group_fanout=True, last_bn=None)
Weight initialization as per Tensorflow official implementations. Args: m (nn.Module): module to init n (str): module name fix_group_fanout (bool): enable correct (matching Tensorflow TPU impl) fanout calculation w/ group convs Handles layers in EfficientNet, EfficientNet-CondConv, MixN...
Weight initialization as per Tensorflow official implementations. Args: m (nn.Module): module to init n (str): module name fix_group_fanout (bool): enable correct (matching Tensorflow TPU impl) fanout calculation w/ group convs Handles layers in EfficientNet, EfficientNet-CondConv, MixN...
def init_weight_goog(m, n='', fix_group_fanout=True, last_bn=None): """ Weight initialization as per Tensorflow official implementations. Args: m (nn.Module): module to init n (str): module name fix_group_fanout (bool): enable correct (matching Tensorflow TPU impl) fanout calculation w/ ...
[ "def", "init_weight_goog", "(", "m", ",", "n", "=", "''", ",", "fix_group_fanout", "=", "True", ",", "last_bn", "=", "None", ")", ":", "if", "isinstance", "(", "m", ",", "CondConv2d", ")", ":", "fan_out", "=", "m", ".", "kernel_size", "[", "0", "]", ...
[ 206, 0 ]
[ 248, 27 ]
python
en
['en', 'en', 'en']
True
SyncThruConfigFlow.async_step_user
(self, user_input=None)
Handle user initiated flow.
Handle user initiated flow.
async def async_step_user(self, user_input=None): """Handle user initiated flow.""" if user_input is None: return await self._async_show_form(step_id="user") return await self._async_check_and_create("user", user_input)
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "return", "await", "self", ".", "_async_show_form", "(", "step_id", "=", "\"user\"", ")", "return", "await", "self", ".", "_asy...
[ 27, 4 ]
[ 31, 69 ]
python
en
['en', 'nl', 'en']
True
SyncThruConfigFlow.async_step_import
(self, user_input=None)
Handle import initiated flow.
Handle import initiated flow.
async def async_step_import(self, user_input=None): """Handle import initiated flow.""" return await self.async_step_user(user_input=user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", "=", "None", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", "=", "user_input", ")" ]
[ 33, 4 ]
[ 35, 64 ]
python
en
['en', 'en', 'en']
True
SyncThruConfigFlow.async_step_ssdp
(self, discovery_info)
Handle SSDP initiated flow.
Handle SSDP initiated flow.
async def async_step_ssdp(self, discovery_info): """Handle SSDP initiated flow.""" await self.async_set_unique_id(discovery_info[ssdp.ATTR_UPNP_UDN]) self._abort_if_unique_id_configured() self.url = url_normalize( discovery_info.get( ssdp.ATTR_UPNP_PRESENTATI...
[ "async", "def", "async_step_ssdp", "(", "self", ",", "discovery_info", ")", ":", "await", "self", ".", "async_set_unique_id", "(", "discovery_info", "[", "ssdp", ".", "ATTR_UPNP_UDN", "]", ")", "self", ".", "_abort_if_unique_id_configured", "(", ")", "self", "."...
[ 37, 4 ]
[ 68, 46 ]
python
en
['en', 'af', 'en']
True
SyncThruConfigFlow.async_step_confirm
(self, user_input=None)
Handle discovery confirmation by user.
Handle discovery confirmation by user.
async def async_step_confirm(self, user_input=None): """Handle discovery confirmation by user.""" if user_input is not None: return await self._async_check_and_create("confirm", user_input) return await self._async_show_form( step_id="confirm", user_input={CO...
[ "async", "def", "async_step_confirm", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "await", "self", ".", "_async_check_and_create", "(", "\"confirm\"", ",", "user_input", ")", "return", "await",...
[ 70, 4 ]
[ 78, 9 ]
python
en
['en', 'en', 'en']
True
SyncThruConfigFlow._async_show_form
(self, step_id, user_input=None, errors=None)
Show our form.
Show our form.
async def _async_show_form(self, step_id, user_input=None, errors=None): """Show our form.""" if user_input is None: user_input = {} return self.async_show_form( step_id=step_id, data_schema=vol.Schema( { vol.Required(CONF_U...
[ "async", "def", "_async_show_form", "(", "self", ",", "step_id", ",", "user_input", "=", "None", ",", "errors", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "user_input", "=", "{", "}", "return", "self", ".", "async_show_form", "(", "ste...
[ 80, 4 ]
[ 93, 9 ]
python
en
['en', 'en', 'en']
True
SyncThruConfigFlow._async_check_and_create
(self, step_id, user_input)
Validate input, proceed to create.
Validate input, proceed to create.
async def _async_check_and_create(self, step_id, user_input): """Validate input, proceed to create.""" user_input[CONF_URL] = url_normalize( user_input[CONF_URL], default_scheme="http" ) if "://" not in user_input[CONF_URL]: return await self._async_show_form( ...
[ "async", "def", "_async_check_and_create", "(", "self", ",", "step_id", ",", "user_input", ")", ":", "user_input", "[", "CONF_URL", "]", "=", "url_normalize", "(", "user_input", "[", "CONF_URL", "]", ",", "default_scheme", "=", "\"http\"", ")", "if", "\"://\""...
[ 95, 4 ]
[ 138, 9 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Create the ViCare water_heater devices.
Create the ViCare water_heater devices.
def setup_platform(hass, config, add_entities, discovery_info=None): """Create the ViCare water_heater devices.""" if discovery_info is None: return vicare_api = hass.data[VICARE_DOMAIN][VICARE_API] heating_type = hass.data[VICARE_DOMAIN][VICARE_HEATING_TYPE] add_entities( [ ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "vicare_api", "=", "hass", ".", "data", "[", "VICARE_DOMAIN", "]", "[", "VICARE_API",...
[ 49, 0 ]
[ 63, 5 ]
python
en
['en', 'en', 'en']
True
ViCareWater.__init__
(self, name, api, heating_type)
Initialize the DHW water_heater device.
Initialize the DHW water_heater device.
def __init__(self, name, api, heating_type): """Initialize the DHW water_heater device.""" self._name = name self._state = None self._api = api self._attributes = {} self._target_temperature = None self._current_temperature = None self._current_mode = None...
[ "def", "__init__", "(", "self", ",", "name", ",", "api", ",", "heating_type", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None", "self", ".", "_api", "=", "api", "self", ".", "_attributes", "=", "{", "}", "self", ".", ...
[ 69, 4 ]
[ 78, 41 ]
python
en
['en', 'en', 'en']
True
ViCareWater.update
(self)
Let HA know there has been an update from the ViCare API.
Let HA know there has been an update from the ViCare API.
def update(self): """Let HA know there has been an update from the ViCare API.""" try: current_temperature = self._api.getDomesticHotWaterStorageTemperature() if current_temperature != PYVICARE_ERROR: self._current_temperature = current_temperature els...
[ "def", "update", "(", "self", ")", ":", "try", ":", "current_temperature", "=", "self", ".", "_api", ".", "getDomesticHotWaterStorageTemperature", "(", ")", "if", "current_temperature", "!=", "PYVICARE_ERROR", ":", "self", ".", "_current_temperature", "=", "curren...
[ 80, 4 ]
[ 97, 69 ]
python
en
['en', 'en', 'en']
True
ViCareWater.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_FLAGS_HEATER
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_FLAGS_HEATER" ]
[ 100, 4 ]
[ 102, 35 ]
python
en
['en', 'en', 'en']
True
ViCareWater.name
(self)
Return the name of the water_heater device.
Return the name of the water_heater device.
def name(self): """Return the name of the water_heater device.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 105, 4 ]
[ 107, 25 ]
python
en
['en', 'en', 'en']
True
ViCareWater.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 110, 4 ]
[ 112, 27 ]
python
en
['en', 'la', 'en']
True
ViCareWater.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._current_temperature
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_current_temperature" ]
[ 115, 4 ]
[ 117, 40 ]
python
en
['en', 'la', 'en']
True
ViCareWater.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._target_temperature
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_target_temperature" ]
[ 120, 4 ]
[ 122, 39 ]
python
en
['en', 'en', 'en']
True
ViCareWater.set_temperature
(self, **kwargs)
Set new target temperatures.
Set new target temperatures.
def set_temperature(self, **kwargs): """Set new target temperatures.""" temp = kwargs.get(ATTR_TEMPERATURE) if temp is not None: self._api.setDomesticHotWaterTemperature(temp) self._target_temperature = temp
[ "def", "set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "temp", "=", "kwargs", ".", "get", "(", "ATTR_TEMPERATURE", ")", "if", "temp", "is", "not", "None", ":", "self", ".", "_api", ".", "setDomesticHotWaterTemperature", "(", "temp", ")...
[ 124, 4 ]
[ 129, 43 ]
python
en
['en', 'ca', 'en']
True
ViCareWater.min_temp
(self)
Return the minimum temperature.
Return the minimum temperature.
def min_temp(self): """Return the minimum temperature.""" return VICARE_TEMP_WATER_MIN
[ "def", "min_temp", "(", "self", ")", ":", "return", "VICARE_TEMP_WATER_MIN" ]
[ 132, 4 ]
[ 134, 36 ]
python
en
['en', 'la', 'en']
True
ViCareWater.max_temp
(self)
Return the maximum temperature.
Return the maximum temperature.
def max_temp(self): """Return the maximum temperature.""" return VICARE_TEMP_WATER_MAX
[ "def", "max_temp", "(", "self", ")", ":", "return", "VICARE_TEMP_WATER_MAX" ]
[ 137, 4 ]
[ 139, 36 ]
python
en
['en', 'la', 'en']
True
ViCareWater.precision
(self)
Return the precision of the system.
Return the precision of the system.
def precision(self): """Return the precision of the system.""" return PRECISION_WHOLE
[ "def", "precision", "(", "self", ")", ":", "return", "PRECISION_WHOLE" ]
[ 142, 4 ]
[ 144, 30 ]
python
en
['en', 'en', 'en']
True
ViCareWater.current_operation
(self)
Return current operation ie. heat, cool, idle.
Return current operation ie. heat, cool, idle.
def current_operation(self): """Return current operation ie. heat, cool, idle.""" return VICARE_TO_HA_HVAC_DHW.get(self._current_mode)
[ "def", "current_operation", "(", "self", ")", ":", "return", "VICARE_TO_HA_HVAC_DHW", ".", "get", "(", "self", ".", "_current_mode", ")" ]
[ 147, 4 ]
[ 149, 60 ]
python
en
['nl', 'en', 'en']
True
ViCareWater.operation_list
(self)
Return the list of available operation modes.
Return the list of available operation modes.
def operation_list(self): """Return the list of available operation modes.""" return list(HA_TO_VICARE_HVAC_DHW)
[ "def", "operation_list", "(", "self", ")", ":", "return", "list", "(", "HA_TO_VICARE_HVAC_DHW", ")" ]
[ 152, 4 ]
[ 154, 42 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the IGN Sismologia Feed platform.
Set up the IGN Sismologia Feed platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the IGN Sismologia Feed platform.""" scan_interval = config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL) coordinates = ( config.get(CONF_LATITUDE, hass.config.latitude), config.get(CONF_LONGITUDE, hass.config.longitude)...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "scan_interval", "=", "config", ".", "get", "(", "CONF_SCAN_INTERVAL", ",", "SCAN_INTERVAL", ")", "coordinates", "=", "(", "config", ".", ...
[ 53, 0 ]
[ 71, 71 ]
python
en
['en', 'zu', 'en']
True
IgnSismologiaFeedEntityManager.__init__
( self, hass, add_entities, scan_interval, coordinates, radius_in_km, minimum_magnitude, )
Initialize the Feed Entity Manager.
Initialize the Feed Entity Manager.
def __init__( self, hass, add_entities, scan_interval, coordinates, radius_in_km, minimum_magnitude, ): """Initialize the Feed Entity Manager.""" self._hass = hass self._feed_manager = IgnSismologiaFeedManager( self._genera...
[ "def", "__init__", "(", "self", ",", "hass", ",", "add_entities", ",", "scan_interval", ",", "coordinates", ",", "radius_in_km", ",", "minimum_magnitude", ",", ")", ":", "self", ".", "_hass", "=", "hass", "self", ".", "_feed_manager", "=", "IgnSismologiaFeedMa...
[ 77, 4 ]
[ 98, 43 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaFeedEntityManager.startup
(self)
Start up this manager.
Start up this manager.
def startup(self): """Start up this manager.""" self._feed_manager.update() self._init_regular_updates()
[ "def", "startup", "(", "self", ")", ":", "self", ".", "_feed_manager", ".", "update", "(", ")", "self", ".", "_init_regular_updates", "(", ")" ]
[ 100, 4 ]
[ 103, 36 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaFeedEntityManager._init_regular_updates
(self)
Schedule regular updates at the specified interval.
Schedule regular updates at the specified interval.
def _init_regular_updates(self): """Schedule regular updates at the specified interval.""" track_time_interval( self._hass, lambda now: self._feed_manager.update(), self._scan_interval )
[ "def", "_init_regular_updates", "(", "self", ")", ":", "track_time_interval", "(", "self", ".", "_hass", ",", "lambda", "now", ":", "self", ".", "_feed_manager", ".", "update", "(", ")", ",", "self", ".", "_scan_interval", ")" ]
[ 105, 4 ]
[ 109, 9 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaFeedEntityManager.get_entry
(self, external_id)
Get feed entry by external id.
Get feed entry by external id.
def get_entry(self, external_id): """Get feed entry by external id.""" return self._feed_manager.feed_entries.get(external_id)
[ "def", "get_entry", "(", "self", ",", "external_id", ")", ":", "return", "self", ".", "_feed_manager", ".", "feed_entries", ".", "get", "(", "external_id", ")" ]
[ 111, 4 ]
[ 113, 63 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaFeedEntityManager._generate_entity
(self, external_id)
Generate new entity.
Generate new entity.
def _generate_entity(self, external_id): """Generate new entity.""" new_entity = IgnSismologiaLocationEvent(self, external_id) # Add new entities to HA. self._add_entities([new_entity], True)
[ "def", "_generate_entity", "(", "self", ",", "external_id", ")", ":", "new_entity", "=", "IgnSismologiaLocationEvent", "(", "self", ",", "external_id", ")", "# Add new entities to HA.", "self", ".", "_add_entities", "(", "[", "new_entity", "]", ",", "True", ")" ]
[ 115, 4 ]
[ 119, 46 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaFeedEntityManager._update_entity
(self, external_id)
Update entity.
Update entity.
def _update_entity(self, external_id): """Update entity.""" dispatcher_send(self._hass, f"ign_sismologia_update_{external_id}")
[ "def", "_update_entity", "(", "self", ",", "external_id", ")", ":", "dispatcher_send", "(", "self", ".", "_hass", ",", "f\"ign_sismologia_update_{external_id}\"", ")" ]
[ 121, 4 ]
[ 123, 75 ]
python
en
['es', 'en', 'en']
False
IgnSismologiaFeedEntityManager._remove_entity
(self, external_id)
Remove entity.
Remove entity.
def _remove_entity(self, external_id): """Remove entity.""" dispatcher_send(self._hass, f"ign_sismologia_delete_{external_id}")
[ "def", "_remove_entity", "(", "self", ",", "external_id", ")", ":", "dispatcher_send", "(", "self", ".", "_hass", ",", "f\"ign_sismologia_delete_{external_id}\"", ")" ]
[ 125, 4 ]
[ 127, 75 ]
python
en
['es', 'it', 'en']
False
IgnSismologiaLocationEvent.__init__
(self, feed_manager, external_id)
Initialize entity with data from feed entry.
Initialize entity with data from feed entry.
def __init__(self, feed_manager, external_id): """Initialize entity with data from feed entry.""" self._feed_manager = feed_manager self._external_id = external_id self._title = None self._distance = None self._latitude = None self._longitude = None self._...
[ "def", "__init__", "(", "self", ",", "feed_manager", ",", "external_id", ")", ":", "self", ".", "_feed_manager", "=", "feed_manager", "self", ".", "_external_id", "=", "external_id", "self", ".", "_title", "=", "None", "self", ".", "_distance", "=", "None", ...
[ 133, 4 ]
[ 147, 41 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent.async_added_to_hass
(self)
Call when entity is added to hass.
Call when entity is added to hass.
async def async_added_to_hass(self): """Call when entity is added to hass.""" self._remove_signal_delete = async_dispatcher_connect( self.hass, f"ign_sismologia_delete_{self._external_id}", self._delete_callback, ) self._remove_signal_update = async_di...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "self", ".", "_remove_signal_delete", "=", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "f\"ign_sismologia_delete_{self._external_id}\"", ",", "self", ".", "_delete_callback", ",", ")", "self"...
[ 149, 4 ]
[ 160, 9 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent._delete_callback
(self)
Remove this entity.
Remove this entity.
def _delete_callback(self): """Remove this entity.""" self._remove_signal_delete() self._remove_signal_update() self.hass.async_create_task(self.async_remove())
[ "def", "_delete_callback", "(", "self", ")", ":", "self", ".", "_remove_signal_delete", "(", ")", "self", ".", "_remove_signal_update", "(", ")", "self", ".", "hass", ".", "async_create_task", "(", "self", ".", "async_remove", "(", ")", ")" ]
[ 163, 4 ]
[ 167, 56 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent._update_callback
(self)
Call update method.
Call update method.
def _update_callback(self): """Call update method.""" self.async_schedule_update_ha_state(True)
[ "def", "_update_callback", "(", "self", ")", ":", "self", ".", "async_schedule_update_ha_state", "(", "True", ")" ]
[ 170, 4 ]
[ 172, 49 ]
python
en
['en', 'sn', 'en']
True
IgnSismologiaLocationEvent.should_poll
(self)
No polling needed for IGN Sismologia feed location events.
No polling needed for IGN Sismologia feed location events.
def should_poll(self): """No polling needed for IGN Sismologia feed location events.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 175, 4 ]
[ 177, 20 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent.async_update
(self)
Update this entity from the data held in the feed manager.
Update this entity from the data held in the feed manager.
async def async_update(self): """Update this entity from the data held in the feed manager.""" _LOGGER.debug("Updating %s", self._external_id) feed_entry = self._feed_manager.get_entry(self._external_id) if feed_entry: self._update_from_feed(feed_entry)
[ "async", "def", "async_update", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Updating %s\"", ",", "self", ".", "_external_id", ")", "feed_entry", "=", "self", ".", "_feed_manager", ".", "get_entry", "(", "self", ".", "_external_id", ")", "if", "...
[ 179, 4 ]
[ 184, 46 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent._update_from_feed
(self, feed_entry)
Update the internal state from the provided feed entry.
Update the internal state from the provided feed entry.
def _update_from_feed(self, feed_entry): """Update the internal state from the provided feed entry.""" self._title = feed_entry.title self._distance = feed_entry.distance_to_home self._latitude = feed_entry.coordinates[0] self._longitude = feed_entry.coordinates[1] self._...
[ "def", "_update_from_feed", "(", "self", ",", "feed_entry", ")", ":", "self", ".", "_title", "=", "feed_entry", ".", "title", "self", ".", "_distance", "=", "feed_entry", ".", "distance_to_home", "self", ".", "_latitude", "=", "feed_entry", ".", "coordinates",...
[ 186, 4 ]
[ 196, 46 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent.icon
(self)
Return the icon to use in the frontend.
Return the icon to use in the frontend.
def icon(self): """Return the icon to use in the frontend.""" return "mdi:pulse"
[ "def", "icon", "(", "self", ")", ":", "return", "\"mdi:pulse\"" ]
[ 199, 4 ]
[ 201, 26 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent.source
(self)
Return source value of this external event.
Return source value of this external event.
def source(self) -> str: """Return source value of this external event.""" return SOURCE
[ "def", "source", "(", "self", ")", "->", "str", ":", "return", "SOURCE" ]
[ 204, 4 ]
[ 206, 21 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> Optional[str]: """Return the name of the entity.""" if self._magnitude and self._region: return f"M {self._magnitude:.1f} - {self._region}" if self._magnitude: return f"M {self._magnitude:.1f}" if self._region: return self._region ...
[ "def", "name", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "_magnitude", "and", "self", ".", "_region", ":", "return", "f\"M {self._magnitude:.1f} - {self._region}\"", "if", "self", ".", "_magnitude", ":", "return", "f\"M {self...
[ 209, 4 ]
[ 217, 26 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent.distance
(self)
Return distance value of this external event.
Return distance value of this external event.
def distance(self) -> Optional[float]: """Return distance value of this external event.""" return self._distance
[ "def", "distance", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "_distance" ]
[ 220, 4 ]
[ 222, 29 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent.latitude
(self)
Return latitude value of this external event.
Return latitude value of this external event.
def latitude(self) -> Optional[float]: """Return latitude value of this external event.""" return self._latitude
[ "def", "latitude", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "_latitude" ]
[ 225, 4 ]
[ 227, 29 ]
python
en
['en', 'la', 'en']
True
IgnSismologiaLocationEvent.longitude
(self)
Return longitude value of this external event.
Return longitude value of this external event.
def longitude(self) -> Optional[float]: """Return longitude value of this external event.""" return self._longitude
[ "def", "longitude", "(", "self", ")", "->", "Optional", "[", "float", "]", ":", "return", "self", ".", "_longitude" ]
[ 230, 4 ]
[ 232, 30 ]
python
en
['en', 'en', 'en']
True
IgnSismologiaLocationEvent.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 LENGTH_KILOMETERS
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "LENGTH_KILOMETERS" ]
[ 235, 4 ]
[ 237, 32 ]
python
en
['en', 'la', 'en']
True
IgnSismologiaLocationEvent.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" attributes = {} for key, value in ( (ATTR_EXTERNAL_ID, self._external_id), (ATTR_TITLE, self._title), (ATTR_REGION, self._region), (ATTR_MAGNITUDE, self._magnitude), ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attributes", "=", "{", "}", "for", "key", ",", "value", "in", "(", "(", "ATTR_EXTERNAL_ID", ",", "self", ".", "_external_id", ")", ",", "(", "ATTR_TITLE", ",", "self", ".", "_title", ")", ",", "...
[ 240, 4 ]
[ 254, 25 ]
python
en
['en', 'en', 'en']
True
device_climate_mock
(hass, zigpy_device_mock, zha_device_joined)
Test regular thermostat device.
Test regular thermostat device.
def device_climate_mock(hass, zigpy_device_mock, zha_device_joined): """Test regular thermostat device.""" async def _dev(clusters, plug=None, manuf=None): if plug is None: plugged_attrs = ZCL_ATTR_PLUG else: plugged_attrs = {**ZCL_ATTR_PLUG, **plug} zigpy_devic...
[ "def", "device_climate_mock", "(", "hass", ",", "zigpy_device_mock", ",", "zha_device_joined", ")", ":", "async", "def", "_dev", "(", "clusters", ",", "plug", "=", "None", ",", "manuf", "=", "None", ")", ":", "if", "plug", "is", "None", ":", "plugged_attrs...
[ 133, 0 ]
[ 149, 15 ]
python
en
['en', 'en', 'en']
True
device_climate
(device_climate_mock)
Plain Climate device.
Plain Climate device.
async def device_climate(device_climate_mock): """Plain Climate device.""" return await device_climate_mock(CLIMATE)
[ "async", "def", "device_climate", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE", ")" ]
[ 153, 0 ]
[ 156, 45 ]
python
fr
['fr', 'fr', 'en']
True
device_climate_fan
(device_climate_mock)
Test thermostat with fan device.
Test thermostat with fan device.
async def device_climate_fan(device_climate_mock): """Test thermostat with fan device.""" return await device_climate_mock(CLIMATE_FAN)
[ "async", "def", "device_climate_fan", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE_FAN", ")" ]
[ 160, 0 ]
[ 163, 49 ]
python
en
['en', 'en', 'en']
True
device_climate_sinope
(device_climate_mock)
Sinope thermostat.
Sinope thermostat.
async def device_climate_sinope(device_climate_mock): """Sinope thermostat.""" return await device_climate_mock(CLIMATE_SINOPE, manuf=MANUF_SINOPE)
[ "async", "def", "device_climate_sinope", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE_SINOPE", ",", "manuf", "=", "MANUF_SINOPE", ")" ]
[ 172, 0 ]
[ 175, 72 ]
python
en
['en', 'ja', 'ru']
False
device_climate_zen
(device_climate_mock)
Zen Within thermostat.
Zen Within thermostat.
async def device_climate_zen(device_climate_mock): """Zen Within thermostat.""" return await device_climate_mock(CLIMATE_ZEN, manuf=MANUF_ZEN)
[ "async", "def", "device_climate_zen", "(", "device_climate_mock", ")", ":", "return", "await", "device_climate_mock", "(", "CLIMATE_ZEN", ",", "manuf", "=", "MANUF_ZEN", ")" ]
[ 179, 0 ]
[ 182, 66 ]
python
en
['en', 'en', 'en']
True
test_sequence_mappings
()
Test correct mapping between control sequence -> HVAC Mode -> Sysmode.
Test correct mapping between control sequence -> HVAC Mode -> Sysmode.
def test_sequence_mappings(): """Test correct mapping between control sequence -> HVAC Mode -> Sysmode.""" for hvac_modes in SEQ_OF_OPERATION.values(): for hvac_mode in hvac_modes: assert hvac_mode in HVAC_MODE_2_SYSTEM assert Thermostat.SystemMode(HVAC_MODE_2_SYSTEM[hvac_mode])...
[ "def", "test_sequence_mappings", "(", ")", ":", "for", "hvac_modes", "in", "SEQ_OF_OPERATION", ".", "values", "(", ")", ":", "for", "hvac_mode", "in", "hvac_modes", ":", "assert", "hvac_mode", "in", "HVAC_MODE_2_SYSTEM", "assert", "Thermostat", ".", "SystemMode", ...
[ 185, 0 ]
[ 191, 83 ]
python
en
['en', 'en', 'en']
True
test_climate_local_temp
(hass, device_climate)
Test local temperature.
Test local temperature.
async def test_climate_local_temp(hass, device_climate): """Test local temperature.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert state.attributes[ATTR_CURRENT_TEMPERATURE] is...
[ "async", "def", "test_climate_local_temp", "(", "hass", ",", "device_climate", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN", ",", ...
[ 194, 0 ]
[ 205, 61 ]
python
en
['en', 'la', 'en']
True
test_climate_hvac_action_running_state
(hass, device_climate)
Test hvac action via running state.
Test hvac action via running state.
async def test_climate_hvac_action_running_state(hass, device_climate): """Test hvac action via running state.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert state.attributes[A...
[ "async", "def", "test_climate_hvac_action_running_state", "(", "hass", ",", "device_climate", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity_id", "(", "DOM...
[ 208, 0 ]
[ 251, 65 ]
python
de
['no', 'de', 'en']
False
test_climate_hvac_action_running_state_zen
(hass, device_climate_zen)
Test Zen hvac action via running state.
Test Zen hvac action via running state.
async def test_climate_hvac_action_running_state_zen(hass, device_climate_zen): """Test Zen hvac action via running state.""" thrm_cluster = device_climate_zen.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate_zen, hass) state = hass.states.get(entity_id) asser...
[ "async", "def", "test_climate_hvac_action_running_state_zen", "(", "hass", ",", "device_climate_zen", ")", ":", "thrm_cluster", "=", "device_climate_zen", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity_id", ...
[ 254, 0 ]
[ 315, 66 ]
python
de
['no', 'de', 'en']
False
test_climate_hvac_action_pi_demand
(hass, device_climate)
Test hvac action based on pi_heating/cooling_demand attrs.
Test hvac action based on pi_heating/cooling_demand attrs.
async def test_climate_hvac_action_pi_demand(hass, device_climate): """Test hvac action based on pi_heating/cooling_demand attrs.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert...
[ "async", "def", "test_climate_hvac_action_pi_demand", "(", "hass", ",", "device_climate", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity_id", "(", "DOMAIN"...
[ 318, 0 ]
[ 351, 66 ]
python
en
['en', 'da', 'en']
True
test_hvac_mode
(hass, device_climate, sys_mode, hvac_mode)
Test HVAC modee.
Test HVAC modee.
async def test_hvac_mode(hass, device_climate, sys_mode, hvac_mode): """Test HVAC modee.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert state.state == HVAC_MODE_OFF await ...
[ "async", "def", "test_hvac_mode", "(", "hass", ",", "device_climate", ",", "sys_mode", ",", "hvac_mode", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_entity...
[ 365, 0 ]
[ 386, 39 ]
python
en
['en', 'zh', 'nl']
False
test_hvac_modes
(hass, device_climate_mock, seq_of_op, modes)
Test HVAC modes from sequence of operations.
Test HVAC modes from sequence of operations.
async def test_hvac_modes(hass, device_climate_mock, seq_of_op, modes): """Test HVAC modes from sequence of operations.""" device_climate = await device_climate_mock( CLIMATE, {"ctrl_seqe_of_oper": seq_of_op} ) entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.stat...
[ "async", "def", "test_hvac_modes", "(", "hass", ",", "device_climate_mock", ",", "seq_of_op", ",", "modes", ")", ":", "device_climate", "=", "await", "device_climate_mock", "(", "CLIMATE", ",", "{", "\"ctrl_seqe_of_oper\"", ":", "seq_of_op", "}", ")", "entity_id",...
[ 401, 0 ]
[ 409, 58 ]
python
en
['en', 'en', 'en']
True
test_target_temperature
( hass, device_climate_mock, sys_mode, preset, target_temp )
Test target temperature property.
Test target temperature property.
async def test_target_temperature( hass, device_climate_mock, sys_mode, preset, target_temp ): """Test target temperature property.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific", ): ...
[ "async", "def", "test_target_temperature", "(", "hass", ",", "device_climate_mock", ",", "sys_mode", ",", "preset", ",", "target_temp", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".", "Man...
[ 421, 0 ]
[ 452, 60 ]
python
en
['en', 'en', 'en']
True
test_target_temperature_high
( hass, device_climate_mock, preset, unoccupied, target_temp )
Test target temperature high property.
Test target temperature high property.
async def test_target_temperature_high( hass, device_climate_mock, preset, unoccupied, target_temp ): """Test target temperature high property.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific",...
[ "async", "def", "test_target_temperature_high", "(", "hass", ",", "device_climate_mock", ",", "preset", ",", "unoccupied", ",", "target_temp", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".",...
[ 463, 0 ]
[ 492, 65 ]
python
en
['en', 'en', 'en']
True
test_target_temperature_low
( hass, device_climate_mock, preset, unoccupied, target_temp )
Test target temperature low property.
Test target temperature low property.
async def test_target_temperature_low( hass, device_climate_mock, preset, unoccupied, target_temp ): """Test target temperature low property.""" with patch.object( zigpy.zcl.clusters.manufacturer_specific.ManufacturerSpecificCluster, "ep_attribute", "sinope_manufacturer_specific", ...
[ "async", "def", "test_target_temperature_low", "(", "hass", ",", "device_climate_mock", ",", "preset", ",", "unoccupied", ",", "target_temp", ")", ":", "with", "patch", ".", "object", "(", "zigpy", ".", "zcl", ".", "clusters", ".", "manufacturer_specific", ".", ...
[ 503, 0 ]
[ 532, 64 ]
python
en
['en', 'en', 'en']
True
test_set_hvac_mode
(hass, device_climate, hvac_mode, sys_mode)
Test setting hvac mode.
Test setting hvac mode.
async def test_set_hvac_mode(hass, device_climate, hvac_mode, sys_mode): """Test setting hvac mode.""" thrm_cluster = device_climate.device.endpoints[1].thermostat entity_id = await find_entity_id(DOMAIN, device_climate, hass) state = hass.states.get(entity_id) assert state.state == HVAC_MODE_OFF ...
[ "async", "def", "test_set_hvac_mode", "(", "hass", ",", "device_climate", ",", "hvac_mode", ",", "sys_mode", ")", ":", "thrm_cluster", "=", "device_climate", ".", "device", ".", "endpoints", "[", "1", "]", ".", "thermostat", "entity_id", "=", "await", "find_en...
[ 546, 0 ]
[ 585, 5 ]
python
en
['en', 'sq', 'ru']
False