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
MpdDevice.play_media
(self, media_type, media_id, **kwargs)
Send the media player the command for playing a playlist.
Send the media player the command for playing a playlist.
def play_media(self, media_type, media_id, **kwargs): """Send the media player the command for playing a playlist.""" _LOGGER.debug("Playing playlist: %s", media_id) if media_type == MEDIA_TYPE_PLAYLIST: if media_id in self._playlists: self._currentplaylist = media_id...
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Playing playlist: %s\"", ",", "media_id", ")", "if", "media_type", "==", "MEDIA_TYPE_PLAYLIST", ":", "if", "media_id", "...
[ 353, 4 ]
[ 368, 31 ]
python
en
['en', 'en', 'en']
True
MpdDevice.repeat
(self)
Return current repeat mode.
Return current repeat mode.
def repeat(self): """Return current repeat mode.""" if self._status["repeat"] == "1": if self._status["single"] == "1": return REPEAT_MODE_ONE return REPEAT_MODE_ALL return REPEAT_MODE_OFF
[ "def", "repeat", "(", "self", ")", ":", "if", "self", ".", "_status", "[", "\"repeat\"", "]", "==", "\"1\"", ":", "if", "self", ".", "_status", "[", "\"single\"", "]", "==", "\"1\"", ":", "return", "REPEAT_MODE_ONE", "return", "REPEAT_MODE_ALL", "return", ...
[ 371, 4 ]
[ 377, 30 ]
python
en
['en', 'la', 'en']
True
MpdDevice.set_repeat
(self, repeat)
Set repeat mode.
Set repeat mode.
def set_repeat(self, repeat): """Set repeat mode.""" if repeat == REPEAT_MODE_OFF: self._client.repeat(0) self._client.single(0) else: self._client.repeat(1) if repeat == REPEAT_MODE_ONE: self._client.single(1) else: ...
[ "def", "set_repeat", "(", "self", ",", "repeat", ")", ":", "if", "repeat", "==", "REPEAT_MODE_OFF", ":", "self", ".", "_client", ".", "repeat", "(", "0", ")", "self", ".", "_client", ".", "single", "(", "0", ")", "else", ":", "self", ".", "_client", ...
[ 379, 4 ]
[ 389, 38 ]
python
en
['en', 'id', 'en']
True
MpdDevice.shuffle
(self)
Boolean if shuffle is enabled.
Boolean if shuffle is enabled.
def shuffle(self): """Boolean if shuffle is enabled.""" return bool(int(self._status["random"]))
[ "def", "shuffle", "(", "self", ")", ":", "return", "bool", "(", "int", "(", "self", ".", "_status", "[", "\"random\"", "]", ")", ")" ]
[ 392, 4 ]
[ 394, 48 ]
python
en
['en', 'en', 'en']
True
MpdDevice.set_shuffle
(self, shuffle)
Enable/disable shuffle mode.
Enable/disable shuffle mode.
def set_shuffle(self, shuffle): """Enable/disable shuffle mode.""" self._client.random(int(shuffle))
[ "def", "set_shuffle", "(", "self", ",", "shuffle", ")", ":", "self", ".", "_client", ".", "random", "(", "int", "(", "shuffle", ")", ")" ]
[ 396, 4 ]
[ 398, 41 ]
python
en
['en', 'st', 'en']
True
MpdDevice.turn_off
(self)
Service to send the MPD the command to stop playing.
Service to send the MPD the command to stop playing.
def turn_off(self): """Service to send the MPD the command to stop playing.""" self._client.stop()
[ "def", "turn_off", "(", "self", ")", ":", "self", ".", "_client", ".", "stop", "(", ")" ]
[ 400, 4 ]
[ 402, 27 ]
python
en
['en', 'en', 'en']
True
MpdDevice.turn_on
(self)
Service to send the MPD the command to start playing.
Service to send the MPD the command to start playing.
def turn_on(self): """Service to send the MPD the command to start playing.""" self._client.play() self._update_playlists(no_throttle=True)
[ "def", "turn_on", "(", "self", ")", ":", "self", ".", "_client", ".", "play", "(", ")", "self", ".", "_update_playlists", "(", "no_throttle", "=", "True", ")" ]
[ 404, 4 ]
[ 407, 48 ]
python
en
['en', 'en', 'en']
True
MpdDevice.clear_playlist
(self)
Clear players playlist.
Clear players playlist.
def clear_playlist(self): """Clear players playlist.""" self._client.clear()
[ "def", "clear_playlist", "(", "self", ")", ":", "self", ".", "_client", ".", "clear", "(", ")" ]
[ 409, 4 ]
[ 411, 28 ]
python
en
['fr', 'en', 'en']
True
MpdDevice.media_seek
(self, position)
Send seek command.
Send seek command.
def media_seek(self, position): """Send seek command.""" self._client.seekcur(position)
[ "def", "media_seek", "(", "self", ",", "position", ")", ":", "self", ".", "_client", ".", "seekcur", "(", "position", ")" ]
[ 413, 4 ]
[ 415, 38 ]
python
en
['en', 'ig', 'en']
True
test_get_triggers
(hass)
Test triggers work.
Test triggers work.
async def test_get_triggers(hass): """Test triggers work.""" data = deepcopy(DECONZ_WEB_REQUEST) data["sensors"] = deepcopy(SENSORS) config_entry = await setup_deconz_integration(hass, get_state_response=data) gateway = get_gateway_from_config_entry(hass, config_entry) device_id = gateway.events...
[ "async", "def", "test_get_triggers", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"sensors\"", "]", "=", "deepcopy", "(", "SENSORS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "hass", "...
[ 45, 0 ]
[ 106, 50 ]
python
en
['en', 'en', 'en']
True
test_helper_successful
(hass)
Verify trigger helper.
Verify trigger helper.
async def test_helper_successful(hass): """Verify trigger helper.""" data = deepcopy(DECONZ_WEB_REQUEST) data["sensors"] = deepcopy(SENSORS) config_entry = await setup_deconz_integration(hass, get_state_response=data) gateway = get_gateway_from_config_entry(hass, config_entry) device_id = gatewa...
[ "async", "def", "test_helper_successful", "(", "hass", ")", ":", "data", "=", "deepcopy", "(", "DECONZ_WEB_REQUEST", ")", "data", "[", "\"sensors\"", "]", "=", "deepcopy", "(", "SENSORS", ")", "config_entry", "=", "await", "setup_deconz_integration", "(", "hass"...
[ 109, 0 ]
[ 117, 44 ]
python
en
['en', 'pt', 'en']
True
test_helper_no_match
(hass)
Verify trigger helper returns None when no event could be matched.
Verify trigger helper returns None when no event could be matched.
async def test_helper_no_match(hass): """Verify trigger helper returns None when no event could be matched.""" await setup_deconz_integration(hass) deconz_event = device_trigger._get_deconz_event_from_device_id(hass, "mock-id") assert deconz_event is None
[ "async", "def", "test_helper_no_match", "(", "hass", ")", ":", "await", "setup_deconz_integration", "(", "hass", ")", "deconz_event", "=", "device_trigger", ".", "_get_deconz_event_from_device_id", "(", "hass", ",", "\"mock-id\"", ")", "assert", "deconz_event", "is", ...
[ 120, 0 ]
[ 124, 31 ]
python
en
['en', 'en', 'en']
True
test_helper_no_gateway_exist
(hass)
Verify trigger helper returns None when no gateway exist.
Verify trigger helper returns None when no gateway exist.
async def test_helper_no_gateway_exist(hass): """Verify trigger helper returns None when no gateway exist.""" deconz_event = device_trigger._get_deconz_event_from_device_id(hass, "mock-id") assert deconz_event is None
[ "async", "def", "test_helper_no_gateway_exist", "(", "hass", ")", ":", "deconz_event", "=", "device_trigger", ".", "_get_deconz_event_from_device_id", "(", "hass", ",", "\"mock-id\"", ")", "assert", "deconz_event", "is", "None" ]
[ 127, 0 ]
[ 130, 31 ]
python
en
['en', 'de', 'en']
True
ValueChoice.__getitem__
(self, item)
Get a sub-element of value choice. The underlying implementation is to clone the current instance, and append item to "accessor", which records all the history getitem calls. For example, when accessor is ``[a, b, c]``, the value choice will return ``vc[a][b][c]`` where ``vc`` is the o...
Get a sub-element of value choice.
def __getitem__(self, item): """ Get a sub-element of value choice. The underlying implementation is to clone the current instance, and append item to "accessor", which records all the history getitem calls. For example, when accessor is ``[a, b, c]``, the value choice will return ``vc[...
[ "def", "__getitem__", "(", "self", ",", "item", ")", ":", "access", "=", "copy", ".", "deepcopy", "(", "self", ")", "access", ".", "_accessor", ".", "append", "(", "item", ")", "for", "candidate", "in", "self", ".", "candidates", ":", "access", ".", ...
[ 329, 4 ]
[ 341, 21 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
(hass, config_entry, async_add_entities)
Set up AdvantageAir cover platform.
Set up AdvantageAir cover platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up AdvantageAir cover platform.""" instance = hass.data[ADVANTAGE_AIR_DOMAIN][config_entry.entry_id] entities = [] for ac_key, ac_device in instance["coordinator"].data["aircons"].items(): for zone_key, zone in ac_devi...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "instance", "=", "hass", ".", "data", "[", "ADVANTAGE_AIR_DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "entities", "=", "[", "]", "for", "...
[ 21, 0 ]
[ 32, 32 ]
python
en
['en', 'lv', 'en']
True
AdvantageAirZoneVent.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return f'{self._zone["name"]}'
[ "def", "name", "(", "self", ")", ":", "return", "f'{self._zone[\"name\"]}'" ]
[ 39, 4 ]
[ 41, 38 ]
python
en
['en', 'ig', 'en']
True
AdvantageAirZoneVent.unique_id
(self)
Return a unique id.
Return a unique id.
def unique_id(self): """Return a unique id.""" return f'{self.coordinator.data["system"]["rid"]}-{self.ac_key}-{self.zone_key}'
[ "def", "unique_id", "(", "self", ")", ":", "return", "f'{self.coordinator.data[\"system\"][\"rid\"]}-{self.ac_key}-{self.zone_key}'" ]
[ 44, 4 ]
[ 46, 88 ]
python
ca
['fr', 'ca', 'en']
False
AdvantageAirZoneVent.device_class
(self)
Return the device class of the vent.
Return the device class of the vent.
def device_class(self): """Return the device class of the vent.""" return DEVICE_CLASS_DAMPER
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_DAMPER" ]
[ 49, 4 ]
[ 51, 34 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneVent.supported_features
(self)
Return the supported features.
Return the supported features.
def supported_features(self): """Return the supported features.""" return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_SET_POSITION
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_OPEN", "|", "SUPPORT_CLOSE", "|", "SUPPORT_SET_POSITION" ]
[ 54, 4 ]
[ 56, 66 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneVent.is_closed
(self)
Return if vent is fully closed.
Return if vent is fully closed.
def is_closed(self): """Return if vent is fully closed.""" return self._zone["state"] == ADVANTAGE_AIR_STATE_CLOSE
[ "def", "is_closed", "(", "self", ")", ":", "return", "self", ".", "_zone", "[", "\"state\"", "]", "==", "ADVANTAGE_AIR_STATE_CLOSE" ]
[ 59, 4 ]
[ 61, 63 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneVent.current_cover_position
(self)
Return vents current position as a percentage.
Return vents current position as a percentage.
def current_cover_position(self): """Return vents current position as a percentage.""" if self._zone["state"] == ADVANTAGE_AIR_STATE_OPEN: return self._zone["value"] return 0
[ "def", "current_cover_position", "(", "self", ")", ":", "if", "self", ".", "_zone", "[", "\"state\"", "]", "==", "ADVANTAGE_AIR_STATE_OPEN", ":", "return", "self", ".", "_zone", "[", "\"value\"", "]", "return", "0" ]
[ 64, 4 ]
[ 68, 16 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneVent.async_open_cover
(self, **kwargs)
Fully open zone vent.
Fully open zone vent.
async def async_open_cover(self, **kwargs): """Fully open zone vent.""" await self.async_change( { self.ac_key: { "zones": { self.zone_key: {"state": ADVANTAGE_AIR_STATE_OPEN, "value": 100} } } ...
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_change", "(", "{", "self", ".", "ac_key", ":", "{", "\"zones\"", ":", "{", "self", ".", "zone_key", ":", "{", "\"state\"", ":", "ADVANTAGE_...
[ 70, 4 ]
[ 80, 9 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneVent.async_close_cover
(self, **kwargs)
Fully close zone vent.
Fully close zone vent.
async def async_close_cover(self, **kwargs): """Fully close zone vent.""" await self.async_change( { self.ac_key: { "zones": {self.zone_key: {"state": ADVANTAGE_AIR_STATE_CLOSE}} } } )
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_change", "(", "{", "self", ".", "ac_key", ":", "{", "\"zones\"", ":", "{", "self", ".", "zone_key", ":", "{", "\"state\"", ":", "ADVANTAGE...
[ 82, 4 ]
[ 90, 9 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneVent.async_set_cover_position
(self, **kwargs)
Change vent position.
Change vent position.
async def async_set_cover_position(self, **kwargs): """Change vent position.""" position = round(kwargs[ATTR_POSITION] / 5) * 5 if position == 0: await self.async_change( { self.ac_key: { "zones": {self.zone_key: {"state": A...
[ "async", "def", "async_set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "position", "=", "round", "(", "kwargs", "[", "ATTR_POSITION", "]", "/", "5", ")", "*", "5", "if", "position", "==", "0", ":", "await", "self", ".", "async_chan...
[ 92, 4 ]
[ 115, 13 ]
python
fr
['fr', 'fr', 'en']
True
convert_condition
(time, weather)
Convert NWS codes to HA condition. Choose first condition in CONDITION_CLASSES that exists in weather code. If no match is found, return first condition from NWS
Convert NWS codes to HA condition.
def convert_condition(time, weather): """ Convert NWS codes to HA condition. Choose first condition in CONDITION_CLASSES that exists in weather code. If no match is found, return first condition from NWS """ conditions = [w[0] for w in weather] prec_probs = [w[1] or 0 for w in weather] ...
[ "def", "convert_condition", "(", "time", ",", "weather", ")", ":", "conditions", "=", "[", "w", "[", "0", "]", "for", "w", "in", "weather", "]", "prec_probs", "=", "[", "w", "[", "1", "]", "or", "0", "for", "w", "in", "weather", "]", "# Choose cond...
[ 57, 0 ]
[ 82, 32 ]
python
en
['en', 'error', 'th']
False
async_setup_entry
( hass: HomeAssistantType, entry: ConfigType, async_add_entities )
Set up the NWS weather platform.
Set up the NWS weather platform.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigType, async_add_entities ) -> None: """Set up the NWS weather platform.""" hass_data = hass.data[DOMAIN][entry.entry_id] async_add_entities( [ NWSWeather(entry.data, hass_data, DAYNIGHT, hass.config.units), ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigType", ",", "async_add_entities", ")", "->", "None", ":", "hass_data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "...
[ 85, 0 ]
[ 97, 5 ]
python
en
['en', 'da', 'en']
True
NWSWeather.__init__
(self, entry_data, hass_data, mode, units)
Initialise the platform with a data instance and station name.
Initialise the platform with a data instance and station name.
def __init__(self, entry_data, hass_data, mode, units): """Initialise the platform with a data instance and station name.""" self.nws = hass_data[NWS_DATA] self.latitude = entry_data[CONF_LATITUDE] self.longitude = entry_data[CONF_LONGITUDE] self.coordinator_observation = hass_da...
[ "def", "__init__", "(", "self", ",", "entry_data", ",", "hass_data", ",", "mode", ",", "units", ")", ":", "self", ".", "nws", "=", "hass_data", "[", "NWS_DATA", "]", "self", ".", "latitude", "=", "entry_data", "[", "CONF_LATITUDE", "]", "self", ".", "l...
[ 103, 4 ]
[ 119, 29 ]
python
en
['en', 'en', 'en']
True
NWSWeather.async_added_to_hass
(self)
Set up a listener and load data.
Set up a listener and load data.
async def async_added_to_hass(self) -> None: """Set up a listener and load data.""" self.async_on_remove( self.coordinator_observation.async_add_listener(self._update_callback) ) self.async_on_remove( self.coordinator_forecast.async_add_listener(self._update_callb...
[ "async", "def", "async_added_to_hass", "(", "self", ")", "->", "None", ":", "self", ".", "async_on_remove", "(", "self", ".", "coordinator_observation", ".", "async_add_listener", "(", "self", ".", "_update_callback", ")", ")", "self", ".", "async_on_remove", "(...
[ 121, 4 ]
[ 129, 31 ]
python
en
['en', 'en', 'en']
True
NWSWeather._update_callback
(self)
Load data from integration.
Load data from integration.
def _update_callback(self) -> None: """Load data from integration.""" self.observation = self.nws.observation if self.mode == DAYNIGHT: self._forecast = self.nws.forecast else: self._forecast = self.nws.forecast_hourly self.async_write_ha_state()
[ "def", "_update_callback", "(", "self", ")", "->", "None", ":", "self", ".", "observation", "=", "self", ".", "nws", ".", "observation", "if", "self", ".", "mode", "==", "DAYNIGHT", ":", "self", ".", "_forecast", "=", "self", ".", "nws", ".", "forecast...
[ 132, 4 ]
[ 140, 35 ]
python
en
['en', 'en', 'en']
True
NWSWeather.should_poll
(self)
Entities do not individually poll.
Entities do not individually poll.
def should_poll(self) -> bool: """Entities do not individually poll.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 143, 4 ]
[ 145, 20 ]
python
en
['en', 'en', 'en']
True
NWSWeather.attribution
(self)
Return the attribution.
Return the attribution.
def attribution(self): """Return the attribution.""" return ATTRIBUTION
[ "def", "attribution", "(", "self", ")", ":", "return", "ATTRIBUTION" ]
[ 148, 4 ]
[ 150, 26 ]
python
en
['en', 'ja', 'en']
True
NWSWeather.name
(self)
Return the name of the station.
Return the name of the station.
def name(self): """Return the name of the station.""" return f"{self.station} {self.mode.title()}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self.station} {self.mode.title()}\"" ]
[ 153, 4 ]
[ 155, 52 ]
python
en
['en', 'en', 'en']
True
NWSWeather.temperature
(self)
Return the current temperature.
Return the current temperature.
def temperature(self): """Return the current temperature.""" temp_c = None if self.observation: temp_c = self.observation.get("temperature") if temp_c: return convert_temperature(temp_c, TEMP_CELSIUS, TEMP_FAHRENHEIT) return None
[ "def", "temperature", "(", "self", ")", ":", "temp_c", "=", "None", "if", "self", ".", "observation", ":", "temp_c", "=", "self", ".", "observation", ".", "get", "(", "\"temperature\"", ")", "if", "temp_c", ":", "return", "convert_temperature", "(", "temp_...
[ 158, 4 ]
[ 165, 19 ]
python
en
['en', 'la', 'en']
True
NWSWeather.pressure
(self)
Return the current pressure.
Return the current pressure.
def pressure(self): """Return the current pressure.""" pressure_pa = None if self.observation: pressure_pa = self.observation.get("seaLevelPressure") if pressure_pa is None: return None if self.is_metric: pressure = convert_pressure(pressure_pa...
[ "def", "pressure", "(", "self", ")", ":", "pressure_pa", "=", "None", "if", "self", ".", "observation", ":", "pressure_pa", "=", "self", ".", "observation", ".", "get", "(", "\"seaLevelPressure\"", ")", "if", "pressure_pa", "is", "None", ":", "return", "No...
[ 168, 4 ]
[ 181, 23 ]
python
en
['en', 'co', 'en']
True
NWSWeather.humidity
(self)
Return the name of the sensor.
Return the name of the sensor.
def humidity(self): """Return the name of the sensor.""" humidity = None if self.observation: humidity = self.observation.get("relativeHumidity") return humidity
[ "def", "humidity", "(", "self", ")", ":", "humidity", "=", "None", "if", "self", ".", "observation", ":", "humidity", "=", "self", ".", "observation", ".", "get", "(", "\"relativeHumidity\"", ")", "return", "humidity" ]
[ 184, 4 ]
[ 189, 23 ]
python
en
['en', 'mi', 'en']
True
NWSWeather.wind_speed
(self)
Return the current windspeed.
Return the current windspeed.
def wind_speed(self): """Return the current windspeed.""" wind_km_hr = None if self.observation: wind_km_hr = self.observation.get("windSpeed") if wind_km_hr is None: return None if self.is_metric: wind = wind_km_hr else: w...
[ "def", "wind_speed", "(", "self", ")", ":", "wind_km_hr", "=", "None", "if", "self", ".", "observation", ":", "wind_km_hr", "=", "self", ".", "observation", ".", "get", "(", "\"windSpeed\"", ")", "if", "wind_km_hr", "is", "None", ":", "return", "None", "...
[ 192, 4 ]
[ 204, 26 ]
python
en
['en', 'en', 'en']
True
NWSWeather.wind_bearing
(self)
Return the current wind bearing (degrees).
Return the current wind bearing (degrees).
def wind_bearing(self): """Return the current wind bearing (degrees).""" wind_bearing = None if self.observation: wind_bearing = self.observation.get("windDirection") return wind_bearing
[ "def", "wind_bearing", "(", "self", ")", ":", "wind_bearing", "=", "None", "if", "self", ".", "observation", ":", "wind_bearing", "=", "self", ".", "observation", ".", "get", "(", "\"windDirection\"", ")", "return", "wind_bearing" ]
[ 207, 4 ]
[ 212, 27 ]
python
en
['en', 'en', 'en']
True
NWSWeather.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" return TEMP_FAHRENHEIT
[ "def", "temperature_unit", "(", "self", ")", ":", "return", "TEMP_FAHRENHEIT" ]
[ 215, 4 ]
[ 217, 30 ]
python
en
['en', 'la', 'en']
True
NWSWeather.condition
(self)
Return current condition.
Return current condition.
def condition(self): """Return current condition.""" weather = None if self.observation: weather = self.observation.get("iconWeather") time = self.observation.get("iconTime") if weather: cond, _ = convert_condition(time, weather) return co...
[ "def", "condition", "(", "self", ")", ":", "weather", "=", "None", "if", "self", ".", "observation", ":", "weather", "=", "self", ".", "observation", ".", "get", "(", "\"iconWeather\"", ")", "time", "=", "self", ".", "observation", ".", "get", "(", "\"...
[ 220, 4 ]
[ 230, 19 ]
python
en
['en', 'la', 'en']
True
NWSWeather.visibility
(self)
Return visibility.
Return visibility.
def visibility(self): """Return visibility.""" vis_m = None if self.observation: vis_m = self.observation.get("visibility") if vis_m is None: return None if self.is_metric: vis = convert_distance(vis_m, LENGTH_METERS, LENGTH_KILOMETERS) ...
[ "def", "visibility", "(", "self", ")", ":", "vis_m", "=", "None", "if", "self", ".", "observation", ":", "vis_m", "=", "self", ".", "observation", ".", "get", "(", "\"visibility\"", ")", "if", "vis_m", "is", "None", ":", "return", "None", "if", "self",...
[ 233, 4 ]
[ 245, 28 ]
python
en
['en', 'hi-Latn', 'en']
False
NWSWeather.forecast
(self)
Return forecast.
Return forecast.
def forecast(self): """Return forecast.""" if self._forecast is None: return None forecast = [] for forecast_entry in self._forecast: data = { ATTR_FORECAST_DETAILED_DESCRIPTION: forecast_entry.get( "detailedForecast" ...
[ "def", "forecast", "(", "self", ")", ":", "if", "self", ".", "_forecast", "is", "None", ":", "return", "None", "forecast", "=", "[", "]", "for", "forecast_entry", "in", "self", ".", "_forecast", ":", "data", "=", "{", "ATTR_FORECAST_DETAILED_DESCRIPTION", ...
[ 248, 4 ]
[ 285, 23 ]
python
en
['en', 'no', 'en']
False
NWSWeather.unique_id
(self)
Return a unique_id for this entity.
Return a unique_id for this entity.
def unique_id(self): """Return a unique_id for this entity.""" return f"{base_unique_id(self.latitude, self.longitude)}_{self.mode}"
[ "def", "unique_id", "(", "self", ")", ":", "return", "f\"{base_unique_id(self.latitude, self.longitude)}_{self.mode}\"" ]
[ 288, 4 ]
[ 290, 77 ]
python
en
['en', 'en', 'en']
True
NWSWeather.available
(self)
Return if state is available.
Return if state is available.
def available(self): """Return if state is available.""" last_success = ( self.coordinator_observation.last_update_success and self.coordinator_forecast.last_update_success ) if ( self.coordinator_observation.last_update_success_time and se...
[ "def", "available", "(", "self", ")", ":", "last_success", "=", "(", "self", ".", "coordinator_observation", ".", "last_update_success", "and", "self", ".", "coordinator_forecast", ".", "last_update_success", ")", "if", "(", "self", ".", "coordinator_observation", ...
[ 293, 4 ]
[ 311, 48 ]
python
en
['en', 'en', 'en']
True
NWSWeather.async_update
(self)
Update the entity. Only used by the generic entity update service.
Update the entity.
async def async_update(self): """Update the entity. Only used by the generic entity update service. """ await self.coordinator_observation.async_request_refresh() await self.coordinator_forecast.async_request_refresh()
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "coordinator_observation", ".", "async_request_refresh", "(", ")", "await", "self", ".", "coordinator_forecast", ".", "async_request_refresh", "(", ")" ]
[ 313, 4 ]
[ 319, 63 ]
python
en
['en', 'en', 'en']
True
NWSWeather.entity_registry_enabled_default
(self)
Return if the entity should be enabled when first added to the entity registry.
Return if the entity should be enabled when first added to the entity registry.
def entity_registry_enabled_default(self) -> bool: """Return if the entity should be enabled when first added to the entity registry.""" return self.mode == DAYNIGHT
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "mode", "==", "DAYNIGHT" ]
[ 322, 4 ]
[ 324, 36 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], )
Set up the sensor config entry.
Set up the sensor config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], ) -> None: """Set up the sensor config entry.""" controller_data = get_controller_data(hass, entry) async_add_entities( [ VeraCover(device, controll...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "List", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", ")", "->", "None", ":", ...
[ 19, 0 ]
[ 31, 5 ]
python
en
['en', 'pt', 'en']
True
VeraCover.__init__
( self, vera_device: veraApi.VeraCurtain, controller_data: ControllerData )
Initialize the Vera device.
Initialize the Vera device.
def __init__( self, vera_device: veraApi.VeraCurtain, controller_data: ControllerData ): """Initialize the Vera device.""" VeraDevice.__init__(self, vera_device, controller_data) self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id)
[ "def", "__init__", "(", "self", ",", "vera_device", ":", "veraApi", ".", "VeraCurtain", ",", "controller_data", ":", "ControllerData", ")", ":", "VeraDevice", ".", "__init__", "(", "self", ",", "vera_device", ",", "controller_data", ")", "self", ".", "entity_i...
[ 37, 4 ]
[ 42, 62 ]
python
en
['en', 'en', 'en']
True
VeraCover.current_cover_position
(self)
Return current position of cover. 0 is closed, 100 is fully open.
Return current position of cover.
def current_cover_position(self) -> int: """ Return current position of cover. 0 is closed, 100 is fully open. """ position = self.vera_device.get_level() if position <= 5: return 0 if position >= 95: return 100 return position
[ "def", "current_cover_position", "(", "self", ")", "->", "int", ":", "position", "=", "self", ".", "vera_device", ".", "get_level", "(", ")", "if", "position", "<=", "5", ":", "return", "0", "if", "position", ">=", "95", ":", "return", "100", "return", ...
[ 45, 4 ]
[ 56, 23 ]
python
en
['en', 'error', 'th']
False
VeraCover.set_cover_position
(self, **kwargs)
Move the cover to a specific position.
Move the cover to a specific position.
def set_cover_position(self, **kwargs) -> None: """Move the cover to a specific position.""" self.vera_device.set_level(kwargs.get(ATTR_POSITION)) self.schedule_update_ha_state()
[ "def", "set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "self", ".", "vera_device", ".", "set_level", "(", "kwargs", ".", "get", "(", "ATTR_POSITION", ")", ")", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 58, 4 ]
[ 61, 39 ]
python
en
['en', 'en', 'en']
True
VeraCover.is_closed
(self)
Return if the cover is closed.
Return if the cover is closed.
def is_closed(self) -> bool: """Return if the cover is closed.""" if self.current_cover_position is not None: return self.current_cover_position == 0
[ "def", "is_closed", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "current_cover_position", "is", "not", "None", ":", "return", "self", ".", "current_cover_position", "==", "0" ]
[ 64, 4 ]
[ 67, 51 ]
python
en
['en', 'en', 'en']
True
VeraCover.open_cover
(self, **kwargs: Any)
Open the cover.
Open the cover.
def open_cover(self, **kwargs: Any) -> None: """Open the cover.""" self.vera_device.open() self.schedule_update_ha_state()
[ "def", "open_cover", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "self", ".", "vera_device", ".", "open", "(", ")", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 69, 4 ]
[ 72, 39 ]
python
en
['en', 'en', 'en']
True
VeraCover.close_cover
(self, **kwargs: Any)
Close the cover.
Close the cover.
def close_cover(self, **kwargs: Any) -> None: """Close the cover.""" self.vera_device.close() self.schedule_update_ha_state()
[ "def", "close_cover", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "self", ".", "vera_device", ".", "close", "(", ")", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 74, 4 ]
[ 77, 39 ]
python
en
['en', 'en', 'en']
True
VeraCover.stop_cover
(self, **kwargs: Any)
Stop the cover.
Stop the cover.
def stop_cover(self, **kwargs: Any) -> None: """Stop the cover.""" self.vera_device.stop() self.schedule_update_ha_state()
[ "def", "stop_cover", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "self", ".", "vera_device", ".", "stop", "(", ")", "self", ".", "schedule_update_ha_state", "(", ")" ]
[ 79, 4 ]
[ 82, 39 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities )
Set up the Synology NAS binary sensor.
Set up the Synology NAS binary sensor.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities ) -> None: """Set up the Synology NAS binary sensor.""" api = hass.data[DOMAIN][entry.unique_id][SYNO_API] entities = [ SynoDSMSecurityBinarySensor( api, sensor_type, SECURITY_BINARY_SENSOR...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "api", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "unique_id", "]", "[", ...
[ 18, 0 ]
[ 49, 32 ]
python
en
['en', 'haw', 'en']
True
SynoDSMSecurityBinarySensor.is_on
(self)
Return the state.
Return the state.
def is_on(self) -> bool: """Return the state.""" return getattr(self._api.security, self.entity_type) != "safe"
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "getattr", "(", "self", ".", "_api", ".", "security", ",", "self", ".", "entity_type", ")", "!=", "\"safe\"" ]
[ 56, 4 ]
[ 58, 70 ]
python
en
['en', 'en', 'en']
True
SynoDSMSecurityBinarySensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return bool(self._api.security)
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_api", ".", "security", ")" ]
[ 61, 4 ]
[ 63, 39 ]
python
en
['en', 'en', 'en']
True
SynoDSMSecurityBinarySensor.device_state_attributes
(self)
Return security checks details.
Return security checks details.
def device_state_attributes(self) -> Dict[str, str]: """Return security checks details.""" return self._api.security.status_by_check
[ "def", "device_state_attributes", "(", "self", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "return", "self", ".", "_api", ".", "security", ".", "status_by_check" ]
[ 66, 4 ]
[ 68, 49 ]
python
en
['en', 'pt', 'en']
True
SynoDSMStorageBinarySensor.is_on
(self)
Return the state.
Return the state.
def is_on(self) -> bool: """Return the state.""" return getattr(self._api.storage, self.entity_type)(self._device_id)
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "getattr", "(", "self", ".", "_api", ".", "storage", ",", "self", ".", "entity_type", ")", "(", "self", ".", "_device_id", ")" ]
[ 75, 4 ]
[ 77, 76 ]
python
en
['en', 'en', 'en']
True
SynoDSMUpgradeBinarySensor.is_on
(self)
Return the state.
Return the state.
def is_on(self) -> bool: """Return the state.""" return getattr(self._api.upgrade, self.entity_type)
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "getattr", "(", "self", ".", "_api", ".", "upgrade", ",", "self", ".", "entity_type", ")" ]
[ 84, 4 ]
[ 86, 59 ]
python
en
['en', 'en', 'en']
True
SynoDSMUpgradeBinarySensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return bool(self._api.upgrade)
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "bool", "(", "self", ".", "_api", ".", "upgrade", ")" ]
[ 89, 4 ]
[ 91, 38 ]
python
en
['en', 'en', 'en']
True
RagRayDistributedRetriever.init_retrieval
(self)
Retriever initialization function, needs to be called from the training process. This function triggers retrieval initialization for all retrieval actors if using distributed setting, or loads index into current process if training is not distributed.
Retriever initialization function, needs to be called from the training process. This function triggers retrieval initialization for all retrieval actors if using distributed setting, or loads index into current process if training is not distributed.
def init_retrieval(self): """ Retriever initialization function, needs to be called from the training process. This function triggers retrieval initialization for all retrieval actors if using distributed setting, or loads index into current process if training is not distributed...
[ "def", "init_retrieval", "(", "self", ")", ":", "logger", ".", "info", "(", "\"initializing retrieval\"", ")", "if", "len", "(", "self", ".", "retrieval_workers", ")", ">", "0", ":", "ray", ".", "get", "(", "[", "worker", ".", "init_retrieval", ".", "rem...
[ 87, 4 ]
[ 100, 35 ]
python
en
['en', 'error', 'th']
False
RagRayDistributedRetriever.retrieve
(self, question_hidden_states, n_docs)
Retrieves documents for specified ``question_hidden_states``. If running training with multiple workers, a random retrieval actor is selected to perform the index lookup and return the result. Args: question_hidden_states (:obj:`np.ndarray` of shape :obj:`(batch_size, vecto...
Retrieves documents for specified ``question_hidden_states``. If running training with multiple workers, a random retrieval actor is selected to perform the index lookup and return the result.
def retrieve(self, question_hidden_states, n_docs): """ Retrieves documents for specified ``question_hidden_states``. If running training with multiple workers, a random retrieval actor is selected to perform the index lookup and return the result. Args: question_hid...
[ "def", "retrieve", "(", "self", ",", "question_hidden_states", ",", "n_docs", ")", ":", "if", "len", "(", "self", ".", "retrieval_workers", ")", ">", "0", ":", "# Select a random retrieval actor.", "random_worker", "=", "self", ".", "retrieval_workers", "[", "ra...
[ 102, 4 ]
[ 128, 79 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up a sensor for a Hydrawise device.
Set up a sensor for a Hydrawise device.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up a sensor for a Hydrawise device.""" hydrawise = hass.data[DATA_HYDRAWISE].data sensors = [] for sensor_type in config.get(CONF_MONITORED_CONDITIONS): for zone in hydrawise.relays: sensors.append(Hydrawise...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "hydrawise", "=", "hass", ".", "data", "[", "DATA_HYDRAWISE", "]", ".", "data", "sensors", "=", "[", "]", "for", "sensor_type", "in", ...
[ 26, 0 ]
[ 35, 31 ]
python
en
['en', 'en', 'en']
True
HydrawiseSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 42, 4 ]
[ 44, 26 ]
python
en
['en', 'en', 'en']
True
HydrawiseSensor.update
(self)
Get the latest data and updates the states.
Get the latest data and updates the states.
def update(self): """Get the latest data and updates the states.""" mydata = self.hass.data[DATA_HYDRAWISE].data _LOGGER.debug("Updating Hydrawise sensor: %s", self._name) relay_data = mydata.relays[self.data["relay"] - 1] if self._sensor_type == "watering_time": if r...
[ "def", "update", "(", "self", ")", ":", "mydata", "=", "self", ".", "hass", ".", "data", "[", "DATA_HYDRAWISE", "]", ".", "data", "_LOGGER", ".", "debug", "(", "\"Updating Hydrawise sensor: %s\"", ",", "self", ".", "_name", ")", "relay_data", "=", "mydata"...
[ 46, 4 ]
[ 61, 25 ]
python
en
['en', 'en', 'en']
True
main_zone_fixture
()
Mock the main zone.
Mock the main zone.
def main_zone_fixture(): """Mock the main zone.""" return _create_zone_mock("Main zone", "http://main")
[ "def", "main_zone_fixture", "(", ")", ":", "return", "_create_zone_mock", "(", "\"Main zone\"", ",", "\"http://main\"", ")" ]
[ 36, 0 ]
[ 38, 56 ]
python
en
['en', 'mg', 'en']
True
device_fixture
(main_zone)
Mock the yamaha device.
Mock the yamaha device.
def device_fixture(main_zone): """Mock the yamaha device.""" device = FakeYamahaDevice("http://receiver", "Receiver", zones=[main_zone]) with patch("rxv.RXV", return_value=device): yield device
[ "def", "device_fixture", "(", "main_zone", ")", ":", "device", "=", "FakeYamahaDevice", "(", "\"http://receiver\"", ",", "\"Receiver\"", ",", "zones", "=", "[", "main_zone", "]", ")", "with", "patch", "(", "\"rxv.RXV\"", ",", "return_value", "=", "device", ")"...
[ 42, 0 ]
[ 46, 20 ]
python
en
['en', 'zu', 'en']
True
test_setup_host
(hass, device, main_zone)
Test set up integration with host.
Test set up integration with host.
async def test_setup_host(hass, device, main_zone): """Test set up integration with host.""" assert await async_setup_component(hass, mp.DOMAIN, CONFIG) await hass.async_block_till_done() state = hass.states.get("media_player.yamaha_receiver_main_zone") assert state is not None assert state.st...
[ "async", "def", "test_setup_host", "(", "hass", ",", "device", ",", "main_zone", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "mp", ".", "DOMAIN", ",", "CONFIG", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "state"...
[ 49, 0 ]
[ 57, 31 ]
python
en
['en', 'da', 'en']
True
test_setup_no_host
(hass, device, main_zone)
Test set up integration without host.
Test set up integration without host.
async def test_setup_no_host(hass, device, main_zone): """Test set up integration without host.""" with patch("rxv.find", return_value=[device]): assert await async_setup_component( hass, mp.DOMAIN, {"media_player": {"platform": "yamaha"}} ) await hass.async_block_till_done()...
[ "async", "def", "test_setup_no_host", "(", "hass", ",", "device", ",", "main_zone", ")", ":", "with", "patch", "(", "\"rxv.find\"", ",", "return_value", "=", "[", "device", "]", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "mp", ...
[ 60, 0 ]
[ 71, 31 ]
python
en
['en', 'da', 'en']
True
test_setup_discovery
(hass, device, main_zone)
Test set up integration via discovery.
Test set up integration via discovery.
async def test_setup_discovery(hass, device, main_zone): """Test set up integration via discovery.""" discovery_info = { "name": "Yamaha Receiver", "model_name": "Yamaha", "control_url": "http://receiver", "description_url": "http://receiver/description", } await async_lo...
[ "async", "def", "test_setup_discovery", "(", "hass", ",", "device", ",", "main_zone", ")", ":", "discovery_info", "=", "{", "\"name\"", ":", "\"Yamaha Receiver\"", ",", "\"model_name\"", ":", "\"Yamaha\"", ",", "\"control_url\"", ":", "\"http://receiver\"", ",", "...
[ 74, 0 ]
[ 90, 31 ]
python
en
['en', 'pt', 'en']
True
test_setup_zone_ignore
(hass, device, main_zone)
Test set up integration without host.
Test set up integration without host.
async def test_setup_zone_ignore(hass, device, main_zone): """Test set up integration without host.""" assert await async_setup_component( hass, mp.DOMAIN, { "media_player": { "platform": "yamaha", "host": "127.0.0.1", "zone_ign...
[ "async", "def", "test_setup_zone_ignore", "(", "hass", ",", "device", ",", "main_zone", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "mp", ".", "DOMAIN", ",", "{", "\"media_player\"", ":", "{", "\"platform\"", ":", "\"yamaha\"", ",",...
[ 93, 0 ]
[ 110, 24 ]
python
en
['en', 'da', 'en']
True
test_enable_output
(hass, device, main_zone)
Test enable output service.
Test enable output service.
async def test_enable_output(hass, device, main_zone): """Test enable output service.""" assert await async_setup_component(hass, mp.DOMAIN, CONFIG) await hass.async_block_till_done() port = "hdmi1" enabled = True data = { "entity_id": "media_player.yamaha_receiver_main_zone", "...
[ "async", "def", "test_enable_output", "(", "hass", ",", "device", ",", "main_zone", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "mp", ".", "DOMAIN", ",", "CONFIG", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "por...
[ 113, 0 ]
[ 129, 67 ]
python
en
['fr', 'en', 'en']
True
test_select_scene
(hass, device, main_zone, caplog)
Test select scene service.
Test select scene service.
async def test_select_scene(hass, device, main_zone, caplog): """Test select scene service.""" scene_prop = PropertyMock(return_value=None) type(main_zone).scene = scene_prop assert await async_setup_component(hass, mp.DOMAIN, CONFIG) await hass.async_block_till_done() scene = "TV Viewing" ...
[ "async", "def", "test_select_scene", "(", "hass", ",", "device", ",", "main_zone", ",", "caplog", ")", ":", "scene_prop", "=", "PropertyMock", "(", "return_value", "=", "None", ")", "type", "(", "main_zone", ")", ".", "scene", "=", "scene_prop", "assert", ...
[ 132, 0 ]
[ 166, 68 ]
python
en
['no', 'ro', 'en']
False
FakeYamahaDevice.__init__
(self, ctrl_url, name, zones=None)
Initialize the fake Yamaha device.
Initialize the fake Yamaha device.
def __init__(self, ctrl_url, name, zones=None): """Initialize the fake Yamaha device.""" self.ctrl_url = ctrl_url self.name = name self._zones = zones or []
[ "def", "__init__", "(", "self", ",", "ctrl_url", ",", "name", ",", "zones", "=", "None", ")", ":", "self", ".", "ctrl_url", "=", "ctrl_url", "self", ".", "name", "=", "name", "self", ".", "_zones", "=", "zones", "or", "[", "]" ]
[ 24, 4 ]
[ 28, 33 ]
python
en
['en', 'zu', 'en']
True
FakeYamahaDevice.zone_controllers
(self)
Return controllers for all available zones.
Return controllers for all available zones.
def zone_controllers(self): """Return controllers for all available zones.""" return self._zones
[ "def", "zone_controllers", "(", "self", ")", ":", "return", "self", ".", "_zones" ]
[ 30, 4 ]
[ 32, 26 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the ThinkingCleaner platform.
Set up the ThinkingCleaner platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the ThinkingCleaner platform.""" host = config.get(CONF_HOST) if host: devices = [ThinkingCleaner(host, "unknown")] else: discovery = Discovery() devices = discovery.discover() @util.Throttle(MIN_...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")", "if", "host", ":", "devices", "=", "[", "ThinkingCleaner", "(", "host", ",",...
[ 28, 0 ]
[ 48, 21 ]
python
en
['en', 'zu', 'en']
True
ThinkingCleanerSwitch.__init__
(self, tc_object, switch_type, update_devices)
Initialize the ThinkingCleaner.
Initialize the ThinkingCleaner.
def __init__(self, tc_object, switch_type, update_devices): """Initialize the ThinkingCleaner.""" self.type = switch_type self._update_devices = update_devices self._tc_object = tc_object self._state = self._tc_object.is_cleaning if switch_type == "clean" else False self...
[ "def", "__init__", "(", "self", ",", "tc_object", ",", "switch_type", ",", "update_devices", ")", ":", "self", ".", "type", "=", "switch_type", "self", ".", "_update_devices", "=", "update_devices", "self", ".", "_tc_object", "=", "tc_object", "self", ".", "...
[ 54, 4 ]
[ 63, 35 ]
python
en
['en', 'en', 'en']
True
ThinkingCleanerSwitch.lock_update
(self)
Lock the update since TC clean takes some time to update.
Lock the update since TC clean takes some time to update.
def lock_update(self): """Lock the update since TC clean takes some time to update.""" if self.is_update_locked(): return self.lock = True self.last_lock_time = time.time()
[ "def", "lock_update", "(", "self", ")", ":", "if", "self", ".", "is_update_locked", "(", ")", ":", "return", "self", ".", "lock", "=", "True", "self", ".", "last_lock_time", "=", "time", ".", "time", "(", ")" ]
[ 65, 4 ]
[ 70, 41 ]
python
en
['en', 'en', 'en']
True
ThinkingCleanerSwitch.reset_update_lock
(self)
Reset the update lock.
Reset the update lock.
def reset_update_lock(self): """Reset the update lock.""" self.lock = False self.last_lock_time = None
[ "def", "reset_update_lock", "(", "self", ")", ":", "self", ".", "lock", "=", "False", "self", ".", "last_lock_time", "=", "None" ]
[ 72, 4 ]
[ 75, 34 ]
python
en
['en', 'la', 'en']
True
ThinkingCleanerSwitch.set_graceful_lock
(self, state)
Set the graceful state.
Set the graceful state.
def set_graceful_lock(self, state): """Set the graceful state.""" self.graceful_state = state self.reset_update_lock() self.lock_update()
[ "def", "set_graceful_lock", "(", "self", ",", "state", ")", ":", "self", ".", "graceful_state", "=", "state", "self", ".", "reset_update_lock", "(", ")", "self", ".", "lock_update", "(", ")" ]
[ 77, 4 ]
[ 81, 26 ]
python
en
['en', 'en', 'en']
True
ThinkingCleanerSwitch.is_update_locked
(self)
Check if the update method is locked.
Check if the update method is locked.
def is_update_locked(self): """Check if the update method is locked.""" if self.last_lock_time is None: return False if time.time() - self.last_lock_time >= MIN_TIME_TO_LOCK_UPDATE: self.last_lock_time = None return False return True
[ "def", "is_update_locked", "(", "self", ")", ":", "if", "self", ".", "last_lock_time", "is", "None", ":", "return", "False", "if", "time", ".", "time", "(", ")", "-", "self", ".", "last_lock_time", ">=", "MIN_TIME_TO_LOCK_UPDATE", ":", "self", ".", "last_l...
[ 83, 4 ]
[ 92, 19 ]
python
en
['en', 'en', 'en']
True
ThinkingCleanerSwitch.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return f"{self._tc_object.name} {SWITCH_TYPES[self.type][0]}"
[ "def", "name", "(", "self", ")", ":", "return", "f\"{self._tc_object.name} {SWITCH_TYPES[self.type][0]}\"" ]
[ 95, 4 ]
[ 97, 69 ]
python
en
['en', 'mi', 'en']
True
ThinkingCleanerSwitch.is_on
(self)
Return true if device is on.
Return true if device is on.
def is_on(self): """Return true if device is on.""" if self.type == "clean": return ( self.graceful_state if self.is_update_locked() else self._tc_object.is_cleaning ) return False
[ "def", "is_on", "(", "self", ")", ":", "if", "self", ".", "type", "==", "\"clean\"", ":", "return", "(", "self", ".", "graceful_state", "if", "self", ".", "is_update_locked", "(", ")", "else", "self", ".", "_tc_object", ".", "is_cleaning", ")", "return",...
[ 100, 4 ]
[ 109, 20 ]
python
en
['en', 'fy', 'en']
True
ThinkingCleanerSwitch.turn_on
(self, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, **kwargs): """Turn the device on.""" if self.type == "clean": self.set_graceful_lock(True) self._tc_object.start_cleaning() elif self.type == "dock": self._tc_object.dock() elif self.type == "find": self._tc_object.find_me...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "type", "==", "\"clean\"", ":", "self", ".", "set_graceful_lock", "(", "True", ")", "self", ".", "_tc_object", ".", "start_cleaning", "(", ")", "elif", "self", ".", ...
[ 111, 4 ]
[ 119, 37 ]
python
en
['en', 'en', 'en']
True
ThinkingCleanerSwitch.turn_off
(self, **kwargs)
Turn the device off.
Turn the device off.
def turn_off(self, **kwargs): """Turn the device off.""" if self.type == "clean": self.set_graceful_lock(False) self._tc_object.stop_cleaning()
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "type", "==", "\"clean\"", ":", "self", ".", "set_graceful_lock", "(", "False", ")", "self", ".", "_tc_object", ".", "stop_cleaning", "(", ")" ]
[ 121, 4 ]
[ 125, 43 ]
python
en
['en', 'en', 'en']
True
ThinkingCleanerSwitch.update
(self)
Update the switch state (Only for clean).
Update the switch state (Only for clean).
def update(self): """Update the switch state (Only for clean).""" if self.type == "clean" and not self.is_update_locked(): self._tc_object.update() self._state = STATE_ON if self._tc_object.is_cleaning else STATE_OFF
[ "def", "update", "(", "self", ")", ":", "if", "self", ".", "type", "==", "\"clean\"", "and", "not", "self", ".", "is_update_locked", "(", ")", ":", "self", ".", "_tc_object", ".", "update", "(", ")", "self", ".", "_state", "=", "STATE_ON", "if", "sel...
[ 127, 4 ]
[ 131, 80 ]
python
en
['en', 'en', 'en']
True
test_remote_connection_sensor
(hass)
Test the remote connection sensor.
Test the remote connection sensor.
async def test_remote_connection_sensor(hass): """Test the remote connection sensor.""" assert await async_setup_component(hass, "cloud", {"cloud": {}}) await hass.async_block_till_done() assert hass.states.get("binary_sensor.remote_ui") is None # Fake connection/discovery await hass.helpers.d...
[ "async", "def", "test_remote_connection_sensor", "(", "hass", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"cloud\"", ",", "{", "\"cloud\"", ":", "{", "}", "}", ")", "await", "hass", ".", "async_block_till_done", "(", ")", "assert"...
[ 7, 0 ]
[ 42, 34 ]
python
en
['en', 'en', 'en']
True
_assert_tensors_equal
(a, b, atol=1e-12, prefix="")
If tensors not close, or a and b arent both tensors, raise a nice Assertion error.
If tensors not close, or a and b arent both tensors, raise a nice Assertion error.
def _assert_tensors_equal(a, b, atol=1e-12, prefix=""): """If tensors not close, or a and b arent both tensors, raise a nice Assertion error.""" if a is None and b is None: return True try: if torch.allclose(a, b, atol=atol): return True raise except Exception: ...
[ "def", "_assert_tensors_equal", "(", "a", ",", "b", ",", "atol", "=", "1e-12", ",", "prefix", "=", "\"\"", ")", ":", "if", "a", "is", "None", "and", "b", "is", "None", ":", "return", "True", "try", ":", "if", "torch", ".", "allclose", "(", "a", "...
[ 67, 0 ]
[ 79, 33 ]
python
en
['en', 'en', 'en']
True
require_retrieval
(test_case)
Decorator marking a test that requires a set of dependencies necessary for pefrorm retrieval with :class:`~transformers.RagRetriever`. These tests are skipped when respective libraries are not installed.
Decorator marking a test that requires a set of dependencies necessary for pefrorm retrieval with :class:`~transformers.RagRetriever`.
def require_retrieval(test_case): """ Decorator marking a test that requires a set of dependencies necessary for pefrorm retrieval with :class:`~transformers.RagRetriever`. These tests are skipped when respective libraries are not installed. """ if not (is_torch_available() and is_datasets_ava...
[ "def", "require_retrieval", "(", "test_case", ")", ":", "if", "not", "(", "is_torch_available", "(", ")", "and", "is_datasets_available", "(", ")", "and", "is_faiss_available", "(", ")", ")", ":", "test_case", "=", "unittest", ".", "skip", "(", "\"test require...
[ 82, 0 ]
[ 92, 20 ]
python
en
['en', 'error', 'th']
False
Trainer.train_one_epoch
(self, epoch)
Train one epoch. Parameters ---------- epoch : int Epoch number starting from 0.
Train one epoch.
def train_one_epoch(self, epoch): """ Train one epoch. Parameters ---------- epoch : int Epoch number starting from 0. """ pass
[ "def", "train_one_epoch", "(", "self", ",", "epoch", ")", ":", "pass" ]
[ 102, 4 ]
[ 111, 12 ]
python
en
['en', 'error', 'th']
False
Trainer.validate_one_epoch
(self, epoch)
Validate one epoch. Parameters ---------- epoch : int Epoch number starting from 0.
Validate one epoch.
def validate_one_epoch(self, epoch): """ Validate one epoch. Parameters ---------- epoch : int Epoch number starting from 0. """ pass
[ "def", "validate_one_epoch", "(", "self", ",", "epoch", ")", ":", "pass" ]
[ 114, 4 ]
[ 123, 12 ]
python
en
['en', 'error', 'th']
False
Trainer.train
(self, validate=True)
Train ``num_epochs``. Trigger callbacks at the start and the end of each epoch. Parameters ---------- validate : bool If ``true``, will do validation every epoch.
Train ``num_epochs``. Trigger callbacks at the start and the end of each epoch.
def train(self, validate=True): """ Train ``num_epochs``. Trigger callbacks at the start and the end of each epoch. Parameters ---------- validate : bool If ``true``, will do validation every epoch. """ for epoch in range(self.num_epochs): ...
[ "def", "train", "(", "self", ",", "validate", "=", "True", ")", ":", "for", "epoch", "in", "range", "(", "self", ".", "num_epochs", ")", ":", "for", "callback", "in", "self", ".", "callbacks", ":", "callback", ".", "on_epoch_begin", "(", "epoch", ")", ...
[ 125, 4 ]
[ 149, 44 ]
python
en
['en', 'error', 'th']
False
Trainer.validate
(self)
Do one validation.
Do one validation.
def validate(self): """ Do one validation. """ self.validate_one_epoch(-1)
[ "def", "validate", "(", "self", ")", ":", "self", ".", "validate_one_epoch", "(", "-", "1", ")" ]
[ 151, 4 ]
[ 155, 35 ]
python
en
['en', 'error', 'th']
False
Trainer.export
(self, file)
Call ``mutator.export()`` and dump the architecture to ``file``. Parameters ---------- file : str A file path. Expected to be a JSON.
Call ``mutator.export()`` and dump the architecture to ``file``.
def export(self, file): """ Call ``mutator.export()`` and dump the architecture to ``file``. Parameters ---------- file : str A file path. Expected to be a JSON. """ mutator_export = self.mutator.export() with open(file, "w") as f: ...
[ "def", "export", "(", "self", ",", "file", ")", ":", "mutator_export", "=", "self", ".", "mutator", ".", "export", "(", ")", "with", "open", "(", "file", ",", "\"w\"", ")", "as", "f", ":", "json", ".", "dump", "(", "mutator_export", ",", "f", ",", ...
[ 157, 4 ]
[ 168, 90 ]
python
en
['en', 'error', 'th']
False
Trainer.checkpoint
(self)
Return trainer checkpoint.
Return trainer checkpoint.
def checkpoint(self): """ Return trainer checkpoint. """ raise NotImplementedError("Not implemented yet")
[ "def", "checkpoint", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "\"Not implemented yet\"", ")" ]
[ 170, 4 ]
[ 174, 56 ]
python
en
['en', 'error', 'th']
False
Trainer.enable_visualization
(self)
Enable visualization. Write graph and training log to folder ``logs/<timestamp>``.
Enable visualization. Write graph and training log to folder ``logs/<timestamp>``.
def enable_visualization(self): """ Enable visualization. Write graph and training log to folder ``logs/<timestamp>``. """ sample = None for x, _ in self.train_loader: sample = x.to(self.device)[:2] break if sample is None: _logger.warn...
[ "def", "enable_visualization", "(", "self", ")", ":", "sample", "=", "None", "for", "x", ",", "_", "in", "self", ".", "train_loader", ":", "sample", "=", "x", ".", "to", "(", "self", ".", "device", ")", "[", ":", "2", "]", "break", "if", "sample", ...
[ 176, 4 ]
[ 189, 41 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass: HomeAssistantType, config: ConfigType)
Set up iCloud from legacy config file.
Set up iCloud from legacy config file.
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: """Set up iCloud from legacy config file.""" conf = config.get(DOMAIN) if conf is None: return True for account_conf in conf: hass.async_create_task( hass.config_entries.flow.async_init( ...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistantType", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "if", "conf", "is", "None", ":", "return", "True", "for", "account_conf...
[ 88, 0 ]
[ 102, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Set up an iCloud account from a config entry.
Set up an iCloud account from a config entry.
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: """Set up an iCloud account from a config entry.""" hass.data.setdefault(DOMAIN, {}) username = entry.data[CONF_USERNAME] password = entry.data[CONF_PASSWORD] with_family = entry.data[CONF_WITH_FAMILY] max_interv...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "username", "=", "entry", ".", "data", "[", ...
[ 105, 0 ]
[ 220, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, platform) for platform in PLATFORMS ] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_un...
[ 223, 0 ]
[ 236, 20 ]
python
en
['en', 'es', 'en']
True
pyorbit_dynesty
(config_in, input_datasets=None, return_output=None)
A dummy file is created to let the cpulimit script to proceed with the next step
A dummy file is created to let the cpulimit script to proceed with the next step
def pyorbit_dynesty(config_in, input_datasets=None, return_output=None): output_directory = './' + config_in['output'] + '/dynesty/' mc = ModelContainerDynesty() pars_input(config_in, mc, input_datasets) if mc.nested_sampling_parameters['shutdown_jitter']: for dataset in mc.dataset_dict.iter...
[ "def", "pyorbit_dynesty", "(", "config_in", ",", "input_datasets", "=", "None", ",", "return_output", "=", "None", ")", ":", "output_directory", "=", "'./'", "+", "config_in", "[", "'output'", "]", "+", "'/dynesty/'", "mc", "=", "ModelContainerDynesty", "(", "...
[ 20, 0 ]
[ 96, 14 ]
python
en
['en', 'en', 'en']
True