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
QSBinarySensor.__init__
(self, sensor)
Initialize the sensor.
Initialize the sensor.
def __init__(self, sensor): """Initialize the sensor.""" super().__init__(sensor["id"], sensor["name"]) self.channel = sensor["channel"] sensor_type = sensor["type"] self._decode, _ = SENSORS[sensor_type] self._invert = not sensor.get("invert", False) self._clas...
[ "def", "__init__", "(", "self", ",", "sensor", ")", ":", "super", "(", ")", ".", "__init__", "(", "sensor", "[", "\"id\"", "]", ",", "sensor", "[", "\"name\"", "]", ")", "self", ".", "channel", "=", "sensor", "[", "\"channel\"", "]", "sensor_type", "...
[ 29, 4 ]
[ 38, 49 ]
python
en
['en', 'en', 'en']
True
QSBinarySensor.update_packet
(self, packet)
Receive update packet from QSUSB.
Receive update packet from QSUSB.
def update_packet(self, packet): """Receive update packet from QSUSB.""" val = self._decode(packet, channel=self.channel) _LOGGER.debug( "Update %s (%s:%s) decoded as %s: %s", self.entity_id, self.qsid, self.channel, val, pa...
[ "def", "update_packet", "(", "self", ",", "packet", ")", ":", "val", "=", "self", ".", "_decode", "(", "packet", ",", "channel", "=", "self", ".", "channel", ")", "_LOGGER", ".", "debug", "(", "\"Update %s (%s:%s) decoded as %s: %s\"", ",", "self", ".", "e...
[ 41, 4 ]
[ 54, 39 ]
python
en
['en', 'en', 'en']
True
QSBinarySensor.is_on
(self)
Check if device is on (non-zero).
Check if device is on (non-zero).
def is_on(self): """Check if device is on (non-zero).""" return self._val == self._invert
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_val", "==", "self", ".", "_invert" ]
[ 57, 4 ]
[ 59, 40 ]
python
en
['en', 'en', 'en']
True
QSBinarySensor.unique_id
(self)
Return a unique identifier for this sensor.
Return a unique identifier for this sensor.
def unique_id(self): """Return a unique identifier for this sensor.""" return f"qs{self.qsid}:{self.channel}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"qs{self.qsid}:{self.channel}\"" ]
[ 62, 4 ]
[ 64, 46 ]
python
en
['en', 'fr', 'en']
True
QSBinarySensor.device_class
(self)
Return the class of this sensor.
Return the class of this sensor.
def device_class(self): """Return the class of this sensor.""" return self._class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_class" ]
[ 67, 4 ]
[ 69, 26 ]
python
en
['en', 'en', 'en']
True
distance2bbox
(points, distance, max_shape=None)
Decode distance prediction to bounding box. Args: points (Tensor): Shape (n, 2), [x, y]. distance (Tensor): Distance from the given point to 4 boundaries (left, top, right, bottom). max_shape (tuple): Shape of the image. Returns: Tensor: Decoded bboxes.
Decode distance prediction to bounding box.
def distance2bbox(points, distance, max_shape=None): """Decode distance prediction to bounding box. Args: points (Tensor): Shape (n, 2), [x, y]. distance (Tensor): Distance from the given point to 4 boundaries (left, top, right, bottom). max_shape (tuple): Shape of the image...
[ "def", "distance2bbox", "(", "points", ",", "distance", ",", "max_shape", "=", "None", ")", ":", "x1", "=", "points", "[", ":", ",", "0", "]", "-", "distance", "[", ":", ",", "0", "]", "y1", "=", "points", "[", ":", ",", "1", "]", "-", "distanc...
[ 27, 0 ]
[ 48, 46 ]
python
en
['en', 'en', 'en']
True
distance2kps
(points, distance, max_shape=None)
Decode distance prediction to bounding box. Args: points (Tensor): Shape (n, 2), [x, y]. distance (Tensor): Distance from the given point to 4 boundaries (left, top, right, bottom). max_shape (tuple): Shape of the image. Returns: Tensor: Decoded bboxes.
Decode distance prediction to bounding box.
def distance2kps(points, distance, max_shape=None): """Decode distance prediction to bounding box. Args: points (Tensor): Shape (n, 2), [x, y]. distance (Tensor): Distance from the given point to 4 boundaries (left, top, right, bottom). max_shape (tuple): Shape of the image....
[ "def", "distance2kps", "(", "points", ",", "distance", ",", "max_shape", "=", "None", ")", ":", "preds", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "distance", ".", "shape", "[", "1", "]", ",", "2", ")", ":", "px", "=", "points", ...
[ 51, 0 ]
[ 72, 35 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Old way of setting up the Daikin HVAC platform. Can only be called when a user accidentally mentions the platform in their config. But even in that case it would have been ignored.
Old way of setting up the Daikin HVAC platform.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Old way of setting up the Daikin HVAC platform. Can only be called when a user accidentally mentions the platform in their config. But even in that case it would have been ignored. """
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":" ]
[ 82, 0 ]
[ 87, 7 ]
python
en
['en', 'jv', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up Daikin climate based on config_entry.
Set up Daikin climate based on config_entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up Daikin climate based on config_entry.""" daikin_api = hass.data[DAIKIN_DOMAIN].get(entry.entry_id) async_add_entities([DaikinClimate(daikin_api)], update_before_add=True)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "daikin_api", "=", "hass", ".", "data", "[", "DAIKIN_DOMAIN", "]", ".", "get", "(", "entry", ".", "entry_id", ")", "async_add_entities", "(", "[", "DaikinCli...
[ 90, 0 ]
[ 93, 75 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.__init__
(self, api)
Initialize the climate device.
Initialize the climate device.
def __init__(self, api): """Initialize the climate device.""" self._api = api self._list = { ATTR_HVAC_MODE: list(HA_STATE_TO_DAIKIN), ATTR_FAN_MODE: self._api.device.fan_rate, ATTR_SWING_MODE: self._api.device.swing_modes, } self._supported_...
[ "def", "__init__", "(", "self", ",", "api", ")", ":", "self", ".", "_api", "=", "api", "self", ".", "_list", "=", "{", "ATTR_HVAC_MODE", ":", "list", "(", "HA_STATE_TO_DAIKIN", ")", ",", "ATTR_FAN_MODE", ":", "self", ".", "_api", ".", "device", ".", ...
[ 99, 4 ]
[ 121, 58 ]
python
en
['en', 'en', 'en']
True
DaikinClimate._set
(self, settings)
Set device settings using API.
Set device settings using API.
async def _set(self, settings): """Set device settings using API.""" values = {} for attr in [ATTR_TEMPERATURE, ATTR_FAN_MODE, ATTR_SWING_MODE, ATTR_HVAC_MODE]: value = settings.get(attr) if value is None: continue daikin_attr = HA_ATTR_TO_DA...
[ "async", "def", "_set", "(", "self", ",", "settings", ")", ":", "values", "=", "{", "}", "for", "attr", "in", "[", "ATTR_TEMPERATURE", ",", "ATTR_FAN_MODE", ",", "ATTR_SWING_MODE", ",", "ATTR_HVAC_MODE", "]", ":", "value", "=", "settings", ".", "get", "(...
[ 123, 4 ]
[ 149, 46 ]
python
en
['fr', 'sq', 'en']
False
DaikinClimate.supported_features
(self)
Return the list of supported features.
Return the list of supported features.
def supported_features(self): """Return the list of supported features.""" return self._supported_features
[ "def", "supported_features", "(", "self", ")", ":", "return", "self", ".", "_supported_features" ]
[ 152, 4 ]
[ 154, 39 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.name
(self)
Return the name of the thermostat, if any.
Return the name of the thermostat, if any.
def name(self): """Return the name of the thermostat, if any.""" return self._api.name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "name" ]
[ 157, 4 ]
[ 159, 29 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._api.device.mac
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "device", ".", "mac" ]
[ 162, 4 ]
[ 164, 35 ]
python
ca
['fr', 'ca', 'en']
False
DaikinClimate.temperature_unit
(self)
Return the unit of measurement which this thermostat uses.
Return the unit of measurement which this thermostat uses.
def temperature_unit(self): """Return the unit of measurement which this thermostat uses.""" return TEMP_CELSIUS
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_CELSIUS" ]
[ 167, 4 ]
[ 169, 27 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._api.device.inside_temperature
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "device", ".", "inside_temperature" ]
[ 172, 4 ]
[ 174, 50 ]
python
en
['en', 'la', 'en']
True
DaikinClimate.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" return self._api.device.target_temperature
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "device", ".", "target_temperature" ]
[ 177, 4 ]
[ 179, 50 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.target_temperature_step
(self)
Return the supported step of target temperature.
Return the supported step of target temperature.
def target_temperature_step(self): """Return the supported step of target temperature.""" return 1
[ "def", "target_temperature_step", "(", "self", ")", ":", "return", "1" ]
[ 182, 4 ]
[ 184, 16 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.async_set_temperature
(self, **kwargs)
Set new target temperature.
Set new target temperature.
async def async_set_temperature(self, **kwargs): """Set new target temperature.""" await self._set(kwargs)
[ "async", "def", "async_set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_set", "(", "kwargs", ")" ]
[ 186, 4 ]
[ 188, 31 ]
python
en
['en', 'ca', 'en']
True
DaikinClimate.hvac_mode
(self)
Return current operation ie. heat, cool, idle.
Return current operation ie. heat, cool, idle.
def hvac_mode(self): """Return current operation ie. heat, cool, idle.""" daikin_mode = self._api.device.represent(HA_ATTR_TO_DAIKIN[ATTR_HVAC_MODE])[1] return DAIKIN_TO_HA_STATE.get(daikin_mode, HVAC_MODE_HEAT_COOL)
[ "def", "hvac_mode", "(", "self", ")", ":", "daikin_mode", "=", "self", ".", "_api", ".", "device", ".", "represent", "(", "HA_ATTR_TO_DAIKIN", "[", "ATTR_HVAC_MODE", "]", ")", "[", "1", "]", "return", "DAIKIN_TO_HA_STATE", ".", "get", "(", "daikin_mode", "...
[ 191, 4 ]
[ 194, 71 ]
python
en
['nl', 'en', 'en']
True
DaikinClimate.hvac_modes
(self)
Return the list of available operation modes.
Return the list of available operation modes.
def hvac_modes(self): """Return the list of available operation modes.""" return self._list.get(ATTR_HVAC_MODE)
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "self", ".", "_list", ".", "get", "(", "ATTR_HVAC_MODE", ")" ]
[ 197, 4 ]
[ 199, 45 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.async_set_hvac_mode
(self, hvac_mode)
Set HVAC mode.
Set HVAC mode.
async def async_set_hvac_mode(self, hvac_mode): """Set HVAC mode.""" await self._set({ATTR_HVAC_MODE: hvac_mode})
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "await", "self", ".", "_set", "(", "{", "ATTR_HVAC_MODE", ":", "hvac_mode", "}", ")" ]
[ 201, 4 ]
[ 203, 52 ]
python
en
['en', 'pt', 'en']
True
DaikinClimate.fan_mode
(self)
Return the fan setting.
Return the fan setting.
def fan_mode(self): """Return the fan setting.""" return self._api.device.represent(HA_ATTR_TO_DAIKIN[ATTR_FAN_MODE])[1].title()
[ "def", "fan_mode", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "device", ".", "represent", "(", "HA_ATTR_TO_DAIKIN", "[", "ATTR_FAN_MODE", "]", ")", "[", "1", "]", ".", "title", "(", ")" ]
[ 206, 4 ]
[ 208, 86 ]
python
en
['en', 'fy', 'en']
True
DaikinClimate.async_set_fan_mode
(self, fan_mode)
Set fan mode.
Set fan mode.
async def async_set_fan_mode(self, fan_mode): """Set fan mode.""" await self._set({ATTR_FAN_MODE: fan_mode})
[ "async", "def", "async_set_fan_mode", "(", "self", ",", "fan_mode", ")", ":", "await", "self", ".", "_set", "(", "{", "ATTR_FAN_MODE", ":", "fan_mode", "}", ")" ]
[ 210, 4 ]
[ 212, 50 ]
python
fy
['sv', 'fy', 'nl']
False
DaikinClimate.fan_modes
(self)
List of available fan modes.
List of available fan modes.
def fan_modes(self): """List of available fan modes.""" return self._list.get(ATTR_FAN_MODE)
[ "def", "fan_modes", "(", "self", ")", ":", "return", "self", ".", "_list", ".", "get", "(", "ATTR_FAN_MODE", ")" ]
[ 215, 4 ]
[ 217, 44 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.swing_mode
(self)
Return the fan setting.
Return the fan setting.
def swing_mode(self): """Return the fan setting.""" return self._api.device.represent(HA_ATTR_TO_DAIKIN[ATTR_SWING_MODE])[1].title()
[ "def", "swing_mode", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "device", ".", "represent", "(", "HA_ATTR_TO_DAIKIN", "[", "ATTR_SWING_MODE", "]", ")", "[", "1", "]", ".", "title", "(", ")" ]
[ 220, 4 ]
[ 222, 88 ]
python
en
['en', 'fy', 'en']
True
DaikinClimate.async_set_swing_mode
(self, swing_mode)
Set new target temperature.
Set new target temperature.
async def async_set_swing_mode(self, swing_mode): """Set new target temperature.""" await self._set({ATTR_SWING_MODE: swing_mode})
[ "async", "def", "async_set_swing_mode", "(", "self", ",", "swing_mode", ")", ":", "await", "self", ".", "_set", "(", "{", "ATTR_SWING_MODE", ":", "swing_mode", "}", ")" ]
[ 224, 4 ]
[ 226, 54 ]
python
en
['en', 'ca', 'en']
True
DaikinClimate.swing_modes
(self)
List of available swing modes.
List of available swing modes.
def swing_modes(self): """List of available swing modes.""" return self._list.get(ATTR_SWING_MODE)
[ "def", "swing_modes", "(", "self", ")", ":", "return", "self", ".", "_list", ".", "get", "(", "ATTR_SWING_MODE", ")" ]
[ 229, 4 ]
[ 231, 46 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.preset_mode
(self)
Return the preset_mode.
Return the preset_mode.
def preset_mode(self): """Return the preset_mode.""" if ( self._api.device.represent(HA_ATTR_TO_DAIKIN[ATTR_PRESET_MODE])[1] == HA_PRESET_TO_DAIKIN[PRESET_AWAY] ): return PRESET_AWAY if ( HA_PRESET_TO_DAIKIN[PRESET_BOOST] in sel...
[ "def", "preset_mode", "(", "self", ")", ":", "if", "(", "self", ".", "_api", ".", "device", ".", "represent", "(", "HA_ATTR_TO_DAIKIN", "[", "ATTR_PRESET_MODE", "]", ")", "[", "1", "]", "==", "HA_PRESET_TO_DAIKIN", "[", "PRESET_AWAY", "]", ")", ":", "ret...
[ 234, 4 ]
[ 251, 26 ]
python
en
['en', 'no', 'en']
True
DaikinClimate.async_set_preset_mode
(self, preset_mode)
Set preset mode.
Set preset mode.
async def async_set_preset_mode(self, preset_mode): """Set preset mode.""" if preset_mode == PRESET_AWAY: await self._api.device.set_holiday(ATTR_STATE_ON) elif preset_mode == PRESET_BOOST: await self._api.device.set_advanced_mode( HA_PRESET_TO_DAIKIN[PRES...
[ "async", "def", "async_set_preset_mode", "(", "self", ",", "preset_mode", ")", ":", "if", "preset_mode", "==", "PRESET_AWAY", ":", "await", "self", ".", "_api", ".", "device", ".", "set_holiday", "(", "ATTR_STATE_ON", ")", "elif", "preset_mode", "==", "PRESET_...
[ 253, 4 ]
[ 275, 17 ]
python
de
['de', 'pt', 'it']
False
DaikinClimate.preset_modes
(self)
List of available preset modes.
List of available preset modes.
def preset_modes(self): """List of available preset modes.""" ret = [PRESET_NONE] if self._api.device.support_away_mode: ret.append(PRESET_AWAY) if self._api.device.support_advanced_modes: ret += [PRESET_ECO, PRESET_BOOST] return ret
[ "def", "preset_modes", "(", "self", ")", ":", "ret", "=", "[", "PRESET_NONE", "]", "if", "self", ".", "_api", ".", "device", ".", "support_away_mode", ":", "ret", ".", "append", "(", "PRESET_AWAY", ")", "if", "self", ".", "_api", ".", "device", ".", ...
[ 278, 4 ]
[ 285, 18 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.async_update
(self)
Retrieve latest state.
Retrieve latest state.
async def async_update(self): """Retrieve latest state.""" await self._api.async_update()
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "_api", ".", "async_update", "(", ")" ]
[ 287, 4 ]
[ 289, 38 ]
python
en
['es', 'sk', 'en']
False
DaikinClimate.async_turn_on
(self)
Turn device on.
Turn device on.
async def async_turn_on(self): """Turn device on.""" await self._api.device.set({})
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "await", "self", ".", "_api", ".", "device", ".", "set", "(", "{", "}", ")" ]
[ 291, 4 ]
[ 293, 38 ]
python
en
['es', 'en', 'en']
True
DaikinClimate.async_turn_off
(self)
Turn device off.
Turn device off.
async def async_turn_off(self): """Turn device off.""" await self._api.device.set( {HA_ATTR_TO_DAIKIN[ATTR_HVAC_MODE]: HA_STATE_TO_DAIKIN[HVAC_MODE_OFF]} )
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "await", "self", ".", "_api", ".", "device", ".", "set", "(", "{", "HA_ATTR_TO_DAIKIN", "[", "ATTR_HVAC_MODE", "]", ":", "HA_STATE_TO_DAIKIN", "[", "HVAC_MODE_OFF", "]", "}", ")" ]
[ 295, 4 ]
[ 299, 9 ]
python
en
['en', 'en', 'en']
True
DaikinClimate.device_info
(self)
Return a device description for device registry.
Return a device description for device registry.
def device_info(self): """Return a device description for device registry.""" return self._api.device_info
[ "def", "device_info", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "device_info" ]
[ 302, 4 ]
[ 304, 36 ]
python
en
['ro', 'fr', 'en']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Tesla binary_sensors by config_entry.
Set up the Tesla binary_sensors by config_entry.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Tesla binary_sensors by config_entry.""" entities = [ TeslaLock( device, hass.data[TESLA_DOMAIN][config_entry.entry_id]["coordinator"], ) for device in hass.data[TESLA_DOMAIN][confi...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "TeslaLock", "(", "device", ",", "hass", ".", "data", "[", "TESLA_DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "[", ...
[ 10, 0 ]
[ 19, 38 ]
python
en
['en', 'en', 'en']
True
TeslaLock.async_lock
(self, **kwargs)
Send the lock command.
Send the lock command.
async def async_lock(self, **kwargs): """Send the lock command.""" _LOGGER.debug("Locking doors for: %s", self.name) await self.tesla_device.lock()
[ "async", "def", "async_lock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Locking doors for: %s\"", ",", "self", ".", "name", ")", "await", "self", ".", "tesla_device", ".", "lock", "(", ")" ]
[ 25, 4 ]
[ 28, 38 ]
python
en
['en', 'it', 'en']
True
TeslaLock.async_unlock
(self, **kwargs)
Send the unlock command.
Send the unlock command.
async def async_unlock(self, **kwargs): """Send the unlock command.""" _LOGGER.debug("Unlocking doors for: %s", self.name) await self.tesla_device.unlock()
[ "async", "def", "async_unlock", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Unlocking doors for: %s\"", ",", "self", ".", "name", ")", "await", "self", ".", "tesla_device", ".", "unlock", "(", ")" ]
[ 30, 4 ]
[ 33, 40 ]
python
en
['en', 'zh', 'en']
True
TeslaLock.is_locked
(self)
Get whether the lock is in locked state.
Get whether the lock is in locked state.
def is_locked(self): """Get whether the lock is in locked state.""" if self.tesla_device.is_locked() is None: return None return self.tesla_device.is_locked()
[ "def", "is_locked", "(", "self", ")", ":", "if", "self", ".", "tesla_device", ".", "is_locked", "(", ")", "is", "None", ":", "return", "None", "return", "self", ".", "tesla_device", ".", "is_locked", "(", ")" ]
[ 36, 4 ]
[ 40, 44 ]
python
en
['en', 'en', 'en']
True
setup_ozw
(hass, entry=None, fixture=None)
Set up OZW and load a dump.
Set up OZW and load a dump.
async def setup_ozw(hass, entry=None, fixture=None): """Set up OZW and load a dump.""" hass.config.components.add("mqtt") if entry is None: entry = MockConfigEntry( domain=DOMAIN, title="Z-Wave", connection_class=config_entries.CONN_CLASS_LOCAL_PUSH, ) ...
[ "async", "def", "setup_ozw", "(", "hass", ",", "entry", "=", "None", ",", "fixture", "=", "None", ")", ":", "hass", ".", "config", ".", "components", ".", "add", "(", "\"mqtt\"", ")", "if", "entry", "is", "None", ":", "entry", "=", "MockConfigEntry", ...
[ 10, 0 ]
[ 42, 26 ]
python
en
['en', 'en', 'en']
True
MQTTMessage.__init__
(self, topic, payload)
Set up message.
Set up message.
def __init__(self, topic, payload): """Set up message.""" self.topic = topic self.payload = payload
[ "def", "__init__", "(", "self", ",", "topic", ",", "payload", ")", ":", "self", ".", "topic", "=", "topic", "self", ".", "payload", "=", "payload" ]
[ 48, 4 ]
[ 51, 30 ]
python
en
['en', 'lb', 'en']
True
MQTTMessage.decode
(self)
Decode message payload from a string to a json dict.
Decode message payload from a string to a json dict.
def decode(self): """Decode message payload from a string to a json dict.""" self.payload = json.loads(self.payload)
[ "def", "decode", "(", "self", ")", ":", "self", ".", "payload", "=", "json", ".", "loads", "(", "self", ".", "payload", ")" ]
[ 53, 4 ]
[ 55, 47 ]
python
en
['en', 'en', 'en']
True
MQTTMessage.encode
(self)
Encode message payload into a string.
Encode message payload into a string.
def encode(self): """Encode message payload into a string.""" self.payload = json.dumps(self.payload)
[ "def", "encode", "(", "self", ")", ":", "self", ".", "payload", "=", "json", ".", "dumps", "(", "self", ".", "payload", ")" ]
[ 57, 4 ]
[ 59, 47 ]
python
en
['en', 'en', 'en']
True
DotAttention.get_pre_compute
(self, s)
:param s: [src_sequence, batch_size, src_dim] :return: [src_sequence, batch_size. hidden_dim]
:param s: [src_sequence, batch_size, src_dim] :return: [src_sequence, batch_size. hidden_dim]
def get_pre_compute(self, s): ''' :param s: [src_sequence, batch_size, src_dim] :return: [src_sequence, batch_size. hidden_dim] ''' hidden_dim = self.hidden_dim src_dim = s.get_shape().as_list()[-1] assert src_dim is not None, 'src dim must be defined' W =...
[ "def", "get_pre_compute", "(", "self", ",", "s", ")", ":", "hidden_dim", "=", "self", ".", "hidden_dim", "src_dim", "=", "s", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "[", "-", "1", "]", "assert", "src_dim", "is", "not", "None", ",", "...
[ 91, 4 ]
[ 101, 49 ]
python
en
['en', 'error', 'th']
False
DotAttention.get_prob
(self, src, tgt, mask, pre_compute, return_logits=False)
:param s: [src_sequence_length, batch_size, src_dim] :param h: [batch_size, tgt_dim] or [tgt_sequence_length, batch_size, tgt_dim] :param mask: [src_sequence_length, batch_size]\ or [tgt_sequence_length, src_sequence_length, batch_sizse] :param pre_compute: [src_sequence_le...
:param s: [src_sequence_length, batch_size, src_dim] :param h: [batch_size, tgt_dim] or [tgt_sequence_length, batch_size, tgt_dim] :param mask: [src_sequence_length, batch_size]\ or [tgt_sequence_length, src_sequence_length, batch_sizse] :param pre_compute: [src_sequence_le...
def get_prob(self, src, tgt, mask, pre_compute, return_logits=False): ''' :param s: [src_sequence_length, batch_size, src_dim] :param h: [batch_size, tgt_dim] or [tgt_sequence_length, batch_size, tgt_dim] :param mask: [src_sequence_length, batch_size]\ or [tgt_sequence_lengt...
[ "def", "get_prob", "(", "self", ",", "src", ",", "tgt", ",", "mask", ",", "pre_compute", ",", "return_logits", "=", "False", ")", ":", "s_shape", "=", "src", ".", "get_shape", "(", ")", ".", "as_list", "(", ")", "h_shape", "=", "tgt", ".", "get_shape...
[ 103, 4 ]
[ 157, 19 ]
python
en
['en', 'error', 'th']
False
DotAttention.get_att
(self, s, prob)
:param s: [src_sequence_length, batch_size, src_dim] :param prob: [src_sequence_length, batch_size]\ or [tgt_sequence_length, src_sequence_length, batch_size] :return: [batch_size, src_dim] or [tgt_sequence_length, batch_size, src_dim]
:param s: [src_sequence_length, batch_size, src_dim] :param prob: [src_sequence_length, batch_size]\ or [tgt_sequence_length, src_sequence_length, batch_size] :return: [batch_size, src_dim] or [tgt_sequence_length, batch_size, src_dim]
def get_att(self, s, prob): ''' :param s: [src_sequence_length, batch_size, src_dim] :param prob: [src_sequence_length, batch_size]\ or [tgt_sequence_length, src_sequence_length, batch_size] :return: [batch_size, src_dim] or [tgt_sequence_length, batch_size, src_dim] ...
[ "def", "get_att", "(", "self", ",", "s", ",", "prob", ")", ":", "buf", "=", "s", "*", "tf", ".", "expand_dims", "(", "prob", ",", "axis", "=", "-", "1", ")", "att", "=", "tf", ".", "reduce_sum", "(", "buf", ",", "axis", "=", "-", "3", ")", ...
[ 159, 4 ]
[ 168, 18 ]
python
en
['en', 'error', 'th']
False
SamsungTVConfigFlow.__init__
(self)
Initialize flow.
Initialize flow.
def __init__(self): """Initialize flow.""" self._host = None self._ip = None self._manufacturer = None self._model = None self._name = None self._title = None self._id = None self._bridge = None
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "_host", "=", "None", "self", ".", "_ip", "=", "None", "self", ".", "_manufacturer", "=", "None", "self", ".", "_model", "=", "None", "self", ".", "_name", "=", "None", "self", ".", "_title", "...
[ 55, 4 ]
[ 64, 27 ]
python
en
['en', 'pl', 'en']
False
SamsungTVConfigFlow._try_connect
(self)
Try to connect and check auth.
Try to connect and check auth.
def _try_connect(self): """Try to connect and check auth.""" for method in SUPPORTED_METHODS: self._bridge = SamsungTVBridge.get_bridge(method, self._host) result = self._bridge.try_connect() if result != RESULT_CANNOT_CONNECT: return result LO...
[ "def", "_try_connect", "(", "self", ")", ":", "for", "method", "in", "SUPPORTED_METHODS", ":", "self", ".", "_bridge", "=", "SamsungTVBridge", ".", "get_bridge", "(", "method", ",", "self", ".", "_host", ")", "result", "=", "self", ".", "_bridge", ".", "...
[ 84, 4 ]
[ 92, 36 ]
python
en
['en', 'en', 'en']
True
SamsungTVConfigFlow.async_step_import
(self, user_input=None)
Handle configuration by yaml file.
Handle configuration by yaml file.
async def async_step_import(self, user_input=None): """Handle configuration by yaml file.""" return await self.async_step_user(user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", "=", "None", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", ")" ]
[ 94, 4 ]
[ 96, 53 ]
python
en
['en', 'en', 'en']
True
SamsungTVConfigFlow.async_step_user
(self, user_input=None)
Handle a flow initialized by the user.
Handle a flow initialized by the user.
async def async_step_user(self, user_input=None): """Handle a flow initialized by the user.""" if user_input is not None: ip_address = await self.hass.async_add_executor_job( _get_ip, user_input[CONF_HOST] ) await self.async_set_unique_id(ip_address) ...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "ip_address", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "_get_ip", ",", "user_input", "[", ...
[ 98, 4 ]
[ 119, 76 ]
python
en
['en', 'en', 'en']
True
SamsungTVConfigFlow.async_step_ssdp
(self, discovery_info)
Handle a flow initialized by discovery.
Handle a flow initialized by discovery.
async def async_step_ssdp(self, discovery_info): """Handle a flow initialized by discovery.""" host = urlparse(discovery_info[ATTR_SSDP_LOCATION]).hostname ip_address = await self.hass.async_add_executor_job(_get_ip, host) self._host = host self._ip = self.context[CONF_IP_ADDRES...
[ "async", "def", "async_step_ssdp", "(", "self", ",", "discovery_info", ")", ":", "host", "=", "urlparse", "(", "discovery_info", "[", "ATTR_SSDP_LOCATION", "]", ")", ".", "hostname", "ip_address", "=", "await", "self", ".", "hass", ".", "async_add_executor_job",...
[ 121, 4 ]
[ 150, 46 ]
python
en
['en', 'en', 'en']
True
SamsungTVConfigFlow.async_step_confirm
(self, user_input=None)
Handle user-confirmation of discovered node.
Handle user-confirmation of discovered node.
async def async_step_confirm(self, user_input=None): """Handle user-confirmation of discovered node.""" if user_input is not None: result = await self.hass.async_add_executor_job(self._try_connect) if result != RESULT_SUCCESS: return self.async_abort(reason=resul...
[ "async", "def", "async_step_confirm", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "result", "=", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_try_connect", ")", "i...
[ 152, 4 ]
[ 163, 9 ]
python
en
['en', 'en', 'en']
True
SamsungTVConfigFlow.async_step_reauth
(self, user_input=None)
Handle configuration by re-auth.
Handle configuration by re-auth.
async def async_step_reauth(self, user_input=None): """Handle configuration by re-auth.""" self._host = user_input[CONF_HOST] self._id = user_input.get(CONF_ID) self._ip = user_input[CONF_IP_ADDRESS] self._manufacturer = user_input.get(CONF_MANUFACTURER) self._model = use...
[ "async", "def", "async_step_reauth", "(", "self", ",", "user_input", "=", "None", ")", ":", "self", ".", "_host", "=", "user_input", "[", "CONF_HOST", "]", "self", ".", "_id", "=", "user_input", ".", "get", "(", "CONF_ID", ")", "self", ".", "_ip", "=",...
[ 165, 4 ]
[ 178, 46 ]
python
en
['en', 'en', 'en']
True
list_jobs
()
List the jobs in the cluster. Returns: None.
List the jobs in the cluster.
def list_jobs(): """List the jobs in the cluster. Returns: None. """ name_to_job_details = redis_controller.get_name_to_job_details() return list(name_to_job_details.values())
[ "def", "list_jobs", "(", ")", ":", "name_to_job_details", "=", "redis_controller", ".", "get_name_to_job_details", "(", ")", "return", "list", "(", "name_to_job_details", ".", "values", "(", ")", ")" ]
[ 32, 0 ]
[ 40, 45 ]
python
en
['en', 'en', 'en']
True
get_job
(job_name: str)
Get the job with job_name. Returns: None.
Get the job with job_name.
def get_job(job_name: str): """Get the job with job_name. Returns: None. """ job_details = redis_controller.get_job_details(job_name=job_name) return job_details
[ "def", "get_job", "(", "job_name", ":", "str", ")", ":", "job_details", "=", "redis_controller", ".", "get_job_details", "(", "job_name", "=", "job_name", ")", "return", "job_details" ]
[ 45, 0 ]
[ 53, 22 ]
python
en
['en', 'su', 'en']
True
create_job
(**kwargs)
Create a job. Returns: None.
Create a job.
def create_job(**kwargs): """Create a job. Returns: None. """ job_details = kwargs["json_dict"] redis_controller.set_job_details( job_name=job_details["name"], job_details=job_details ) redis_controller.push_pending_job_ticket( job_name=job_details["name"] ...
[ "def", "create_job", "(", "*", "*", "kwargs", ")", ":", "job_details", "=", "kwargs", "[", "\"json_dict\"", "]", "redis_controller", ".", "set_job_details", "(", "job_name", "=", "job_details", "[", "\"name\"", "]", ",", "job_details", "=", "job_details", ")",...
[ 58, 0 ]
[ 73, 13 ]
python
en
['en', 'ga', 'en']
True
delete_job
(job_name: str)
Delete a job. Returns: None.
Delete a job.
def delete_job(job_name: str): """Delete a job. Returns: None. """ redis_controller.remove_pending_job_ticket(job_name=job_name) redis_controller.push_killed_job_ticket(job_name=job_name) redis_controller.delete_job_details(job_name=job_name) return {}
[ "def", "delete_job", "(", "job_name", ":", "str", ")", ":", "redis_controller", ".", "remove_pending_job_ticket", "(", "job_name", "=", "job_name", ")", "redis_controller", ".", "push_killed_job_ticket", "(", "job_name", "=", "job_name", ")", "redis_controller", "."...
[ 78, 0 ]
[ 87, 13 ]
python
en
['en', 'ca', 'en']
True
stop_job
(job_name: str)
Stop a job. Returns: None.
Stop a job.
def stop_job(job_name: str): """Stop a job. Returns: None. """ redis_controller.remove_pending_job_ticket(job_name=job_name) redis_controller.push_killed_job_ticket(job_name=job_name) return {}
[ "def", "stop_job", "(", "job_name", ":", "str", ")", ":", "redis_controller", ".", "remove_pending_job_ticket", "(", "job_name", "=", "job_name", ")", "redis_controller", ".", "push_killed_job_ticket", "(", "job_name", "=", "job_name", ")", "return", "{", "}" ]
[ 92, 0 ]
[ 100, 13 ]
python
en
['en', 'su', 'en']
True
clean_jobs
()
Clean all jobs in the cluster. Returns: None.
Clean all jobs in the cluster.
def clean_jobs(): """Clean all jobs in the cluster. Returns: None. """ # Delete all job related resources. redis_controller.delete_pending_jobs_queue() redis_controller.delete_killed_jobs_queue() name_to_node_details = redis_controller.get_name_to_node_details() for _, node_det...
[ "def", "clean_jobs", "(", ")", ":", "# Delete all job related resources.", "redis_controller", ".", "delete_pending_jobs_queue", "(", ")", "redis_controller", ".", "delete_killed_jobs_queue", "(", ")", "name_to_node_details", "=", "redis_controller", ".", "get_name_to_node_de...
[ 105, 0 ]
[ 122, 13 ]
python
en
['en', 'en', 'en']
True
same_channel_sets
(channel_sets: list)
Validate that all the channel sets are consistent, return false if not
Validate that all the channel sets are consistent, return false if not
def same_channel_sets(channel_sets: list): """Validate that all the channel sets are consistent, return false if not""" for chs in channel_sets[1:]: if chs.shape[0] != channel_sets[0].shape[0] or chs.shape[1] != channel_sets[0].shape[1]: return False # if not np.all(channel_sets[0] =...
[ "def", "same_channel_sets", "(", "channel_sets", ":", "list", ")", ":", "for", "chs", "in", "channel_sets", "[", "1", ":", "]", ":", "if", "chs", ".", "shape", "[", "0", "]", "!=", "channel_sets", "[", "0", "]", ".", "shape", "[", "0", "]", "or", ...
[ 15, 0 ]
[ 22, 15 ]
python
en
['en', 'en', 'en']
True
InstanceTransform.__init__
(self, only_trial_data=True)
Trial transforms are, for the most part, simply operations that are performed on the loaded tensors when they are fetched via the :meth:`__call__` method. Ideally this is implemented with pytorch operations for ease of execution graph integration.
Trial transforms are, for the most part, simply operations that are performed on the loaded tensors when they are fetched via the :meth:`__call__` method. Ideally this is implemented with pytorch operations for ease of execution graph integration.
def __init__(self, only_trial_data=True): """ Trial transforms are, for the most part, simply operations that are performed on the loaded tensors when they are fetched via the :meth:`__call__` method. Ideally this is implemented with pytorch operations for ease of execution graph integra...
[ "def", "__init__", "(", "self", ",", "only_trial_data", "=", "True", ")", ":", "self", ".", "only_trial_data", "=", "only_trial_data" ]
[ 27, 4 ]
[ 33, 46 ]
python
en
['en', 'error', 'th']
False
InstanceTransform.__call__
(self, *x)
Modifies a batch of tensors. Parameters ---------- x : torch.Tensor, tuple The trial tensor, not including a batch-dimension. If initialized with `only_trial_data=False`, then this is a tuple of all ids, labels, etc. being propagated. Returns ----...
Modifies a batch of tensors. Parameters ---------- x : torch.Tensor, tuple The trial tensor, not including a batch-dimension. If initialized with `only_trial_data=False`, then this is a tuple of all ids, labels, etc. being propagated. Returns ----...
def __call__(self, *x): """ Modifies a batch of tensors. Parameters ---------- x : torch.Tensor, tuple The trial tensor, not including a batch-dimension. If initialized with `only_trial_data=False`, then this is a tuple of all ids, labels, etc. being propa...
[ "def", "__call__", "(", "self", ",", "*", "x", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 38, 4 ]
[ 51, 35 ]
python
en
['en', 'error', 'th']
False
InstanceTransform.new_channels
(self, old_channels)
This is an optional method that indicates the transformation modifies the representation and/or presence of channels. Parameters ---------- old_channels : ndarray An array whose last two dimensions are channel names and channel types. Returns ...
This is an optional method that indicates the transformation modifies the representation and/or presence of channels.
def new_channels(self, old_channels): """ This is an optional method that indicates the transformation modifies the representation and/or presence of channels. Parameters ---------- old_channels : ndarray An array whose last two dimensions are chan...
[ "def", "new_channels", "(", "self", ",", "old_channels", ")", ":", "return", "old_channels" ]
[ 53, 4 ]
[ 70, 27 ]
python
en
['en', 'error', 'th']
False
InstanceTransform.new_sfreq
(self, old_sfreq)
This is an optional method that indicates the transformation modifies the sampling frequency of the underlying time-series. Parameters ---------- old_sfreq : float Returns ------- new_sfreq : float
This is an optional method that indicates the transformation modifies the sampling frequency of the underlying time-series.
def new_sfreq(self, old_sfreq): """ This is an optional method that indicates the transformation modifies the sampling frequency of the underlying time-series. Parameters ---------- old_sfreq : float Returns ------- new_sfreq : float """ ...
[ "def", "new_sfreq", "(", "self", ",", "old_sfreq", ")", ":", "return", "old_sfreq" ]
[ 72, 4 ]
[ 85, 24 ]
python
en
['en', 'error', 'th']
False
InstanceTransform.new_sequence_length
(self, old_sequence_length)
This is an optional method that indicates the transformation modifies the length of the acquired extracts, specified in number of samples. Parameters ---------- old_sequence_length : int Returns ------- new_sequence_length : int
This is an optional method that indicates the transformation modifies the length of the acquired extracts, specified in number of samples.
def new_sequence_length(self, old_sequence_length): """ This is an optional method that indicates the transformation modifies the length of the acquired extracts, specified in number of samples. Parameters ---------- old_sequence_length : int Returns ---...
[ "def", "new_sequence_length", "(", "self", ",", "old_sequence_length", ")", ":", "return", "old_sequence_length" ]
[ 87, 4 ]
[ 100, 34 ]
python
en
['en', 'error', 'th']
False
TemporalPadding.__init__
(self, start_padding, end_padding, mode='constant', constant_value=0)
Pad the number of samples. Parameters ---------- start_padding : int The number of padded samples to add to the beginning of a trial end_padding : int The number of padded samples to add to the end of a trial mode : str ...
Pad the number of samples.
def __init__(self, start_padding, end_padding, mode='constant', constant_value=0): """ Pad the number of samples. Parameters ---------- start_padding : int The number of padded samples to add to the beginning of a trial end_padding : int ...
[ "def", "__init__", "(", "self", ",", "start_padding", ",", "end_padding", ",", "mode", "=", "'constant'", ",", "constant_value", "=", "0", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "start_padding", "=", "start_padding", "self", ...
[ 135, 4 ]
[ 154, 44 ]
python
en
['en', 'error', 'th']
False
TemporalInterpolation.__init__
(self, desired_sequence_length, mode='nearest', new_sfreq=None)
This is in essence a DN3 wrapper for the pytorch function `interpolate() <https://pytorch.org/docs/stable/nn.functional.html>`_ Currently only supports single dimensional samples (i.e. channels have not been projected into more dimensions) Warnings -------- Using this ...
This is in essence a DN3 wrapper for the pytorch function `interpolate() <https://pytorch.org/docs/stable/nn.functional.html>`_
def __init__(self, desired_sequence_length, mode='nearest', new_sfreq=None): """ This is in essence a DN3 wrapper for the pytorch function `interpolate() <https://pytorch.org/docs/stable/nn.functional.html>`_ Currently only supports single dimensional samples (i.e. channels have not bee...
[ "def", "__init__", "(", "self", ",", "desired_sequence_length", ",", "mode", "=", "'nearest'", ",", "new_sfreq", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_new_sequence_length", "=", "desired_sequence_length", "self", ...
[ 166, 4 ]
[ 192, 35 ]
python
en
['en', 'error', 'th']
False
TemporalCrop.__init__
(self, cropped_length, start_offset=None)
Crop to a new length of `cropped_length` from the specified `start_offset`, or randomly select an offset. Parameters ---------- cropped_length : int The cropped sequence length (in samples). start_offset : int, None, List[int] If ...
Crop to a new length of `cropped_length` from the specified `start_offset`, or randomly select an offset.
def __init__(self, cropped_length, start_offset=None): """ Crop to a new length of `cropped_length` from the specified `start_offset`, or randomly select an offset. Parameters ---------- cropped_length : int The cropped sequence length (in samples). ...
[ "def", "__init__", "(", "self", ",", "cropped_length", ",", "start_offset", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "if", "isinstance", "(", "start_offset", ",", "int", ")", ":", "start_offset", "=", "[", "0", "for", "_", ...
[ 230, 4 ]
[ 250, 41 ]
python
en
['en', 'error', 'th']
False
MappingDeep1010.__init__
(self, dataset, add_scale_ind=True, return_mask=False)
Creates a Deep10-10 mapping for the provided dataset. Parameters ---------- dataset : Dataset add_scale_ind : bool If `True` (default), the scale ind is filled with the relative scale of the trial with respect to the data min and...
Creates a Deep10-10 mapping for the provided dataset.
def __init__(self, dataset, add_scale_ind=True, return_mask=False): """ Creates a Deep10-10 mapping for the provided dataset. Parameters ---------- dataset : Dataset add_scale_ind : bool If `True` (default), the scale ind is filled with the relat...
[ "def", "__init__", "(", "self", ",", "dataset", ",", "add_scale_ind", "=", "True", ",", "return_mask", "=", "False", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "mapping", "=", "map_dataset_channels_deep_1010", "(", "dataset", ".",...
[ 312, 4 ]
[ 336, 38 ]
python
en
['en', 'error', 'th']
False
To1020.__init__
(self, only_trial_data=True, include_scale_ch=True, include_ref_chs=False)
Transforms incoming Deep1010 data into exclusively the more limited 1020 channel set.
Transforms incoming Deep1010 data into exclusively the more limited 1020 channel set.
def __init__(self, only_trial_data=True, include_scale_ch=True, include_ref_chs=False): """ Transforms incoming Deep1010 data into exclusively the more limited 1020 channel set. """ super(To1020, self).__init__(only_trial_data=only_trial_data) self._inds_20_div = [DEEP_1010_CHS_L...
[ "def", "__init__", "(", "self", ",", "only_trial_data", "=", "True", ",", "include_scale_ch", "=", "True", ",", "include_ref_chs", "=", "False", ")", ":", "super", "(", "To1020", ",", "self", ")", ".", "__init__", "(", "only_trial_data", "=", "only_trial_dat...
[ 398, 4 ]
[ 407, 47 ]
python
en
['en', 'error', 'th']
False
UniformTransformSelection.__init__
(self, transform_list, weights=None, suppress_warnings=False)
Uniformly selects a transform from the `transform_list` with probabilities according to `p`. Parameters ---------- transform_list: List[InstanceTransform] List of transforms to select from. weights: None, List[float] This is either `None`, in ...
Uniformly selects a transform from the `transform_list` with probabilities according to `p`.
def __init__(self, transform_list, weights=None, suppress_warnings=False): """ Uniformly selects a transform from the `transform_list` with probabilities according to `p`. Parameters ---------- transform_list: List[InstanceTransform] List of transforms to...
[ "def", "__init__", "(", "self", ",", "transform_list", ",", "weights", "=", "None", ",", "suppress_warnings", "=", "False", ")", ":", "super", "(", ")", ".", "__init__", "(", "only_trial_data", "=", "False", ")", "self", ".", "suppress_warnings", "=", "sup...
[ 481, 4 ]
[ 507, 54 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass, config)
Initialize the FreeDNS component.
Initialize the FreeDNS component.
async def async_setup(hass, config): """Initialize the FreeDNS component.""" conf = config[DOMAIN] url = conf.get(CONF_URL) auth_token = conf.get(CONF_ACCESS_TOKEN) update_interval = conf[CONF_SCAN_INTERVAL] session = hass.helpers.aiohttp_client.async_get_clientsession() result = await _up...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "url", "=", "conf", ".", "get", "(", "CONF_URL", ")", "auth_token", "=", "conf", ".", "get", "(", "CONF_ACCESS_TOKEN", ")", "update_interval",...
[ 37, 0 ]
[ 59, 15 ]
python
en
['en', 'en', 'en']
True
_update_freedns
(hass, session, url, auth_token)
Update FreeDNS.
Update FreeDNS.
async def _update_freedns(hass, session, url, auth_token): """Update FreeDNS.""" params = None if url is None: url = UPDATE_URL if auth_token is not None: params = {} params[auth_token] = "" try: with async_timeout.timeout(TIMEOUT): resp = await session...
[ "async", "def", "_update_freedns", "(", "hass", ",", "session", ",", "url", ",", "auth_token", ")", ":", "params", "=", "None", "if", "url", "is", "None", ":", "url", "=", "UPDATE_URL", "if", "auth_token", "is", "not", "None", ":", "params", "=", "{", ...
[ 62, 0 ]
[ 98, 16 ]
python
en
['en', 'de', 'en']
False
alexa_client
(loop, hass, hass_client)
Initialize a Home Assistant server for testing this module.
Initialize a Home Assistant server for testing this module.
def alexa_client(loop, hass, hass_client): """Initialize a Home Assistant server for testing this module.""" @callback def mock_service(call): calls.append(call) hass.services.async_register("test", "alexa", mock_service) assert loop.run_until_complete( async_setup_component( ...
[ "def", "alexa_client", "(", "loop", ",", "hass", ",", "hass_client", ")", ":", "@", "callback", "def", "mock_service", "(", "call", ")", ":", "calls", ".", "append", "(", "call", ")", "hass", ".", "services", ".", "async_register", "(", "\"test\"", ",", ...
[ 23, 0 ]
[ 63, 49 ]
python
en
['en', 'en', 'en']
True
test_flash_briefing_invalid_id
(alexa_client)
Test an invalid Flash Briefing ID.
Test an invalid Flash Briefing ID.
async def test_flash_briefing_invalid_id(alexa_client): """Test an invalid Flash Briefing ID.""" req = await _flash_briefing_req(alexa_client, 10000) assert req.status == HTTP_NOT_FOUND text = await req.text() assert text == ""
[ "async", "def", "test_flash_briefing_invalid_id", "(", "alexa_client", ")", ":", "req", "=", "await", "_flash_briefing_req", "(", "alexa_client", ",", "10000", ")", "assert", "req", ".", "status", "==", "HTTP_NOT_FOUND", "text", "=", "await", "req", ".", "text",...
[ 73, 0 ]
[ 78, 21 ]
python
en
['en', 'cy', 'en']
True
test_flash_briefing_no_password
(alexa_client)
Test for no Flash Briefing password.
Test for no Flash Briefing password.
async def test_flash_briefing_no_password(alexa_client): """Test for no Flash Briefing password.""" req = await _flash_briefing_req(alexa_client, "weather", password=None) assert req.status == HTTP_UNAUTHORIZED text = await req.text() assert text == ""
[ "async", "def", "test_flash_briefing_no_password", "(", "alexa_client", ")", ":", "req", "=", "await", "_flash_briefing_req", "(", "alexa_client", ",", "\"weather\"", ",", "password", "=", "None", ")", "assert", "req", ".", "status", "==", "HTTP_UNAUTHORIZED", "te...
[ 81, 0 ]
[ 86, 21 ]
python
en
['en', 'en', 'en']
True
test_flash_briefing_invalid_password
(alexa_client)
Test an invalid Flash Briefing password.
Test an invalid Flash Briefing password.
async def test_flash_briefing_invalid_password(alexa_client): """Test an invalid Flash Briefing password.""" req = await _flash_briefing_req(alexa_client, "weather", password="wrongpass") assert req.status == HTTP_UNAUTHORIZED text = await req.text() assert text == ""
[ "async", "def", "test_flash_briefing_invalid_password", "(", "alexa_client", ")", ":", "req", "=", "await", "_flash_briefing_req", "(", "alexa_client", ",", "\"weather\"", ",", "password", "=", "\"wrongpass\"", ")", "assert", "req", ".", "status", "==", "HTTP_UNAUTH...
[ 89, 0 ]
[ 94, 21 ]
python
en
['en', 'en', 'en']
True
test_flash_briefing_request_for_password
(alexa_client)
Test for "password" Flash Briefing.
Test for "password" Flash Briefing.
async def test_flash_briefing_request_for_password(alexa_client): """Test for "password" Flash Briefing.""" req = await _flash_briefing_req(alexa_client, "password") assert req.status == HTTP_NOT_FOUND text = await req.text() assert text == ""
[ "async", "def", "test_flash_briefing_request_for_password", "(", "alexa_client", ")", ":", "req", "=", "await", "_flash_briefing_req", "(", "alexa_client", ",", "\"password\"", ")", "assert", "req", ".", "status", "==", "HTTP_NOT_FOUND", "text", "=", "await", "req",...
[ 97, 0 ]
[ 102, 21 ]
python
en
['en', 'en', 'en']
True
test_flash_briefing_date_from_str
(alexa_client)
Test the response has a valid date parsed from string.
Test the response has a valid date parsed from string.
async def test_flash_briefing_date_from_str(alexa_client): """Test the response has a valid date parsed from string.""" req = await _flash_briefing_req(alexa_client, "weather") assert req.status == 200 data = await req.json() assert isinstance( datetime.datetime.strptime( data[0]...
[ "async", "def", "test_flash_briefing_date_from_str", "(", "alexa_client", ")", ":", "req", "=", "await", "_flash_briefing_req", "(", "alexa_client", ",", "\"weather\"", ")", "assert", "req", ".", "status", "==", "200", "data", "=", "await", "req", ".", "json", ...
[ 105, 0 ]
[ 115, 5 ]
python
en
['en', 'en', 'en']
True
test_flash_briefing_valid
(alexa_client)
Test the response is valid.
Test the response is valid.
async def test_flash_briefing_valid(alexa_client): """Test the response is valid.""" data = [ { "titleText": "NPR", "redirectionURL": "https://npr.org", "streamUrl": NPR_NEWS_MP3_URL, "mainText": "", "uid": "uuid", "updateDate": "20...
[ "async", "def", "test_flash_briefing_valid", "(", "alexa_client", ")", ":", "data", "=", "[", "{", "\"titleText\"", ":", "\"NPR\"", ",", "\"redirectionURL\"", ":", "\"https://npr.org\"", ",", "\"streamUrl\"", ":", "NPR_NEWS_MP3_URL", ",", "\"mainText\"", ":", "\"\""...
[ 118, 0 ]
[ 142, 23 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, disc_info=None)
Set up the WebDav Calendar platform.
Set up the WebDav Calendar platform.
def setup_platform(hass, config, add_entities, disc_info=None): """Set up the WebDav Calendar platform.""" url = config[CONF_URL] username = config.get(CONF_USERNAME) password = config.get(CONF_PASSWORD) days = config[CONF_DAYS] client = caldav.DAVClient( url, None, username, password, ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "disc_info", "=", "None", ")", ":", "url", "=", "config", "[", "CONF_URL", "]", "username", "=", "config", ".", "get", "(", "CONF_USERNAME", ")", "password", "=", "config", "....
[ 65, 0 ]
[ 110, 40 ]
python
en
['en', 'pt', 'en']
True
WebDavCalendarEventDevice.__init__
(self, name, calendar, entity_id, days, all_day=False, search=None)
Create the WebDav Calendar Event Device.
Create the WebDav Calendar Event Device.
def __init__(self, name, calendar, entity_id, days, all_day=False, search=None): """Create the WebDav Calendar Event Device.""" self.data = WebDavCalendarData(calendar, days, all_day, search) self.entity_id = entity_id self._event = None self._name = name self._offset_rea...
[ "def", "__init__", "(", "self", ",", "name", ",", "calendar", ",", "entity_id", ",", "days", ",", "all_day", "=", "False", ",", "search", "=", "None", ")", ":", "self", ".", "data", "=", "WebDavCalendarData", "(", "calendar", ",", "days", ",", "all_day...
[ 116, 4 ]
[ 122, 36 ]
python
en
['en', 'pt', 'en']
True
WebDavCalendarEventDevice.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" return {"offset_reached": self._offset_reached}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"offset_reached\"", ":", "self", ".", "_offset_reached", "}" ]
[ 125, 4 ]
[ 127, 55 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarEventDevice.event
(self)
Return the next upcoming event.
Return the next upcoming event.
def event(self): """Return the next upcoming event.""" return self._event
[ "def", "event", "(", "self", ")", ":", "return", "self", ".", "_event" ]
[ 130, 4 ]
[ 132, 26 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarEventDevice.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self): """Return the name of the entity.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 135, 4 ]
[ 137, 25 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarEventDevice.async_get_events
(self, hass, start_date, end_date)
Get all events in a specific time frame.
Get all events in a specific time frame.
async def async_get_events(self, hass, start_date, end_date): """Get all events in a specific time frame.""" return await self.data.async_get_events(hass, start_date, end_date)
[ "async", "def", "async_get_events", "(", "self", ",", "hass", ",", "start_date", ",", "end_date", ")", ":", "return", "await", "self", ".", "data", ".", "async_get_events", "(", "hass", ",", "start_date", ",", "end_date", ")" ]
[ 139, 4 ]
[ 141, 75 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarEventDevice.update
(self)
Update event data.
Update event data.
def update(self): """Update event data.""" self.data.update() event = copy.deepcopy(self.data.event) if event is None: self._event = event return event = calculate_offset(event, OFFSET) self._offset_reached = is_offset_reached(event) self._...
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "update", "(", ")", "event", "=", "copy", ".", "deepcopy", "(", "self", ".", "data", ".", "event", ")", "if", "event", "is", "None", ":", "self", ".", "_event", "=", "event", "retu...
[ 143, 4 ]
[ 152, 27 ]
python
co
['fr', 'co', 'en']
False
WebDavCalendarData.__init__
(self, calendar, days, include_all_day, search)
Set up how we are going to search the WebDav calendar.
Set up how we are going to search the WebDav calendar.
def __init__(self, calendar, days, include_all_day, search): """Set up how we are going to search the WebDav calendar.""" self.calendar = calendar self.days = days self.include_all_day = include_all_day self.search = search self.event = None
[ "def", "__init__", "(", "self", ",", "calendar", ",", "days", ",", "include_all_day", ",", "search", ")", ":", "self", ".", "calendar", "=", "calendar", "self", ".", "days", "=", "days", "self", ".", "include_all_day", "=", "include_all_day", "self", ".", ...
[ 158, 4 ]
[ 164, 25 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.async_get_events
(self, hass, start_date, end_date)
Get all events in a specific time frame.
Get all events in a specific time frame.
async def async_get_events(self, hass, start_date, end_date): """Get all events in a specific time frame.""" # Get event list from the current calendar vevent_list = await hass.async_add_executor_job( self.calendar.date_search, start_date, end_date ) event_list = [] ...
[ "async", "def", "async_get_events", "(", "self", ",", "hass", ",", "start_date", ",", "end_date", ")", ":", "# Get event list from the current calendar", "vevent_list", "=", "await", "hass", ".", "async_add_executor_job", "(", "self", ".", "calendar", ".", "date_sea...
[ 166, 4 ]
[ 192, 25 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.update
(self)
Get the latest data.
Get the latest data.
def update(self): """Get the latest data.""" start_of_today = dt.start_of_local_day() start_of_tomorrow = dt.start_of_local_day() + timedelta(days=self.days) # We have to retrieve the results for the whole day as the server # won't return events that have already started ...
[ "def", "update", "(", "self", ")", ":", "start_of_today", "=", "dt", ".", "start_of_local_day", "(", ")", "start_of_tomorrow", "=", "dt", ".", "start_of_local_day", "(", ")", "+", "timedelta", "(", "days", "=", "self", ".", "days", ")", "# We have to retriev...
[ 195, 4 ]
[ 263, 9 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.is_matching
(vevent, search)
Return if the event matches the filter criteria.
Return if the event matches the filter criteria.
def is_matching(vevent, search): """Return if the event matches the filter criteria.""" if search is None: return True pattern = re.compile(search) return ( hasattr(vevent, "summary") and pattern.match(vevent.summary.value) or hasattr(veve...
[ "def", "is_matching", "(", "vevent", ",", "search", ")", ":", "if", "search", "is", "None", ":", "return", "True", "pattern", "=", "re", ".", "compile", "(", "search", ")", "return", "(", "hasattr", "(", "vevent", ",", "\"summary\"", ")", "and", "patte...
[ 266, 4 ]
[ 279, 9 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.is_all_day
(vevent)
Return if the event last the whole day.
Return if the event last the whole day.
def is_all_day(vevent): """Return if the event last the whole day.""" return not isinstance(vevent.dtstart.value, datetime)
[ "def", "is_all_day", "(", "vevent", ")", ":", "return", "not", "isinstance", "(", "vevent", ".", "dtstart", ".", "value", ",", "datetime", ")" ]
[ 282, 4 ]
[ 284, 61 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.is_over
(vevent)
Return if the event is over.
Return if the event is over.
def is_over(vevent): """Return if the event is over.""" return dt.now() >= WebDavCalendarData.to_datetime( WebDavCalendarData.get_end_date(vevent) )
[ "def", "is_over", "(", "vevent", ")", ":", "return", "dt", ".", "now", "(", ")", ">=", "WebDavCalendarData", ".", "to_datetime", "(", "WebDavCalendarData", ".", "get_end_date", "(", "vevent", ")", ")" ]
[ 287, 4 ]
[ 291, 9 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.get_hass_date
(obj)
Return if the event matches.
Return if the event matches.
def get_hass_date(obj): """Return if the event matches.""" if isinstance(obj, datetime): return {"dateTime": obj.isoformat()} return {"date": obj.isoformat()}
[ "def", "get_hass_date", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "datetime", ")", ":", "return", "{", "\"dateTime\"", ":", "obj", ".", "isoformat", "(", ")", "}", "return", "{", "\"date\"", ":", "obj", ".", "isoformat", "(", ")", "}...
[ 294, 4 ]
[ 299, 40 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.to_datetime
(obj)
Return a datetime.
Return a datetime.
def to_datetime(obj): """Return a datetime.""" if isinstance(obj, datetime): if obj.tzinfo is None: # floating value, not bound to any time zone in particular # represent same time regardless of which time zone is currently being observed retur...
[ "def", "to_datetime", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "datetime", ")", ":", "if", "obj", ".", "tzinfo", "is", "None", ":", "# floating value, not bound to any time zone in particular", "# represent same time regardless of which time zone is curr...
[ 302, 4 ]
[ 310, 71 ]
python
en
['en', 'ro', 'en']
True
WebDavCalendarData.get_attr_value
(obj, attribute)
Return the value of the attribute if defined.
Return the value of the attribute if defined.
def get_attr_value(obj, attribute): """Return the value of the attribute if defined.""" if hasattr(obj, attribute): return getattr(obj, attribute).value return None
[ "def", "get_attr_value", "(", "obj", ",", "attribute", ")", ":", "if", "hasattr", "(", "obj", ",", "attribute", ")", ":", "return", "getattr", "(", "obj", ",", "attribute", ")", ".", "value", "return", "None" ]
[ 313, 4 ]
[ 317, 19 ]
python
en
['en', 'en', 'en']
True
WebDavCalendarData.get_end_date
(obj)
Return the end datetime as determined by dtend or duration.
Return the end datetime as determined by dtend or duration.
def get_end_date(obj): """Return the end datetime as determined by dtend or duration.""" if hasattr(obj, "dtend"): enddate = obj.dtend.value elif hasattr(obj, "duration"): enddate = obj.dtstart.value + obj.duration.value else: enddate = obj.dtstart.v...
[ "def", "get_end_date", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "\"dtend\"", ")", ":", "enddate", "=", "obj", ".", "dtend", ".", "value", "elif", "hasattr", "(", "obj", ",", "\"duration\"", ")", ":", "enddate", "=", "obj", ".", "dtstar...
[ 320, 4 ]
[ 331, 22 ]
python
en
['en', 'en', 'en']
True
CascadeEvent.add_immediate_event
(self, event, is_head: bool = False)
Add an immediate event, that will be processed right after the current event. Immediate events are only supported to be inserted into the head or tail of the immediate event list. By default, the events will be appended to the end. NOTE: The tick of the event to insert must be the ...
Add an immediate event, that will be processed right after the current event.
def add_immediate_event(self, event, is_head: bool = False) -> bool: """Add an immediate event, that will be processed right after the current event. Immediate events are only supported to be inserted into the head or tail of the immediate event list. By default, the events will be appended to ...
[ "def", "add_immediate_event", "(", "self", ",", "event", ",", "is_head", ":", "bool", "=", "False", ")", "->", "bool", ":", "# Make sure the immediate event's tick is the same as the current one.", "if", "event", ".", "tick", "!=", "self", ".", "tick", ":", "retur...
[ 26, 4 ]
[ 64, 19 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Configure the platform and add the sensors.
Configure the platform and add the sensors.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Configure the platform and add the sensors.""" websession = aiohttp_client.async_get_clientsession(hass) client = SeventeenTrackClient(websession) try: login_result = await client.profile.login( ...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "websession", "=", "aiohttp_client", ".", "async_get_clientsession", "(", "hass", ")", "client", "=", "SeventeenTrackClient",...
[ 64, 0 ]
[ 92, 29 ]
python
en
['en', 'en', 'en']
True
SeventeenTrackSummarySensor.__init__
(self, data, status, initial_state)
Initialize.
Initialize.
def __init__(self, data, status, initial_state): """Initialize.""" self._attrs = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION} self._data = data self._state = initial_state self._status = status
[ "def", "__init__", "(", "self", ",", "data", ",", "status", ",", "initial_state", ")", ":", "self", ".", "_attrs", "=", "{", "ATTR_ATTRIBUTION", ":", "DEFAULT_ATTRIBUTION", "}", "self", ".", "_data", "=", "data", "self", ".", "_state", "=", "initial_state"...
[ 98, 4 ]
[ 103, 29 ]
python
en
['en', 'en', 'it']
False