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
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the Lutron Caseta cover platform. Adds shades from the Caseta bridge associated with the config_entry as cover entities.
Set up the Lutron Caseta cover platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the Lutron Caseta cover platform. Adds shades from the Caseta bridge associated with the config_entry as cover entities. """ entities = [] bridge = hass.data[CASETA_DOMAIN][config_entry.entry_id] cover_devices =...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "]", "bridge", "=", "hass", ".", "data", "[", "CASETA_DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "cover_devices", ...
[ 19, 0 ]
[ 34, 38 ]
python
en
['en', 'pt', 'en']
True
LutronCasetaCover.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_OPEN", "|", "SUPPORT_CLOSE", "|", "SUPPORT_STOP", "|", "SUPPORT_SET_POSITION" ]
[ 41, 4 ]
[ 43, 81 ]
python
en
['da', 'en', 'en']
True
LutronCasetaCover.is_closed
(self)
Return if the cover is closed.
Return if the cover is closed.
def is_closed(self): """Return if the cover is closed.""" return self._device["current_state"] < 1
[ "def", "is_closed", "(", "self", ")", ":", "return", "self", ".", "_device", "[", "\"current_state\"", "]", "<", "1" ]
[ 46, 4 ]
[ 48, 48 ]
python
en
['en', 'en', 'en']
True
LutronCasetaCover.current_cover_position
(self)
Return the current position of cover.
Return the current position of cover.
def current_cover_position(self): """Return the current position of cover.""" return self._device["current_state"]
[ "def", "current_cover_position", "(", "self", ")", ":", "return", "self", ".", "_device", "[", "\"current_state\"", "]" ]
[ 51, 4 ]
[ 53, 44 ]
python
en
['en', 'en', 'en']
True
LutronCasetaCover.device_class
(self)
Return the device class.
Return the device class.
def device_class(self): """Return the device class.""" return DEVICE_CLASS_SHADE
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_SHADE" ]
[ 56, 4 ]
[ 58, 33 ]
python
en
['en', 'en', 'en']
True
LutronCasetaCover.async_stop_cover
(self, **kwargs)
Top the cover.
Top the cover.
async def async_stop_cover(self, **kwargs): """Top the cover.""" await self._smartbridge.stop_cover(self.device_id)
[ "async", "def", "async_stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_smartbridge", ".", "stop_cover", "(", "self", ".", "device_id", ")" ]
[ 60, 4 ]
[ 62, 58 ]
python
en
['en', 'en', 'en']
True
LutronCasetaCover.async_close_cover
(self, **kwargs)
Close the cover.
Close the cover.
async def async_close_cover(self, **kwargs): """Close the cover.""" await self._smartbridge.lower_cover(self.device_id) self.async_update() self.async_write_ha_state()
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_smartbridge", ".", "lower_cover", "(", "self", ".", "device_id", ")", "self", ".", "async_update", "(", ")", "self", ".", "async_write_ha_state", "...
[ 64, 4 ]
[ 68, 35 ]
python
en
['en', 'en', 'en']
True
LutronCasetaCover.async_open_cover
(self, **kwargs)
Open the cover.
Open the cover.
async def async_open_cover(self, **kwargs): """Open the cover.""" await self._smartbridge.raise_cover(self.device_id) self.async_update() self.async_write_ha_state()
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "_smartbridge", ".", "raise_cover", "(", "self", ".", "device_id", ")", "self", ".", "async_update", "(", ")", "self", ".", "async_write_ha_state", "(...
[ 70, 4 ]
[ 74, 35 ]
python
en
['en', 'en', 'en']
True
LutronCasetaCover.async_set_cover_position
(self, **kwargs)
Move the shade to a specific position.
Move the shade to a specific position.
async def async_set_cover_position(self, **kwargs): """Move the shade to a specific position.""" if ATTR_POSITION in kwargs: position = kwargs[ATTR_POSITION] await self._smartbridge.set_value(self.device_id, position)
[ "async", "def", "async_set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "ATTR_POSITION", "in", "kwargs", ":", "position", "=", "kwargs", "[", "ATTR_POSITION", "]", "await", "self", ".", "_smartbridge", ".", "set_value", "(", "self",...
[ 76, 4 ]
[ 80, 71 ]
python
en
['en', 'en', 'en']
True
LutronCasetaCover.async_update
(self)
Call when forcing a refresh of the device.
Call when forcing a refresh of the device.
async def async_update(self): """Call when forcing a refresh of the device.""" self._device = self._smartbridge.get_device_by_id(self.device_id) _LOGGER.debug(self._device)
[ "async", "def", "async_update", "(", "self", ")", ":", "self", ".", "_device", "=", "self", ".", "_smartbridge", ".", "get_device_by_id", "(", "self", ".", "device_id", ")", "_LOGGER", ".", "debug", "(", "self", ".", "_device", ")" ]
[ 82, 4 ]
[ 85, 35 ]
python
en
['en', 'en', 'en']
True
test_creating_entry_tries_discover
(hass)
Test setting up does discovery.
Test setting up does discovery.
async def test_creating_entry_tries_discover(hass): """Test setting up does discovery.""" with patch( "homeassistant.components.tplink.async_setup_entry", return_value=mock_coro(True), ) as mock_setup, patch( "homeassistant.components.tplink.common.Discover.discover", return_...
[ "async", "def", "test_creating_entry_tries_discover", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.tplink.async_setup_entry\"", ",", "return_value", "=", "mock_coro", "(", "True", ")", ",", ")", "as", "mock_setup", ",", "patch", "(", "\"h...
[ 21, 0 ]
[ 42, 42 ]
python
en
['fr', 'en', 'en']
True
test_configuring_tplink_causes_discovery
(hass)
Test that specifying empty config does discovery.
Test that specifying empty config does discovery.
async def test_configuring_tplink_causes_discovery(hass): """Test that specifying empty config does discovery.""" with patch("homeassistant.components.tplink.common.Discover.discover") as discover: discover.return_value = {"host": 1234} await async_setup_component(hass, tplink.DOMAIN, {tplink.DO...
[ "async", "def", "test_configuring_tplink_causes_discovery", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.tplink.common.Discover.discover\"", ")", "as", "discover", ":", "discover", ".", "return_value", "=", "{", "\"host\"", ":", "1234", "}", ...
[ 45, 0 ]
[ 52, 40 ]
python
en
['en', 'en', 'en']
True
test_configuring_device_types
(hass, name, cls, platform, count)
Test that light or switch platform list is filled correctly.
Test that light or switch platform list is filled correctly.
async def test_configuring_device_types(hass, name, cls, platform, count): """Test that light or switch platform list is filled correctly.""" with patch( "homeassistant.components.tplink.common.Discover.discover" ) as discover, patch( "homeassistant.components.tplink.common.SmartDevice._quer...
[ "async", "def", "test_configuring_device_types", "(", "hass", ",", "name", ",", "cls", ",", "platform", ",", "count", ")", ":", "with", "patch", "(", "\"homeassistant.components.tplink.common.Discover.discover\"", ")", "as", "discover", ",", "patch", "(", "\"homeass...
[ 63, 0 ]
[ 81, 59 ]
python
en
['en', 'en', 'en']
True
test_configuring_devices_from_multiple_sources
(hass)
Test static and discover devices are not duplicated.
Test static and discover devices are not duplicated.
async def test_configuring_devices_from_multiple_sources(hass): """Test static and discover devices are not duplicated.""" with patch( "homeassistant.components.tplink.common.Discover.discover" ) as discover, patch( "homeassistant.components.tplink.common.SmartDevice._query_helper" ), pa...
[ "async", "def", "test_configuring_devices_from_multiple_sources", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.tplink.common.Discover.discover\"", ")", "as", "discover", ",", "patch", "(", "\"homeassistant.components.tplink.common.SmartDevice._query_help...
[ 111, 0 ]
[ 147, 62 ]
python
en
['en', 'en', 'en']
True
test_is_dimmable
(hass)
Test that is_dimmable switches are correctly added as lights.
Test that is_dimmable switches are correctly added as lights.
async def test_is_dimmable(hass): """Test that is_dimmable switches are correctly added as lights.""" with patch( "homeassistant.components.tplink.common.Discover.discover" ) as discover, patch( "homeassistant.components.tplink.light.async_setup_entry", return_value=mock_coro(True), ...
[ "async", "def", "test_is_dimmable", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.tplink.common.Discover.discover\"", ")", "as", "discover", ",", "patch", "(", "\"homeassistant.components.tplink.light.async_setup_entry\"", ",", "return_value", "=", ...
[ 150, 0 ]
[ 171, 52 ]
python
en
['en', 'en', 'en']
True
test_configuring_discovery_disabled
(hass)
Test that discover does not get called when disabled.
Test that discover does not get called when disabled.
async def test_configuring_discovery_disabled(hass): """Test that discover does not get called when disabled.""" with patch( "homeassistant.components.tplink.async_setup_entry", return_value=mock_coro(True), ) as mock_setup, patch( "homeassistant.components.tplink.common.Discover.dis...
[ "async", "def", "test_configuring_discovery_disabled", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.tplink.async_setup_entry\"", ",", "return_value", "=", "mock_coro", "(", "True", ")", ",", ")", "as", "mock_setup", ",", "patch", "(", "\"...
[ 174, 0 ]
[ 188, 37 ]
python
en
['en', 'en', 'en']
True
test_platforms_are_initialized
(hass)
Test that platforms are initialized per configuration array.
Test that platforms are initialized per configuration array.
async def test_platforms_are_initialized(hass): """Test that platforms are initialized per configuration array.""" config = { tplink.DOMAIN: { CONF_DISCOVERY: False, CONF_LIGHT: [{CONF_HOST: "123.123.123.123"}], CONF_SWITCH: [{CONF_HOST: "321.321.321.321"}], }...
[ "async", "def", "test_platforms_are_initialized", "(", "hass", ")", ":", "config", "=", "{", "tplink", ".", "DOMAIN", ":", "{", "CONF_DISCOVERY", ":", "False", ",", "CONF_LIGHT", ":", "[", "{", "CONF_HOST", ":", "\"123.123.123.123\"", "}", "]", ",", "CONF_SW...
[ 191, 0 ]
[ 220, 39 ]
python
en
['en', 'en', 'en']
True
test_no_config_creates_no_entry
(hass)
Test for when there is no tplink in config.
Test for when there is no tplink in config.
async def test_no_config_creates_no_entry(hass): """Test for when there is no tplink in config.""" with patch( "homeassistant.components.tplink.async_setup_entry", return_value=mock_coro(True), ) as mock_setup: await async_setup_component(hass, tplink.DOMAIN, {}) await hass.a...
[ "async", "def", "test_no_config_creates_no_entry", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.tplink.async_setup_entry\"", ",", "return_value", "=", "mock_coro", "(", "True", ")", ",", ")", "as", "mock_setup", ":", "await", "async_setup_c...
[ 223, 0 ]
[ 232, 37 ]
python
en
['en', 'en', 'en']
True
test_unload
(hass, platform)
Test that the async_unload_entry works.
Test that the async_unload_entry works.
async def test_unload(hass, platform): """Test that the async_unload_entry works.""" # As we have currently no configuration, we just to pass the domain here. entry = MockConfigEntry(domain=tplink.DOMAIN) entry.add_to_hass(hass) with patch( "homeassistant.components.tplink.common.SmartDevic...
[ "async", "def", "test_unload", "(", "hass", ",", "platform", ")", ":", "# As we have currently no configuration, we just to pass the domain here.", "entry", "=", "MockConfigEntry", "(", "domain", "=", "tplink", ".", "DOMAIN", ")", "entry", ".", "add_to_hass", "(", "ha...
[ 236, 0 ]
[ 261, 39 ]
python
en
['en', 'en', 'en']
True
UnknownSmartDevice.has_emeter
(self)
Do nothing.
Do nothing.
def has_emeter(self) -> bool: """Do nothing.""" pass
[ "def", "has_emeter", "(", "self", ")", "->", "bool", ":", "pass" ]
[ 88, 4 ]
[ 90, 12 ]
python
en
['en', 'zu', 'en']
False
UnknownSmartDevice.turn_off
(self)
Do nothing.
Do nothing.
def turn_off(self) -> None: """Do nothing.""" pass
[ "def", "turn_off", "(", "self", ")", "->", "None", ":", "pass" ]
[ 92, 4 ]
[ 94, 12 ]
python
en
['en', 'zu', 'en']
False
UnknownSmartDevice.turn_on
(self)
Do nothing.
Do nothing.
def turn_on(self) -> None: """Do nothing.""" pass
[ "def", "turn_on", "(", "self", ")", "->", "None", ":", "pass" ]
[ 96, 4 ]
[ 98, 12 ]
python
en
['en', 'zu', 'en']
False
UnknownSmartDevice.is_on
(self)
Do nothing.
Do nothing.
def is_on(self) -> bool: """Do nothing.""" pass
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "pass" ]
[ 101, 4 ]
[ 103, 12 ]
python
en
['en', 'zu', 'en']
False
UnknownSmartDevice.state_information
(self)
Do nothing.
Do nothing.
def state_information(self) -> Dict[str, Any]: """Do nothing.""" pass
[ "def", "state_information", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "pass" ]
[ 106, 4 ]
[ 108, 12 ]
python
en
['en', 'zu', 'en']
False
TibberConfigFlow.async_step_import
(self, import_info)
Set the config entry up from yaml.
Set the config entry up from yaml.
async def async_step_import(self, import_info): """Set the config entry up from yaml.""" return await self.async_step_user(import_info)
[ "async", "def", "async_step_import", "(", "self", ",", "import_info", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "import_info", ")" ]
[ 22, 4 ]
[ 24, 54 ]
python
en
['en', 'en', 'en']
True
TibberConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" if self._async_current_entries(): return self.async_abort(reason="already_configured") if user_input is not None: access_token = user_input[CONF_ACCESS_TOKEN].replace(" ", "") ...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "self", ".", "_async_current_entries", "(", ")", ":", "return", "self", ".", "async_abort", "(", "reason", "=", "\"already_configured\"", ")", "if", "user_input", ...
[ 26, 4 ]
[ 71, 9 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up for the AlarmDecoder devices.
Set up for the AlarmDecoder devices.
async def async_setup(hass, config): """Set up for the AlarmDecoder devices.""" return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "return", "True" ]
[ 41, 0 ]
[ 43, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Set up AlarmDecoder config flow.
Set up AlarmDecoder config flow.
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: """Set up AlarmDecoder config flow.""" undo_listener = entry.add_update_listener(_update_listener) ad_connection = entry.data protocol = ad_connection[CONF_PROTOCOL] def stop_alarmdecoder(event): """Handle th...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", "->", "bool", ":", "undo_listener", "=", "entry", ".", "add_update_listener", "(", "_update_listener", ")", "ad_connection", "=", "entry", ".", "da...
[ 46, 0 ]
[ 136, 15 ]
python
en
['en', 'ru', 'en']
True
async_unload_entry
(hass: HomeAssistantType, entry: ConfigEntry)
Unload a AlarmDecoder entry.
Unload a AlarmDecoder entry.
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): """Unload a AlarmDecoder entry.""" hass.data[DOMAIN][entry.entry_id][DATA_RESTART] = False unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "[", "DATA_RESTART", "]", "=", "False", "unload_ok", "=", ...
[ 139, 0 ]
[ 164, 15 ]
python
en
['en', 'sv', 'en']
True
_update_listener
(hass: HomeAssistantType, entry: ConfigEntry)
Handle options update.
Handle options update.
async def _update_listener(hass: HomeAssistantType, entry: ConfigEntry): """Handle options update.""" _LOGGER.debug("AlarmDecoder options updated: %s", entry.as_dict()["options"]) await hass.config_entries.async_reload(entry.entry_id)
[ "async", "def", "_update_listener", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ")", ":", "_LOGGER", ".", "debug", "(", "\"AlarmDecoder options updated: %s\"", ",", "entry", ".", "as_dict", "(", ")", "[", "\"options\"", "]", ")", "...
[ 167, 0 ]
[ 170, 58 ]
python
en
['en', 'nl', 'en']
True
async_setup
(hass, config)
Set up the weather component.
Set up the weather component.
async def async_setup(hass, config): """Set up the weather component.""" component = hass.data[DOMAIN] = EntityComponent( _LOGGER, DOMAIN, hass, SCAN_INTERVAL ) await component.async_setup(config) return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "component", "=", "hass", ".", "data", "[", "DOMAIN", "]", "=", "EntityComponent", "(", "_LOGGER", ",", "DOMAIN", ",", "hass", ",", "SCAN_INTERVAL", ")", "await", "component", ".", "asy...
[ 58, 0 ]
[ 64, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Set up a config entry.
Set up a config entry.
async def async_setup_entry(hass, entry): """Set up a config entry.""" return await hass.data[DOMAIN].async_setup_entry(entry)
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "return", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_setup_entry", "(", "entry", ")" ]
[ 67, 0 ]
[ 69, 59 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, entry): """Unload a config entry.""" return await hass.data[DOMAIN].async_unload_entry(entry)
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "return", "await", "hass", ".", "data", "[", "DOMAIN", "]", ".", "async_unload_entry", "(", "entry", ")" ]
[ 72, 0 ]
[ 74, 60 ]
python
en
['en', 'es', 'en']
True
WeatherEntity.temperature
(self)
Return the platform temperature.
Return the platform temperature.
def temperature(self): """Return the platform temperature.""" raise NotImplementedError()
[ "def", "temperature", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 81, 4 ]
[ 83, 35 ]
python
en
['en', 'la', 'en']
True
WeatherEntity.temperature_unit
(self)
Return the unit of measurement.
Return the unit of measurement.
def temperature_unit(self): """Return the unit of measurement.""" raise NotImplementedError()
[ "def", "temperature_unit", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 86, 4 ]
[ 88, 35 ]
python
en
['en', 'la', 'en']
True
WeatherEntity.pressure
(self)
Return the pressure.
Return the pressure.
def pressure(self): """Return the pressure.""" return None
[ "def", "pressure", "(", "self", ")", ":", "return", "None" ]
[ 91, 4 ]
[ 93, 19 ]
python
en
['en', 'ig', 'en']
True
WeatherEntity.humidity
(self)
Return the humidity.
Return the humidity.
def humidity(self): """Return the humidity.""" raise NotImplementedError()
[ "def", "humidity", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 96, 4 ]
[ 98, 35 ]
python
en
['en', 'sw', 'en']
True
WeatherEntity.wind_speed
(self)
Return the wind speed.
Return the wind speed.
def wind_speed(self): """Return the wind speed.""" return None
[ "def", "wind_speed", "(", "self", ")", ":", "return", "None" ]
[ 101, 4 ]
[ 103, 19 ]
python
en
['en', 'zh', 'en']
True
WeatherEntity.wind_bearing
(self)
Return the wind bearing.
Return the wind bearing.
def wind_bearing(self): """Return the wind bearing.""" return None
[ "def", "wind_bearing", "(", "self", ")", ":", "return", "None" ]
[ 106, 4 ]
[ 108, 19 ]
python
en
['en', 'ig', 'en']
True
WeatherEntity.ozone
(self)
Return the ozone level.
Return the ozone level.
def ozone(self): """Return the ozone level.""" return None
[ "def", "ozone", "(", "self", ")", ":", "return", "None" ]
[ 111, 4 ]
[ 113, 19 ]
python
en
['en', 'zu', 'en']
True
WeatherEntity.attribution
(self)
Return the attribution.
Return the attribution.
def attribution(self): """Return the attribution.""" return None
[ "def", "attribution", "(", "self", ")", ":", "return", "None" ]
[ 116, 4 ]
[ 118, 19 ]
python
en
['en', 'ja', 'en']
True
WeatherEntity.visibility
(self)
Return the visibility.
Return the visibility.
def visibility(self): """Return the visibility.""" return None
[ "def", "visibility", "(", "self", ")", ":", "return", "None" ]
[ 121, 4 ]
[ 123, 19 ]
python
en
['en', 'en', 'en']
True
WeatherEntity.forecast
(self)
Return the forecast.
Return the forecast.
def forecast(self): """Return the forecast.""" return None
[ "def", "forecast", "(", "self", ")", ":", "return", "None" ]
[ 126, 4 ]
[ 128, 19 ]
python
en
['en', 'no', 'en']
True
WeatherEntity.precision
(self)
Return the precision of the temperature value.
Return the precision of the temperature value.
def precision(self): """Return the precision of the temperature value.""" return ( PRECISION_TENTHS if self.temperature_unit == TEMP_CELSIUS else PRECISION_WHOLE )
[ "def", "precision", "(", "self", ")", ":", "return", "(", "PRECISION_TENTHS", "if", "self", ".", "temperature_unit", "==", "TEMP_CELSIUS", "else", "PRECISION_WHOLE", ")" ]
[ 131, 4 ]
[ 137, 9 ]
python
en
['en', 'it', 'en']
True
WeatherEntity.state_attributes
(self)
Return the state attributes.
Return the state attributes.
def state_attributes(self): """Return the state attributes.""" data = {} if self.temperature is not None: data[ATTR_WEATHER_TEMPERATURE] = show_temp( self.hass, self.temperature, self.temperature_unit, self.precision ) humidity = self.humidity ...
[ "def", "state_attributes", "(", "self", ")", ":", "data", "=", "{", "}", "if", "self", ".", "temperature", "is", "not", "None", ":", "data", "[", "ATTR_WEATHER_TEMPERATURE", "]", "=", "show_temp", "(", "self", ".", "hass", ",", "self", ".", "temperature"...
[ 140, 4 ]
[ 197, 19 ]
python
en
['en', 'en', 'en']
True
WeatherEntity.state
(self)
Return the current state.
Return the current state.
def state(self): """Return the current state.""" return self.condition
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "condition" ]
[ 200, 4 ]
[ 202, 29 ]
python
en
['en', 'en', 'en']
True
WeatherEntity.condition
(self)
Return the current condition.
Return the current condition.
def condition(self): """Return the current condition.""" raise NotImplementedError()
[ "def", "condition", "(", "self", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 205, 4 ]
[ 207, 35 ]
python
en
['en', 'en', 'en']
True
GensimDoc2Vectorizer.__init__
(self, size=5, min_count=3)
gensim_doc2vec_vectorize
gensim_doc2vec_vectorize
def __init__(self, size=5, min_count=3): """ gensim_doc2vec_vectorize """ self.size = size self.min_count = min_count
[ "def", "__init__", "(", "self", ",", "size", "=", "5", ",", "min_count", "=", "3", ")", ":", "self", ".", "size", "=", "size", "self", ".", "min_count", "=", "min_count" ]
[ 67, 4 ]
[ 72, 34 ]
python
en
['en', 'error', 'th']
False
GensimTfidfVectorizer.__init__
(self, nfeatures=100, tofull=False)
Pass in a directory that holds the lexicon in corpus.dict and the TFIDF model in tfidf.model (for now). Set tofull = True if the next thing is a Scikit-Learn estimator otherwise keep False if the next thing is a Gensim model.
Pass in a directory that holds the lexicon in corpus.dict and the TFIDF model in tfidf.model (for now).
def __init__(self, nfeatures=100, tofull=False): """ Pass in a directory that holds the lexicon in corpus.dict and the TFIDF model in tfidf.model (for now). Set tofull = True if the next thing is a Scikit-Learn estimator otherwise keep False if the next thing is a Gensim model. ...
[ "def", "__init__", "(", "self", ",", "nfeatures", "=", "100", ",", "tofull", "=", "False", ")", ":", "self", ".", "_lexicon_path", "=", "\"lexigram.dict\"", "self", ".", "_tfidf_path", "=", "\"tfidf.model\"", "self", ".", "nfeatures", "=", "nfeatures", "self...
[ 87, 4 ]
[ 102, 19 ]
python
en
['en', 'error', 'th']
False
KeyphraseExtractor.normalize
(self, sent)
Removes punctuation from a tokenized/tagged sentence and lowercases words.
Removes punctuation from a tokenized/tagged sentence and lowercases words.
def normalize(self, sent): """ Removes punctuation from a tokenized/tagged sentence and lowercases words. """ is_punct = lambda word: all(unicat(c).startswith('P') for c in word) sent = filter(lambda t: not is_punct(t[0]), sent) sent = map(lambda t: (t[0].lower(),...
[ "def", "normalize", "(", "self", ",", "sent", ")", ":", "is_punct", "=", "lambda", "word", ":", "all", "(", "unicat", "(", "c", ")", ".", "startswith", "(", "'P'", ")", "for", "c", "in", "word", ")", "sent", "=", "filter", "(", "lambda", "t", ":"...
[ 152, 4 ]
[ 160, 25 ]
python
en
['en', 'error', 'th']
False
KeyphraseExtractor.extract_candidate_phrases
(self, sents)
For a document, parse sentences using our chunker created by our grammar, converting the parse tree into a tagged sequence. Extract phrases, rejoin with a space, and yield the document represented as a list of it's keyphrases.
For a document, parse sentences using our chunker created by our grammar, converting the parse tree into a tagged sequence. Extract phrases, rejoin with a space, and yield the document represented as a list of it's keyphrases.
def extract_candidate_phrases(self, sents): """ For a document, parse sentences using our chunker created by our grammar, converting the parse tree into a tagged sequence. Extract phrases, rejoin with a space, and yield the document represented as a list of it's keyphrases. ...
[ "def", "extract_candidate_phrases", "(", "self", ",", "sents", ")", ":", "for", "sent", "in", "sents", ":", "sent", "=", "self", ".", "normalize", "(", "sent", ")", "if", "not", "sent", ":", "continue", "chunks", "=", "tree2conlltags", "(", "self", ".", ...
[ 162, 4 ]
[ 180, 28 ]
python
en
['en', 'error', 'th']
False
KeyphraseExtractor.get_lexicon
(self, keydocs)
Build a lexicon of size nfeatures
Build a lexicon of size nfeatures
def get_lexicon(self, keydocs): """ Build a lexicon of size nfeatures """ keyphrases = [keyphrase for doc in keydocs for keyphrase in doc] fdist = FreqDist(keyphrases) counts = fdist.most_common(self.nfeatures) lexicon = [phrase for phrase, count in counts] ...
[ "def", "get_lexicon", "(", "self", ",", "keydocs", ")", ":", "keyphrases", "=", "[", "keyphrase", "for", "doc", "in", "keydocs", "for", "keyphrase", "in", "doc", "]", "fdist", "=", "FreqDist", "(", "keyphrases", ")", "counts", "=", "fdist", ".", "most_co...
[ 185, 4 ]
[ 193, 68 ]
python
en
['en', 'error', 'th']
False
KeyphraseExtractor.clip
(self, keydoc, lexicon)
Remove keyphrases from documents that aren't in the lexicon
Remove keyphrases from documents that aren't in the lexicon
def clip(self, keydoc, lexicon): """ Remove keyphrases from documents that aren't in the lexicon """ return [lexicon[keyphrase] for keyphrase in keydoc if keyphrase in lexicon.keys()]
[ "def", "clip", "(", "self", ",", "keydoc", ",", "lexicon", ")", ":", "return", "[", "lexicon", "[", "keyphrase", "]", "for", "keyphrase", "in", "keydoc", "if", "keyphrase", "in", "lexicon", ".", "keys", "(", ")", "]" ]
[ 195, 4 ]
[ 200, 47 ]
python
en
['en', 'error', 'th']
False
ChildNetBuilder.__call__
(self, in_chs, model_block_args)
Build the blocks Args: in_chs: Number of input-channels passed to first block model_block_args: A list of lists, outer list defines stages, inner list contains strings defining block configuration(s) Return: List of block stacks (each stack wrapped i...
Build the blocks Args: in_chs: Number of input-channels passed to first block model_block_args: A list of lists, outer list defines stages, inner list contains strings defining block configuration(s) Return: List of block stacks (each stack wrapped i...
def __call__(self, in_chs, model_block_args): """ Build the blocks Args: in_chs: Number of input-channels passed to first block model_block_args: A list of lists, outer list defines stages, inner list contains strings defining block configuration(s) Return...
[ "def", "__call__", "(", "self", ",", "in_chs", ",", "model_block_args", ")", ":", "if", "self", ".", "verbose", ":", "self", ".", "logger", ".", "info", "(", "'Building model trunk with %d stages...'", "%", "len", "(", "model_block_args", ")", ")", "self", "...
[ 86, 4 ]
[ 180, 21 ]
python
en
['en', 'la', 'en']
True
ConfigEntrySmappeeApi.__init__
( self, hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation, )
Initialize Smappee Auth.
Initialize Smappee Auth.
def __init__( self, hass: core.HomeAssistant, config_entry: config_entries.ConfigEntry, implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation, ): """Initialize Smappee Auth.""" self.hass = hass self.config_entry = config_entry self.sess...
[ "def", "__init__", "(", "self", ",", "hass", ":", "core", ".", "HomeAssistant", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ",", "implementation", ":", "config_entry_oauth2_flow", ".", "AbstractOAuth2Implementation", ",", ")", ":", "self", ".",...
[ 15, 4 ]
[ 38, 9 ]
python
en
['en', 'en', 'it']
True
ConfigEntrySmappeeApi.refresh_tokens
(self)
Refresh and return new Smappee tokens using Home Assistant OAuth2 session.
Refresh and return new Smappee tokens using Home Assistant OAuth2 session.
def refresh_tokens(self) -> dict: """Refresh and return new Smappee tokens using Home Assistant OAuth2 session.""" run_coroutine_threadsafe( self.session.async_ensure_token_valid(), self.hass.loop ).result() return self.session.token
[ "def", "refresh_tokens", "(", "self", ")", "->", "dict", ":", "run_coroutine_threadsafe", "(", "self", ".", "session", ".", "async_ensure_token_valid", "(", ")", ",", "self", ".", "hass", ".", "loop", ")", ".", "result", "(", ")", "return", "self", ".", ...
[ 40, 4 ]
[ 46, 33 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities )
Setups an entity from a config entry (UI config flow).
Setups an entity from a config entry (UI config flow).
async def async_setup_entry( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities ) -> None: """Setups an entity from a config entry (UI config flow).""" entity = TwinklyLight(config_entry, hass) async_add_entities([entity], update_before_add=True)
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "entity", "=", "TwinklyLight", "(", "config_entry", ",", "hass", ")", "async_add_entities", "(",...
[ 31, 0 ]
[ 38, 56 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.__init__
( self, conf: ConfigEntry, hass: HomeAssistantType, )
Initialize a TwinklyLight entity.
Initialize a TwinklyLight entity.
def __init__( self, conf: ConfigEntry, hass: HomeAssistantType, ): """Initialize a TwinklyLight entity.""" self._id = conf.data[CONF_ENTRY_ID] self._hass = hass self._conf = conf # Those are saved in the config entry in order to have meaningful values...
[ "def", "__init__", "(", "self", ",", "conf", ":", "ConfigEntry", ",", "hass", ":", "HomeAssistantType", ",", ")", ":", "self", ".", "_id", "=", "conf", ".", "data", "[", "CONF_ENTRY_ID", "]", "self", ".", "_hass", "=", "hass", "self", ".", "_conf", "...
[ 44, 4 ]
[ 68, 57 ]
python
en
['fr', 'en', 'en']
True
TwinklyLight.supported_features
(self)
Get the features supported by this entity.
Get the features supported by this entity.
def supported_features(self): """Get the features supported by this entity.""" return SUPPORT_BRIGHTNESS
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_BRIGHTNESS" ]
[ 71, 4 ]
[ 73, 33 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.should_poll
(self)
Get a boolean which indicates if this entity should be polled.
Get a boolean which indicates if this entity should be polled.
def should_poll(self) -> bool: """Get a boolean which indicates if this entity should be polled.""" return True
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "True" ]
[ 76, 4 ]
[ 78, 19 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.available
(self)
Get a boolean which indicates if this entity is currently available.
Get a boolean which indicates if this entity is currently available.
def available(self) -> bool: """Get a boolean which indicates if this entity is currently available.""" return self._is_available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_is_available" ]
[ 81, 4 ]
[ 83, 33 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.unique_id
(self)
Id of the device.
Id of the device.
def unique_id(self) -> Optional[str]: """Id of the device.""" return self._id
[ "def", "unique_id", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "self", ".", "_id" ]
[ 86, 4 ]
[ 88, 23 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.name
(self)
Name of the device.
Name of the device.
def name(self) -> str: """Name of the device.""" return self.__name if self.__name else "Twinkly light"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "__name", "if", "self", ".", "__name", "else", "\"Twinkly light\"" ]
[ 91, 4 ]
[ 93, 62 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.model
(self)
Name of the device.
Name of the device.
def model(self) -> str: """Name of the device.""" return self.__model
[ "def", "model", "(", "self", ")", "->", "str", ":", "return", "self", ".", "__model" ]
[ 96, 4 ]
[ 98, 27 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.icon
(self)
Icon of the device.
Icon of the device.
def icon(self) -> str: """Icon of the device.""" return "mdi:string-lights"
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "\"mdi:string-lights\"" ]
[ 101, 4 ]
[ 103, 34 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.device_info
(self)
Get device specific attributes.
Get device specific attributes.
def device_info(self) -> Optional[Dict[str, Any]]: """Get device specific attributes.""" return ( { "identifiers": {(DOMAIN, self._id)}, "name": self.name, "manufacturer": "LEDWORKS", "model": self.model, } ...
[ "def", "device_info", "(", "self", ")", "->", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "(", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_id", ")", "}", ",", "\"name\"", ":", "self", ".", "n...
[ 106, 4 ]
[ 117, 9 ]
python
en
['fr', 'en', 'en']
True
TwinklyLight.is_on
(self)
Return true if light is on.
Return true if light is on.
def is_on(self) -> bool: """Return true if light is on.""" return self._is_on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_is_on" ]
[ 120, 4 ]
[ 122, 26 ]
python
en
['en', 'et', 'en']
True
TwinklyLight.brightness
(self)
Return the brightness of the light.
Return the brightness of the light.
def brightness(self) -> Optional[int]: """Return the brightness of the light.""" return self._brightness
[ "def", "brightness", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "return", "self", ".", "_brightness" ]
[ 125, 4 ]
[ 127, 31 ]
python
en
['en', 'no', 'en']
True
TwinklyLight.state_attributes
(self)
Return device specific state attributes.
Return device specific state attributes.
def state_attributes(self) -> dict: """Return device specific state attributes.""" attributes = self._attributes # Make sure to update any normalized property attributes[ATTR_HOST] = self._client.host attributes[ATTR_BRIGHTNESS] = self._brightness return attributes
[ "def", "state_attributes", "(", "self", ")", "->", "dict", ":", "attributes", "=", "self", ".", "_attributes", "# Make sure to update any normalized property", "attributes", "[", "ATTR_HOST", "]", "=", "self", ".", "_client", ".", "host", "attributes", "[", "ATTR_...
[ 130, 4 ]
[ 139, 25 ]
python
en
['fr', 'en', 'en']
True
TwinklyLight.async_turn_on
(self, **kwargs)
Turn device on.
Turn device on.
async def async_turn_on(self, **kwargs) -> None: """Turn device on.""" if ATTR_BRIGHTNESS in kwargs: brightness = int(int(kwargs[ATTR_BRIGHTNESS]) / 2.55) # If brightness is 0, the twinkly will only "disable" the brightness, # which means that it will be 100%. ...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "ATTR_BRIGHTNESS", "in", "kwargs", ":", "brightness", "=", "int", "(", "int", "(", "kwargs", "[", "ATTR_BRIGHTNESS", "]", ")", "/", "2.55", ")", "# If ...
[ 141, 4 ]
[ 154, 42 ]
python
en
['es', 'en', 'en']
True
TwinklyLight.async_turn_off
(self, **kwargs)
Turn device off.
Turn device off.
async def async_turn_off(self, **kwargs) -> None: """Turn device off.""" await self._client.set_is_on(False)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "_client", ".", "set_is_on", "(", "False", ")" ]
[ 156, 4 ]
[ 158, 43 ]
python
en
['en', 'en', 'en']
True
TwinklyLight.async_update
(self)
Asynchronously updates the device properties.
Asynchronously updates the device properties.
async def async_update(self) -> None: """Asynchronously updates the device properties.""" _LOGGER.info("Updating '%s'", self._client.host) try: self._is_on = await self._client.get_is_on() self._brightness = ( int(round((await self._client.get_brightness...
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "_LOGGER", ".", "info", "(", "\"Updating '%s'\"", ",", "self", ".", "_client", ".", "host", ")", "try", ":", "self", ".", "_is_on", "=", "await", "self", ".", "_client", ".", "get_is_...
[ 160, 4 ]
[ 215, 38 ]
python
en
['en', 'en', 'en']
True
get_scanner
(hass, config)
Return a Tado scanner.
Return a Tado scanner.
def get_scanner(hass, config): """Return a Tado scanner.""" scanner = TadoDeviceScanner(hass, config[DOMAIN]) return scanner if scanner.success_init else None
[ "def", "get_scanner", "(", "hass", ",", "config", ")", ":", "scanner", "=", "TadoDeviceScanner", "(", "hass", ",", "config", "[", "DOMAIN", "]", ")", "return", "scanner", "if", "scanner", ".", "success_init", "else", "None" ]
[ 35, 0 ]
[ 38, 52 ]
python
cy
['pt', 'cy', 'en']
False
TadoDeviceScanner.__init__
(self, hass, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, hass, config): """Initialize the scanner.""" self.hass = hass self.last_results = [] self.username = config[CONF_USERNAME] self.password = config[CONF_PASSWORD] # The Tado device tracker can work with or without a home_id self.home_id = config...
[ "def", "__init__", "(", "self", ",", "hass", ",", "config", ")", ":", "self", ".", "hass", "=", "hass", "self", ".", "last_results", "=", "[", "]", "self", ".", "username", "=", "config", "[", "CONF_USERNAME", "]", "self", ".", "password", "=", "conf...
[ 47, 4 ]
[ 73, 43 ]
python
en
['en', 'en', 'en']
True
TadoDeviceScanner.async_scan_devices
(self)
Scan for devices and return a list containing found device ids.
Scan for devices and return a list containing found device ids.
async def async_scan_devices(self): """Scan for devices and return a list containing found device ids.""" await self._async_update_info() return [device.mac for device in self.last_results]
[ "async", "def", "async_scan_devices", "(", "self", ")", ":", "await", "self", ".", "_async_update_info", "(", ")", "return", "[", "device", ".", "mac", "for", "device", "in", "self", ".", "last_results", "]" ]
[ 75, 4 ]
[ 78, 59 ]
python
en
['en', 'en', 'en']
True
TadoDeviceScanner.async_get_device_name
(self, device)
Return the name of the given device or None if we don't know.
Return the name of the given device or None if we don't know.
async def async_get_device_name(self, device): """Return the name of the given device or None if we don't know.""" filter_named = [ result.name for result in self.last_results if result.mac == device ] if filter_named: return filter_named[0] return None
[ "async", "def", "async_get_device_name", "(", "self", ",", "device", ")", ":", "filter_named", "=", "[", "result", ".", "name", "for", "result", "in", "self", ".", "last_results", "if", "result", ".", "mac", "==", "device", "]", "if", "filter_named", ":", ...
[ 80, 4 ]
[ 88, 19 ]
python
en
['en', 'en', 'en']
True
TadoDeviceScanner._async_update_info
(self)
Query Tado for device marked as at home. Returns boolean if scanning successful.
Query Tado for device marked as at home.
async def _async_update_info(self): """ Query Tado for device marked as at home. Returns boolean if scanning successful. """ _LOGGER.debug("Requesting Tado") if self.websession is None: self.websession = async_create_clientsession( self.hass,...
[ "async", "def", "_async_update_info", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Requesting Tado\"", ")", "if", "self", ".", "websession", "is", "None", ":", "self", ".", "websession", "=", "async_create_clientsession", "(", "self", ".", "hass", ...
[ 91, 4 ]
[ 146, 19 ]
python
en
['en', 'error', 'th']
False
data_from_dumps
(dumps_folder: str)
Collect data from dump folder which contains following files: ports.csv, vessels.csv, routes.csv, order_proportion.csv, global_order_proportion.txt, misc.yml, stops.bin Args: dumps_folder(str): Folder contains dumped files. Returns: CimDataContainer: Data container used to provide cim data...
Collect data from dump folder which contains following files: ports.csv, vessels.csv, routes.csv, order_proportion.csv, global_order_proportion.txt, misc.yml, stops.bin
def data_from_dumps(dumps_folder: str) -> CimDataContainer: """Collect data from dump folder which contains following files: ports.csv, vessels.csv, routes.csv, order_proportion.csv, global_order_proportion.txt, misc.yml, stops.bin Args: dumps_folder(str): Folder contains dumped files. Returns...
[ "def", "data_from_dumps", "(", "dumps_folder", ":", "str", ")", "->", "CimDataContainer", ":", "assert", "os", ".", "path", ".", "exists", "(", "dumps_folder", ")", "data_collection", "=", "load_from_folder", "(", "dumps_folder", ")", "return", "CimDataContainer",...
[ 40, 0 ]
[ 54, 44 ]
python
en
['en', 'en', 'en']
True
data_from_generator
(config_path: str, max_tick: int, start_tick: int = 0)
Collect data from data generator with configurations. Args: config_path(str): Path of configuration file (yaml). max_tick (int): Max tick to generate data. start_tick(int): Start tick to generate data. Returns: CimDataContainer: Data container used to provide cim data related i...
Collect data from data generator with configurations.
def data_from_generator(config_path: str, max_tick: int, start_tick: int = 0) -> CimDataContainer: """Collect data from data generator with configurations. Args: config_path(str): Path of configuration file (yaml). max_tick (int): Max tick to generate data. start_tick(int): Start tick t...
[ "def", "data_from_generator", "(", "config_path", ":", "str", ",", "max_tick", ":", "int", ",", "start_tick", ":", "int", "=", "0", ")", "->", "CimDataContainer", ":", "edg", "=", "CimDataGenerator", "(", ")", "data_collection", "=", "edg", ".", "gen_data", ...
[ 57, 0 ]
[ 72, 44 ]
python
en
['en', 'en', 'en']
True
CimDataContainerWrapper.reset
(self)
Reset data container internal state
Reset data container internal state
def reset(self): """Reset data container internal state""" self._data_cntr.reset()
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_data_cntr", ".", "reset", "(", ")" ]
[ 32, 4 ]
[ 34, 31 ]
python
en
['en', 'en', 'en']
True
LmSeqsDataset.check
(self)
Some sanity checks
Some sanity checks
def check(self): """ Some sanity checks """ assert len(self.token_ids) == len(self.lengths) assert all(self.lengths[i] == len(self.token_ids[i]) for i in range(len(self.lengths)))
[ "def", "check", "(", "self", ")", ":", "assert", "len", "(", "self", ".", "token_ids", ")", "==", "len", "(", "self", ".", "lengths", ")", "assert", "all", "(", "self", ".", "lengths", "[", "i", "]", "==", "len", "(", "self", ".", "token_ids", "[...
[ 54, 4 ]
[ 59, 95 ]
python
en
['en', 'error', 'th']
False
LmSeqsDataset.remove_long_sequences
(self)
Sequences that are too long are split by chunk of max_model_input_size.
Sequences that are too long are split by chunk of max_model_input_size.
def remove_long_sequences(self): """ Sequences that are too long are split by chunk of max_model_input_size. """ max_len = self.params.max_model_input_size indices = self.lengths > max_len logger.info(f"Splitting {sum(indices)} too long sequences.") def divide_ch...
[ "def", "remove_long_sequences", "(", "self", ")", ":", "max_len", "=", "self", ".", "params", ".", "max_model_input_size", "indices", "=", "self", ".", "lengths", ">", "max_len", "logger", ".", "info", "(", "f\"Splitting {sum(indices)} too long sequences.\"", ")", ...
[ 61, 4 ]
[ 99, 44 ]
python
en
['en', 'error', 'th']
False
LmSeqsDataset.remove_empty_sequences
(self)
Too short sequences are simply removed. This could be tuned.
Too short sequences are simply removed. This could be tuned.
def remove_empty_sequences(self): """ Too short sequences are simply removed. This could be tuned. """ init_size = len(self) indices = self.lengths > 11 self.token_ids = self.token_ids[indices] self.lengths = self.lengths[indices] new_size = len(self) ...
[ "def", "remove_empty_sequences", "(", "self", ")", ":", "init_size", "=", "len", "(", "self", ")", "indices", "=", "self", ".", "lengths", ">", "11", "self", ".", "token_ids", "=", "self", ".", "token_ids", "[", "indices", "]", "self", ".", "lengths", ...
[ 101, 4 ]
[ 110, 88 ]
python
en
['en', 'error', 'th']
False
LmSeqsDataset.remove_unknown_sequences
(self)
Remove sequences with a (too) high level of unknown tokens.
Remove sequences with a (too) high level of unknown tokens.
def remove_unknown_sequences(self): """ Remove sequences with a (too) high level of unknown tokens. """ if "unk_token" not in self.params.special_tok_ids: return else: unk_token_id = self.params.special_tok_ids["unk_token"] init_size = len(self) ...
[ "def", "remove_unknown_sequences", "(", "self", ")", ":", "if", "\"unk_token\"", "not", "in", "self", ".", "params", ".", "special_tok_ids", ":", "return", "else", ":", "unk_token_id", "=", "self", ".", "params", ".", "special_tok_ids", "[", "\"unk_token\"", "...
[ 112, 4 ]
[ 126, 106 ]
python
en
['en', 'error', 'th']
False
LmSeqsDataset.print_statistics
(self)
Print some statistics on the corpus. Only the master process.
Print some statistics on the corpus. Only the master process.
def print_statistics(self): """ Print some statistics on the corpus. Only the master process. """ if not self.params.is_master: return logger.info(f"{len(self)} sequences")
[ "def", "print_statistics", "(", "self", ")", ":", "if", "not", "self", ".", "params", ".", "is_master", ":", "return", "logger", ".", "info", "(", "f\"{len(self)} sequences\"", ")" ]
[ 128, 4 ]
[ 134, 45 ]
python
en
['en', 'error', 'th']
False
LmSeqsDataset.batch_sequences
(self, batch)
Do the padding and transform into torch.tensor.
Do the padding and transform into torch.tensor.
def batch_sequences(self, batch): """ Do the padding and transform into torch.tensor. """ token_ids = [t[0] for t in batch] lengths = [t[1] for t in batch] assert len(token_ids) == len(lengths) # Max for paddings max_seq_len_ = max(lengths) # Pad...
[ "def", "batch_sequences", "(", "self", ",", "batch", ")", ":", "token_ids", "=", "[", "t", "[", "0", "]", "for", "t", "in", "batch", "]", "lengths", "=", "[", "t", "[", "1", "]", "for", "t", "in", "batch", "]", "assert", "len", "(", "token_ids", ...
[ 143, 4 ]
[ 165, 25 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the Supervisord platform.
Set up the Supervisord platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Supervisord platform.""" url = config.get(CONF_URL) try: supervisor_server = xmlrpc.client.ServerProxy(url) processes = supervisor_server.supervisor.getAllProcessInfo() except ConnectionRefusedError: ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "url", "=", "config", ".", "get", "(", "CONF_URL", ")", "try", ":", "supervisor_server", "=", "xmlrpc", ".", "client", ".", "ServerProxy...
[ 23, 0 ]
[ 35, 5 ]
python
en
['en', 'da', 'en']
True
SupervisorProcessSensor.__init__
(self, info, server)
Initialize the sensor.
Initialize the sensor.
def __init__(self, info, server): """Initialize the sensor.""" self._info = info self._server = server self._available = True
[ "def", "__init__", "(", "self", ",", "info", ",", "server", ")", ":", "self", ".", "_info", "=", "info", "self", ".", "_server", "=", "server", "self", ".", "_available", "=", "True" ]
[ 41, 4 ]
[ 45, 30 ]
python
en
['en', 'en', 'en']
True
SupervisorProcessSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._info.get("name")
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_info", ".", "get", "(", "\"name\"", ")" ]
[ 48, 4 ]
[ 50, 37 ]
python
en
['en', 'mi', 'en']
True
SupervisorProcessSensor.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._info.get("statename")
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_info", ".", "get", "(", "\"statename\"", ")" ]
[ 53, 4 ]
[ 55, 42 ]
python
en
['en', 'en', 'en']
True
SupervisorProcessSensor.available
(self)
Could the device be accessed during the last update call.
Could the device be accessed during the last update call.
def available(self): """Could the device be accessed during the last update call.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 58, 4 ]
[ 60, 30 ]
python
en
['en', 'en', 'en']
True
SupervisorProcessSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return { ATTR_DESCRIPTION: self._info.get("description"), ATTR_GROUP: self._info.get("group"), }
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_DESCRIPTION", ":", "self", ".", "_info", ".", "get", "(", "\"description\"", ")", ",", "ATTR_GROUP", ":", "self", ".", "_info", ".", "get", "(", "\"group\"", ")", ",", "}" ]
[ 63, 4 ]
[ 68, 9 ]
python
en
['en', 'en', 'en']
True
SupervisorProcessSensor.update
(self)
Update device state.
Update device state.
def update(self): """Update device state.""" try: self._info = self._server.supervisor.getProcessInfo( self._info.get("group") + ":" + self._info.get("name") ) self._available = True except ConnectionRefusedError: _LOGGER.warning("S...
[ "def", "update", "(", "self", ")", ":", "try", ":", "self", ".", "_info", "=", "self", ".", "_server", ".", "supervisor", ".", "getProcessInfo", "(", "self", ".", "_info", ".", "get", "(", "\"group\"", ")", "+", "\":\"", "+", "self", ".", "_info", ...
[ 70, 4 ]
[ 79, 35 ]
python
en
['fr', 'en', 'en']
True
DenseFilter.__init__
(self, in_features, growth_rate, filter_len=5, do=0.5, bottleneck=2, activation=nn.LeakyReLU, dim=-2)
This DenseNet-inspired filter block features in the TIDNet network from Kostas & Rudzicz 2020 (Thinker Invariance). 2D convolution is used, but with a kernel that only spans one of the dimensions. In TIDNet it is used to develop channel operations independently of temporal changes. Par...
This DenseNet-inspired filter block features in the TIDNet network from Kostas & Rudzicz 2020 (Thinker Invariance). 2D convolution is used, but with a kernel that only spans one of the dimensions. In TIDNet it is used to develop channel operations independently of temporal changes.
def __init__(self, in_features, growth_rate, filter_len=5, do=0.5, bottleneck=2, activation=nn.LeakyReLU, dim=-2): """ This DenseNet-inspired filter block features in the TIDNet network from Kostas & Rudzicz 2020 (Thinker Invariance). 2D convolution is used, but with a kernel that only spans one...
[ "def", "__init__", "(", "self", ",", "in_features", ",", "growth_rate", ",", "filter_len", "=", "5", ",", "do", "=", "0.5", ",", "bottleneck", "=", "2", ",", "activation", "=", "nn", ".", "LeakyReLU", ",", "dim", "=", "-", "2", ")", ":", "super", "...
[ 104, 4 ]
[ 134, 9 ]
python
en
['en', 'error', 'th']
False
DenseSpatialFilter.__init__
(self, channels, growth, depth, in_ch=1, bottleneck=4, dropout_rate=0.0, activation=nn.LeakyReLU, collapse=True)
This extends the :any:`DenseFilter` to specifically operate in channel space and collapse this dimension over the course of `depth` layers. Parameters ---------- channels growth depth in_ch bottleneck dropout_rate activation ...
This extends the :any:`DenseFilter` to specifically operate in channel space and collapse this dimension over the course of `depth` layers.
def __init__(self, channels, growth, depth, in_ch=1, bottleneck=4, dropout_rate=0.0, activation=nn.LeakyReLU, collapse=True): """ This extends the :any:`DenseFilter` to specifically operate in channel space and collapse this dimension over the course of `depth` layers. ...
[ "def", "__init__", "(", "self", ",", "channels", ",", "growth", ",", "depth", ",", "in_ch", "=", "1", ",", "bottleneck", "=", "4", ",", "dropout_rate", "=", "0.0", ",", "activation", "=", "nn", ".", "LeakyReLU", ",", "collapse", "=", "True", ")", ":"...
[ 141, 4 ]
[ 166, 95 ]
python
en
['en', 'error', 'th']
False
TemporalFilter.__init__
(self, channels, filters, depth, temp_len, dropout=0., activation=nn.LeakyReLU, residual='netwise')
This implements the dilated temporal-only spanning convolution from TIDNet. Parameters ---------- channels filters depth temp_len dropout activation residual
This implements the dilated temporal-only spanning convolution from TIDNet.
def __init__(self, channels, filters, depth, temp_len, dropout=0., activation=nn.LeakyReLU, residual='netwise'): """ This implements the dilated temporal-only spanning convolution from TIDNet. Parameters ---------- channels filters depth temp_len ...
[ "def", "__init__", "(", "self", ",", "channels", ",", "filters", ",", "depth", ",", "temp_len", ",", "dropout", "=", "0.", ",", "activation", "=", "nn", ".", "LeakyReLU", ",", "residual", "=", "'netwise'", ")", ":", "super", "(", ")", ".", "__init__", ...
[ 204, 4 ]
[ 236, 26 ]
python
en
['en', 'error', 'th']
False
validate_input
(hass: core.HomeAssistant, data)
Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user.
Validate the user input allows us to connect.
async def validate_input(hass: core.HomeAssistant, data): """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. """ device = DoorBird(data[CONF_HOST], data[CONF_USERNAME], data[CONF_PASSWORD]) try: status = await hass.async_add...
[ "async", "def", "validate_input", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "data", ")", ":", "device", "=", "DoorBird", "(", "data", "[", "CONF_HOST", "]", ",", "data", "[", "CONF_USERNAME", "]", ",", "data", "[", "CONF_PASSWORD", "]", ")", ...
[ 37, 0 ]
[ 59, 59 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.__init__
(self)
Initialize the DoorBird config flow.
Initialize the DoorBird config flow.
def __init__(self): """Initialize the DoorBird config flow.""" self.discovery_schema = {}
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "discovery_schema", "=", "{", "}" ]
[ 68, 4 ]
[ 70, 34 ]
python
en
['en', 'nl', 'en']
True
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: info, errors = await self._async_validate_or_error(user_input) if not errors: await self.async_set_unique_id(info["mac_addr"]) ...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "info", ",", "errors", "=", "await", "self", ".", "_async_validate_or_error", "(", "user_input"...
[ 72, 4 ]
[ 83, 84 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_zeroconf
(self, discovery_info)
Prepare configuration for a discovered doorbird device.
Prepare configuration for a discovered doorbird device.
async def async_step_zeroconf(self, discovery_info): """Prepare configuration for a discovered doorbird device.""" macaddress = discovery_info["properties"]["macaddress"] if macaddress[:6] != DOORBIRD_OUI: return self.async_abort(reason="not_doorbird_device") if is_link_loca...
[ "async", "def", "async_step_zeroconf", "(", "self", ",", "discovery_info", ")", ":", "macaddress", "=", "discovery_info", "[", "\"properties\"", "]", "[", "\"macaddress\"", "]", "if", "macaddress", "[", ":", "6", "]", "!=", "DOORBIRD_OUI", ":", "return", "self...
[ 85, 4 ]
[ 114, 43 ]
python
en
['en', 'en', 'en']
True