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
Measurement.unique_id
(self)
Return the unique id of the gauge.
Return the unique id of the gauge.
def unique_id(self): """Return the unique id of the gauge.""" return self.key
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "key" ]
[ 115, 4 ]
[ 117, 23 ]
python
en
['en', 'en', 'en']
True
Measurement.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return { "identifiers": {(DOMAIN, "measure-id", self.station_id)}, "name": self.name, "manufacturer": "https://environment.data.gov.uk/", "model": self.parameter_name, "entry_type": "service"...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "\"measure-id\"", ",", "self", ".", "station_id", ")", "}", ",", "\"name\"", ":", "self", ".", "name", ",", "\"manufacturer\"", ":", "\"https://env...
[ 120, 4 ]
[ 128, 9 ]
python
en
['en', 'en', 'en']
True
Measurement.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" if not self.coordinator.last_update_success: return False # If sensor goes offline it will no longer contain a reading if "latestReading" not in self.coordinator.data["measures"][self.key]: re...
[ "def", "available", "(", "self", ")", "->", "bool", ":", "if", "not", "self", ".", "coordinator", ".", "last_update_success", ":", "return", "False", "# If sensor goes offline it will no longer contain a reading", "if", "\"latestReading\"", "not", "in", "self", ".", ...
[ 131, 4 ]
[ 147, 19 ]
python
en
['en', 'en', 'en']
True
Measurement.unit_of_measurement
(self)
Return units for the sensor.
Return units for the sensor.
def unit_of_measurement(self): """Return units for the sensor.""" measure = self.coordinator.data["measures"][self.key] if "unit" not in measure: return None return UNIT_MAPPING.get(measure["unit"], measure["unitName"])
[ "def", "unit_of_measurement", "(", "self", ")", ":", "measure", "=", "self", ".", "coordinator", ".", "data", "[", "\"measures\"", "]", "[", "self", ".", "key", "]", "if", "\"unit\"", "not", "in", "measure", ":", "return", "None", "return", "UNIT_MAPPING",...
[ 150, 4 ]
[ 155, 69 ]
python
en
['en', 'sq', 'en']
True
Measurement.device_state_attributes
(self)
Return the sensor specific state attributes.
Return the sensor specific state attributes.
def device_state_attributes(self): """Return the sensor specific state attributes.""" return {ATTR_ATTRIBUTION: self.attribution}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "self", ".", "attribution", "}" ]
[ 158, 4 ]
[ 160, 51 ]
python
en
['en', 'en', 'en']
True
Measurement.state
(self)
Return the current sensor value.
Return the current sensor value.
def state(self): """Return the current sensor value.""" return self.coordinator.data["measures"][self.key]["latestReading"]["value"]
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "coordinator", ".", "data", "[", "\"measures\"", "]", "[", "self", ".", "key", "]", "[", "\"latestReading\"", "]", "[", "\"value\"", "]" ]
[ 163, 4 ]
[ 165, 84 ]
python
en
['en', 'da', 'en']
True
get_dataset_filter
(expr: Expression, expected_to_file_map: dict)
Given an Iceberg Expression and a mapping of names in the iceberg schema to the file schema, convert to an equivalent dataset filter using the file column names. Recursively iterate through the expressions to convert each portion one predicate at a time Parameters ---------- expr : iceberg.api...
Given an Iceberg Expression and a mapping of names in the iceberg schema to the file schema, convert to an equivalent dataset filter using the file column names. Recursively iterate through the expressions to convert each portion one predicate at a time
def get_dataset_filter(expr: Expression, expected_to_file_map: dict) -> ds.Expression: """ Given an Iceberg Expression and a mapping of names in the iceberg schema to the file schema, convert to an equivalent dataset filter using the file column names. Recursively iterate through the expressions to conv...
[ "def", "get_dataset_filter", "(", "expr", ":", "Expression", ",", "expected_to_file_map", ":", "dict", ")", "->", "ds", ".", "Expression", ":", "if", "expr", "is", "None", ":", "return", "None", "if", "isinstance", "(", "expr", ",", "Predicate", ")", ":", ...
[ 22, 0 ]
[ 58, 69 ]
python
en
['en', 'error', 'th']
False
predicate
(pred: Predicate, field_map: dict)
Given an Iceberg Predicate and a mapping of names in the iceberg schema to the file schema, convert to an equivalent dataset expression using the file column names. Parameters ---------- pred : iceberg.api.expressions.Predicate An Iceberg Predicate to be converted field_map : dict ...
Given an Iceberg Predicate and a mapping of names in the iceberg schema to the file schema, convert to an equivalent dataset expression using the file column names.
def predicate(pred: Predicate, field_map: dict) -> ds.Expression: # noqa: ignore=C901 """ Given an Iceberg Predicate and a mapping of names in the iceberg schema to the file schema, convert to an equivalent dataset expression using the file column names. Parameters ---------- pred : iceberg.ap...
[ "def", "predicate", "(", "pred", ":", "Predicate", ",", "field_map", ":", "dict", ")", "->", "ds", ".", "Expression", ":", "# noqa: ignore=C901", "# get column name in the file schema so we can apply the predicate", "col_name", "=", "field_map", ".", "get", "(", "pred...
[ 61, 0 ]
[ 105, 54 ]
python
en
['en', 'error', 'th']
False
and_
(left: ds.Expression, right: ds.Expression)
Given a left and right expression combined them using the `AND` logical operator Parameters ---------- left : pyarrow._dataset.Expression A Dataset `Expression` to logically `AND` right : pyarrow._dataset.Expression A Dataset `Expression` to logically `AND` Returns ------- ...
Given a left and right expression combined them using the `AND` logical operator
def and_(left: ds.Expression, right: ds.Expression) -> ds.Expression: """ Given a left and right expression combined them using the `AND` logical operator Parameters ---------- left : pyarrow._dataset.Expression A Dataset `Expression` to logically `AND` right : pyarrow._dataset.Expressi...
[ "def", "and_", "(", "left", ":", "ds", ".", "Expression", ",", "right", ":", "ds", ".", "Expression", ")", "->", "ds", ".", "Expression", ":", "return", "left", "&", "right" ]
[ 108, 0 ]
[ 123, 23 ]
python
en
['en', 'error', 'th']
False
or_
(left: ds.Expression, right: ds.Expression)
Given a left and right expression combined them using the `OR` logical operator Parameters ---------- left : pyarrow._dataset.Expression A Dataset `Expression` to logically `OR` right : pyarrow._dataset.Expression A Dataset `Expression` to logically `OR` Returns ------- ...
Given a left and right expression combined them using the `OR` logical operator
def or_(left: ds.Expression, right: ds.Expression) -> ds.Expression: """ Given a left and right expression combined them using the `OR` logical operator Parameters ---------- left : pyarrow._dataset.Expression A Dataset `Expression` to logically `OR` right : pyarrow._dataset.Expression ...
[ "def", "or_", "(", "left", ":", "ds", ".", "Expression", ",", "right", ":", "ds", ".", "Expression", ")", "->", "ds", ".", "Expression", ":", "return", "left", "|", "right" ]
[ 126, 0 ]
[ 141, 23 ]
python
en
['en', 'error', 'th']
False
not_
(child: ds.Expression)
Given a child expression create the logical negation Parameters ---------- child : pyarrow._dataset.Expression A Dataset `Expression` to logically `OR` Returns ------- pyarrow._dataset.Expression The negation of the input `Expression`
Given a child expression create the logical negation
def not_(child: ds.Expression) -> ds.Expression: """ Given a child expression create the logical negation Parameters ---------- child : pyarrow._dataset.Expression A Dataset `Expression` to logically `OR` Returns ------- pyarrow._dataset.Expression The negation of the in...
[ "def", "not_", "(", "child", ":", "ds", ".", "Expression", ")", "->", "ds", ".", "Expression", ":", "return", "~", "child" ]
[ 144, 0 ]
[ 157, 17 ]
python
en
['en', 'error', 'th']
False
BertGenerationTokenizer._tokenize
(self, text, sample=False)
Take as input a string and return a list of strings (tokens) for words/sub-words
Take as input a string and return a list of strings (tokens) for words/sub-words
def _tokenize(self, text, sample=False): """Take as input a string and return a list of strings (tokens) for words/sub-words""" if not sample: pieces = self.sp_model.EncodeAsPieces(text) else: pieces = self.sp_model.SampleEncodeAsPieces(text, 64, 0.1) return piece...
[ "def", "_tokenize", "(", "self", ",", "text", ",", "sample", "=", "False", ")", ":", "if", "not", "sample", ":", "pieces", "=", "self", ".", "sp_model", ".", "EncodeAsPieces", "(", "text", ")", "else", ":", "pieces", "=", "self", ".", "sp_model", "."...
[ 112, 4 ]
[ 118, 21 ]
python
en
['en', 'en', 'en']
True
BertGenerationTokenizer._convert_token_to_id
(self, token)
Converts a token (str) in an id using the vocab.
Converts a token (str) in an id using the vocab.
def _convert_token_to_id(self, token): """ Converts a token (str) in an id using the vocab. """ return self.sp_model.piece_to_id(token)
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ")", ":", "return", "self", ".", "sp_model", ".", "piece_to_id", "(", "token", ")" ]
[ 120, 4 ]
[ 122, 47 ]
python
en
['en', 'en', 'en']
True
BertGenerationTokenizer._convert_id_to_token
(self, index)
Converts an index (integer) in a token (str) using the vocab.
Converts an index (integer) in a token (str) using the vocab.
def _convert_id_to_token(self, index): """Converts an index (integer) in a token (str) using the vocab.""" token = self.sp_model.IdToPiece(index) return token
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ")", ":", "token", "=", "self", ".", "sp_model", ".", "IdToPiece", "(", "index", ")", "return", "token" ]
[ 124, 4 ]
[ 127, 20 ]
python
en
['en', 'en', 'en']
True
BertGenerationTokenizer.convert_tokens_to_string
(self, tokens)
Converts a sequence of tokens (string) in a single string.
Converts a sequence of tokens (string) in a single string.
def convert_tokens_to_string(self, tokens): """ Converts a sequence of tokens (string) in a single string. """ out_string = self.sp_model.decode_pieces(tokens) return out_string
[ "def", "convert_tokens_to_string", "(", "self", ",", "tokens", ")", ":", "out_string", "=", "self", ".", "sp_model", ".", "decode_pieces", "(", "tokens", ")", "return", "out_string" ]
[ 129, 4 ]
[ 132, 25 ]
python
en
['en', 'en', 'en']
True
test_reload_notify
(hass)
Verify we can reload the notify service.
Verify we can reload the notify service.
async def test_reload_notify(hass): """Verify we can reload the notify service.""" with patch("homeassistant.components.telegram_bot.async_setup", return_value=True): assert await async_setup_component( hass, notify.DOMAIN, { notify.DOMAIN: [ ...
[ "async", "def", "test_reload_notify", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.telegram_bot.async_setup\"", ",", "return_value", "=", "True", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "notify", ".", "DOMA...
[ 12, 0 ]
[ 48, 72 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config)
Set up the Atag component.
Set up the Atag component.
async def async_setup(hass: HomeAssistant, config): """Set up the Atag component.""" return True
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ")", ":", "return", "True" ]
[ 26, 0 ]
[ 28, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up Atag integration from a config entry.
Set up Atag integration from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up Atag integration from a config entry.""" session = async_get_clientsession(hass) coordinator = AtagDataUpdateCoordinator(hass, session, entry) await coordinator.async_refresh() if not coordinator.last_update_success: ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "session", "=", "async_get_clientsession", "(", "hass", ")", "coordinator", "=", "AtagDataUpdateCoordinator", "(", "hass", ",", "session", ",", "e...
[ 31, 0 ]
[ 50, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload Atag config entry.
Unload Atag config entry.
async def async_unload_entry(hass, entry): """Unload Atag config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component) for component in PLATFORMS ] ) ) if unload_ok: ...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "entry", ",", "component", ")", ...
[ 75, 0 ]
[ 87, 20 ]
python
da
['da', 'es', 'en']
False
AtagDataUpdateCoordinator.__init__
(self, hass, session, entry)
Initialize.
Initialize.
def __init__(self, hass, session, entry): """Initialize.""" self.atag = AtagOne(session=session, **entry.data) super().__init__( hass, _LOGGER, name=DOMAIN, update_interval=timedelta(seconds=30) )
[ "def", "__init__", "(", "self", ",", "hass", ",", "session", ",", "entry", ")", ":", "self", ".", "atag", "=", "AtagOne", "(", "session", "=", "session", ",", "*", "*", "entry", ".", "data", ")", "super", "(", ")", ".", "__init__", "(", "hass", "...
[ 56, 4 ]
[ 62, 9 ]
python
en
['en', 'en', 'it']
False
AtagDataUpdateCoordinator._async_update_data
(self)
Update data via library.
Update data via library.
async def _async_update_data(self): """Update data via library.""" with async_timeout.timeout(20): try: if not await self.atag.update(): raise UpdateFailed("No data received") except AtagException as error: raise UpdateFailed(er...
[ "async", "def", "_async_update_data", "(", "self", ")", ":", "with", "async_timeout", ".", "timeout", "(", "20", ")", ":", "try", ":", "if", "not", "await", "self", ".", "atag", ".", "update", "(", ")", ":", "raise", "UpdateFailed", "(", "\"No data recei...
[ 64, 4 ]
[ 72, 31 ]
python
en
['fr', 'en', 'en']
True
AtagEntity.__init__
(self, coordinator: AtagDataUpdateCoordinator, atag_id: str)
Initialize the Atag entity.
Initialize the Atag entity.
def __init__(self, coordinator: AtagDataUpdateCoordinator, atag_id: str) -> None: """Initialize the Atag entity.""" super().__init__(coordinator) self._id = atag_id self._name = DOMAIN.title()
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "AtagDataUpdateCoordinator", ",", "atag_id", ":", "str", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ")", "self", ".", "_id", "=", "atag_id", "self", ".", "_name...
[ 93, 4 ]
[ 98, 35 ]
python
en
['en', 'en', 'en']
True
AtagEntity.device_info
(self)
Return info for device registry.
Return info for device registry.
def device_info(self) -> dict: """Return info for device registry.""" device = self.coordinator.atag.id version = self.coordinator.atag.apiversion return { "identifiers": {(DOMAIN, device)}, "name": "Atag Thermostat", "model": "Atag One", "...
[ "def", "device_info", "(", "self", ")", "->", "dict", ":", "device", "=", "self", ".", "coordinator", ".", "atag", ".", "id", "version", "=", "self", ".", "coordinator", ".", "atag", ".", "apiversion", "return", "{", "\"identifiers\"", ":", "{", "(", "...
[ 101, 4 ]
[ 111, 9 ]
python
da
['da', 'no', 'en']
False
AtagEntity.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> str: """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 114, 4 ]
[ 116, 25 ]
python
en
['en', 'en', 'en']
True
AtagEntity.unique_id
(self)
Return a unique ID to use for this entity.
Return a unique ID to use for this entity.
def unique_id(self): """Return a unique ID to use for this entity.""" return f"{self.coordinator.atag.id}-{self._id}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{self.coordinator.atag.id}-{self._id}\"" ]
[ 119, 4 ]
[ 121, 55 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info)
Set up the Iperf3 sensor.
Set up the Iperf3 sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info): """Set up the Iperf3 sensor.""" sensors = [] for iperf3_host in hass.data[IPERF3_DOMAIN].values(): sensors.extend([Iperf3Sensor(iperf3_host, sensor) for sensor in discovery_info]) async_add_entities(sensors, True)
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", ")", ":", "sensors", "=", "[", "]", "for", "iperf3_host", "in", "hass", ".", "data", "[", "IPERF3_DOMAIN", "]", ".", "values", "(", ")", "...
[ 17, 0 ]
[ 22, 37 ]
python
en
['en', 'ca', 'en']
True
Iperf3Sensor.__init__
(self, iperf3_data, sensor_type)
Initialize the sensor.
Initialize the sensor.
def __init__(self, iperf3_data, sensor_type): """Initialize the sensor.""" self._name = f"{SENSOR_TYPES[sensor_type][0]} {iperf3_data.host}" self._state = None self._sensor_type = sensor_type self._unit_of_measurement = SENSOR_TYPES[sensor_type][1] self._iperf3_data = ipe...
[ "def", "__init__", "(", "self", ",", "iperf3_data", ",", "sensor_type", ")", ":", "self", ".", "_name", "=", "f\"{SENSOR_TYPES[sensor_type][0]} {iperf3_data.host}\"", "self", ".", "_state", "=", "None", "self", ".", "_sensor_type", "=", "sensor_type", "self", ".",...
[ 28, 4 ]
[ 34, 39 ]
python
en
['en', 'en', 'en']
True
Iperf3Sensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 37, 4 ]
[ 39, 25 ]
python
en
['en', 'mi', 'en']
True
Iperf3Sensor.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 42, 4 ]
[ 44, 26 ]
python
en
['en', 'en', 'en']
True
Iperf3Sensor.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 self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 47, 4 ]
[ 49, 40 ]
python
en
['en', 'en', 'en']
True
Iperf3Sensor.icon
(self)
Return icon.
Return icon.
def icon(self): """Return icon.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 52, 4 ]
[ 54, 19 ]
python
en
['en', 'la', 'en']
False
Iperf3Sensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return { ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_PROTOCOL: self._iperf3_data.protocol, ATTR_REMOTE_HOST: self._iperf3_data.host, ATTR_REMOTE_PORT: self._iperf3_data.port, ATTR_VE...
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", ",", "ATTR_PROTOCOL", ":", "self", ".", "_iperf3_data", ".", "protocol", ",", "ATTR_REMOTE_HOST", ":", "self", ".", "_iperf3_data", ".", "host", ",", ...
[ 57, 4 ]
[ 65, 9 ]
python
en
['en', 'en', 'en']
True
Iperf3Sensor.should_poll
(self)
Return the polling requirement for this sensor.
Return the polling requirement for this sensor.
def should_poll(self): """Return the polling requirement for this sensor.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 68, 4 ]
[ 70, 20 ]
python
en
['en', 'en', 'en']
True
Iperf3Sensor.async_added_to_hass
(self)
Handle entity which will be added.
Handle entity which will be added.
async def async_added_to_hass(self): """Handle entity which will be added.""" await super().async_added_to_hass() self.async_on_remove( async_dispatcher_connect( self.hass, DATA_UPDATED, self._schedule_immediate_update ) ) state = await s...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "await", "super", "(", ")", ".", "async_added_to_hass", "(", ")", "self", ".", "async_on_remove", "(", "async_dispatcher_connect", "(", "self", ".", "hass", ",", "DATA_UPDATED", ",", "self", ".", ...
[ 72, 4 ]
[ 85, 33 ]
python
en
['en', 'en', 'en']
True
Iperf3Sensor.update
(self)
Get the latest data and update the states.
Get the latest data and update the states.
def update(self): """Get the latest data and update the states.""" data = self._iperf3_data.data.get(self._sensor_type) if data is not None: self._state = round(data, 2)
[ "def", "update", "(", "self", ")", ":", "data", "=", "self", ".", "_iperf3_data", ".", "data", ".", "get", "(", "self", ".", "_sensor_type", ")", "if", "data", "is", "not", "None", ":", "self", ".", "_state", "=", "round", "(", "data", ",", "2", ...
[ 87, 4 ]
[ 91, 40 ]
python
en
['en', 'en', 'en']
True
start_citi_bike_dashboard
(source_path: str, epoch_num: int, prefix: str)
Entrance of Citi_Bike dashboard. Expected folder structure of Scenario Citi Bike: -source_path --epoch_0: Data of each epoch. --stations.csv: Record stations' attributes in this file. --matrices.csv: Record transfer volume information in this file. --stations_summary...
Entrance of Citi_Bike dashboard.
def start_citi_bike_dashboard(source_path: str, epoch_num: int, prefix: str): """Entrance of Citi_Bike dashboard. Expected folder structure of Scenario Citi Bike: -source_path --epoch_0: Data of each epoch. --stations.csv: Record stations' attributes in this file. --matrices...
[ "def", "start_citi_bike_dashboard", "(", "source_path", ":", "str", ",", "epoch_num", ":", "int", ",", "prefix", ":", "str", ")", ":", "if", "epoch_num", ">", "1", ":", "option", "=", "st", ".", "sidebar", ".", "selectbox", "(", "label", "=", "\"Data Typ...
[ 17, 0 ]
[ 49, 57 ]
python
en
['en', 'ha', 'en']
True
render_inter_view
(source_path: str, epoch_num: int)
Render the cross-epoch infomartion chart of Citi Bike data. This part would be displayed only if epoch_num > 1. Args: source_path (str): The root path of the dumped snapshots data for the corresponding experiment. epoch_num (int): Total number of epoches, i.e. the total number of d...
Render the cross-epoch infomartion chart of Citi Bike data.
def render_inter_view(source_path: str, epoch_num: int): """Render the cross-epoch infomartion chart of Citi Bike data. This part would be displayed only if epoch_num > 1. Args: source_path (str): The root path of the dumped snapshots data for the corresponding experiment. epoch_num (int):...
[ "def", "render_inter_view", "(", "source_path", ":", "str", ",", "epoch_num", ":", "int", ")", ":", "helper", ".", "render_h1_title", "(", "\"Citi Bike Inter Epoch Data\"", ")", "sample_ratio", "=", "helper", ".", "get_sample_ratio_selection_list", "(", "epoch_num", ...
[ 52, 0 ]
[ 80, 5 ]
python
en
['en', 'no', 'en']
True
_generate_inter_view_panel
(data: pd.DataFrame, down_pooling_range: List[float])
Generate inter-view i.e. cross-epoch summary data plot. Args: data (pd.Dataframe): Original data. down_pooling_range (List[float]): Sampling data index list.
Generate inter-view i.e. cross-epoch summary data plot.
def _generate_inter_view_panel(data: pd.DataFrame, down_pooling_range: List[float]): """Generate inter-view i.e. cross-epoch summary data plot. Args: data (pd.Dataframe): Original data. down_pooling_range (List[float]): Sampling data index list. """ data["Epoch Index"] = list(down_pooli...
[ "def", "_generate_inter_view_panel", "(", "data", ":", "pd", ".", "DataFrame", ",", "down_pooling_range", ":", "List", "[", "float", "]", ")", ":", "data", "[", "\"Epoch Index\"", "]", "=", "list", "(", "down_pooling_range", ")", "data_melt", "=", "data", "....
[ 83, 0 ]
[ 113, 36 ]
python
en
['en', 'mg', 'it']
False
render_intra_view
(source_path: str, epoch_num: int, prefix: str)
Show Citi Bike intra-view plot. Args: source_path (str): The root path of the dumped snapshots data for the corresponding experiment. epoch_num (int): Total number of epoches, i.e. the total number of data folders since there is a folder per epoch. prefix (str): Prefix of data f...
Show Citi Bike intra-view plot.
def render_intra_view(source_path: str, epoch_num: int, prefix: str): """Show Citi Bike intra-view plot. Args: source_path (str): The root path of the dumped snapshots data for the corresponding experiment. epoch_num (int): Total number of epoches, i.e. the total number of data fold...
[ "def", "render_intra_view", "(", "source_path", ":", "str", ",", "epoch_num", ":", "int", ",", "prefix", ":", "str", ")", ":", "selected_epoch", "=", "0", "if", "epoch_num", ">", "1", ":", "selected_epoch", "=", "st", ".", "sidebar", ".", "select_slider", ...
[ 116, 0 ]
[ 167, 9 ]
python
en
['en', 'it', 'en']
True
render_top_k_summary
(source_path: str, prefix: str, epoch_index: int)
Show top-k summary plot. Args: source_path (str): The root path of the dumped snapshots data for the corresponding experiment. prefix (str): Prefix of data folders. epoch_index (int): The index of selected epoch.
Show top-k summary plot.
def render_top_k_summary(source_path: str, prefix: str, epoch_index: int): """ Show top-k summary plot. Args: source_path (str): The root path of the dumped snapshots data for the corresponding experiment. prefix (str): Prefix of data folders. epoch_index (int): The index of selected ep...
[ "def", "render_top_k_summary", "(", "source_path", ":", "str", ",", "prefix", ":", "str", ",", "epoch_index", ":", "int", ")", ":", "helper", ".", "render_h3_title", "(", "\"Cike Bike Top K\"", ")", "data", "=", "helper", ".", "read_detail_csv", "(", "os", "...
[ 170, 0 ]
[ 201, 92 ]
python
en
['en', 'mg', 'en']
True
_generate_intra_view_by_snapshot
( data_stations: pd.DataFrame, index_name_conversion: pd.DataFrame, attribute_option_candidates: List[str], snapshots_index: List[int], snapshot_num: int, stations_num: int )
Show Citi Bike intra-view data by snapshot. Args: data_stations (pd.Dataframe): Filtered Data. index_name_conversion (pd.Dataframe): Relationship between index and name. attribute_option_candidates (List[str]): All options for users to choose. snapshots_index (List[int]): Sampled sn...
Show Citi Bike intra-view data by snapshot.
def _generate_intra_view_by_snapshot( data_stations: pd.DataFrame, index_name_conversion: pd.DataFrame, attribute_option_candidates: List[str], snapshots_index: List[int], snapshot_num: int, stations_num: int ): """Show Citi Bike intra-view data by snapshot. Args: data_stations (pd.Dataframe): ...
[ "def", "_generate_intra_view_by_snapshot", "(", "data_stations", ":", "pd", ".", "DataFrame", ",", "index_name_conversion", ":", "pd", ".", "DataFrame", ",", "attribute_option_candidates", ":", "List", "[", "str", "]", ",", "snapshots_index", ":", "List", "[", "in...
[ 204, 0 ]
[ 269, 46 ]
python
en
['en', 'sn', 'en']
True
_generate_intra_view_by_station
( data_stations: pd.DataFrame, index_name_conversion: pd.DataFrame, attribute_option_candidates: List[str], stations_index: List[int], snapshot_num: int )
Show Citi Bike intra-view data by station. Args: data_stations (pd.Dataframe): Filtered station data. index_name_conversion (pd.Dataframe): Relationship between index and name. attribute_option_candidates (List[str]): All options for users to choose. stations_index (List[int]): Li...
Show Citi Bike intra-view data by station.
def _generate_intra_view_by_station( data_stations: pd.DataFrame, index_name_conversion: pd.DataFrame, attribute_option_candidates: List[str], stations_index: List[int], snapshot_num: int ): """ Show Citi Bike intra-view data by station. Args: data_stations (pd.Dataframe): Filtered station data...
[ "def", "_generate_intra_view_by_station", "(", "data_stations", ":", "pd", ".", "DataFrame", ",", "index_name_conversion", ":", "pd", ".", "DataFrame", ",", "attribute_option_candidates", ":", "List", "[", "str", "]", ",", "stations_index", ":", "List", "[", "int"...
[ 272, 0 ]
[ 337, 44 ]
python
en
['en', 'en', 'en']
True
device_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def device_reg(hass): """Return an empty, loaded, registry.""" return mock_device_registry(hass)
[ "def", "device_reg", "(", "hass", ")", ":", "return", "mock_device_registry", "(", "hass", ")" ]
[ 28, 0 ]
[ 30, 37 ]
python
en
['en', 'fy', 'en']
True
entity_reg
(hass)
Return an empty, loaded, registry.
Return an empty, loaded, registry.
def entity_reg(hass): """Return an empty, loaded, registry.""" return mock_registry(hass)
[ "def", "entity_reg", "(", "hass", ")", ":", "return", "mock_registry", "(", "hass", ")" ]
[ 34, 0 ]
[ 36, 30 ]
python
en
['en', 'fy', 'en']
True
test_get_actions
(hass, device_reg, entity_reg)
Test we get the expected actions from a alarm_control_panel.
Test we get the expected actions from a alarm_control_panel.
async def test_get_actions(hass, device_reg, entity_reg): """Test we get the expected actions from a alarm_control_panel.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_entry.entry_id,...
[ "async", "def", "test_get_actions", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "hass", ")", ...
[ 39, 0 ]
[ 84, 48 ]
python
en
['en', 'en', 'en']
True
test_get_actions_arm_night_only
(hass, device_reg, entity_reg)
Test we get the expected actions from a alarm_control_panel.
Test we get the expected actions from a alarm_control_panel.
async def test_get_actions_arm_night_only(hass, device_reg, entity_reg): """Test we get the expected actions from a alarm_control_panel.""" config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) device_entry = device_reg.async_get_or_create( config_entry_id=config_...
[ "async", "def", "test_get_actions_arm_night_only", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "\"test\"", ",", "data", "=", "{", "}", ")", "config_entry", ".", "add_to_hass", "(", "h...
[ 87, 0 ]
[ 114, 48 ]
python
en
['en', 'en', 'en']
True
test_get_action_capabilities
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a sensor trigger.
Test we get the expected capabilities from a sensor trigger.
async def test_get_action_capabilities(hass, device_reg, entity_reg): """Test we get the expected capabilities from a sensor trigger.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(hass) de...
[ "async", "def", "test_get_action_capabilities", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "config_entry", "=", "Mo...
[ 117, 0 ]
[ 152, 68 ]
python
en
['en', 'en', 'en']
True
test_get_action_capabilities_arm_code
(hass, device_reg, entity_reg)
Test we get the expected capabilities from a sensor trigger.
Test we get the expected capabilities from a sensor trigger.
async def test_get_action_capabilities_arm_code(hass, device_reg, entity_reg): """Test we get the expected capabilities from a sensor trigger.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() config_entry = MockConfigEntry(domain="test", data={}) config_entry.add_to_hass(has...
[ "async", "def", "test_get_action_capabilities_arm_code", "(", "hass", ",", "device_reg", ",", "entity_reg", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "config_entry", "...
[ 155, 0 ]
[ 196, 68 ]
python
en
['en', 'en', 'en']
True
test_action
(hass)
Test for turn_on and turn_off actions.
Test for turn_on and turn_off actions.
async def test_action(hass): """Test for turn_on and turn_off actions.""" platform = getattr(hass.components, f"test.{DOMAIN}") platform.init() assert await async_setup_component( hass, automation.DOMAIN, { automation.DOMAIN: [ { "...
[ "async", "def", "test_action", "(", "hass", ")", ":", "platform", "=", "getattr", "(", "hass", ".", "components", ",", "f\"test.{DOMAIN}\"", ")", "platform", ".", "init", "(", ")", "assert", "await", "async_setup_component", "(", "hass", ",", "automation", "...
[ 199, 0 ]
[ 310, 5 ]
python
en
['en', 'en', 'en']
True
mock_simple_nws
()
Mock pynws SimpleNWS with default values.
Mock pynws SimpleNWS with default values.
def mock_simple_nws(): """Mock pynws SimpleNWS with default values.""" with patch("homeassistant.components.nws.SimpleNWS") as mock_nws: instance = mock_nws.return_value instance.set_station = AsyncMock(return_value=None) instance.update_observation = AsyncMock(return_value=None) ...
[ "def", "mock_simple_nws", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.nws.SimpleNWS\"", ")", "as", "mock_nws", ":", "instance", "=", "mock_nws", ".", "return_value", "instance", ".", "set_station", "=", "AsyncMock", "(", "return_value", "=", "...
[ 8, 0 ]
[ 21, 22 ]
python
en
['en', 'en', 'en']
True
mock_simple_nws_config
()
Mock pynws SimpleNWS with default values in config_flow.
Mock pynws SimpleNWS with default values in config_flow.
def mock_simple_nws_config(): """Mock pynws SimpleNWS with default values in config_flow.""" with patch("homeassistant.components.nws.config_flow.SimpleNWS") as mock_nws: instance = mock_nws.return_value instance.set_station = AsyncMock(return_value=None) instance.station = "ABC" ...
[ "def", "mock_simple_nws_config", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.nws.config_flow.SimpleNWS\"", ")", "as", "mock_nws", ":", "instance", "=", "mock_nws", ".", "return_value", "instance", ".", "set_station", "=", "AsyncMock", "(", "return...
[ 25, 0 ]
[ 32, 22 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Get all cover devices and setup them via config entry.
Get all cover devices and setup them via config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Get all cover devices and setup them via config entry.""" entities = [] for gateway in hass.data[DOMAIN][entry.entry_id]["gateways"]: for device in gateway.multi_level_switch_devices: ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "entities", "=", "[", "]", "for", "gateway", "in", "hass", ".", "data", "[", "DOMAIN", "]", "["...
[ 15, 0 ]
[ 33, 39 ]
python
en
['en', 'pt', 'en']
True
DevoloCoverDeviceEntity.current_cover_position
(self)
Return the current position. 0 is closed. 100 is open.
Return the current position. 0 is closed. 100 is open.
def current_cover_position(self): """Return the current position. 0 is closed. 100 is open.""" return self._value
[ "def", "current_cover_position", "(", "self", ")", ":", "return", "self", ".", "_value" ]
[ 40, 4 ]
[ 42, 26 ]
python
en
['en', 'en', 'en']
True
DevoloCoverDeviceEntity.device_class
(self)
Return the class of the device.
Return the class of the device.
def device_class(self): """Return the class of the device.""" return DEVICE_CLASS_BLIND
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_BLIND" ]
[ 45, 4 ]
[ 47, 33 ]
python
en
['en', 'en', 'en']
True
DevoloCoverDeviceEntity.is_closed
(self)
Return if the blind is closed or not.
Return if the blind is closed or not.
def is_closed(self): """Return if the blind is closed or not.""" return not bool(self._value)
[ "def", "is_closed", "(", "self", ")", ":", "return", "not", "bool", "(", "self", ".", "_value", ")" ]
[ 50, 4 ]
[ 52, 36 ]
python
en
['en', 'en', 'en']
True
DevoloCoverDeviceEntity.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_OPEN", "|", "SUPPORT_CLOSE", "|", "SUPPORT_SET_POSITION" ]
[ 55, 4 ]
[ 57, 66 ]
python
en
['da', 'en', 'en']
True
DevoloCoverDeviceEntity.open_cover
(self, **kwargs)
Open the blind.
Open the blind.
def open_cover(self, **kwargs): """Open the blind.""" self._multi_level_switch_property.set(100)
[ "def", "open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_multi_level_switch_property", ".", "set", "(", "100", ")" ]
[ 59, 4 ]
[ 61, 50 ]
python
en
['en', 'en', 'en']
True
DevoloCoverDeviceEntity.close_cover
(self, **kwargs)
Close the blind.
Close the blind.
def close_cover(self, **kwargs): """Close the blind.""" self._multi_level_switch_property.set(0)
[ "def", "close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_multi_level_switch_property", ".", "set", "(", "0", ")" ]
[ 63, 4 ]
[ 65, 48 ]
python
en
['en', 'en', 'en']
True
DevoloCoverDeviceEntity.set_cover_position
(self, **kwargs)
Set the blind to the given position.
Set the blind to the given position.
def set_cover_position(self, **kwargs): """Set the blind to the given position.""" self._multi_level_switch_property.set(kwargs["position"])
[ "def", "set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_multi_level_switch_property", ".", "set", "(", "kwargs", "[", "\"position\"", "]", ")" ]
[ 67, 4 ]
[ 69, 65 ]
python
en
['en', 'en', 'en']
True
test_setup_minimum
(hass)
Test old platform setup with minimum configuration.
Test old platform setup with minimum configuration.
async def test_setup_minimum(hass): """Test old platform setup with minimum configuration.""" config = {"sensor": {"platform": "onewire"}} with assert_setup_component(1, "sensor"): assert await async_setup_component(hass, sensor.DOMAIN, config) await hass.async_block_till_done()
[ "async", "def", "test_setup_minimum", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"onewire\"", "}", "}", "with", "assert_setup_component", "(", "1", ",", "\"sensor\"", ")", ":", "assert", "await", "async_setup_comp...
[ 8, 0 ]
[ 13, 38 ]
python
en
['en', 'zu', 'en']
True
test_setup_sysbus
(hass)
Test old platform setup with SysBus configuration.
Test old platform setup with SysBus configuration.
async def test_setup_sysbus(hass): """Test old platform setup with SysBus configuration.""" config = { "sensor": { "platform": "onewire", "mount_dir": DEFAULT_SYSBUS_MOUNT_DIR, } } with assert_setup_component(1, "sensor"): assert await async_setup_componen...
[ "async", "def", "test_setup_sysbus", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"onewire\"", ",", "\"mount_dir\"", ":", "DEFAULT_SYSBUS_MOUNT_DIR", ",", "}", "}", "with", "assert_setup_component", "(", "1", ",", "...
[ 16, 0 ]
[ 26, 38 ]
python
en
['en', 'da', 'en']
True
test_setup_owserver
(hass)
Test old platform setup with OWServer configuration.
Test old platform setup with OWServer configuration.
async def test_setup_owserver(hass): """Test old platform setup with OWServer configuration.""" config = {"sensor": {"platform": "onewire", "host": "localhost"}} with assert_setup_component(1, "sensor"): assert await async_setup_component(hass, sensor.DOMAIN, config) await hass.async_block_till_...
[ "async", "def", "test_setup_owserver", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"onewire\"", ",", "\"host\"", ":", "\"localhost\"", "}", "}", "with", "assert_setup_component", "(", "1", ",", "\"sensor\"", ")", ...
[ 29, 0 ]
[ 34, 38 ]
python
en
['en', 'da', 'en']
True
test_setup_owserver_with_port
(hass)
Test old platform setup with OWServer configuration.
Test old platform setup with OWServer configuration.
async def test_setup_owserver_with_port(hass): """Test old platform setup with OWServer configuration.""" config = {"sensor": {"platform": "onewire", "host": "localhost", "port": "1234"}} with assert_setup_component(1, "sensor"): assert await async_setup_component(hass, sensor.DOMAIN, config) aw...
[ "async", "def", "test_setup_owserver_with_port", "(", "hass", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"onewire\"", ",", "\"host\"", ":", "\"localhost\"", ",", "\"port\"", ":", "\"1234\"", "}", "}", "with", "assert_setup_compo...
[ 37, 0 ]
[ 42, 38 ]
python
en
['en', 'da', 'en']
True
mock_cloud_inst
()
Mock cloud class.
Mock cloud class.
def mock_cloud_inst(): """Mock cloud class.""" return MagicMock(subscription_expired=False)
[ "def", "mock_cloud_inst", "(", ")", ":", "return", "MagicMock", "(", "subscription_expired", "=", "False", ")" ]
[ 23, 0 ]
[ 25, 48 ]
python
en
['nl', 'ro', 'en']
False
test_handler_alexa
(hass)
Test handler Alexa.
Test handler Alexa.
async def test_handler_alexa(hass): """Test handler Alexa.""" hass.states.async_set("switch.test", "on", {"friendly_name": "Test switch"}) hass.states.async_set("switch.test2", "on", {"friendly_name": "Test switch 2"}) await mock_cloud( hass, { "alexa": { "fi...
[ "async", "def", "test_handler_alexa", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"switch.test\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test switch\"", "}", ")", "hass", ".", "states", ".", "async_set", "(", "\"swi...
[ 28, 0 ]
[ 64, 57 ]
python
en
['sv', 'lb', 'en']
False
test_handler_alexa_disabled
(hass, mock_cloud_fixture)
Test handler Alexa when user has disabled it.
Test handler Alexa when user has disabled it.
async def test_handler_alexa_disabled(hass, mock_cloud_fixture): """Test handler Alexa when user has disabled it.""" mock_cloud_fixture._prefs[PREF_ENABLE_ALEXA] = False cloud = hass.data["cloud"] resp = await cloud.client.async_alexa_message( test_alexa.get_new_request("Alexa.Discovery", "Disc...
[ "async", "def", "test_handler_alexa_disabled", "(", "hass", ",", "mock_cloud_fixture", ")", ":", "mock_cloud_fixture", ".", "_prefs", "[", "PREF_ENABLE_ALEXA", "]", "=", "False", "cloud", "=", "hass", ".", "data", "[", "\"cloud\"", "]", "resp", "=", "await", "...
[ 67, 0 ]
[ 78, 67 ]
python
en
['en', 'lb', 'en']
True
test_handler_google_actions
(hass)
Test handler Google Actions.
Test handler Google Actions.
async def test_handler_google_actions(hass): """Test handler Google Actions.""" hass.states.async_set("switch.test", "on", {"friendly_name": "Test switch"}) hass.states.async_set("switch.test2", "on", {"friendly_name": "Test switch 2"}) hass.states.async_set("group.all_locks", "on", {"friendly_name": "E...
[ "async", "def", "test_handler_google_actions", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"switch.test\"", ",", "\"on\"", ",", "{", "\"friendly_name\"", ":", "\"Test switch\"", "}", ")", "hass", ".", "states", ".", "async_set", "(",...
[ 81, 0 ]
[ 129, 46 ]
python
en
['en', 'nl', 'en']
True
test_handler_google_actions_disabled
(hass, mock_cloud_fixture)
Test handler Google Actions when user has disabled it.
Test handler Google Actions when user has disabled it.
async def test_handler_google_actions_disabled(hass, mock_cloud_fixture): """Test handler Google Actions when user has disabled it.""" mock_cloud_fixture._prefs[PREF_ENABLE_GOOGLE] = False with patch("hass_nabucasa.Cloud.start"): assert await async_setup_component(hass, "cloud", {}) reqid = "5...
[ "async", "def", "test_handler_google_actions_disabled", "(", "hass", ",", "mock_cloud_fixture", ")", ":", "mock_cloud_fixture", ".", "_prefs", "[", "PREF_ENABLE_GOOGLE", "]", "=", "False", "with", "patch", "(", "\"hass_nabucasa.Cloud.start\"", ")", ":", "assert", "awa...
[ 132, 0 ]
[ 146, 60 ]
python
en
['en', 'en', 'en']
True
test_webhook_msg
(hass, caplog)
Test webhook msg.
Test webhook msg.
async def test_webhook_msg(hass, caplog): """Test webhook msg.""" with patch("hass_nabucasa.Cloud.start"): setup = await async_setup_component(hass, "cloud", {"cloud": {}}) assert setup cloud = hass.data["cloud"] await cloud.client.prefs.async_initialize() await cloud.client.prefs.a...
[ "async", "def", "test_webhook_msg", "(", "hass", ",", "caplog", ")", ":", "with", "patch", "(", "\"hass_nabucasa.Cloud.start\"", ")", ":", "setup", "=", "await", "async_setup_component", "(", "hass", ",", "\"cloud\"", ",", "{", "\"cloud\"", ":", "{", "}", "}...
[ 149, 0 ]
[ 221, 54 ]
python
da
['en', 'da', 'hi']
False
test_google_config_expose_entity
(hass, mock_cloud_setup, mock_cloud_login)
Test Google config exposing entity method uses latest config.
Test Google config exposing entity method uses latest config.
async def test_google_config_expose_entity(hass, mock_cloud_setup, mock_cloud_login): """Test Google config exposing entity method uses latest config.""" cloud_client = hass.data[DOMAIN].client state = State("light.kitchen", "on") gconf = await cloud_client.get_google_config() assert gconf.should_e...
[ "async", "def", "test_google_config_expose_entity", "(", "hass", ",", "mock_cloud_setup", ",", "mock_cloud_login", ")", ":", "cloud_client", "=", "hass", ".", "data", "[", "DOMAIN", "]", ".", "client", "state", "=", "State", "(", "\"light.kitchen\"", ",", "\"on\...
[ 224, 0 ]
[ 236, 41 ]
python
en
['en', 'en', 'en']
True
test_google_config_should_2fa
(hass, mock_cloud_setup, mock_cloud_login)
Test Google config disabling 2FA method uses latest config.
Test Google config disabling 2FA method uses latest config.
async def test_google_config_should_2fa(hass, mock_cloud_setup, mock_cloud_login): """Test Google config disabling 2FA method uses latest config.""" cloud_client = hass.data[DOMAIN].client gconf = await cloud_client.get_google_config() state = State("light.kitchen", "on") assert gconf.should_2fa(st...
[ "async", "def", "test_google_config_should_2fa", "(", "hass", ",", "mock_cloud_setup", ",", "mock_cloud_login", ")", ":", "cloud_client", "=", "hass", ".", "data", "[", "DOMAIN", "]", ".", "client", "gconf", "=", "await", "cloud_client", ".", "get_google_config", ...
[ 239, 0 ]
[ 251, 38 ]
python
en
['en', 'en', 'en']
True
test_set_username
(hass)
Test we set username during login.
Test we set username during login.
async def test_set_username(hass): """Test we set username during login.""" prefs = MagicMock( alexa_enabled=False, google_enabled=False, async_set_username=AsyncMock(return_value=None), ) client = CloudClient(hass, prefs, None, {}, {}) client.cloud = MagicMock(is_logged_in=T...
[ "async", "def", "test_set_username", "(", "hass", ")", ":", "prefs", "=", "MagicMock", "(", "alexa_enabled", "=", "False", ",", "google_enabled", "=", "False", ",", "async_set_username", "=", "AsyncMock", "(", "return_value", "=", "None", ")", ",", ")", "cli...
[ 254, 0 ]
[ 266, 74 ]
python
en
['fr', 'jv', 'en']
False
test_login_recovers_bad_internet
(hass, caplog)
Test Alexa can recover bad auth.
Test Alexa can recover bad auth.
async def test_login_recovers_bad_internet(hass, caplog): """Test Alexa can recover bad auth.""" prefs = Mock( alexa_enabled=True, google_enabled=False, async_set_username=AsyncMock(return_value=None), ) client = CloudClient(hass, prefs, None, {}, {}) client.cloud = Mock() ...
[ "async", "def", "test_login_recovers_bad_internet", "(", "hass", ",", "caplog", ")", ":", "prefs", "=", "Mock", "(", "alexa_enabled", "=", "True", ",", "google_enabled", "=", "False", ",", "async_set_username", "=", "AsyncMock", "(", "return_value", "=", "None",...
[ 269, 0 ]
[ 288, 80 ]
python
en
['en', 'en', 'en']
True
async_get_scanner
(hass, config)
Return a Sky Hub scanner if successful.
Return a Sky Hub scanner if successful.
async def async_get_scanner(hass, config): """Return a Sky Hub scanner if successful.""" host = config[DOMAIN].get(CONF_HOST, "192.168.1.254") websession = async_get_clientsession(hass) hub = SkyQHub(websession, host) _LOGGER.debug("Initialising Sky Hub") await hub.async_connect() if hub.su...
[ "async", "def", "async_get_scanner", "(", "hass", ",", "config", ")", ":", "host", "=", "config", "[", "DOMAIN", "]", ".", "get", "(", "CONF_HOST", ",", "\"192.168.1.254\"", ")", "websession", "=", "async_get_clientsession", "(", "hass", ")", "hub", "=", "...
[ 20, 0 ]
[ 32, 15 ]
python
en
['en', 'co', 'en']
True
SkyHubDeviceScanner.__init__
(self, hub)
Initialise the scanner.
Initialise the scanner.
def __init__(self, hub): """Initialise the scanner.""" self._hub = hub self.last_results = {}
[ "def", "__init__", "(", "self", ",", "hub", ")", ":", "self", ".", "_hub", "=", "hub", "self", ".", "last_results", "=", "{", "}" ]
[ 38, 4 ]
[ 41, 30 ]
python
en
['en', 'en', 'en']
True
SkyHubDeviceScanner.async_scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
async def async_scan_devices(self): """Scan for new devices and return a list with found device IDs.""" await self._async_update_info() return [device.mac for device in self.last_results]
[ "async", "def", "async_scan_devices", "(", "self", ")", ":", "await", "self", ".", "_async_update_info", "(", ")", "return", "[", "device", ".", "mac", "for", "device", "in", "self", ".", "last_results", "]" ]
[ 43, 4 ]
[ 46, 59 ]
python
en
['en', 'en', 'en']
True
SkyHubDeviceScanner.async_get_device_name
(self, device)
Return the name of the given device.
Return the name of the given device.
async def async_get_device_name(self, device): """Return the name of the given device.""" name = next( (result.name for result in self.last_results if result.mac == device), None, ) return name
[ "async", "def", "async_get_device_name", "(", "self", ",", "device", ")", ":", "name", "=", "next", "(", "(", "result", ".", "name", "for", "result", "in", "self", ".", "last_results", "if", "result", ".", "mac", "==", "device", ")", ",", "None", ",", ...
[ 48, 4 ]
[ 54, 19 ]
python
en
['en', 'en', 'en']
True
SkyHubDeviceScanner.async_get_extra_attributes
(self, device)
Get extra attributes of a device.
Get extra attributes of a device.
async def async_get_extra_attributes(self, device): """Get extra attributes of a device.""" device = next( (result for result in self.last_results if result.mac == device), None ) if device is None: return {} return device.asdict()
[ "async", "def", "async_get_extra_attributes", "(", "self", ",", "device", ")", ":", "device", "=", "next", "(", "(", "result", "for", "result", "in", "self", ".", "last_results", "if", "result", ".", "mac", "==", "device", ")", ",", "None", ")", "if", ...
[ 56, 4 ]
[ 64, 30 ]
python
en
['en', 'en', 'en']
True
SkyHubDeviceScanner._async_update_info
(self)
Ensure the information from the Sky Hub is up to date.
Ensure the information from the Sky Hub is up to date.
async def _async_update_info(self): """Ensure the information from the Sky Hub is up to date.""" _LOGGER.debug("Scanning") data = await self._hub.async_get_skyhub_data() if not data: return self.last_results = data
[ "async", "def", "_async_update_info", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Scanning\"", ")", "data", "=", "await", "self", ".", "_hub", ".", "async_get_skyhub_data", "(", ")", "if", "not", "data", ":", "return", "self", ".", "last_result...
[ 66, 4 ]
[ 75, 32 ]
python
en
['en', 'en', 'en']
True
run_clark2009
(catchment, output_dem, hydro_year_to_take, met_inp_folder, catchment_shp_folder)
wrapper to call the clark 2009 snow model for given area :param catchment: string giving catchment area to run model on :param output_dem: string identifying the grid to run model on :param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001 ...
wrapper to call the clark 2009 snow model for given area :param catchment: string giving catchment area to run model on :param output_dem: string identifying the grid to run model on :param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001 ...
def run_clark2009(catchment, output_dem, hydro_year_to_take, met_inp_folder, catchment_shp_folder): """ wrapper to call the clark 2009 snow model for given area :param catchment: string giving catchment area to run model on :param output_dem: string identifying the grid to run model on :param hydro_...
[ "def", "run_clark2009", "(", "catchment", ",", "output_dem", ",", "hydro_year_to_take", ",", "met_inp_folder", ",", "catchment_shp_folder", ")", ":", "print", "(", "'loading met data'", ")", "data_id", "=", "'{}_{}'", ".", "format", "(", "catchment", ",", "output_...
[ 22, 0 ]
[ 56, 48 ]
python
en
['en', 'error', 'th']
False
load_dsc_snow_output
(catchment, output_dem, hydro_year_to_take, dsc_snow_output_folder, dsc_snow_dem_folder)
load output from dsc_snow model previously run from linux VM :param catchment: string giving catchment area to run model on :param output_dem: string identifying the grid to run model on :param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001 ...
load output from dsc_snow model previously run from linux VM :param catchment: string giving catchment area to run model on :param output_dem: string identifying the grid to run model on :param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001 ...
def load_dsc_snow_output(catchment, output_dem, hydro_year_to_take, dsc_snow_output_folder, dsc_snow_dem_folder): """ load output from dsc_snow model previously run from linux VM :param catchment: string giving catchment area to run model on :param output_dem: string identifying the grid to run model on...
[ "def", "load_dsc_snow_output", "(", "catchment", ",", "output_dem", ",", "hydro_year_to_take", ",", "dsc_snow_output_folder", ",", "dsc_snow_dem_folder", ")", ":", "data_id", "=", "'{}_{}'", ".", "format", "(", "catchment", ",", "output_dem", ")", "dsc_snow_output", ...
[ 59, 0 ]
[ 89, 66 ]
python
en
['en', 'error', 'th']
False
load_subset_modis
(catchment, output_dem, hydro_year_to_take, modis_folder, dem_folder, modis_dem, mask_folder, catchment_shp_folder)
load modis data from file and cut to catchment of interest :param catchment: string giving catchment area to run model on :param output_dem: string identifying the grid to run model on :param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001 ...
load modis data from file and cut to catchment of interest :param catchment: string giving catchment area to run model on :param output_dem: string identifying the grid to run model on :param hydro_year_to_take: integer specifying the hydrological year to run model over. 2001 = 1/4/2000 to 31/3/2001 ...
def load_subset_modis(catchment, output_dem, hydro_year_to_take, modis_folder, dem_folder, modis_dem, mask_folder, catchment_shp_folder): """ load modis data from file and cut to catchment of interest :param catchment: string giving catchment area to run model on :param output_dem: string identifying th...
[ "def", "load_subset_modis", "(", "catchment", ",", "output_dem", ",", "hydro_year_to_take", ",", "modis_folder", ",", "dem_folder", ",", "modis_dem", ",", "mask_folder", ",", "catchment_shp_folder", ")", ":", "# load a file", "nc_file", "=", "nc", ".", "Dataset", ...
[ 92, 0 ]
[ 116, 47 ]
python
en
['en', 'error', 'th']
False
load_mask_modis
(catchment, output_dem, mask_folder, dem_folder, modis_dem)
load mask and trimmed mask of catchment for modis clutha domain
load mask and trimmed mask of catchment for modis clutha domain
def load_mask_modis(catchment, output_dem, mask_folder, dem_folder, modis_dem): ''' load mask and trimmed mask of catchment for modis clutha domain ''' if modis_dem == 'clutha_dem_250m': # dem_file = dem_folder + modis_dem + '.tif' _, x_centres, y_centres, lat_array, lon_array = setup_n...
[ "def", "load_mask_modis", "(", "catchment", ",", "output_dem", ",", "mask_folder", ",", "dem_folder", ",", "modis_dem", ")", ":", "if", "modis_dem", "==", "'clutha_dem_250m'", ":", "# dem_file = dem_folder + modis_dem + '.tif'", "_", ",", "x_centres", ",", "y_centres"...
[ 119, 0 ]
[ 143, 29 ]
python
en
['en', 'error', 'th']
False
fix_device_id_list
(data: List[Any])
Fix the id list by converting it to a supported int list.
Fix the id list by converting it to a supported int list.
def fix_device_id_list(data: List[Any]) -> List[int]: """Fix the id list by converting it to a supported int list.""" return str_to_int_list(list_to_str(data))
[ "def", "fix_device_id_list", "(", "data", ":", "List", "[", "Any", "]", ")", "->", "List", "[", "int", "]", ":", "return", "str_to_int_list", "(", "list_to_str", "(", "data", ")", ")" ]
[ 25, 0 ]
[ 27, 45 ]
python
en
['en', 'en', 'en']
True
str_to_int_list
(data: str)
Convert a string to an int list.
Convert a string to an int list.
def str_to_int_list(data: str) -> List[int]: """Convert a string to an int list.""" return [int(s) for s in LIST_REGEX.split(data) if len(s) > 0]
[ "def", "str_to_int_list", "(", "data", ":", "str", ")", "->", "List", "[", "int", "]", ":", "return", "[", "int", "(", "s", ")", "for", "s", "in", "LIST_REGEX", ".", "split", "(", "data", ")", "if", "len", "(", "s", ")", ">", "0", "]" ]
[ 30, 0 ]
[ 32, 65 ]
python
en
['en', 'lb', 'en']
True
list_to_str
(data: List[Any])
Convert an int list to a string.
Convert an int list to a string.
def list_to_str(data: List[Any]) -> str: """Convert an int list to a string.""" return " ".join([str(i) for i in data])
[ "def", "list_to_str", "(", "data", ":", "List", "[", "Any", "]", ")", "->", "str", ":", "return", "\" \"", ".", "join", "(", "[", "str", "(", "i", ")", "for", "i", "in", "data", "]", ")" ]
[ 35, 0 ]
[ 37, 43 ]
python
en
['en', 'lb', 'en']
True
new_options
(lights: List[int], exclude: List[int])
Create a standard options object.
Create a standard options object.
def new_options(lights: List[int], exclude: List[int]) -> dict: """Create a standard options object.""" return {CONF_LIGHTS: lights, CONF_EXCLUDE: exclude}
[ "def", "new_options", "(", "lights", ":", "List", "[", "int", "]", ",", "exclude", ":", "List", "[", "int", "]", ")", "->", "dict", ":", "return", "{", "CONF_LIGHTS", ":", "lights", ",", "CONF_EXCLUDE", ":", "exclude", "}" ]
[ 40, 0 ]
[ 42, 55 ]
python
en
['en', 'en', 'en']
True
options_schema
(options: dict = None)
Return options schema.
Return options schema.
def options_schema(options: dict = None) -> dict: """Return options schema.""" options = options or {} return { vol.Optional( CONF_LIGHTS, default=list_to_str(options.get(CONF_LIGHTS, [])), ): str, vol.Optional( CONF_EXCLUDE, default=li...
[ "def", "options_schema", "(", "options", ":", "dict", "=", "None", ")", "->", "dict", ":", "options", "=", "options", "or", "{", "}", "return", "{", "vol", ".", "Optional", "(", "CONF_LIGHTS", ",", "default", "=", "list_to_str", "(", "options", ".", "g...
[ 45, 0 ]
[ 57, 5 ]
python
en
['en', 'de', 'en']
True
options_data
(user_input: dict)
Return options dict.
Return options dict.
def options_data(user_input: dict) -> dict: """Return options dict.""" return new_options( str_to_int_list(user_input.get(CONF_LIGHTS, "")), str_to_int_list(user_input.get(CONF_EXCLUDE, "")), )
[ "def", "options_data", "(", "user_input", ":", "dict", ")", "->", "dict", ":", "return", "new_options", "(", "str_to_int_list", "(", "user_input", ".", "get", "(", "CONF_LIGHTS", ",", "\"\"", ")", ")", ",", "str_to_int_list", "(", "user_input", ".", "get", ...
[ 60, 0 ]
[ 65, 5 ]
python
bg
['fr', 'bg', 'en']
False
OptionsFlowHandler.__init__
(self, config_entry: ConfigEntry)
Init object.
Init object.
def __init__(self, config_entry: ConfigEntry): """Init object.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ":", "ConfigEntry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 71, 4 ]
[ 73, 40 ]
python
en
['en', 'en', 'en']
False
OptionsFlowHandler.async_step_init
(self, user_input: dict = None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input: dict = None): """Manage the options.""" if user_input is not None: return self.async_create_entry( title="", data=options_data(user_input), ) return self.async_show_form( step_id="ini...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", ":", "dict", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "options_data", ...
[ 75, 4 ]
[ 86, 9 ]
python
en
['en', 'en', 'en']
True
VeraFlowHandler.async_get_options_flow
(config_entry: ConfigEntry)
Get the options flow.
Get the options flow.
def async_get_options_flow(config_entry: ConfigEntry) -> OptionsFlowHandler: """Get the options flow.""" return OptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ":", "ConfigEntry", ")", "->", "OptionsFlowHandler", ":", "return", "OptionsFlowHandler", "(", "config_entry", ")" ]
[ 94, 4 ]
[ 96, 47 ]
python
en
['en', 'en', 'en']
True
VeraFlowHandler.async_step_user
(self, user_input: dict = None)
Handle user initiated flow.
Handle user initiated flow.
async def async_step_user(self, user_input: dict = None): """Handle user initiated flow.""" if user_input is not None: return await self.async_step_finish( { **user_input, **options_data(user_input), **{CONF_SOURCE: ...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", ":", "dict", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "await", "self", ".", "async_step_finish", "(", "{", "*", "*", "user_input", ",", "*", "*", "...
[ 98, 4 ]
[ 115, 9 ]
python
en
['en', 'nl', 'en']
True
VeraFlowHandler.async_step_import
(self, config: dict)
Handle a flow initialized by import.
Handle a flow initialized by import.
async def async_step_import(self, config: dict): """Handle a flow initialized by import.""" # If there are entities with the legacy unique_id, then this imported config # should also use the legacy unique_id for entity creation. entity_registry: EntityRegistry = ( await self...
[ "async", "def", "async_step_import", "(", "self", ",", "config", ":", "dict", ")", ":", "# If there are entities with the legacy unique_id, then this imported config", "# should also use the legacy unique_id for entity creation.", "entity_registry", ":", "EntityRegistry", "=", "(",...
[ 117, 4 ]
[ 142, 9 ]
python
en
['en', 'en', 'en']
True
VeraFlowHandler.async_step_finish
(self, config: dict)
Validate and create config entry.
Validate and create config entry.
async def async_step_finish(self, config: dict): """Validate and create config entry.""" base_url = config[CONF_CONTROLLER] = config[CONF_CONTROLLER].rstrip("/") controller = pv.VeraController(base_url) # Verify the controller is online and get the serial number. try: ...
[ "async", "def", "async_step_finish", "(", "self", ",", "config", ":", "dict", ")", ":", "base_url", "=", "config", "[", "CONF_CONTROLLER", "]", "=", "config", "[", "CONF_CONTROLLER", "]", ".", "rstrip", "(", "\"/\"", ")", "controller", "=", "pv", ".", "V...
[ 144, 4 ]
[ 161, 67 ]
python
en
['en', 'en', 'en']
True
test_reload_notify
(hass)
Verify we can reload the notify service.
Verify we can reload the notify service.
async def test_reload_notify(hass): """Verify we can reload the notify service.""" with patch( "homeassistant.components.smtp.notify.MailNotificationService.connection_is_valid" ): assert await async_setup_component( hass, notify.DOMAIN, { ...
[ "async", "def", "test_reload_notify", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.smtp.notify.MailNotificationService.connection_is_valid\"", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "notify", ".", "DOMAIN", ",",...
[ 24, 0 ]
[ 65, 68 ]
python
en
['en', 'en', 'en']
True
message
()
Return MockSMTP object with test data.
Return MockSMTP object with test data.
def message(): """Return MockSMTP object with test data.""" mailer = MockSMTP( "localhost", 25, 5, "test@test.com", 1, "testuser", "testpass", ["recip1@example.com", "testrecip@test.com"], "Home Assistant", 0, ) yield mailer
[ "def", "message", "(", ")", ":", "mailer", "=", "MockSMTP", "(", "\"localhost\"", ",", "25", ",", "5", ",", "\"test@test.com\"", ",", "1", ",", "\"testuser\"", ",", "\"testpass\"", ",", "[", "\"recip1@example.com\"", ",", "\"testrecip@test.com\"", "]", ",", ...
[ 73, 0 ]
[ 87, 16 ]
python
en
['en', 'en', 'en']
True
test_send_message
(message_data, data, content_type, hass, message)
Verify if we can send messages of all types correctly.
Verify if we can send messages of all types correctly.
def test_send_message(message_data, data, content_type, hass, message): """Verify if we can send messages of all types correctly.""" sample_email = "<mock@mock>" with patch("email.utils.make_msgid", return_value=sample_email): result = message.send_message(message_data, data=data) assert con...
[ "def", "test_send_message", "(", "message_data", ",", "data", ",", "content_type", ",", "hass", ",", "message", ")", ":", "sample_email", "=", "\"<mock@mock>\"", "with", "patch", "(", "\"email.utils.make_msgid\"", ",", "return_value", "=", "sample_email", ")", ":"...
[ 139, 0 ]
[ 144, 37 ]
python
en
['en', 'en', 'en']
True
test_send_text_message
(hass, message)
Verify if we can send simple text message.
Verify if we can send simple text message.
def test_send_text_message(hass, message): """Verify if we can send simple text message.""" expected = ( '^Content-Type: text/plain; charset="us-ascii"\n' "MIME-Version: 1.0\n" "Content-Transfer-Encoding: 7bit\n" "Subject: Home Assistant\n" "To: recip1@example.com,testrec...
[ "def", "test_send_text_message", "(", "hass", ",", "message", ")", ":", "expected", "=", "(", "'^Content-Type: text/plain; charset=\"us-ascii\"\\n'", "\"MIME-Version: 1.0\\n\"", "\"Content-Transfer-Encoding: 7bit\\n\"", "\"Subject: Home Assistant\\n\"", "\"To: recip1@example.com,testre...
[ 147, 0 ]
[ 166, 42 ]
python
en
['en', 'en', 'en']
True
MockSMTP._send_email
(self, msg)
Just return string for testing.
Just return string for testing.
def _send_email(self, msg): """Just return string for testing.""" return msg.as_string()
[ "def", "_send_email", "(", "self", ",", "msg", ")", ":", "return", "msg", ".", "as_string", "(", ")" ]
[ 19, 4 ]
[ 21, 30 ]
python
en
['en', 'no', 'en']
True