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
_is_start_of_word
(text)
Checks whether the first character in text is one of a punctuation, control or whitespace character.
Checks whether the first character in text is one of a punctuation, control or whitespace character.
def _is_start_of_word(text): """Checks whether the first character in text is one of a punctuation, control or whitespace character.""" first_char = text[0] return bool(_is_control(first_char) | _is_punctuation(first_char) | _is_whitespace(first_char))
[ "def", "_is_start_of_word", "(", "text", ")", ":", "first_char", "=", "text", "[", "0", "]", "return", "bool", "(", "_is_control", "(", "first_char", ")", "|", "_is_punctuation", "(", "first_char", ")", "|", "_is_whitespace", "(", "first_char", ")", ")" ]
[ 95, 0 ]
[ 98, 99 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.frame
(self)
FrameBase: Frame instance of current business engine.
FrameBase: Frame instance of current business engine.
def frame(self) -> FrameBase: """FrameBase: Frame instance of current business engine.""" pass
[ "def", "frame", "(", "self", ")", "->", "FrameBase", ":", "pass" ]
[ 57, 4 ]
[ 59, 12 ]
python
en
['en', 'da', 'en']
True
AbsBusinessEngine.snapshots
(self)
SnapshotList: Snapshot list of current frame, this is used to expose querying interface for outside.
SnapshotList: Snapshot list of current frame, this is used to expose querying interface for outside.
def snapshots(self) -> SnapshotList: """SnapshotList: Snapshot list of current frame, this is used to expose querying interface for outside.""" pass
[ "def", "snapshots", "(", "self", ")", "->", "SnapshotList", ":", "pass" ]
[ 63, 4 ]
[ 65, 12 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.frame_index
(self, tick: int)
Helper method for child class, used to get index of frame in snapshot list for specified tick. Args: tick (int): Tick to calculate frame index. Returns: int: Frame index in snapshot list of specified tick.
Helper method for child class, used to get index of frame in snapshot list for specified tick.
def frame_index(self, tick: int) -> int: """Helper method for child class, used to get index of frame in snapshot list for specified tick. Args: tick (int): Tick to calculate frame index. Returns: int: Frame index in snapshot list of specified tick. """ ...
[ "def", "frame_index", "(", "self", ",", "tick", ":", "int", ")", "->", "int", ":", "return", "tick_to_frame_index", "(", "self", ".", "_start_tick", ",", "tick", ",", "self", ".", "_snapshot_resolution", ")" ]
[ 67, 4 ]
[ 76, 85 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.calc_max_snapshots
(self)
Helper method to calculate total snapshot should be in snapshot list with parameters passed via constructor. NOTE: This method will return max number that can contains all the frame state to the end. You can use a small size to hold states, when hit the limitation, oldest one will be ov...
Helper method to calculate total snapshot should be in snapshot list with parameters passed via constructor.
def calc_max_snapshots(self) -> int: """Helper method to calculate total snapshot should be in snapshot list with parameters passed via constructor. NOTE: This method will return max number that can contains all the frame state to the end. You can use a small size to hold states...
[ "def", "calc_max_snapshots", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_max_snapshots", "if", "self", ".", "_max_snapshots", "is", "not", "None", "else", "total_frames", "(", "self", ".", "_start_tick", ",", "self", ".", "_max_tick", ",", ...
[ 78, 4 ]
[ 89, 90 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.update_config_root_path
(self, business_engine_file_path: str)
Helper method used to update the config path with business engine path if you follow the way to load configuration file as built-in scenarios. This method assuming that all the configuration (topologies) is under their scenario folder, and named as topologies, each topology is one folder. ...
Helper method used to update the config path with business engine path if you follow the way to load configuration file as built-in scenarios.
def update_config_root_path(self, business_engine_file_path: str): """Helper method used to update the config path with business engine path if you follow the way to load configuration file as built-in scenarios. This method assuming that all the configuration (topologies) is under their scenar...
[ "def", "update_config_root_path", "(", "self", ",", "business_engine_file_path", ":", "str", ")", ":", "if", "self", ".", "_topology", ":", "path", "=", "Path", "(", "self", ".", "_topology", ")", "if", "path", ".", "exists", "(", ")", "and", "path", "."...
[ 91, 4 ]
[ 124, 92 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.step
(self, tick: int)
Method that is called at each tick, usually used to trigger business logic at current tick. Args: tick (int): Current tick from simulator.
Method that is called at each tick, usually used to trigger business logic at current tick.
def step(self, tick: int): """Method that is called at each tick, usually used to trigger business logic at current tick. Args: tick (int): Current tick from simulator. """ pass
[ "def", "step", "(", "self", ",", "tick", ":", "int", ")", ":", "pass" ]
[ 127, 4 ]
[ 133, 12 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.configs
(self)
dict: Configurations of this business engine.
dict: Configurations of this business engine.
def configs(self) -> dict: """dict: Configurations of this business engine.""" pass
[ "def", "configs", "(", "self", ")", "->", "dict", ":", "pass" ]
[ 136, 4 ]
[ 138, 12 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.reset
(self)
Reset states business engine.
Reset states business engine.
def reset(self): """Reset states business engine.""" pass
[ "def", "reset", "(", "self", ")", ":", "pass" ]
[ 141, 4 ]
[ 143, 12 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.post_step
(self, tick: int)
This method will be called at the end of each tick, used to post-process for each tick, for complex business logic with many events, it maybe not easy to determine if stop the scenario at the middle of tick, so this method is used to avoid this. Args: tick (int): Current tick. ...
This method will be called at the end of each tick, used to post-process for each tick, for complex business logic with many events, it maybe not easy to determine if stop the scenario at the middle of tick, so this method is used to avoid this.
def post_step(self, tick: int) -> bool: """This method will be called at the end of each tick, used to post-process for each tick, for complex business logic with many events, it maybe not easy to determine if stop the scenario at the middle of tick, so this method is used to avoid this. ...
[ "def", "post_step", "(", "self", ",", "tick", ":", "int", ")", "->", "bool", ":", "return", "False" ]
[ 145, 4 ]
[ 156, 20 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.get_node_mapping
(self)
Get mapping for nodes, like index->name or index->id, may different for scenarios. Returns: dict: Key is node index, value is decided by scenario, usually is name or id.
Get mapping for nodes, like index->name or index->id, may different for scenarios.
def get_node_mapping(self) -> dict: """Get mapping for nodes, like index->name or index->id, may different for scenarios. Returns: dict: Key is node index, value is decided by scenario, usually is name or id. """ return {}
[ "def", "get_node_mapping", "(", "self", ")", "->", "dict", ":", "return", "{", "}" ]
[ 158, 4 ]
[ 164, 17 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.get_event_payload_detail
(self)
Get payload keys for all kinds of event. For the performance of the simulator, some event payload has no corresponding Python object. This mapping is provided for your convenience in such case. Returns: dict: Key is the event type in string format, value is a list of available keys...
Get payload keys for all kinds of event.
def get_event_payload_detail(self) -> dict: """Get payload keys for all kinds of event. For the performance of the simulator, some event payload has no corresponding Python object. This mapping is provided for your convenience in such case. Returns: dict: Key is the event t...
[ "def", "get_event_payload_detail", "(", "self", ")", "->", "dict", ":", "return", "{", "}" ]
[ 166, 4 ]
[ 175, 17 ]
python
en
['en', 'en', 'en']
True
AbsBusinessEngine.get_metrics
(self)
Get statistics information, may different for scenarios. Returns: dict: Dictionary about metrics, content and format determined by business engine.
Get statistics information, may different for scenarios.
def get_metrics(self) -> dict: """Get statistics information, may different for scenarios. Returns: dict: Dictionary about metrics, content and format determined by business engine. """ return {}
[ "def", "get_metrics", "(", "self", ")", "->", "dict", ":", "return", "{", "}" ]
[ 177, 4 ]
[ 183, 17 ]
python
en
['es', 'en', 'en']
True
AbsBusinessEngine.dump
(self, folder: str)
Dump something from business engine. Args: folder (str): Folder to place dumped files.
Dump something from business engine.
def dump(self, folder: str): """Dump something from business engine. Args: folder (str): Folder to place dumped files. """ pass
[ "def", "dump", "(", "self", ",", "folder", ":", "str", ")", ":", "pass" ]
[ 185, 4 ]
[ 191, 12 ]
python
en
['en', 'en', 'en']
True
SummarizationDataProcessingTest.test_fit_to_block_sequence_too_small
(self)
Pad the sequence with 0 if the sequence is smaller than the block size.
Pad the sequence with 0 if the sequence is smaller than the block size.
def test_fit_to_block_sequence_too_small(self): """ Pad the sequence with 0 if the sequence is smaller than the block size.""" sequence = [1, 2, 3, 4] expected_output = [1, 2, 3, 4, 0, 0, 0, 0, 0, 0] self.assertEqual(truncate_or_pad(sequence, self.block_size, 0), expected_output)
[ "def", "test_fit_to_block_sequence_too_small", "(", "self", ")", ":", "sequence", "=", "[", "1", ",", "2", ",", "3", ",", "4", "]", "expected_output", "=", "[", "1", ",", "2", ",", "3", ",", "4", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0"...
[ 26, 4 ]
[ 30, 88 ]
python
en
['en', 'en', 'en']
True
SummarizationDataProcessingTest.test_fit_to_block_sequence_fit_exactly
(self)
Do nothing if the sequence is the right size.
Do nothing if the sequence is the right size.
def test_fit_to_block_sequence_fit_exactly(self): """ Do nothing if the sequence is the right size. """ sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] expected_output = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] self.assertEqual(truncate_or_pad(sequence, self.block_size, 0), expected_output)
[ "def", "test_fit_to_block_sequence_fit_exactly", "(", "self", ")", ":", "sequence", "=", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", ",", "9", ",", "10", "]", "expected_output", "=", "[", "1", ",", "2", ",", ...
[ 32, 4 ]
[ 36, 88 ]
python
en
['en', 'en', 'en']
True
SummarizationDataProcessingTest.test_fit_to_block_sequence_too_big
(self)
Truncate the sequence if it is too long.
Truncate the sequence if it is too long.
def test_fit_to_block_sequence_too_big(self): """ Truncate the sequence if it is too long. """ sequence = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] expected_output = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] self.assertEqual(truncate_or_pad(sequence, self.block_size, 0), expected_output)
[ "def", "test_fit_to_block_sequence_too_big", "(", "self", ")", ":", "sequence", "=", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "8", ",", "9", ",", "10", ",", "11", ",", "12", ",", "13", "]", "expected_output", "...
[ 38, 4 ]
[ 42, 88 ]
python
en
['en', 'en', 'en']
True
SummarizationDataProcessingTest.test_process_story_no_highlights
(self)
Processing a story with no highlights returns an empty list for the summary.
Processing a story with no highlights returns an empty list for the summary.
def test_process_story_no_highlights(self): """Processing a story with no highlights returns an empty list for the summary.""" raw_story = """It was the year of Our Lord one thousand seven hundred and seventy-five.\n\nSpiritual revelations were conceded to England at that favoured period...
[ "def", "test_process_story_no_highlights", "(", "self", ")", ":", "raw_story", "=", "\"\"\"It was the year of Our Lord one thousand seven hundred and\n seventy-five.\\n\\nSpiritual revelations were conceded to England at that\n favoured period, as at this.\"\"\"", "_", ",", "summ...
[ 44, 4 ]
[ 50, 43 ]
python
en
['en', 'en', 'en']
True
SummarizationDataProcessingTest.test_process_empty_story
(self)
An empty story returns an empty collection of lines.
An empty story returns an empty collection of lines.
def test_process_empty_story(self): """An empty story returns an empty collection of lines.""" raw_story = "" story_lines, summary_lines = process_story(raw_story) self.assertEqual(story_lines, []) self.assertEqual(summary_lines, [])
[ "def", "test_process_empty_story", "(", "self", ")", ":", "raw_story", "=", "\"\"", "story_lines", ",", "summary_lines", "=", "process_story", "(", "raw_story", ")", "self", ".", "assertEqual", "(", "story_lines", ",", "[", "]", ")", "self", ".", "assertEqual"...
[ 52, 4 ]
[ 57, 43 ]
python
en
['en', 'en', 'en']
True
AbsEnv.step
(self, action)
Push the environment to next step with action. Args: action (Action): Action(s) from agent. Returns: tuple: a tuple of (metrics, decision event, is_done).
Push the environment to next step with action.
def step(self, action): """Push the environment to next step with action. Args: action (Action): Action(s) from agent. Returns: tuple: a tuple of (metrics, decision event, is_done). """ pass
[ "def", "step", "(", "self", ",", "action", ")", ":", "pass" ]
[ 63, 4 ]
[ 72, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.dump
(self)
Dump environment for restore.
Dump environment for restore.
def dump(self): """Dump environment for restore.""" pass
[ "def", "dump", "(", "self", ")", ":", "pass" ]
[ 75, 4 ]
[ 77, 12 ]
python
en
['en', 'no', 'en']
True
AbsEnv.reset
(self)
Reset environment.
Reset environment.
def reset(self): """Reset environment.""" pass
[ "def", "reset", "(", "self", ")", ":", "pass" ]
[ 80, 4 ]
[ 82, 12 ]
python
be
['fr', 'be', 'en']
False
AbsEnv.configs
(self)
object: Configurations of current environment, this field would be different for different scenario.
object: Configurations of current environment, this field would be different for different scenario.
def configs(self) -> dict: """object: Configurations of current environment, this field would be different for different scenario.""" pass
[ "def", "configs", "(", "self", ")", "->", "dict", ":", "pass" ]
[ 86, 4 ]
[ 88, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.agent_idx_list
(self)
List[int]: Agent index list that related to this environment.
List[int]: Agent index list that related to this environment.
def agent_idx_list(self) -> List[int]: """List[int]: Agent index list that related to this environment.""" pass
[ "def", "agent_idx_list", "(", "self", ")", "->", "List", "[", "int", "]", ":", "pass" ]
[ 92, 4 ]
[ 94, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.name
(self)
str: Name of current environment.
str: Name of current environment.
def name(self) -> str: """str: Name of current environment.""" pass
[ "def", "name", "(", "self", ")", "->", "str", ":", "pass" ]
[ 98, 4 ]
[ 100, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.tick
(self)
int: Current tick of environment.
int: Current tick of environment.
def tick(self) -> int: """int: Current tick of environment.""" pass
[ "def", "tick", "(", "self", ")", "->", "int", ":", "pass" ]
[ 104, 4 ]
[ 106, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.frame_index
(self)
int: Frame index in snapshot list for current tick, USE this for snapshot querying.
int: Frame index in snapshot list for current tick, USE this for snapshot querying.
def frame_index(self) -> int: """int: Frame index in snapshot list for current tick, USE this for snapshot querying.""" pass
[ "def", "frame_index", "(", "self", ")", "->", "int", ":", "pass" ]
[ 109, 4 ]
[ 111, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.summary
(self)
dict: Summary about current simulator, may include node details, and mappings.
dict: Summary about current simulator, may include node details, and mappings.
def summary(self) -> dict: """dict: Summary about current simulator, may include node details, and mappings.""" pass
[ "def", "summary", "(", "self", ")", "->", "dict", ":", "pass" ]
[ 115, 4 ]
[ 117, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.snapshot_list
(self)
SnapshotList: Current snapshot list, a snapshot list contains all the snapshots of frame at each tick.
SnapshotList: Current snapshot list, a snapshot list contains all the snapshots of frame at each tick.
def snapshot_list(self) -> SnapshotList: """SnapshotList: Current snapshot list, a snapshot list contains all the snapshots of frame at each tick.""" pass
[ "def", "snapshot_list", "(", "self", ")", "->", "SnapshotList", ":", "pass" ]
[ 121, 4 ]
[ 123, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.set_seed
(self, seed: int)
Set random seed used by simulator. NOTE: This will not set seed for Python random or other packages' seed, such as NumPy. Args: seed (int): Seed to set.
Set random seed used by simulator.
def set_seed(self, seed: int): """Set random seed used by simulator. NOTE: This will not set seed for Python random or other packages' seed, such as NumPy. Args: seed (int): Seed to set. """ pass
[ "def", "set_seed", "(", "self", ",", "seed", ":", "int", ")", ":", "pass" ]
[ 125, 4 ]
[ 134, 12 ]
python
en
['en', 'et', 'en']
True
AbsEnv.metrics
(self)
Some statistics information provided by business engine. Returns: dict: Dictionary of metrics, content and format is determined by business engine.
Some statistics information provided by business engine.
def metrics(self) -> dict: """Some statistics information provided by business engine. Returns: dict: Dictionary of metrics, content and format is determined by business engine. """ return {}
[ "def", "metrics", "(", "self", ")", "->", "dict", ":", "return", "{", "}" ]
[ 137, 4 ]
[ 143, 17 ]
python
en
['en', 'en', 'en']
True
AbsEnv.get_finished_events
(self)
list: All events finished so far.
list: All events finished so far.
def get_finished_events(self) -> list: """list: All events finished so far.""" pass
[ "def", "get_finished_events", "(", "self", ")", "->", "list", ":", "pass" ]
[ 145, 4 ]
[ 147, 12 ]
python
en
['en', 'en', 'en']
True
AbsEnv.get_pending_events
(self, tick: int)
list: Pending events at certain tick. Args: tick (int): Specified tick.
list: Pending events at certain tick.
def get_pending_events(self, tick: int) -> list: """list: Pending events at certain tick. Args: tick (int): Specified tick. """ pass
[ "def", "get_pending_events", "(", "self", ",", "tick", ":", "int", ")", "->", "list", ":", "pass" ]
[ 149, 4 ]
[ 155, 12 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up Tile device trackers.
Set up Tile device trackers.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up Tile device trackers.""" coordinator = hass.data[DOMAIN][DATA_COORDINATOR][config_entry.entry_id] async_add_entities( [ TileDeviceTracker(coordinator, tile_uuid, tile) for tile_uuid, tile in coord...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "coordinator", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_COORDINATOR", "]", "[", "config_entry", ".", "entry_id", "]", "async_add_entities"...
[ 22, 0 ]
[ 32, 5 ]
python
en
['fr', 'en', 'en']
True
async_setup_scanner
(hass, config, async_see, discovery_info=None)
Detect a legacy configuration and import it.
Detect a legacy configuration and import it.
async def async_setup_scanner(hass, config, async_see, discovery_info=None): """Detect a legacy configuration and import it.""" hass.async_create_task( hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_IMPORT}, data={ CONF_USERNAME...
[ "async", "def", "async_setup_scanner", "(", "hass", ",", "config", ",", "async_see", ",", "discovery_info", "=", "None", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "cont...
[ 35, 0 ]
[ 53, 15 ]
python
en
['en', 'en', 'en']
True
TileDeviceTracker.__init__
(self, coordinator, tile_uuid, tile)
Initialize.
Initialize.
def __init__(self, coordinator, tile_uuid, tile): """Initialize.""" super().__init__(coordinator) self._name = tile["name"] self._tile = tile self._tile_uuid = tile_uuid self._unique_id = f"tile_{tile_uuid}"
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "tile_uuid", ",", "tile", ")", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "_name", "=", "tile", "[", "\"name\"", "]", "self", ".", "_tile", "=", "tile", "sel...
[ 59, 4 ]
[ 65, 45 ]
python
en
['en', 'en', 'it']
False
TileDeviceTracker.available
(self)
Return if entity is available.
Return if entity is available.
def available(self): """Return if entity is available.""" return self.coordinator.last_update_success and not self._tile["is_dead"]
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "coordinator", ".", "last_update_success", "and", "not", "self", ".", "_tile", "[", "\"is_dead\"", "]" ]
[ 68, 4 ]
[ 70, 81 ]
python
en
['en', 'en', 'en']
True
TileDeviceTracker.battery_level
(self)
Return the battery level of the device. Percentage from 0-100.
Return the battery level of the device.
def battery_level(self): """Return the battery level of the device. Percentage from 0-100. """ return None
[ "def", "battery_level", "(", "self", ")", ":", "return", "None" ]
[ 73, 4 ]
[ 78, 19 ]
python
en
['en', 'en', 'en']
True
TileDeviceTracker.location_accuracy
(self)
Return the location accuracy of the device. Value in meters.
Return the location accuracy of the device.
def location_accuracy(self): """Return the location accuracy of the device. Value in meters. """ state = self._tile["last_tile_state"] h_accuracy = state.get("h_accuracy") v_accuracy = state.get("v_accuracy") if h_accuracy is not None and v_accuracy is not None:...
[ "def", "location_accuracy", "(", "self", ")", ":", "state", "=", "self", ".", "_tile", "[", "\"last_tile_state\"", "]", "h_accuracy", "=", "state", ".", "get", "(", "\"h_accuracy\"", ")", "v_accuracy", "=", "state", ".", "get", "(", "\"v_accuracy\"", ")", ...
[ 81, 4 ]
[ 105, 19 ]
python
en
['en', 'en', 'en']
True
TileDeviceTracker.latitude
(self)
Return latitude value of the device.
Return latitude value of the device.
def latitude(self) -> float: """Return latitude value of the device.""" return self._tile["last_tile_state"]["latitude"]
[ "def", "latitude", "(", "self", ")", "->", "float", ":", "return", "self", ".", "_tile", "[", "\"last_tile_state\"", "]", "[", "\"latitude\"", "]" ]
[ 108, 4 ]
[ 110, 56 ]
python
en
['en', 'en', 'en']
True
TileDeviceTracker.longitude
(self)
Return longitude value of the device.
Return longitude value of the device.
def longitude(self) -> float: """Return longitude value of the device.""" return self._tile["last_tile_state"]["longitude"]
[ "def", "longitude", "(", "self", ")", "->", "float", ":", "return", "self", ".", "_tile", "[", "\"last_tile_state\"", "]", "[", "\"longitude\"", "]" ]
[ 113, 4 ]
[ 115, 57 ]
python
en
['en', 'zu', 'en']
True
TileDeviceTracker.source_type
(self)
Return the source type, eg gps or router, of the device.
Return the source type, eg gps or router, of the device.
def source_type(self): """Return the source type, eg gps or router, of the device.""" return SOURCE_TYPE_GPS
[ "def", "source_type", "(", "self", ")", ":", "return", "SOURCE_TYPE_GPS" ]
[ 118, 4 ]
[ 120, 30 ]
python
en
['en', 'en', 'en']
True
TileDeviceTracker._update_from_latest_data
(self)
Update the entity from the latest data.
Update the entity from the latest data.
def _update_from_latest_data(self): """Update the entity from the latest data.""" self._tile = self.coordinator.data[self._tile_uuid] self._attrs[ATTR_ALTITUDE] = self._tile["last_tile_state"]["altitude"] self._attrs[ATTR_IS_LOST] = self._tile["last_tile_state"]["is_lost"] self._...
[ "def", "_update_from_latest_data", "(", "self", ")", ":", "self", ".", "_tile", "=", "self", ".", "coordinator", ".", "data", "[", "self", ".", "_tile_uuid", "]", "self", ".", "_attrs", "[", "ATTR_ALTITUDE", "]", "=", "self", ".", "_tile", "[", "\"last_t...
[ 123, 4 ]
[ 129, 82 ]
python
en
['en', 'en', 'en']
True
separate_process_wrapper_fn
(func: Callable[[], None], do_multi_processing: bool)
This function wraps another function into its own separated process. In order to ensure accurate memory measurements it is important that the function is executed in a separate process Args: - `func`: (`callable`): function() -> ... generic function which will be executed in its own separate proc...
This function wraps another function into its own separated process. In order to ensure accurate memory measurements it is important that the function is executed in a separate process
def separate_process_wrapper_fn(func: Callable[[], None], do_multi_processing: bool) -> Callable[[], None]: """ This function wraps another function into its own separated process. In order to ensure accurate memory measurements it is important that the function is executed in a separate process Args: ...
[ "def", "separate_process_wrapper_fn", "(", "func", ":", "Callable", "[", "[", "]", ",", "None", "]", ",", "do_multi_processing", ":", "bool", ")", "->", "Callable", "[", "[", "]", ",", "None", "]", ":", "def", "multi_process_func", "(", "*", "args", ",",...
[ 75, 0 ]
[ 109, 19 ]
python
en
['en', 'error', 'th']
False
measure_peak_memory_cpu
(function: Callable[[], None], interval=0.5, device_idx=None)
measures peak cpu memory consumption of a given `function` running the function for at least interval seconds and at most 20 * interval seconds. This function is heavily inspired by: `memory_usage` of the package `memory_profiler`: https://github.com/pythonprofilers/memory_profiler/blob/895c4ac7a08020d...
measures peak cpu memory consumption of a given `function` running the function for at least interval seconds and at most 20 * interval seconds. This function is heavily inspired by: `memory_usage` of the package `memory_profiler`: https://github.com/pythonprofilers/memory_profiler/blob/895c4ac7a08020d...
def measure_peak_memory_cpu(function: Callable[[], None], interval=0.5, device_idx=None) -> int: """ measures peak cpu memory consumption of a given `function` running the function for at least interval seconds and at most 20 * interval seconds. This function is heavily inspired by: `memory_usage` of the pa...
[ "def", "measure_peak_memory_cpu", "(", "function", ":", "Callable", "[", "[", "]", ",", "None", "]", ",", "interval", "=", "0.5", ",", "device_idx", "=", "None", ")", "->", "int", ":", "def", "get_cpu_memory", "(", "process_id", ":", "int", ")", "->", ...
[ 204, 0 ]
[ 322, 25 ]
python
en
['en', 'error', 'th']
False
start_memory_tracing
( modules_to_trace: Optional[Union[str, Iterable[str]]] = None, modules_not_to_trace: Optional[Union[str, Iterable[str]]] = None, events_to_trace: str = "line", gpus_to_trace: Optional[List[int]] = None, )
Setup line-by-line tracing to record rss mem (RAM) at each line of a module or sub-module. See `./benchmark.py` for usage examples. Current memory consumption is returned using psutil and in particular is the RSS memory "Resident Set Size” (the non-swapped physical memory the process is using). See htt...
Setup line-by-line tracing to record rss mem (RAM) at each line of a module or sub-module. See `./benchmark.py` for usage examples. Current memory consumption is returned using psutil and in particular is the RSS memory "Resident Set Size” (the non-swapped physical memory the process is using). See htt...
def start_memory_tracing( modules_to_trace: Optional[Union[str, Iterable[str]]] = None, modules_not_to_trace: Optional[Union[str, Iterable[str]]] = None, events_to_trace: str = "line", gpus_to_trace: Optional[List[int]] = None, ) -> MemoryTrace: """ Setup line-by-line tracing to record rss mem (...
[ "def", "start_memory_tracing", "(", "modules_to_trace", ":", "Optional", "[", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", "]", "=", "None", ",", "modules_not_to_trace", ":", "Optional", "[", "Union", "[", "str", ",", "Iterable", "[", "str",...
[ 325, 0 ]
[ 475, 23 ]
python
en
['en', 'error', 'th']
False
stop_memory_tracing
( memory_trace: Optional[MemoryTrace] = None, ignore_released_memory: bool = True )
Stop memory tracing cleanly and return a summary of the memory trace if a trace is given. Args: `memory_trace` (optional output of start_memory_tracing, default: None): memory trace to convert in summary `ignore_released_memory` (boolean, default: None): if True we onl...
Stop memory tracing cleanly and return a summary of the memory trace if a trace is given.
def stop_memory_tracing( memory_trace: Optional[MemoryTrace] = None, ignore_released_memory: bool = True ) -> Optional[MemorySummary]: """ Stop memory tracing cleanly and return a summary of the memory trace if a trace is given. Args: `memory_trace` (optional output of start_memory_tracing, de...
[ "def", "stop_memory_tracing", "(", "memory_trace", ":", "Optional", "[", "MemoryTrace", "]", "=", "None", ",", "ignore_released_memory", ":", "bool", "=", "True", ")", "->", "Optional", "[", "MemorySummary", "]", ":", "global", "_is_memory_tracing_enabled", "_is_m...
[ 478, 0 ]
[ 592, 15 ]
python
en
['en', 'error', 'th']
False
bytes_to_mega_bytes
(memory_amount: int)
Utility to convert a number of bytes (int) into a number of mega bytes (int)
Utility to convert a number of bytes (int) into a number of mega bytes (int)
def bytes_to_mega_bytes(memory_amount: int) -> int: """Utility to convert a number of bytes (int) into a number of mega bytes (int)""" return memory_amount >> 20
[ "def", "bytes_to_mega_bytes", "(", "memory_amount", ":", "int", ")", "->", "int", ":", "return", "memory_amount", ">>", "20" ]
[ 595, 0 ]
[ 597, 30 ]
python
en
['en', 'en', 'en']
True
train
(args)
@nni.variable(nni.choice('UNetResNetV4', 'UNetResNetV5', 'UNetResNetV6'), name=model_name)
def train(args): print('start training...') """@nni.variable(nni.choice('UNetResNetV4', 'UNetResNetV5', 'UNetResNetV6'), name=model_name)""" model_name = args.model_name model = eval(model_name)(args.layers, num_filters=args.nf) model_subdir = args.pad_mode if args.meta_version == 2: m...
[ "def", "train", "(", "args", ")", ":", "print", "(", "'start training...'", ")", "model_name", "=", "args", ".", "model_name", "model", "=", "eval", "(", "model_name", ")", "(", "args", ".", "layers", ",", "num_filters", "=", "args", ".", "nf", ")", "m...
[ 57, 0 ]
[ 164, 45 ]
python
en
['en', 'gl', 'sw']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Perform the setup for Xiaomi devices.
Perform the setup for Xiaomi devices.
async def async_setup_entry(hass, config_entry, async_add_entities): """Perform the setup for Xiaomi devices.""" entities = [] gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id] for device in gateway.devices["sensor"]: if device["model"] == "sensor_ht": entities.append(...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "]", "gateway", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "GATEWAYS_KEY", "]", "[", "config_entry", ".", "entry_id", ...
[ 34, 0 ]
[ 106, 32 ]
python
en
['en', 'en', 'en']
True
XiaomiSensor.__init__
(self, device, name, data_key, xiaomi_hub, config_entry)
Initialize the XiaomiSensor.
Initialize the XiaomiSensor.
def __init__(self, device, name, data_key, xiaomi_hub, config_entry): """Initialize the XiaomiSensor.""" self._data_key = data_key super().__init__(device, name, xiaomi_hub, config_entry)
[ "def", "__init__", "(", "self", ",", "device", ",", "name", ",", "data_key", ",", "xiaomi_hub", ",", "config_entry", ")", ":", "self", ".", "_data_key", "=", "data_key", "super", "(", ")", ".", "__init__", "(", "device", ",", "name", ",", "xiaomi_hub", ...
[ 112, 4 ]
[ 115, 64 ]
python
en
['en', 'en', 'en']
True
XiaomiSensor.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.""" try: return SENSOR_TYPES.get(self._data_key)[1] except TypeError: return None
[ "def", "icon", "(", "self", ")", ":", "try", ":", "return", "SENSOR_TYPES", ".", "get", "(", "self", ".", "_data_key", ")", "[", "1", "]", "except", "TypeError", ":", "return", "None" ]
[ 118, 4 ]
[ 123, 23 ]
python
en
['en', 'en', 'en']
True
XiaomiSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" try: return SENSOR_TYPES.get(self._data_key)[0] except TypeError: return None
[ "def", "unit_of_measurement", "(", "self", ")", ":", "try", ":", "return", "SENSOR_TYPES", ".", "get", "(", "self", ".", "_data_key", ")", "[", "0", "]", "except", "TypeError", ":", "return", "None" ]
[ 126, 4 ]
[ 131, 23 ]
python
en
['en', 'en', 'en']
True
XiaomiSensor.device_class
(self)
Return the device class of this entity.
Return the device class of this entity.
def device_class(self): """Return the device class of this entity.""" return ( SENSOR_TYPES.get(self._data_key)[2] if self._data_key in SENSOR_TYPES else None )
[ "def", "device_class", "(", "self", ")", ":", "return", "(", "SENSOR_TYPES", ".", "get", "(", "self", ".", "_data_key", ")", "[", "2", "]", "if", "self", ".", "_data_key", "in", "SENSOR_TYPES", "else", "None", ")" ]
[ 134, 4 ]
[ 140, 9 ]
python
en
['en', 'en', 'en']
True
XiaomiSensor.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" ]
[ 143, 4 ]
[ 145, 26 ]
python
en
['en', 'en', 'en']
True
XiaomiSensor.parse_data
(self, data, raw_data)
Parse data sent by gateway.
Parse data sent by gateway.
def parse_data(self, data, raw_data): """Parse data sent by gateway.""" value = data.get(self._data_key) if value is None: return False if self._data_key in ["coordination", "status"]: self._state = value return True value = float(value) ...
[ "def", "parse_data", "(", "self", ",", "data", ",", "raw_data", ")", ":", "value", "=", "data", ".", "get", "(", "self", ".", "_data_key", ")", "if", "value", "is", "None", ":", "return", "False", "if", "self", ".", "_data_key", "in", "[", "\"coordin...
[ 147, 4 ]
[ 170, 19 ]
python
en
['en', 'de', 'en']
True
XiaomiBatterySensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self): """Return the unit of measurement of this entity, if any.""" return PERCENTAGE
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "PERCENTAGE" ]
[ 177, 4 ]
[ 179, 25 ]
python
en
['en', 'en', 'en']
True
XiaomiBatterySensor.device_class
(self)
Return the device class of this entity.
Return the device class of this entity.
def device_class(self): """Return the device class of this entity.""" return DEVICE_CLASS_BATTERY
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_BATTERY" ]
[ 182, 4 ]
[ 184, 35 ]
python
en
['en', 'en', 'en']
True
XiaomiBatterySensor.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" ]
[ 187, 4 ]
[ 189, 26 ]
python
en
['en', 'en', 'en']
True
XiaomiBatterySensor.parse_data
(self, data, raw_data)
Parse data sent by gateway.
Parse data sent by gateway.
def parse_data(self, data, raw_data): """Parse data sent by gateway.""" succeed = super().parse_voltage(data) if not succeed: return False battery_level = int(self._device_state_attributes.pop(ATTR_BATTERY_LEVEL)) if battery_level <= 0 or battery_level > 100: ...
[ "def", "parse_data", "(", "self", ",", "data", ",", "raw_data", ")", ":", "succeed", "=", "super", "(", ")", ".", "parse_voltage", "(", "data", ")", "if", "not", "succeed", ":", "return", "False", "battery_level", "=", "int", "(", "self", ".", "_device...
[ 191, 4 ]
[ 200, 19 ]
python
en
['en', 'de', 'en']
True
XiaomiBatterySensor.parse_voltage
(self, data)
Parse battery level data sent by gateway.
Parse battery level data sent by gateway.
def parse_voltage(self, data): """Parse battery level data sent by gateway.""" return False
[ "def", "parse_voltage", "(", "self", ",", "data", ")", ":", "return", "False" ]
[ 202, 4 ]
[ 204, 20 ]
python
en
['en', 'en', 'en']
True
test_form_user
(hass)
Test we get the form with user source.
Test we get the form with user source.
async def test_form_user(hass): """Test we get the form with user source.""" await setup.async_setup_component(hass, "persistent_notification", {}) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) assert result["type"] == "form" ...
[ "async", "def", "test_form_user", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init",...
[ 12, 0 ]
[ 52, 48 ]
python
en
['en', 'en', 'en']
True
test_form_import
(hass)
Test we get the form with import source.
Test we get the form with import source.
async def test_form_import(hass): """Test we get the form with import source.""" await setup.async_setup_component(hass, "persistent_notification", {}) mock_thermostat = _get_mock_thermostat_run() with patch( "homeassistant.components.nuheat.config_flow.nuheat.NuHeat.authenticate", ret...
[ "async", "def", "test_form_import", "(", "hass", ")", ":", "await", "setup", ".", "async_setup_component", "(", "hass", ",", "\"persistent_notification\"", ",", "{", "}", ")", "mock_thermostat", "=", "_get_mock_thermostat_run", "(", ")", "with", "patch", "(", "\...
[ 55, 0 ]
[ 91, 48 ]
python
en
['en', 'en', 'en']
True
test_form_invalid_auth
(hass)
Test we handle invalid auth.
Test we handle invalid auth.
async def test_form_invalid_auth(hass): """Test we handle invalid auth.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.nuheat.config_flow.nuheat.NuHeat.authenticate", side_effe...
[ "async", "def", "test_form_invalid_auth", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", ")"...
[ 94, 0 ]
[ 132, 56 ]
python
en
['en', 'en', 'en']
True
test_form_invalid_thermostat
(hass)
Test we handle invalid thermostats.
Test we handle invalid thermostats.
async def test_form_invalid_thermostat(hass): """Test we handle invalid thermostats.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) response_mock = MagicMock() type(response_mock).status_code = HTTP_INTERNAL_SERVER_ERROR ...
[ "async", "def", "test_form_invalid_thermostat", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}",...
[ 135, 0 ]
[ 161, 62 ]
python
en
['en', 'en', 'en']
True
test_form_cannot_connect
(hass)
Test we handle cannot connect error.
Test we handle cannot connect error.
async def test_form_cannot_connect(hass): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) with patch( "homeassistant.components.nuheat.config_flow.nuheat.NuHeat.authenticate", ...
[ "async", "def", "test_form_cannot_connect", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "config_entries", ".", "SOURCE_USER", "}", "...
[ 164, 0 ]
[ 184, 58 ]
python
en
['en', 'en', 'en']
True
max_pool2d
(A, kernel_size=3, stride=1, padding=1)
2D Max Pooling Parameters: A: input 2D array kernel_size: int, the size of the window stride: int, the stride of the window padding: int, implicit zero paddings on both sides of the input
2D Max Pooling Parameters: A: input 2D array kernel_size: int, the size of the window stride: int, the stride of the window padding: int, implicit zero paddings on both sides of the input
def max_pool2d(A, kernel_size=3, stride=1, padding=1): """2D Max Pooling Parameters: A: input 2D array kernel_size: int, the size of the window stride: int, the stride of the window padding: int, implicit zero paddings on both sides of the input """ A = np.pad(A, padding,...
[ "def", "max_pool2d", "(", "A", ",", "kernel_size", "=", "3", ",", "stride", "=", "1", ",", "padding", "=", "1", ")", ":", "A", "=", "np", ".", "pad", "(", "A", ",", "padding", ",", "mode", "=", "'constant'", ")", "output_shape", "=", "(", "(", ...
[ 33, 0 ]
[ 48, 53 ]
python
en
['en', 'bg', 'en']
True
load_corpus
(name, download=True)
Loads and wrangles the passed in text corpus by name. If download is specified, this method will download any missing files. Note: This function is slightly different to the `load_data` function used above to load pandas dataframes into memory.
Loads and wrangles the passed in text corpus by name. If download is specified, this method will download any missing files.
def load_corpus(name, download=True): """ Loads and wrangles the passed in text corpus by name. If download is specified, this method will download any missing files. Note: This function is slightly different to the `load_data` function used above to load pandas dataframes into memory. """ ...
[ "def", "load_corpus", "(", "name", ",", "download", "=", "True", ")", ":", "# Get the path from the datasets", "path", "=", "corpora", "[", "name", "]", "# Check if the data exists, otherwise download or raise", "if", "not", "os", ".", "path", ".", "exists", "(", ...
[ 14, 0 ]
[ 58, 5 ]
python
en
['en', 'error', 'th']
False
_calc_banned_ngram_tokens
( ngram_size: int, prev_input_ids: torch.Tensor, num_hypos: int, cur_len: int )
Copied from fairseq for no_repeat_ngram in beam_search
Copied from fairseq for no_repeat_ngram in beam_search
def _calc_banned_ngram_tokens( ngram_size: int, prev_input_ids: torch.Tensor, num_hypos: int, cur_len: int ) -> List[Iterable[int]]: """Copied from fairseq for no_repeat_ngram in beam_search""" if cur_len + 1 < ngram_size: # return no banned tokens if we haven't generated no_repeat_ngram_size tokens...
[ "def", "_calc_banned_ngram_tokens", "(", "ngram_size", ":", "int", ",", "prev_input_ids", ":", "torch", ".", "Tensor", ",", "num_hypos", ":", "int", ",", "cur_len", ":", "int", ")", "->", "List", "[", "Iterable", "[", "int", "]", "]", ":", "if", "cur_len...
[ 259, 0 ]
[ 273, 24 ]
python
en
['en', 'en', 'en']
True
LogitsProcessor.__call__
(self, input_ids: torch.LongTensor, scores: torch.FloatTensor)
Torch method for processing logits.
Torch method for processing logits.
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor: """Torch method for processing logits.""" raise NotImplementedError( f"{self.__class__} is an abstract class. Only classes inheriting this class can be called." )
[ "def", "__call__", "(", "self", ",", "input_ids", ":", "torch", ".", "LongTensor", ",", "scores", ":", "torch", ".", "FloatTensor", ")", "->", "torch", ".", "FloatTensor", ":", "raise", "NotImplementedError", "(", "f\"{self.__class__} is an abstract class. Only clas...
[ 56, 4 ]
[ 60, 9 ]
python
en
['en', 'en', 'en']
True
LogitsWarper.__call__
(self, input_ids: torch.LongTensor, scores: torch.FloatTensor)
Torch method for warping logits.
Torch method for warping logits.
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor: """Torch method for warping logits.""" raise NotImplementedError( f"{self.__class__} is an abstract class. Only classes inheriting this class can be called." )
[ "def", "__call__", "(", "self", ",", "input_ids", ":", "torch", ".", "LongTensor", ",", "scores", ":", "torch", ".", "FloatTensor", ")", "->", "torch", ".", "FloatTensor", ":", "raise", "NotImplementedError", "(", "f\"{self.__class__} is an abstract class. Only clas...
[ 67, 4 ]
[ 71, 9 ]
python
en
['en', 'en', 'en']
True
NoBadWordsLogitsProcessor._set_scores_to_inf_for_banned_tokens
(self, scores: torch.Tensor, banned_tokens: List[List[int]])
Modifies the scores in place by setting the banned token positions to `-inf`. Banned token is expected to be a list of list of banned tokens to ban in the format [[batch index, vocabulary position],... Args: scores: logits distribution of shape (batch size, vocabulary size) ...
Modifies the scores in place by setting the banned token positions to `-inf`. Banned token is expected to be a list of list of banned tokens to ban in the format [[batch index, vocabulary position],...
def _set_scores_to_inf_for_banned_tokens(self, scores: torch.Tensor, banned_tokens: List[List[int]]) -> None: """ Modifies the scores in place by setting the banned token positions to `-inf`. Banned token is expected to be a list of list of banned tokens to ban in the format [[batch index, vocab...
[ "def", "_set_scores_to_inf_for_banned_tokens", "(", "self", ",", "scores", ":", "torch", ".", "Tensor", ",", "banned_tokens", ":", "List", "[", "List", "[", "int", "]", "]", ")", "->", "None", ":", "banned_mask_list", "=", "[", "]", "for", "idx", ",", "b...
[ 411, 4 ]
[ 445, 21 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the deCONZ binary sensor.
Set up the deCONZ binary sensor.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the deCONZ binary sensor.""" gateway = get_gateway_from_config_entry(hass, config_entry) gateway.entities[DOMAIN] = set() @callback def async_add_sensor(sensors): """Add binary sensor from deCONZ.""" enti...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "gateway", "=", "get_gateway_from_config_entry", "(", "hass", ",", "config_entry", ")", "gateway", ".", "entities", "[", "DOMAIN", "]", "=", "set", "(", ...
[ 35, 0 ]
[ 68, 5 ]
python
en
['en', 'pt', 'en']
True
DeconzBinarySensor.async_update_callback
(self, force_update=False)
Update the sensor's state.
Update the sensor's state.
def async_update_callback(self, force_update=False): """Update the sensor's state.""" keys = {"on", "reachable", "state"} if force_update or self._device.changed_keys.intersection(keys): super().async_update_callback(force_update=force_update)
[ "def", "async_update_callback", "(", "self", ",", "force_update", "=", "False", ")", ":", "keys", "=", "{", "\"on\"", ",", "\"reachable\"", ",", "\"state\"", "}", "if", "force_update", "or", "self", ".", "_device", ".", "changed_keys", ".", "intersection", "...
[ 77, 4 ]
[ 81, 68 ]
python
en
['en', 'en', 'en']
True
DeconzBinarySensor.is_on
(self)
Return true if sensor is on.
Return true if sensor is on.
def is_on(self): """Return true if sensor is on.""" return self._device.is_tripped
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "is_tripped" ]
[ 84, 4 ]
[ 86, 38 ]
python
en
['en', 'et', 'en']
True
DeconzBinarySensor.device_class
(self)
Return the class of the sensor.
Return the class of the sensor.
def device_class(self): """Return the class of the sensor.""" return DEVICE_CLASS.get(type(self._device))
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS", ".", "get", "(", "type", "(", "self", ".", "_device", ")", ")" ]
[ 89, 4 ]
[ 91, 51 ]
python
en
['en', 'pt', 'en']
True
DeconzBinarySensor.device_state_attributes
(self)
Return the state attributes of the sensor.
Return the state attributes of the sensor.
def device_state_attributes(self): """Return the state attributes of the sensor.""" attr = {} if self._device.on is not None: attr[ATTR_ON] = self._device.on if self._device.secondary_temperature is not None: attr[ATTR_TEMPERATURE] = self._device.secondary_tempe...
[ "def", "device_state_attributes", "(", "self", ")", ":", "attr", "=", "{", "}", "if", "self", ".", "_device", ".", "on", "is", "not", "None", ":", "attr", "[", "ATTR_ON", "]", "=", "self", ".", "_device", ".", "on", "if", "self", ".", "_device", "....
[ 94, 4 ]
[ 114, 19 ]
python
en
['en', 'en', 'en']
True
async_set_preset_mode
(hass, preset_mode, entity_id=ENTITY_MATCH_ALL)
Set new preset mode.
Set new preset mode.
async def async_set_preset_mode(hass, preset_mode, entity_id=ENTITY_MATCH_ALL): """Set new preset mode.""" data = {ATTR_PRESET_MODE: preset_mode} if entity_id: data[ATTR_ENTITY_ID] = entity_id await hass.services.async_call(DOMAIN, SERVICE_SET_PRESET_MODE, data, blocking=True)
[ "async", "def", "async_set_preset_mode", "(", "hass", ",", "preset_mode", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_PRESET_MODE", ":", "preset_mode", "}", "if", "entity_id", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "enti...
[ 34, 0 ]
[ 41, 88 ]
python
en
['en', 'sr', 'en']
True
set_preset_mode
(hass, preset_mode, entity_id=ENTITY_MATCH_ALL)
Set new preset mode.
Set new preset mode.
def set_preset_mode(hass, preset_mode, entity_id=ENTITY_MATCH_ALL): """Set new preset mode.""" data = {ATTR_PRESET_MODE: preset_mode} if entity_id: data[ATTR_ENTITY_ID] = entity_id hass.services.call(DOMAIN, SERVICE_SET_PRESET_MODE, data)
[ "def", "set_preset_mode", "(", "hass", ",", "preset_mode", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_PRESET_MODE", ":", "preset_mode", "}", "if", "entity_id", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "entity_id", "hass",...
[ 45, 0 ]
[ 52, 61 ]
python
en
['en', 'sr', 'en']
True
async_set_aux_heat
(hass, aux_heat, entity_id=ENTITY_MATCH_ALL)
Turn all or specified climate devices auxiliary heater on.
Turn all or specified climate devices auxiliary heater on.
async def async_set_aux_heat(hass, aux_heat, entity_id=ENTITY_MATCH_ALL): """Turn all or specified climate devices auxiliary heater on.""" data = {ATTR_AUX_HEAT: aux_heat} if entity_id: data[ATTR_ENTITY_ID] = entity_id await hass.services.async_call(DOMAIN, SERVICE_SET_AUX_HEAT, data, blocking...
[ "async", "def", "async_set_aux_heat", "(", "hass", ",", "aux_heat", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_AUX_HEAT", ":", "aux_heat", "}", "if", "entity_id", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "entity_id", "a...
[ 55, 0 ]
[ 62, 85 ]
python
en
['fr', 'en', 'en']
True
set_aux_heat
(hass, aux_heat, entity_id=ENTITY_MATCH_ALL)
Turn all or specified climate devices auxiliary heater on.
Turn all or specified climate devices auxiliary heater on.
def set_aux_heat(hass, aux_heat, entity_id=ENTITY_MATCH_ALL): """Turn all or specified climate devices auxiliary heater on.""" data = {ATTR_AUX_HEAT: aux_heat} if entity_id: data[ATTR_ENTITY_ID] = entity_id hass.services.call(DOMAIN, SERVICE_SET_AUX_HEAT, data)
[ "def", "set_aux_heat", "(", "hass", ",", "aux_heat", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_AUX_HEAT", ":", "aux_heat", "}", "if", "entity_id", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "entity_id", "hass", ".", "s...
[ 66, 0 ]
[ 73, 58 ]
python
en
['fr', 'en', 'en']
True
async_set_temperature
( hass, temperature=None, entity_id=ENTITY_MATCH_ALL, target_temp_high=None, target_temp_low=None, hvac_mode=None, )
Set new target temperature.
Set new target temperature.
async def async_set_temperature( hass, temperature=None, entity_id=ENTITY_MATCH_ALL, target_temp_high=None, target_temp_low=None, hvac_mode=None, ): """Set new target temperature.""" kwargs = { key: value for key, value in [ (ATTR_TEMPERATURE, temperature), ...
[ "async", "def", "async_set_temperature", "(", "hass", ",", "temperature", "=", "None", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ",", "target_temp_high", "=", "None", ",", "target_temp_low", "=", "None", ",", "hvac_mode", "=", "None", ",", ")", ":", "kwargs",...
[ 76, 0 ]
[ 99, 5 ]
python
en
['en', 'ca', 'en']
True
set_temperature
( hass, temperature=None, entity_id=ENTITY_MATCH_ALL, target_temp_high=None, target_temp_low=None, hvac_mode=None, )
Set new target temperature.
Set new target temperature.
def set_temperature( hass, temperature=None, entity_id=ENTITY_MATCH_ALL, target_temp_high=None, target_temp_low=None, hvac_mode=None, ): """Set new target temperature.""" kwargs = { key: value for key, value in [ (ATTR_TEMPERATURE, temperature), (A...
[ "def", "set_temperature", "(", "hass", ",", "temperature", "=", "None", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ",", "target_temp_high", "=", "None", ",", "target_temp_low", "=", "None", ",", "hvac_mode", "=", "None", ",", ")", ":", "kwargs", "=", "{", ...
[ 103, 0 ]
[ 124, 63 ]
python
en
['en', 'ca', 'en']
True
async_set_humidity
(hass, humidity, entity_id=ENTITY_MATCH_ALL)
Set new target humidity.
Set new target humidity.
async def async_set_humidity(hass, humidity, entity_id=ENTITY_MATCH_ALL): """Set new target humidity.""" data = {ATTR_HUMIDITY: humidity} if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id await hass.services.async_call(DOMAIN, SERVICE_SET_HUMIDITY, data, blocking=True)
[ "async", "def", "async_set_humidity", "(", "hass", ",", "humidity", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_HUMIDITY", ":", "humidity", "}", "if", "entity_id", "is", "not", "None", ":", "data", "[", "ATTR_ENTITY_ID", "]",...
[ 127, 0 ]
[ 134, 85 ]
python
en
['en', 'en', 'en']
True
set_humidity
(hass, humidity, entity_id=ENTITY_MATCH_ALL)
Set new target humidity.
Set new target humidity.
def set_humidity(hass, humidity, entity_id=ENTITY_MATCH_ALL): """Set new target humidity.""" data = {ATTR_HUMIDITY: humidity} if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id hass.services.call(DOMAIN, SERVICE_SET_HUMIDITY, data)
[ "def", "set_humidity", "(", "hass", ",", "humidity", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_HUMIDITY", ":", "humidity", "}", "if", "entity_id", "is", "not", "None", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "entity...
[ 138, 0 ]
[ 145, 58 ]
python
en
['en', 'en', 'en']
True
async_set_fan_mode
(hass, fan, entity_id=ENTITY_MATCH_ALL)
Set all or specified climate devices fan mode on.
Set all or specified climate devices fan mode on.
async def async_set_fan_mode(hass, fan, entity_id=ENTITY_MATCH_ALL): """Set all or specified climate devices fan mode on.""" data = {ATTR_FAN_MODE: fan} if entity_id: data[ATTR_ENTITY_ID] = entity_id await hass.services.async_call(DOMAIN, SERVICE_SET_FAN_MODE, data, blocking=True)
[ "async", "def", "async_set_fan_mode", "(", "hass", ",", "fan", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_FAN_MODE", ":", "fan", "}", "if", "entity_id", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "entity_id", "await", "...
[ 148, 0 ]
[ 155, 85 ]
python
en
['en', 'en', 'en']
True
set_fan_mode
(hass, fan, entity_id=ENTITY_MATCH_ALL)
Set all or specified climate devices fan mode on.
Set all or specified climate devices fan mode on.
def set_fan_mode(hass, fan, entity_id=ENTITY_MATCH_ALL): """Set all or specified climate devices fan mode on.""" data = {ATTR_FAN_MODE: fan} if entity_id: data[ATTR_ENTITY_ID] = entity_id hass.services.call(DOMAIN, SERVICE_SET_FAN_MODE, data)
[ "def", "set_fan_mode", "(", "hass", ",", "fan", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_FAN_MODE", ":", "fan", "}", "if", "entity_id", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "entity_id", "hass", ".", "services", ...
[ 159, 0 ]
[ 166, 58 ]
python
en
['en', 'en', 'en']
True
async_set_hvac_mode
(hass, hvac_mode, entity_id=ENTITY_MATCH_ALL)
Set new target operation mode.
Set new target operation mode.
async def async_set_hvac_mode(hass, hvac_mode, entity_id=ENTITY_MATCH_ALL): """Set new target operation mode.""" data = {ATTR_HVAC_MODE: hvac_mode} if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id await hass.services.async_call(DOMAIN, SERVICE_SET_HVAC_MODE, data, blocking=True)
[ "async", "def", "async_set_hvac_mode", "(", "hass", ",", "hvac_mode", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_HVAC_MODE", ":", "hvac_mode", "}", "if", "entity_id", "is", "not", "None", ":", "data", "[", "ATTR_ENTITY_ID", ...
[ 169, 0 ]
[ 176, 86 ]
python
en
['nl', 'en', 'en']
True
set_operation_mode
(hass, hvac_mode, entity_id=ENTITY_MATCH_ALL)
Set new target operation mode.
Set new target operation mode.
def set_operation_mode(hass, hvac_mode, entity_id=ENTITY_MATCH_ALL): """Set new target operation mode.""" data = {ATTR_HVAC_MODE: hvac_mode} if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id hass.services.call(DOMAIN, SERVICE_SET_HVAC_MODE, data)
[ "def", "set_operation_mode", "(", "hass", ",", "hvac_mode", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_HVAC_MODE", ":", "hvac_mode", "}", "if", "entity_id", "is", "not", "None", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", ...
[ 180, 0 ]
[ 187, 59 ]
python
en
['nl', 'en', 'en']
True
async_set_swing_mode
(hass, swing_mode, entity_id=ENTITY_MATCH_ALL)
Set new target swing mode.
Set new target swing mode.
async def async_set_swing_mode(hass, swing_mode, entity_id=ENTITY_MATCH_ALL): """Set new target swing mode.""" data = {ATTR_SWING_MODE: swing_mode} if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id await hass.services.async_call(DOMAIN, SERVICE_SET_SWING_MODE, data, blocking=True)
[ "async", "def", "async_set_swing_mode", "(", "hass", ",", "swing_mode", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_SWING_MODE", ":", "swing_mode", "}", "if", "entity_id", "is", "not", "None", ":", "data", "[", "ATTR_ENTITY_ID"...
[ 190, 0 ]
[ 197, 87 ]
python
en
['en', 'jv', 'en']
True
set_swing_mode
(hass, swing_mode, entity_id=ENTITY_MATCH_ALL)
Set new target swing mode.
Set new target swing mode.
def set_swing_mode(hass, swing_mode, entity_id=ENTITY_MATCH_ALL): """Set new target swing mode.""" data = {ATTR_SWING_MODE: swing_mode} if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id hass.services.call(DOMAIN, SERVICE_SET_SWING_MODE, data)
[ "def", "set_swing_mode", "(", "hass", ",", "swing_mode", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "ATTR_SWING_MODE", ":", "swing_mode", "}", "if", "entity_id", "is", "not", "None", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", ...
[ 201, 0 ]
[ 208, 60 ]
python
en
['en', 'jv', 'en']
True
async_turn_on
(hass, entity_id=ENTITY_MATCH_ALL)
Turn on device.
Turn on device.
async def async_turn_on(hass, entity_id=ENTITY_MATCH_ALL): """Turn on device.""" data = {} if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id await hass.services.async_call(DOMAIN, SERVICE_TURN_ON, data, blocking=True)
[ "async", "def", "async_turn_on", "(", "hass", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "}", "if", "entity_id", "is", "not", "None", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "entity_id", "await", "hass", ".", "services", ...
[ 211, 0 ]
[ 218, 80 ]
python
en
['fr', 'en', 'en']
True
async_turn_off
(hass, entity_id=ENTITY_MATCH_ALL)
Turn off device.
Turn off device.
async def async_turn_off(hass, entity_id=ENTITY_MATCH_ALL): """Turn off device.""" data = {} if entity_id is not None: data[ATTR_ENTITY_ID] = entity_id await hass.services.async_call(DOMAIN, SERVICE_TURN_OFF, data, blocking=True)
[ "async", "def", "async_turn_off", "(", "hass", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ")", ":", "data", "=", "{", "}", "if", "entity_id", "is", "not", "None", ":", "data", "[", "ATTR_ENTITY_ID", "]", "=", "entity_id", "await", "hass", ".", "services", ...
[ 221, 0 ]
[ 228, 81 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up esphome cameras based on a config entry.
Set up esphome cameras based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up esphome cameras based on a config entry.""" await platform_async_setup_entry( hass, entry, async_add_entities, component_key="camera", info_type=CameraInf...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "await", "platform_async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ",", "comp...
[ 15, 0 ]
[ 27, 5 ]
python
en
['en', 'en', 'en']
True
EsphomeCamera.__init__
(self, entry_id: str, component_key: str, key: int)
Initialize.
Initialize.
def __init__(self, entry_id: str, component_key: str, key: int): """Initialize.""" Camera.__init__(self) EsphomeBaseEntity.__init__(self, entry_id, component_key, key) self._image_cond = asyncio.Condition()
[ "def", "__init__", "(", "self", ",", "entry_id", ":", "str", ",", "component_key", ":", "str", ",", "key", ":", "int", ")", ":", "Camera", ".", "__init__", "(", "self", ")", "EsphomeBaseEntity", ".", "__init__", "(", "self", ",", "entry_id", ",", "comp...
[ 33, 4 ]
[ 37, 46 ]
python
en
['en', 'en', 'it']
False
EsphomeCamera.async_added_to_hass
(self)
Register callbacks.
Register callbacks.
async def async_added_to_hass(self) -> None: """Register callbacks.""" await super().async_added_to_hass() self.async_on_remove( async_dispatcher_connect( self.hass, ( f"esphome_{self._entry_id}" f"_update_{sel...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "(", "f\"esphome_{self...
[ 47, 4 ]
[ 61, 9 ]
python
en
['en', 'no', 'en']
False
EsphomeCamera._on_state_update
(self)
Notify listeners of new image when update arrives.
Notify listeners of new image when update arrives.
async def _on_state_update(self) -> None: """Notify listeners of new image when update arrives.""" self.async_write_ha_state() async with self._image_cond: self._image_cond.notify_all()
[ "async", "def", "_on_state_update", "(", "self", ")", "->", "None", ":", "self", ".", "async_write_ha_state", "(", ")", "async", "with", "self", ".", "_image_cond", ":", "self", ".", "_image_cond", ".", "notify_all", "(", ")" ]
[ 63, 4 ]
[ 67, 41 ]
python
en
['en', 'en', 'en']
True
EsphomeCamera.async_camera_image
(self)
Return single camera image bytes.
Return single camera image bytes.
async def async_camera_image(self) -> Optional[bytes]: """Return single camera image bytes.""" if not self.available: return None await self._client.request_single_image() async with self._image_cond: await self._image_cond.wait() if not self.available...
[ "async", "def", "async_camera_image", "(", "self", ")", "->", "Optional", "[", "bytes", "]", ":", "if", "not", "self", ".", "available", ":", "return", "None", "await", "self", ".", "_client", ".", "request_single_image", "(", ")", "async", "with", "self",...
[ 69, 4 ]
[ 78, 39 ]
python
en
['es', 'zu', 'en']
False
EsphomeCamera._async_camera_stream_image
(self)
Return a single camera image in a stream.
Return a single camera image in a stream.
async def _async_camera_stream_image(self) -> Optional[bytes]: """Return a single camera image in a stream.""" if not self.available: return None await self._client.request_image_stream() async with self._image_cond: await self._image_cond.wait() if no...
[ "async", "def", "_async_camera_stream_image", "(", "self", ")", "->", "Optional", "[", "bytes", "]", ":", "if", "not", "self", ".", "available", ":", "return", "None", "await", "self", ".", "_client", ".", "request_image_stream", "(", ")", "async", "with", ...
[ 80, 4 ]
[ 89, 39 ]
python
en
['en', 'co', 'en']
True
EsphomeCamera.handle_async_mjpeg_stream
(self, request)
Serve an HTTP MJPEG stream from the camera.
Serve an HTTP MJPEG stream from the camera.
async def handle_async_mjpeg_stream(self, request): """Serve an HTTP MJPEG stream from the camera.""" return await camera.async_get_still_stream( request, self._async_camera_stream_image, camera.DEFAULT_CONTENT_TYPE, 0.0 )
[ "async", "def", "handle_async_mjpeg_stream", "(", "self", ",", "request", ")", ":", "return", "await", "camera", ".", "async_get_still_stream", "(", "request", ",", "self", ".", "_async_camera_stream_image", ",", "camera", ".", "DEFAULT_CONTENT_TYPE", ",", "0.0", ...
[ 91, 4 ]
[ 95, 9 ]
python
en
['en', 'en', 'en']
True