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
PhilipsTVMediaPlayer.media_channel
(self)
Get current channel if it's a channel.
Get current channel if it's a channel.
def media_channel(self): """Get current channel if it's a channel.""" if self.media_content_type == MEDIA_TYPE_CHANNEL: return self._channels.get(self._tv.channel_id) return None
[ "def", "media_channel", "(", "self", ")", ":", "if", "self", ".", "media_content_type", "==", "MEDIA_TYPE_CHANNEL", ":", "return", "self", ".", "_channels", ".", "get", "(", "self", ".", "_tv", ".", "channel_id", ")", "return", "None" ]
[ 235, 4 ]
[ 239, 19 ]
python
en
['en', 'en', 'en']
True
PhilipsTVMediaPlayer.media_title
(self)
Title of current playing media.
Title of current playing media.
def media_title(self): """Title of current playing media.""" if self.media_content_type == MEDIA_TYPE_CHANNEL: return self._channels.get(self._tv.channel_id) return self._sources.get(self._tv.source_id)
[ "def", "media_title", "(", "self", ")", ":", "if", "self", ".", "media_content_type", "==", "MEDIA_TYPE_CHANNEL", ":", "return", "self", ".", "_channels", ".", "get", "(", "self", ".", "_tv", ".", "channel_id", ")", "return", "self", ".", "_sources", ".", ...
[ 242, 4 ]
[ 246, 52 ]
python
en
['en', 'en', 'en']
True
PhilipsTVMediaPlayer.media_content_type
(self)
Return content type of playing media.
Return content type of playing media.
def media_content_type(self): """Return content type of playing media.""" if self._tv.source_id == "tv" or self._tv.source_id == "11": return MEDIA_TYPE_CHANNEL if self._tv.source_id is None and self._tv.channels: return MEDIA_TYPE_CHANNEL return None
[ "def", "media_content_type", "(", "self", ")", ":", "if", "self", ".", "_tv", ".", "source_id", "==", "\"tv\"", "or", "self", ".", "_tv", ".", "source_id", "==", "\"11\"", ":", "return", "MEDIA_TYPE_CHANNEL", "if", "self", ".", "_tv", ".", "source_id", "...
[ 249, 4 ]
[ 255, 19 ]
python
en
['en', 'en', 'en']
True
PhilipsTVMediaPlayer.media_content_id
(self)
Content type of current playing media.
Content type of current playing media.
def media_content_id(self): """Content type of current playing media.""" if self.media_content_type == MEDIA_TYPE_CHANNEL: return self._channels.get(self._tv.channel_id) return None
[ "def", "media_content_id", "(", "self", ")", ":", "if", "self", ".", "media_content_type", "==", "MEDIA_TYPE_CHANNEL", ":", "return", "self", ".", "_channels", ".", "get", "(", "self", ".", "_tv", ".", "channel_id", ")", "return", "None" ]
[ 258, 4 ]
[ 262, 19 ]
python
en
['en', 'en', 'en']
True
PhilipsTVMediaPlayer.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return {"channel_list": list(self._channels.values())}
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"channel_list\"", ":", "list", "(", "self", ".", "_channels", ".", "values", "(", ")", ")", "}" ]
[ 265, 4 ]
[ 267, 62 ]
python
en
['en', 'en', 'en']
True
PhilipsTVMediaPlayer.play_media
(self, media_type, media_id, **kwargs)
Play a piece of media.
Play a piece of media.
def play_media(self, media_type, media_id, **kwargs): """Play a piece of media.""" _LOGGER.debug("Call play media type <%s>, Id <%s>", media_type, media_id) if media_type == MEDIA_TYPE_CHANNEL: channel_id = _inverted(self._channels).get(media_id) if channel_id: ...
[ "def", "play_media", "(", "self", ",", "media_type", ",", "media_id", ",", "*", "*", "kwargs", ")", ":", "_LOGGER", ".", "debug", "(", "\"Call play media type <%s>, Id <%s>\"", ",", "media_type", ",", "media_id", ")", "if", "media_type", "==", "MEDIA_TYPE_CHANNE...
[ 269, 4 ]
[ 281, 68 ]
python
en
['en', 'en', 'en']
True
PhilipsTVMediaPlayer.async_browse_media
(self, media_content_type=None, media_content_id=None)
Implement the websocket media browsing helper.
Implement the websocket media browsing helper.
async def async_browse_media(self, media_content_type=None, media_content_id=None): """Implement the websocket media browsing helper.""" if media_content_id not in (None, ""): raise BrowseError( f"Media not found: {media_content_type} / {media_content_id}" ) ...
[ "async", "def", "async_browse_media", "(", "self", ",", "media_content_type", "=", "None", ",", "media_content_id", "=", "None", ")", ":", "if", "media_content_id", "not", "in", "(", "None", ",", "\"\"", ")", ":", "raise", "BrowseError", "(", "f\"Media not fou...
[ 283, 4 ]
[ 308, 9 ]
python
en
['en', 'af', 'en']
True
PhilipsTVMediaPlayer.update
(self)
Get the latest data and update device state.
Get the latest data and update device state.
def update(self): """Get the latest data and update device state.""" self._tv.update() self._sources = { srcid: source["name"] or f"Source {srcid}" for srcid, source in (self._tv.sources or {}).items() } self._channels = { chid: channel["name...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_tv", ".", "update", "(", ")", "self", ".", "_sources", "=", "{", "srcid", ":", "source", "[", "\"name\"", "]", "or", "f\"Source {srcid}\"", "for", "srcid", ",", "source", "in", "(", "self", ".", ...
[ 310, 4 ]
[ 321, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable )
Set up RainMachine sensors based on a config entry.
Set up RainMachine sensors based on a config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable ) -> None: """Set up RainMachine sensors based on a config entry.""" controller = hass.data[DOMAIN][DATA_CONTROLLER][entry.entry_id] coordinators = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id] ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", ")", "->", "None", ":", "controller", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_CONTROLLER", ...
[ 70, 0 ]
[ 107, 5 ]
python
en
['en', 'en', 'en']
True
RainMachineSensor.__init__
( self, coordinator: DataUpdateCoordinator, controller: Controller, sensor_type: str, name: str, icon: str, unit: str, device_class: str, enabled_by_default: bool, )
Initialize.
Initialize.
def __init__( self, coordinator: DataUpdateCoordinator, controller: Controller, sensor_type: str, name: str, icon: str, unit: str, device_class: str, enabled_by_default: bool, ) -> None: """Initialize.""" super().__init__(coordi...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "DataUpdateCoordinator", ",", "controller", ":", "Controller", ",", "sensor_type", ":", "str", ",", "name", ":", "str", ",", "icon", ":", "str", ",", "unit", ":", "str", ",", "device_class", ":", "...
[ 113, 4 ]
[ 132, 25 ]
python
en
['en', 'en', 'it']
False
RainMachineSensor.entity_registry_enabled_default
(self)
Determine whether an entity is enabled by default.
Determine whether an entity is enabled by default.
def entity_registry_enabled_default(self) -> bool: """Determine whether an entity is enabled by default.""" return self._enabled_by_default
[ "def", "entity_registry_enabled_default", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_enabled_by_default" ]
[ 135, 4 ]
[ 137, 39 ]
python
en
['en', 'en', 'en']
True
RainMachineSensor.icon
(self)
Return the icon.
Return the icon.
def icon(self) -> str: """Return the icon.""" return self._icon
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_icon" ]
[ 140, 4 ]
[ 142, 25 ]
python
en
['en', 'sr', 'en']
True
RainMachineSensor.state
(self)
Return the name of the entity.
Return the name of the entity.
def state(self) -> str: """Return the name of the entity.""" return self._state
[ "def", "state", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_state" ]
[ 145, 4 ]
[ 147, 26 ]
python
en
['en', 'en', 'en']
True
RainMachineSensor.unique_id
(self)
Return a unique, Home Assistant friendly identifier for this entity.
Return a unique, Home Assistant friendly identifier for this entity.
def unique_id(self) -> str: """Return a unique, Home Assistant friendly identifier for this entity.""" return f"{self._unique_id}_{self._sensor_type}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._unique_id}_{self._sensor_type}\"" ]
[ 150, 4 ]
[ 152, 55 ]
python
en
['en', 'en', 'en']
True
RainMachineSensor.unit_of_measurement
(self)
Return the unit the value is expressed in.
Return the unit the value is expressed in.
def unit_of_measurement(self) -> str: """Return the unit the value is expressed in.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unit" ]
[ 155, 4 ]
[ 157, 25 ]
python
en
['en', 'en', 'en']
True
ProvisionSettingsSensor.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" if self._sensor_type == TYPE_FLOW_SENSOR_CLICK_M3: self._state = self.coordinator.data["system"].get( "flowSensorClicksPerCubicMeter" ) elif self._sensor_type == TYPE_FLOW_SENSOR_CONSUMED_L...
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_sensor_type", "==", "TYPE_FLOW_SENSOR_CLICK_M3", ":", "self", ".", "_state", "=", "self", ".", "coordinator", ".", "data", "[", "\"system\"", "]", ".", "get", "(", ...
[ 164, 4 ]
[ 185, 13 ]
python
en
['en', 'en', 'en']
True
UniversalRestrictionsSensor.update_from_latest_data
(self)
Update the state.
Update the state.
def update_from_latest_data(self) -> None: """Update the state.""" if self._sensor_type == TYPE_FREEZE_TEMP: self._state = self.coordinator.data["freezeProtectTemp"]
[ "def", "update_from_latest_data", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_sensor_type", "==", "TYPE_FREEZE_TEMP", ":", "self", ".", "_state", "=", "self", ".", "coordinator", ".", "data", "[", "\"freezeProtectTemp\"", "]" ]
[ 192, 4 ]
[ 195, 68 ]
python
en
['en', 'en', 'en']
True
validate_entity_config
(values)
Validate config entry for CONF_ENTITY.
Validate config entry for CONF_ENTITY.
def validate_entity_config(values): """Validate config entry for CONF_ENTITY.""" if not isinstance(values, dict): raise vol.Invalid("expected a dictionary") entities = {} for entity_id, config in values.items(): entity = cv.entity_id(entity_id) domain, _ = split_entity_id(entity...
[ "def", "validate_entity_config", "(", "values", ")", ":", "if", "not", "isinstance", "(", "values", ",", "dict", ")", ":", "raise", "vol", ".", "Invalid", "(", "\"expected a dictionary\"", ")", "entities", "=", "{", "}", "for", "entity_id", ",", "config", ...
[ 223, 0 ]
[ 266, 19 ]
python
en
['en', 'en', 'en']
True
get_media_player_features
(state)
Determine features for media players.
Determine features for media players.
def get_media_player_features(state): """Determine features for media players.""" features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) supported_modes = [] if features & ( media_player.const.SUPPORT_TURN_ON | media_player.const.SUPPORT_TURN_OFF ): supported_modes.append(FEATU...
[ "def", "get_media_player_features", "(", "state", ")", ":", "features", "=", "state", ".", "attributes", ".", "get", "(", "ATTR_SUPPORTED_FEATURES", ",", "0", ")", "supported_modes", "=", "[", "]", "if", "features", "&", "(", "media_player", ".", "const", "....
[ 269, 0 ]
[ 284, 26 ]
python
en
['en', 'en', 'en']
True
validate_media_player_features
(state, feature_list)
Validate features for media players.
Validate features for media players.
def validate_media_player_features(state, feature_list): """Validate features for media players.""" supported_modes = get_media_player_features(state) if not supported_modes: _LOGGER.error("%s does not support any media_player features", state.entity_id) return False if not feature_lis...
[ "def", "validate_media_player_features", "(", "state", ",", "feature_list", ")", ":", "supported_modes", "=", "get_media_player_features", "(", "state", ")", "if", "not", "supported_modes", ":", "_LOGGER", ".", "error", "(", "\"%s does not support any media_player feature...
[ 287, 0 ]
[ 309, 15 ]
python
en
['en', 'en', 'en']
True
show_setup_message
(hass, entry_id, bridge_name, pincode, uri)
Display persistent notification with setup information.
Display persistent notification with setup information.
def show_setup_message(hass, entry_id, bridge_name, pincode, uri): """Display persistent notification with setup information.""" pin = pincode.decode() _LOGGER.info("Pincode: %s", pin) buffer = io.BytesIO() url = pyqrcode.create(uri) url.svg(buffer, scale=5, module_color="#000", background="#FF...
[ "def", "show_setup_message", "(", "hass", ",", "entry_id", ",", "bridge_name", ",", "pincode", ",", "uri", ")", ":", "pin", "=", "pincode", ".", "decode", "(", ")", "_LOGGER", ".", "info", "(", "\"Pincode: %s\"", ",", "pin", ")", "buffer", "=", "io", "...
[ 362, 0 ]
[ 383, 5 ]
python
en
['en', 'en', 'en']
True
dismiss_setup_message
(hass, entry_id)
Dismiss persistent notification and remove QR code.
Dismiss persistent notification and remove QR code.
def dismiss_setup_message(hass, entry_id): """Dismiss persistent notification and remove QR code.""" hass.components.persistent_notification.dismiss(entry_id)
[ "def", "dismiss_setup_message", "(", "hass", ",", "entry_id", ")", ":", "hass", ".", "components", ".", "persistent_notification", ".", "dismiss", "(", "entry_id", ")" ]
[ 386, 0 ]
[ 388, 61 ]
python
en
['en', 'en', 'en']
True
convert_to_float
(state)
Return float of state, catch errors.
Return float of state, catch errors.
def convert_to_float(state): """Return float of state, catch errors.""" try: return float(state) except (ValueError, TypeError): return None
[ "def", "convert_to_float", "(", "state", ")", ":", "try", ":", "return", "float", "(", "state", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "None" ]
[ 391, 0 ]
[ 396, 19 ]
python
en
['en', 'en', 'en']
True
cleanup_name_for_homekit
(name)
Ensure the name of the device will not crash homekit.
Ensure the name of the device will not crash homekit.
def cleanup_name_for_homekit(name): """Ensure the name of the device will not crash homekit.""" # # This is not a security measure. # # UNICODE_EMOJI is also not allowed but that # likely isn't a problem return name.translate(HOMEKIT_CHAR_TRANSLATIONS)
[ "def", "cleanup_name_for_homekit", "(", "name", ")", ":", "#", "# This is not a security measure.", "#", "# UNICODE_EMOJI is also not allowed but that", "# likely isn't a problem", "return", "name", ".", "translate", "(", "HOMEKIT_CHAR_TRANSLATIONS", ")" ]
[ 399, 0 ]
[ 406, 52 ]
python
en
['en', 'en', 'en']
True
temperature_to_homekit
(temperature, unit)
Convert temperature to Celsius for HomeKit.
Convert temperature to Celsius for HomeKit.
def temperature_to_homekit(temperature, unit): """Convert temperature to Celsius for HomeKit.""" return round(temp_util.convert(temperature, unit, TEMP_CELSIUS), 1)
[ "def", "temperature_to_homekit", "(", "temperature", ",", "unit", ")", ":", "return", "round", "(", "temp_util", ".", "convert", "(", "temperature", ",", "unit", ",", "TEMP_CELSIUS", ")", ",", "1", ")" ]
[ 409, 0 ]
[ 411, 71 ]
python
en
['en', 'la', 'en']
True
temperature_to_states
(temperature, unit)
Convert temperature back from Celsius to Home Assistant unit.
Convert temperature back from Celsius to Home Assistant unit.
def temperature_to_states(temperature, unit): """Convert temperature back from Celsius to Home Assistant unit.""" return round(temp_util.convert(temperature, TEMP_CELSIUS, unit) * 2) / 2
[ "def", "temperature_to_states", "(", "temperature", ",", "unit", ")", ":", "return", "round", "(", "temp_util", ".", "convert", "(", "temperature", ",", "TEMP_CELSIUS", ",", "unit", ")", "*", "2", ")", "/", "2" ]
[ 414, 0 ]
[ 416, 76 ]
python
en
['en', 'en', 'en']
True
density_to_air_quality
(density)
Map PM2.5 density to HomeKit AirQuality level.
Map PM2.5 density to HomeKit AirQuality level.
def density_to_air_quality(density): """Map PM2.5 density to HomeKit AirQuality level.""" if density <= 35: return 1 if density <= 75: return 2 if density <= 115: return 3 if density <= 150: return 4 return 5
[ "def", "density_to_air_quality", "(", "density", ")", ":", "if", "density", "<=", "35", ":", "return", "1", "if", "density", "<=", "75", ":", "return", "2", "if", "density", "<=", "115", ":", "return", "3", "if", "density", "<=", "150", ":", "return", ...
[ 419, 0 ]
[ 429, 12 ]
python
en
['en', 'en', 'en']
True
get_persist_filename_for_entry_id
(entry_id: str)
Determine the filename of the homekit state file.
Determine the filename of the homekit state file.
def get_persist_filename_for_entry_id(entry_id: str): """Determine the filename of the homekit state file.""" return f"{DOMAIN}.{entry_id}.state"
[ "def", "get_persist_filename_for_entry_id", "(", "entry_id", ":", "str", ")", ":", "return", "f\"{DOMAIN}.{entry_id}.state\"" ]
[ 432, 0 ]
[ 434, 39 ]
python
en
['en', 'en', 'en']
True
get_aid_storage_filename_for_entry_id
(entry_id: str)
Determine the ilename of homekit aid storage file.
Determine the ilename of homekit aid storage file.
def get_aid_storage_filename_for_entry_id(entry_id: str): """Determine the ilename of homekit aid storage file.""" return f"{DOMAIN}.{entry_id}.aids"
[ "def", "get_aid_storage_filename_for_entry_id", "(", "entry_id", ":", "str", ")", ":", "return", "f\"{DOMAIN}.{entry_id}.aids\"" ]
[ 437, 0 ]
[ 439, 38 ]
python
en
['en', 'et', 'en']
True
get_persist_fullpath_for_entry_id
(hass: HomeAssistant, entry_id: str)
Determine the path to the homekit state file.
Determine the path to the homekit state file.
def get_persist_fullpath_for_entry_id(hass: HomeAssistant, entry_id: str): """Determine the path to the homekit state file.""" return hass.config.path(STORAGE_DIR, get_persist_filename_for_entry_id(entry_id))
[ "def", "get_persist_fullpath_for_entry_id", "(", "hass", ":", "HomeAssistant", ",", "entry_id", ":", "str", ")", ":", "return", "hass", ".", "config", ".", "path", "(", "STORAGE_DIR", ",", "get_persist_filename_for_entry_id", "(", "entry_id", ")", ")" ]
[ 442, 0 ]
[ 444, 85 ]
python
en
['en', 'en', 'en']
True
get_aid_storage_fullpath_for_entry_id
(hass: HomeAssistant, entry_id: str)
Determine the path to the homekit aid storage file.
Determine the path to the homekit aid storage file.
def get_aid_storage_fullpath_for_entry_id(hass: HomeAssistant, entry_id: str): """Determine the path to the homekit aid storage file.""" return hass.config.path( STORAGE_DIR, get_aid_storage_filename_for_entry_id(entry_id) )
[ "def", "get_aid_storage_fullpath_for_entry_id", "(", "hass", ":", "HomeAssistant", ",", "entry_id", ":", "str", ")", ":", "return", "hass", ".", "config", ".", "path", "(", "STORAGE_DIR", ",", "get_aid_storage_filename_for_entry_id", "(", "entry_id", ")", ")" ]
[ 447, 0 ]
[ 451, 5 ]
python
en
['en', 'en', 'en']
True
format_sw_version
(version)
Extract the version string in a format homekit can consume.
Extract the version string in a format homekit can consume.
def format_sw_version(version): """Extract the version string in a format homekit can consume.""" match = re.search(r"([0-9]+)(\.[0-9]+)?(\.[0-9]+)?", str(version).replace("-", ".")) if match: return match.group(0) return None
[ "def", "format_sw_version", "(", "version", ")", ":", "match", "=", "re", ".", "search", "(", "r\"([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?\"", ",", "str", "(", "version", ")", ".", "replace", "(", "\"-\"", ",", "\".\"", ")", ")", "if", "match", ":", "return", "mat...
[ 454, 0 ]
[ 459, 15 ]
python
en
['en', 'en', 'en']
True
migrate_filesystem_state_data_for_primary_imported_entry_id
( hass: HomeAssistant, entry_id: str )
Migrate the old paths to the storage directory.
Migrate the old paths to the storage directory.
def migrate_filesystem_state_data_for_primary_imported_entry_id( hass: HomeAssistant, entry_id: str ): """Migrate the old paths to the storage directory.""" legacy_persist_file_path = hass.config.path(HOMEKIT_FILE) if os.path.exists(legacy_persist_file_path): os.rename( legacy_persis...
[ "def", "migrate_filesystem_state_data_for_primary_imported_entry_id", "(", "hass", ":", "HomeAssistant", ",", "entry_id", ":", "str", ")", ":", "legacy_persist_file_path", "=", "hass", ".", "config", ".", "path", "(", "HOMEKIT_FILE", ")", "if", "os", ".", "path", ...
[ 462, 0 ]
[ 477, 9 ]
python
en
['en', 'en', 'en']
True
remove_state_files_for_entry_id
(hass: HomeAssistant, entry_id: str)
Remove the state files from disk.
Remove the state files from disk.
def remove_state_files_for_entry_id(hass: HomeAssistant, entry_id: str): """Remove the state files from disk.""" persist_file_path = get_persist_fullpath_for_entry_id(hass, entry_id) aid_storage_path = get_aid_storage_fullpath_for_entry_id(hass, entry_id) os.unlink(persist_file_path) if os.path.exis...
[ "def", "remove_state_files_for_entry_id", "(", "hass", ":", "HomeAssistant", ",", "entry_id", ":", "str", ")", ":", "persist_file_path", "=", "get_persist_fullpath_for_entry_id", "(", "hass", ",", "entry_id", ")", "aid_storage_path", "=", "get_aid_storage_fullpath_for_ent...
[ 480, 0 ]
[ 487, 15 ]
python
en
['en', 'en', 'en']
True
_get_test_socket
()
Create a socket to test binding ports.
Create a socket to test binding ports.
def _get_test_socket(): """Create a socket to test binding ports.""" test_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) test_socket.setblocking(False) test_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) return test_socket
[ "def", "_get_test_socket", "(", ")", ":", "test_socket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "test_socket", ".", "setblocking", "(", "False", ")", "test_socket", ".", "setsockopt", "(", "socket...
[ 490, 0 ]
[ 495, 22 ]
python
en
['en', 'en', 'en']
True
port_is_available
(port: int)
Check to see if a port is available.
Check to see if a port is available.
def port_is_available(port: int): """Check to see if a port is available.""" test_socket = _get_test_socket() try: test_socket.bind(("", port)) except OSError: return False return True
[ "def", "port_is_available", "(", "port", ":", "int", ")", ":", "test_socket", "=", "_get_test_socket", "(", ")", "try", ":", "test_socket", ".", "bind", "(", "(", "\"\"", ",", "port", ")", ")", "except", "OSError", ":", "return", "False", "return", "True...
[ 498, 0 ]
[ 506, 15 ]
python
en
['en', 'en', 'en']
True
find_next_available_port
(start_port: int)
Find the next available port starting with the given port.
Find the next available port starting with the given port.
def find_next_available_port(start_port: int): """Find the next available port starting with the given port.""" test_socket = _get_test_socket() for port in range(start_port, MAX_PORT): try: test_socket.bind(("", port)) return port except OSError: if port ...
[ "def", "find_next_available_port", "(", "start_port", ":", "int", ")", ":", "test_socket", "=", "_get_test_socket", "(", ")", "for", "port", "in", "range", "(", "start_port", ",", "MAX_PORT", ")", ":", "try", ":", "test_socket", ".", "bind", "(", "(", "\"\...
[ 509, 0 ]
[ 519, 20 ]
python
en
['en', 'en', 'en']
True
pid_is_alive
(pid)
Check to see if a process is alive.
Check to see if a process is alive.
def pid_is_alive(pid): """Check to see if a process is alive.""" try: os.kill(pid, 0) return True except OSError: pass return False
[ "def", "pid_is_alive", "(", "pid", ")", ":", "try", ":", "os", ".", "kill", "(", "pid", ",", "0", ")", "return", "True", "except", "OSError", ":", "pass", "return", "False" ]
[ 522, 0 ]
[ 529, 16 ]
python
en
['en', 'en', 'en']
True
HomeKitSpeedMapping.__init__
(self, speed_list)
Initialize a new SpeedMapping object.
Initialize a new SpeedMapping object.
def __init__(self, speed_list): """Initialize a new SpeedMapping object.""" if speed_list[0] != fan.SPEED_OFF: _LOGGER.warning( "%s does not contain the speed setting " "%s as its first element. " "Assuming that %s is equivalent to 'off'", ...
[ "def", "__init__", "(", "self", ",", "speed_list", ")", ":", "if", "speed_list", "[", "0", "]", "!=", "fan", ".", "SPEED_OFF", ":", "_LOGGER", ".", "warning", "(", "\"%s does not contain the speed setting \"", "\"%s as its first element. \"", "\"Assuming that %s is eq...
[ 324, 4 ]
[ 345, 64 ]
python
en
['en', 'en', 'en']
True
HomeKitSpeedMapping.speed_to_homekit
(self, speed)
Map Home Assistant speed state to HomeKit speed.
Map Home Assistant speed state to HomeKit speed.
def speed_to_homekit(self, speed): """Map Home Assistant speed state to HomeKit speed.""" if speed is None: return None speed_range = self.speed_ranges[speed] return round(speed_range.target)
[ "def", "speed_to_homekit", "(", "self", ",", "speed", ")", ":", "if", "speed", "is", "None", ":", "return", "None", "speed_range", "=", "self", ".", "speed_ranges", "[", "speed", "]", "return", "round", "(", "speed_range", ".", "target", ")" ]
[ 347, 4 ]
[ 352, 40 ]
python
en
['en', 'en', 'en']
True
HomeKitSpeedMapping.speed_to_states
(self, speed)
Map HomeKit speed to Home Assistant speed state.
Map HomeKit speed to Home Assistant speed state.
def speed_to_states(self, speed): """Map HomeKit speed to Home Assistant speed state.""" for state, speed_range in reversed(self.speed_ranges.items()): if speed_range.start <= speed: return state return list(self.speed_ranges)[0]
[ "def", "speed_to_states", "(", "self", ",", "speed", ")", ":", "for", "state", ",", "speed_range", "in", "reversed", "(", "self", ".", "speed_ranges", ".", "items", "(", ")", ")", ":", "if", "speed_range", ".", "start", "<=", "speed", ":", "return", "s...
[ 354, 4 ]
[ 359, 41 ]
python
en
['en', 'en', 'en']
True
test_climate_thermostat_run
(hass)
Test a thermostat with the schedule running.
Test a thermostat with the schedule running.
async def test_climate_thermostat_run(hass): """Test a thermostat with the schedule running.""" mock_thermostat = _get_mock_thermostat_run() mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat) with patch( "homeassistant.components.nuheat.nuheat.NuHeat", return_value=mock_nuhe...
[ "async", "def", "test_climate_thermostat_run", "(", "hass", ")", ":", "mock_thermostat", "=", "_get_mock_thermostat_run", "(", ")", "mock_nuheat", "=", "_get_mock_nuheat", "(", "get_thermostat", "=", "mock_thermostat", ")", "with", "patch", "(", "\"homeassistant.compone...
[ 21, 0 ]
[ 49, 88 ]
python
en
['en', 'en', 'en']
True
test_climate_thermostat_schedule_hold_unavailable
(hass)
Test a thermostat with the schedule hold that is offline.
Test a thermostat with the schedule hold that is offline.
async def test_climate_thermostat_schedule_hold_unavailable(hass): """Test a thermostat with the schedule hold that is offline.""" mock_thermostat = _get_mock_thermostat_schedule_hold_unavailable() mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat) with patch( "homeassistant.compone...
[ "async", "def", "test_climate_thermostat_schedule_hold_unavailable", "(", "hass", ")", ":", "mock_thermostat", "=", "_get_mock_thermostat_schedule_hold_unavailable", "(", ")", "mock_nuheat", "=", "_get_mock_nuheat", "(", "get_thermostat", "=", "mock_thermostat", ")", "with", ...
[ 52, 0 ]
[ 77, 88 ]
python
en
['en', 'en', 'en']
True
test_climate_thermostat_schedule_hold_available
(hass)
Test a thermostat with the schedule hold that is online.
Test a thermostat with the schedule hold that is online.
async def test_climate_thermostat_schedule_hold_available(hass): """Test a thermostat with the schedule hold that is online.""" mock_thermostat = _get_mock_thermostat_schedule_hold_available() mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat) with patch( "homeassistant.components.n...
[ "async", "def", "test_climate_thermostat_schedule_hold_available", "(", "hass", ")", ":", "mock_thermostat", "=", "_get_mock_thermostat_schedule_hold_available", "(", ")", "mock_nuheat", "=", "_get_mock_nuheat", "(", "get_thermostat", "=", "mock_thermostat", ")", "with", "p...
[ 80, 0 ]
[ 109, 88 ]
python
en
['en', 'en', 'en']
True
test_climate_thermostat_schedule_temporary_hold
(hass)
Test a thermostat with the temporary schedule hold that is online.
Test a thermostat with the temporary schedule hold that is online.
async def test_climate_thermostat_schedule_temporary_hold(hass): """Test a thermostat with the temporary schedule hold that is online.""" mock_thermostat = _get_mock_thermostat_schedule_temporary_hold() mock_nuheat = _get_mock_nuheat(get_thermostat=mock_thermostat) with patch( "homeassistant.co...
[ "async", "def", "test_climate_thermostat_schedule_temporary_hold", "(", "hass", ")", ":", "mock_thermostat", "=", "_get_mock_thermostat_schedule_temporary_hold", "(", ")", "mock_nuheat", "=", "_get_mock_nuheat", "(", "get_thermostat", "=", "mock_thermostat", ")", "with", "p...
[ 112, 0 ]
[ 161, 50 ]
python
en
['en', 'en', 'en']
True
create_window_covering_service
(accessory)
Define a window-covering characteristics as per page 219 of HAP spec.
Define a window-covering characteristics as per page 219 of HAP spec.
def create_window_covering_service(accessory): """Define a window-covering characteristics as per page 219 of HAP spec.""" service = accessory.add_service(ServicesTypes.WINDOW_COVERING) cur_state = service.add_char(CharacteristicsTypes.POSITION_CURRENT) cur_state.value = 0 targ_state = service.add...
[ "def", "create_window_covering_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "WINDOW_COVERING", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "POSITION_CURRENT",...
[ 24, 0 ]
[ 46, 18 ]
python
en
['en', 'en', 'en']
True
create_window_covering_service_with_h_tilt
(accessory)
Define a window-covering characteristics as per page 219 of HAP spec.
Define a window-covering characteristics as per page 219 of HAP spec.
def create_window_covering_service_with_h_tilt(accessory): """Define a window-covering characteristics as per page 219 of HAP spec.""" service = create_window_covering_service(accessory) tilt_current = service.add_char(CharacteristicsTypes.HORIZONTAL_TILT_CURRENT) tilt_current.value = 0 tilt_targe...
[ "def", "create_window_covering_service_with_h_tilt", "(", "accessory", ")", ":", "service", "=", "create_window_covering_service", "(", "accessory", ")", "tilt_current", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "HORIZONTAL_TILT_CURRENT", ")", "ti...
[ 49, 0 ]
[ 57, 25 ]
python
en
['en', 'en', 'en']
True
create_window_covering_service_with_v_tilt
(accessory)
Define a window-covering characteristics as per page 219 of HAP spec.
Define a window-covering characteristics as per page 219 of HAP spec.
def create_window_covering_service_with_v_tilt(accessory): """Define a window-covering characteristics as per page 219 of HAP spec.""" service = create_window_covering_service(accessory) tilt_current = service.add_char(CharacteristicsTypes.VERTICAL_TILT_CURRENT) tilt_current.value = 0 tilt_target ...
[ "def", "create_window_covering_service_with_v_tilt", "(", "accessory", ")", ":", "service", "=", "create_window_covering_service", "(", "accessory", ")", "tilt_current", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "VERTICAL_TILT_CURRENT", ")", "tilt...
[ 60, 0 ]
[ 68, 25 ]
python
en
['en', 'en', 'en']
True
test_change_window_cover_state
(hass, utcnow)
Test that we can turn a HomeKit alarm on and off again.
Test that we can turn a HomeKit alarm on and off again.
async def test_change_window_cover_state(hass, utcnow): """Test that we can turn a HomeKit alarm on and off again.""" helper = await setup_test_component(hass, create_window_covering_service) await hass.services.async_call( "cover", "open_cover", {"entity_id": helper.entity_id}, blocking=True )...
[ "async", "def", "test_change_window_cover_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_window_covering_service", ")", "await", "hass", ".", "services", ".", "async_call", "(", "\"cover\"", ...
[ 71, 0 ]
[ 83, 61 ]
python
en
['en', 'en', 'en']
True
test_read_window_cover_state
(hass, utcnow)
Test that we can read the state of a HomeKit alarm accessory.
Test that we can read the state of a HomeKit alarm accessory.
async def test_read_window_cover_state(hass, utcnow): """Test that we can read the state of a HomeKit alarm accessory.""" helper = await setup_test_component(hass, create_window_covering_service) helper.characteristics[POSITION_STATE].value = 0 state = await helper.poll_and_get_state() assert state...
[ "async", "def", "test_read_window_cover_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_window_covering_service", ")", "helper", ".", "characteristics", "[", "POSITION_STATE", "]", ".", "value",...
[ 86, 0 ]
[ 104, 59 ]
python
en
['en', 'en', 'en']
True
test_read_window_cover_tilt_horizontal
(hass, utcnow)
Test that horizontal tilt is handled correctly.
Test that horizontal tilt is handled correctly.
async def test_read_window_cover_tilt_horizontal(hass, utcnow): """Test that horizontal tilt is handled correctly.""" helper = await setup_test_component( hass, create_window_covering_service_with_h_tilt ) helper.characteristics[H_TILT_CURRENT].value = 75 state = await helper.poll_and_get_s...
[ "async", "def", "test_read_window_cover_tilt_horizontal", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_window_covering_service_with_h_tilt", ")", "helper", ".", "characteristics", "[", "H_TILT_CURRENT", ...
[ 107, 0 ]
[ 115, 58 ]
python
en
['en', 'en', 'en']
True
test_read_window_cover_tilt_vertical
(hass, utcnow)
Test that vertical tilt is handled correctly.
Test that vertical tilt is handled correctly.
async def test_read_window_cover_tilt_vertical(hass, utcnow): """Test that vertical tilt is handled correctly.""" helper = await setup_test_component( hass, create_window_covering_service_with_v_tilt ) helper.characteristics[V_TILT_CURRENT].value = 75 state = await helper.poll_and_get_state...
[ "async", "def", "test_read_window_cover_tilt_vertical", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_window_covering_service_with_v_tilt", ")", "helper", ".", "characteristics", "[", "V_TILT_CURRENT", "]...
[ 118, 0 ]
[ 126, 58 ]
python
en
['en', 'en', 'en']
True
test_write_window_cover_tilt_horizontal
(hass, utcnow)
Test that horizontal tilt is written correctly.
Test that horizontal tilt is written correctly.
async def test_write_window_cover_tilt_horizontal(hass, utcnow): """Test that horizontal tilt is written correctly.""" helper = await setup_test_component( hass, create_window_covering_service_with_h_tilt ) await hass.services.async_call( "cover", "set_cover_tilt_position", ...
[ "async", "def", "test_write_window_cover_tilt_horizontal", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_window_covering_service_with_h_tilt", ")", "await", "hass", ".", "services", ".", "async_call", "...
[ 129, 0 ]
[ 141, 60 ]
python
en
['en', 'hu', 'en']
True
test_write_window_cover_tilt_vertical
(hass, utcnow)
Test that vertical tilt is written correctly.
Test that vertical tilt is written correctly.
async def test_write_window_cover_tilt_vertical(hass, utcnow): """Test that vertical tilt is written correctly.""" helper = await setup_test_component( hass, create_window_covering_service_with_v_tilt ) await hass.services.async_call( "cover", "set_cover_tilt_position", ...
[ "async", "def", "test_write_window_cover_tilt_vertical", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_window_covering_service_with_v_tilt", ")", "await", "hass", ".", "services", ".", "async_call", "("...
[ 144, 0 ]
[ 156, 60 ]
python
en
['en', 'lb', 'en']
True
test_window_cover_stop
(hass, utcnow)
Test that vertical tilt is written correctly.
Test that vertical tilt is written correctly.
async def test_window_cover_stop(hass, utcnow): """Test that vertical tilt is written correctly.""" helper = await setup_test_component( hass, create_window_covering_service_with_v_tilt ) await hass.services.async_call( "cover", "stop_cover", {"entity_id": helper.entity_id}, blocking=Tr...
[ "async", "def", "test_window_cover_stop", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_window_covering_service_with_v_tilt", ")", "await", "hass", ".", "services", ".", "async_call", "(", "\"cover\""...
[ 159, 0 ]
[ 168, 59 ]
python
en
['en', 'lb', 'en']
True
create_garage_door_opener_service
(accessory)
Define a garage-door-opener chars as per page 217 of HAP spec.
Define a garage-door-opener chars as per page 217 of HAP spec.
def create_garage_door_opener_service(accessory): """Define a garage-door-opener chars as per page 217 of HAP spec.""" service = accessory.add_service(ServicesTypes.GARAGE_DOOR_OPENER) cur_state = service.add_char(CharacteristicsTypes.DOOR_STATE_CURRENT) cur_state.value = 0 cur_state = service.add...
[ "def", "create_garage_door_opener_service", "(", "accessory", ")", ":", "service", "=", "accessory", ".", "add_service", "(", "ServicesTypes", ".", "GARAGE_DOOR_OPENER", ")", "cur_state", "=", "service", ".", "add_char", "(", "CharacteristicsTypes", ".", "DOOR_STATE_C...
[ 171, 0 ]
[ 187, 18 ]
python
en
['en', 'nl', 'en']
True
test_change_door_state
(hass, utcnow)
Test that we can turn open and close a HomeKit garage door.
Test that we can turn open and close a HomeKit garage door.
async def test_change_door_state(hass, utcnow): """Test that we can turn open and close a HomeKit garage door.""" helper = await setup_test_component(hass, create_garage_door_opener_service) await hass.services.async_call( "cover", "open_cover", {"entity_id": helper.entity_id}, blocking=True ) ...
[ "async", "def", "test_change_door_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_garage_door_opener_service", ")", "await", "hass", ".", "services", ".", "async_call", "(", "\"cover\"", ",", ...
[ 190, 0 ]
[ 202, 57 ]
python
en
['en', 'en', 'en']
True
test_read_door_state
(hass, utcnow)
Test that we can read the state of a HomeKit garage door.
Test that we can read the state of a HomeKit garage door.
async def test_read_door_state(hass, utcnow): """Test that we can read the state of a HomeKit garage door.""" helper = await setup_test_component(hass, create_garage_door_opener_service) helper.characteristics[DOOR_CURRENT].value = 0 state = await helper.poll_and_get_state() assert state.state == "...
[ "async", "def", "test_read_door_state", "(", "hass", ",", "utcnow", ")", ":", "helper", "=", "await", "setup_test_component", "(", "hass", ",", "create_garage_door_opener_service", ")", "helper", ".", "characteristics", "[", "DOOR_CURRENT", "]", ".", "value", "=",...
[ 205, 0 ]
[ 227, 59 ]
python
en
['en', 'en', 'en']
True
MatMulWrapper.forward
(self, mat1, mat2)
:param inputs: two torch tensors :return: matmul of these tensors Here are the typical dimensions found in BERT (the B is optional) mat1.shape: [B, <optional extra dims>, M, K] mat2.shape: [B, <optional extra dims>, K, N] output shape: [B, <optional extra dims>, M, N]
def forward(self, mat1, mat2): """ :param inputs: two torch tensors :return: matmul of these tensors Here are the typical dimensions found in BERT (the B is optional) mat1.shape: [B, <optional extra dims>, M, K] mat2.shape: [B, <optional extra dims>, K, N] output shape: [B, <optional e...
[ "def", "forward", "(", "self", ",", "mat1", ",", "mat2", ")", ":", "return", "torch", ".", "matmul", "(", "mat1", ",", "mat2", ")" ]
[ 103, 4 ]
[ 111, 39 ]
python
en
['en', 'error', 'th']
False
SqueezeBertSelfAttention.__init__
(self, config, cin, q_groups=1, k_groups=1, v_groups=1)
config = used for some things; ignored for others (work in progress...) cin = input channels = output channels groups = number of groups to use in conv1d layers
config = used for some things; ignored for others (work in progress...) cin = input channels = output channels groups = number of groups to use in conv1d layers
def __init__(self, config, cin, q_groups=1, k_groups=1, v_groups=1): """ config = used for some things; ignored for others (work in progress...) cin = input channels = output channels groups = number of groups to use in conv1d layers """ super().__init__() if cin % config...
[ "def", "__init__", "(", "self", ",", "config", ",", "cin", ",", "q_groups", "=", "1", ",", "k_groups", "=", "1", ",", "v_groups", "=", "1", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "if", "cin", "%", "config", ".", "num_attention_head...
[ 166, 4 ]
[ 189, 41 ]
python
en
['en', 'error', 'th']
False
SqueezeBertSelfAttention.transpose_for_scores
(self, x)
- input: [N, C, W] - output: [N, C1, W, C2] where C1 is the head index, and C2 is one head's contents
- input: [N, C, W] - output: [N, C1, W, C2] where C1 is the head index, and C2 is one head's contents
def transpose_for_scores(self, x): """ - input: [N, C, W] - output: [N, C1, W, C2] where C1 is the head index, and C2 is one head's contents """ new_x_shape = (x.size()[0], self.num_attention_heads, self.attention_head_size, x.size()[-1]) # [N, C1, C2, W] x = x.view(*new...
[ "def", "transpose_for_scores", "(", "self", ",", "x", ")", ":", "new_x_shape", "=", "(", "x", ".", "size", "(", ")", "[", "0", "]", ",", "self", ".", "num_attention_heads", ",", "self", ".", "attention_head_size", ",", "x", ".", "size", "(", ")", "["...
[ 191, 4 ]
[ 198, 36 ]
python
en
['en', 'error', 'th']
False
SqueezeBertSelfAttention.transpose_key_for_scores
(self, x)
- input: [N, C, W] - output: [N, C1, C2, W] where C1 is the head index, and C2 is one head's contents
- input: [N, C, W] - output: [N, C1, C2, W] where C1 is the head index, and C2 is one head's contents
def transpose_key_for_scores(self, x): """ - input: [N, C, W] - output: [N, C1, C2, W] where C1 is the head index, and C2 is one head's contents """ new_x_shape = (x.size()[0], self.num_attention_heads, self.attention_head_size, x.size()[-1]) # [N, C1, C2, W] x = x.view(...
[ "def", "transpose_key_for_scores", "(", "self", ",", "x", ")", ":", "new_x_shape", "=", "(", "x", ".", "size", "(", ")", "[", "0", "]", ",", "self", ".", "num_attention_heads", ",", "self", ".", "attention_head_size", ",", "x", ".", "size", "(", ")", ...
[ 200, 4 ]
[ 208, 16 ]
python
en
['en', 'error', 'th']
False
SqueezeBertSelfAttention.transpose_output
(self, x)
- input: [N, C1, W, C2] - output: [N, C, W]
- input: [N, C1, W, C2] - output: [N, C, W]
def transpose_output(self, x): """ - input: [N, C1, W, C2] - output: [N, C, W] """ x = x.permute(0, 1, 3, 2).contiguous() # [N, C1, C2, W] new_x_shape = (x.size()[0], self.all_head_size, x.size()[3]) # [N, C, W] x = x.view(*new_x_shape) return x
[ "def", "transpose_output", "(", "self", ",", "x", ")", ":", "x", "=", "x", ".", "permute", "(", "0", ",", "1", ",", "3", ",", "2", ")", ".", "contiguous", "(", ")", "# [N, C1, C2, W]", "new_x_shape", "=", "(", "x", ".", "size", "(", ")", "[", "...
[ 210, 4 ]
[ 218, 16 ]
python
en
['en', 'error', 'th']
False
SqueezeBertSelfAttention.forward
(self, hidden_states, attention_mask, output_attentions)
expects hidden_states in [N, C, W] data layout. The attention_mask data layout is [N, W], and it does not need to be transposed.
expects hidden_states in [N, C, W] data layout.
def forward(self, hidden_states, attention_mask, output_attentions): """ expects hidden_states in [N, C, W] data layout. The attention_mask data layout is [N, W], and it does not need to be transposed. """ mixed_query_layer = self.query(hidden_states) mixed_key_layer = s...
[ "def", "forward", "(", "self", ",", "hidden_states", ",", "attention_mask", ",", "output_attentions", ")", ":", "mixed_query_layer", "=", "self", ".", "query", "(", "hidden_states", ")", "mixed_key_layer", "=", "self", ".", "key", "(", "hidden_states", ")", "m...
[ 220, 4 ]
[ 253, 21 ]
python
en
['en', 'error', 'th']
False
SqueezeBertModule.__init__
(self, config)
- hidden_size = input chans = output chans for Q, K, V (they are all the same ... for now) = output chans for the module - intermediate_size = output chans for intermediate layer - groups = number of groups for all layers in the BertModule. (eventually we could change the interface to...
- hidden_size = input chans = output chans for Q, K, V (they are all the same ... for now) = output chans for the module - intermediate_size = output chans for intermediate layer - groups = number of groups for all layers in the BertModule. (eventually we could change the interface to...
def __init__(self, config): """ - hidden_size = input chans = output chans for Q, K, V (they are all the same ... for now) = output chans for the module - intermediate_size = output chans for intermediate layer - groups = number of groups for all layers in the BertModule. (even...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "c0", "=", "config", ".", "hidden_size", "c1", "=", "config", ".", "hidden_size", "c2", "=", "config", ".", "intermediate_size", "c3", "=", "config",...
[ 257, 4 ]
[ 281, 9 ]
python
en
['en', 'error', 'th']
False
SqueezeBertPreTrainedModel._init_weights
(self, module)
Initialize the weights
Initialize the weights
def _init_weights(self, module): """ Initialize the weights """ if isinstance(module, (nn.Linear, nn.Conv1d)): # Slightly different from the TF version which uses truncated_normal for initialization # cf https://github.com/pytorch/pytorch/pull/5617 module.weight.data....
[ "def", "_init_weights", "(", "self", ",", "module", ")", ":", "if", "isinstance", "(", "module", ",", "(", "nn", ".", "Linear", ",", "nn", ".", "Conv1d", ")", ")", ":", "# Slightly different from the TF version which uses truncated_normal for initialization", "# cf ...
[ 433, 4 ]
[ 447, 41 ]
python
en
['en', 'en', 'en']
True
MeteoFranceFlowHandler.__init__
(self)
Init MeteoFranceFlowHandler.
Init MeteoFranceFlowHandler.
def __init__(self): """Init MeteoFranceFlowHandler.""" self.places = []
[ "def", "__init__", "(", "self", ")", ":", "self", ".", "places", "=", "[", "]" ]
[ 23, 4 ]
[ 25, 24 ]
python
en
['en', 'id', 'nl']
False
MeteoFranceFlowHandler.async_get_options_flow
(config_entry)
Get the options flow for this handler.
Get the options flow for this handler.
def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return MeteoFranceOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "MeteoFranceOptionsFlowHandler", "(", "config_entry", ")" ]
[ 29, 4 ]
[ 31, 58 ]
python
en
['en', 'en', 'en']
True
MeteoFranceFlowHandler._show_setup_form
(self, user_input=None, errors=None)
Show the setup form to the user.
Show the setup form to the user.
def _show_setup_form(self, user_input=None, errors=None): """Show the setup form to the user.""" if user_input is None: user_input = {} return self.async_show_form( step_id="user", data_schema=vol.Schema( {vol.Required(CONF_CITY, default=user...
[ "def", "_show_setup_form", "(", "self", ",", "user_input", "=", "None", ",", "errors", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "user_input", "=", "{", "}", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", "...
[ 34, 4 ]
[ 46, 9 ]
python
en
['en', 'en', 'en']
True
MeteoFranceFlowHandler.async_step_user
(self, user_input=None)
Handle a flow initiated by the user.
Handle a flow initiated by the user.
async def async_step_user(self, user_input=None): """Handle a flow initiated by the user.""" errors = {} if user_input is None: return self._show_setup_form(user_input, errors) city = user_input[CONF_CITY] # Might be a city name or a postal code latitude = user_inp...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "None", ":", "return", "self", ".", "_show_setup_form", "(", "user_input", ",", "errors", ")", "city", "=", "user...
[ 48, 4 ]
[ 78, 9 ]
python
en
['en', 'en', 'en']
True
MeteoFranceFlowHandler.async_step_import
(self, user_input)
Import a config entry.
Import a config entry.
async def async_step_import(self, user_input): """Import a config entry.""" return await self.async_step_user(user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", ")" ]
[ 80, 4 ]
[ 82, 53 ]
python
en
['en', 'en', 'en']
True
MeteoFranceFlowHandler.async_step_cities
(self, user_input=None)
Step where the user choose the city from the API search results.
Step where the user choose the city from the API search results.
async def async_step_cities(self, user_input=None): """Step where the user choose the city from the API search results.""" if not user_input: if len(self.places) > 1 and self.source != SOURCE_IMPORT: places_for_form = {} for place in self.places: ...
[ "async", "def", "async_step_cities", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "not", "user_input", ":", "if", "len", "(", "self", ".", "places", ")", ">", "1", "and", "self", ".", "source", "!=", "SOURCE_IMPORT", ":", "places_for_form...
[ 84, 4 ]
[ 111, 9 ]
python
en
['en', 'en', 'en']
True
MeteoFranceOptionsFlowHandler.__init__
(self, config_entry: config_entries.ConfigEntry)
Initialize options flow.
Initialize options flow.
def __init__(self, config_entry: config_entries.ConfigEntry): """Initialize options flow.""" self.config_entry = config_entry
[ "def", "__init__", "(", "self", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ")", ":", "self", ".", "config_entry", "=", "config_entry" ]
[ 117, 4 ]
[ 119, 40 ]
python
en
['en', 'en', 'en']
True
MeteoFranceOptionsFlowHandler.async_step_init
(self, user_input=None)
Handle options flow.
Handle options flow.
async def async_step_init(self, user_input=None): """Handle options flow.""" if user_input is not None: return self.async_create_entry(title="", data=user_input) data_schema = vol.Schema( { vol.Optional( CONF_MODE, ...
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "return", "self", ".", "async_create_entry", "(", "title", "=", "\"\"", ",", "data", "=", "user_input", ")", "data_schem...
[ 121, 4 ]
[ 136, 76 ]
python
en
['en', 'nl', 'en']
True
_handle_errors
(func)
Handle error with WebSocket calls.
Handle error with WebSocket calls.
def _handle_errors(func): """Handle error with WebSocket calls.""" @wraps(func) async def send_with_error_handling(hass, connection, msg): url_path = msg.get(CONF_URL_PATH) config = hass.data[DOMAIN]["dashboards"].get(url_path) if config is None: connection.send_error( ...
[ "def", "_handle_errors", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "async", "def", "send_with_error_handling", "(", "hass", ",", "connection", ",", "msg", ")", ":", "url_path", "=", "msg", ".", "get", "(", "CONF_URL_PATH", ")", "config", "="...
[ 13, 0 ]
[ 44, 35 ]
python
en
['en', 'nl', 'en']
True
websocket_lovelace_resources
(hass, connection, msg)
Send Lovelace UI resources over WebSocket configuration.
Send Lovelace UI resources over WebSocket configuration.
async def websocket_lovelace_resources(hass, connection, msg): """Send Lovelace UI resources over WebSocket configuration.""" resources = hass.data[DOMAIN]["resources"] if not resources.loaded: await resources.async_load() resources.loaded = True connection.send_result(msg["id"], resou...
[ "async", "def", "websocket_lovelace_resources", "(", "hass", ",", "connection", ",", "msg", ")", ":", "resources", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "\"resources\"", "]", "if", "not", "resources", ".", "loaded", ":", "await", "resources", ...
[ 49, 0 ]
[ 57, 62 ]
python
en
['en', 'da', 'en']
True
websocket_lovelace_config
(hass, connection, msg, config)
Send Lovelace UI config over WebSocket configuration.
Send Lovelace UI config over WebSocket configuration.
async def websocket_lovelace_config(hass, connection, msg, config): """Send Lovelace UI config over WebSocket configuration.""" return await config.async_load(msg["force"])
[ "async", "def", "websocket_lovelace_config", "(", "hass", ",", "connection", ",", "msg", ",", "config", ")", ":", "return", "await", "config", ".", "async_load", "(", "msg", "[", "\"force\"", "]", ")" ]
[ 69, 0 ]
[ 71, 48 ]
python
en
['en', 'da', 'en']
True
websocket_lovelace_save_config
(hass, connection, msg, config)
Save Lovelace UI configuration.
Save Lovelace UI configuration.
async def websocket_lovelace_save_config(hass, connection, msg, config): """Save Lovelace UI configuration.""" await config.async_save(msg["config"])
[ "async", "def", "websocket_lovelace_save_config", "(", "hass", ",", "connection", ",", "msg", ",", "config", ")", ":", "await", "config", ".", "async_save", "(", "msg", "[", "\"config\"", "]", ")" ]
[ 84, 0 ]
[ 86, 42 ]
python
en
['en', 'ro', 'en']
True
websocket_lovelace_delete_config
(hass, connection, msg, config)
Delete Lovelace UI configuration.
Delete Lovelace UI configuration.
async def websocket_lovelace_delete_config(hass, connection, msg, config): """Delete Lovelace UI configuration.""" await config.async_delete()
[ "async", "def", "websocket_lovelace_delete_config", "(", "hass", ",", "connection", ",", "msg", ",", "config", ")", ":", "await", "config", ".", "async_delete", "(", ")" ]
[ 98, 0 ]
[ 100, 31 ]
python
en
['en', 'fr', 'en']
True
websocket_lovelace_dashboards
(hass, connection, msg)
Delete Lovelace UI configuration.
Delete Lovelace UI configuration.
def websocket_lovelace_dashboards(hass, connection, msg): """Delete Lovelace UI configuration.""" connection.send_result( msg["id"], [ dashboard.config for dashboard in hass.data[DOMAIN]["dashboards"].values() if dashboard.config ], )
[ "def", "websocket_lovelace_dashboards", "(", "hass", ",", "connection", ",", "msg", ")", ":", "connection", ".", "send_result", "(", "msg", "[", "\"id\"", "]", ",", "[", "dashboard", ".", "config", "for", "dashboard", "in", "hass", ".", "data", "[", "DOMAI...
[ 105, 0 ]
[ 114, 5 ]
python
en
['en', 'fr', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up tellduslive sensors dynamically.
Set up tellduslive sensors dynamically.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up tellduslive sensors dynamically.""" async def async_discover_binary_sensor(device_id): """Discover and add a discovered sensor.""" client = hass.data[tellduslive.DOMAIN] async_add_entities([TelldusLiveSensor(...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "async", "def", "async_discover_binary_sensor", "(", "device_id", ")", ":", "\"\"\"Discover and add a discovered sensor.\"\"\"", "client", "=", "hass", ".", "data...
[ 8, 0 ]
[ 22, 5 ]
python
en
['en', 'hu', 'en']
True
TelldusLiveSensor.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self): """Return true if switch is on.""" return self.device.is_on
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "device", ".", "is_on" ]
[ 29, 4 ]
[ 31, 32 ]
python
en
['en', 'fy', 'en']
True
setup
(hass, config)
Set up the Raspberry PI PFIO component.
Set up the Raspberry PI PFIO component.
def setup(hass, config): """Set up the Raspberry PI PFIO component.""" pifacedigital = PFIO.PiFaceDigital() hass.data[DATA_PFIO_LISTENER] = PFIO.InputEventListener(chip=pifacedigital) def cleanup_pfio(event): """Stuff to do before stopping.""" PFIO.deinit() def prepare_pfio(event):...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "pifacedigital", "=", "PFIO", ".", "PiFaceDigital", "(", ")", "hass", ".", "data", "[", "DATA_PFIO_LISTENER", "]", "=", "PFIO", ".", "InputEventListener", "(", "chip", "=", "pifacedigital", ")", "def", ...
[ 10, 0 ]
[ 26, 15 ]
python
en
['en', 'sr', 'en']
True
write_output
(port, value)
Write a value to a PFIO.
Write a value to a PFIO.
def write_output(port, value): """Write a value to a PFIO.""" PFIO.digital_write(port, value)
[ "def", "write_output", "(", "port", ",", "value", ")", ":", "PFIO", ".", "digital_write", "(", "port", ",", "value", ")" ]
[ 29, 0 ]
[ 31, 35 ]
python
en
['en', 'pt', 'en']
True
read_input
(port)
Read a value from a PFIO.
Read a value from a PFIO.
def read_input(port): """Read a value from a PFIO.""" return PFIO.digital_read(port)
[ "def", "read_input", "(", "port", ")", ":", "return", "PFIO", ".", "digital_read", "(", "port", ")" ]
[ 34, 0 ]
[ 36, 34 ]
python
en
['en', 'en', 'en']
True
edge_detect
(hass, port, event_callback, settle)
Add detection for RISING and FALLING events.
Add detection for RISING and FALLING events.
def edge_detect(hass, port, event_callback, settle): """Add detection for RISING and FALLING events.""" hass.data[DATA_PFIO_LISTENER].register( port, PFIO.IODIR_BOTH, event_callback, settle_time=settle )
[ "def", "edge_detect", "(", "hass", ",", "port", ",", "event_callback", ",", "settle", ")", ":", "hass", ".", "data", "[", "DATA_PFIO_LISTENER", "]", ".", "register", "(", "port", ",", "PFIO", ".", "IODIR_BOTH", ",", "event_callback", ",", "settle_time", "=...
[ 39, 0 ]
[ 43, 5 ]
python
en
['en', 'en', 'en']
True
activate_listener
(hass)
Activate the registered listener events.
Activate the registered listener events.
def activate_listener(hass): """Activate the registered listener events.""" hass.data[DATA_PFIO_LISTENER].activate()
[ "def", "activate_listener", "(", "hass", ")", ":", "hass", ".", "data", "[", "DATA_PFIO_LISTENER", "]", ".", "activate", "(", ")" ]
[ 46, 0 ]
[ 48, 44 ]
python
en
['en', 'en', 'en']
True
test_sensor
(hass)
Test states of the sensor.
Test states of the sensor.
async def test_sensor(hass): """Test states of the sensor.""" await init_integration(hass) registry = await hass.helpers.entity_registry.async_get_registry() state = hass.states.get("sensor.home_humidity") assert state assert state.state == "92.8" assert state.attributes.get(ATTR_ATTRIBUTIO...
[ "async", "def", "test_sensor", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "state", "=", "hass", ".", "states", ".", "g...
[ 28, 0 ]
[ 78, 56 ]
python
en
['en', 'en', 'en']
True
test_availability
(hass)
Ensure that we mark the entities unavailable correctly when service is offline.
Ensure that we mark the entities unavailable correctly when service is offline.
async def test_availability(hass): """Ensure that we mark the entities unavailable correctly when service is offline.""" await init_integration(hass) state = hass.states.get("sensor.home_humidity") assert state assert state.state != STATE_UNAVAILABLE assert state.state == "92.8" future = u...
[ "async", "def", "test_availability", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "state", "=", "hass", ".", "states", ".", "get", "(", "\"sensor.home_humidity\"", ")", "assert", "state", "assert", "state", ".", "state", "!=", "STATE...
[ 81, 0 ]
[ 110, 36 ]
python
en
['en', 'en', 'en']
True
test_manual_update_entity
(hass)
Test manual update entity via service homeasasistant/update_entity.
Test manual update entity via service homeasasistant/update_entity.
async def test_manual_update_entity(hass): """Test manual update entity via service homeasasistant/update_entity.""" await init_integration(hass) await async_setup_component(hass, "homeassistant", {}) with patch( "homeassistant.components.airly.AirlyDataUpdateCoordinator._async_update_data" ...
[ "async", "def", "test_manual_update_entity", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "await", "async_setup_component", "(", "hass", ",", "\"homeassistant\"", ",", "{", "}", ")", "with", "patch", "(", "\"homeassistant.components.airly.Ai...
[ 113, 0 ]
[ 127, 42 ]
python
en
['en', 'en', 'en']
True
load_corpus
(name, download=True)
Loads and wrangles the passed in text corpus by name. If download is specified, this method will download any missing files. Note: This function is slightly different to the `load_data` function used above to load pandas dataframes into memory.
Loads and wrangles the passed in text corpus by name. If download is specified, this method will download any missing files.
def load_corpus(name, download=True): """ Loads and wrangles the passed in text corpus by name. If download is specified, this method will download any missing files. Note: This function is slightly different to the `load_data` function used above to load pandas dataframes into memory. """ ...
[ "def", "load_corpus", "(", "name", ",", "download", "=", "True", ")", ":", "# Get the path from the datasets", "path", "=", "corpora", "[", "name", "]", "# Check if the data exists, otherwise download or raise", "if", "not", "os", ".", "path", ".", "exists", "(", ...
[ 16, 0 ]
[ 60, 5 ]
python
en
['en', 'error', 'th']
False
async_setup
(hass, config)
Set up the forked-daapd component.
Set up the forked-daapd component.
async def async_setup(hass, config): """Set up the forked-daapd component.""" return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "return", "True" ]
[ 6, 0 ]
[ 8, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Set up forked-daapd from a config entry by forwarding to platform.
Set up forked-daapd from a config entry by forwarding to platform.
async def async_setup_entry(hass, entry): """Set up forked-daapd from a config entry by forwarding to platform.""" hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, MP_DOMAIN) ) return True
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "async_create_task", "(", "hass", ".", "config_entries", ".", "async_forward_entry_setup", "(", "entry", ",", "MP_DOMAIN", ")", ")", "return", "True" ]
[ 11, 0 ]
[ 16, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Remove forked-daapd component.
Remove forked-daapd component.
async def async_unload_entry(hass, entry): """Remove forked-daapd component.""" status = await hass.config_entries.async_forward_entry_unload(entry, MP_DOMAIN) if status and hass.data.get(DOMAIN) and hass.data[DOMAIN].get(entry.entry_id): hass.data[DOMAIN][entry.entry_id][ HASS_DATA_UPDA...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "status", "=", "await", "hass", ".", "config_entries", ".", "async_forward_entry_unload", "(", "entry", ",", "MP_DOMAIN", ")", "if", "status", "and", "hass", ".", "data", ".", "get", ...
[ 19, 0 ]
[ 33, 17 ]
python
en
['nl', 'en', 'en']
True
test_async_response_request_context
(hass, websocket_client)
Test we can access current request.
Test we can access current request.
async def test_async_response_request_context(hass, websocket_client): """Test we can access current request.""" def handle_request(request, connection, msg): if request is not None: connection.send_result(msg["id"], request.path) else: connection.send_error(msg["id"], "...
[ "async", "def", "test_async_response_request_context", "(", "hass", ",", "websocket_client", ")", ":", "def", "handle_request", "(", "request", ",", "connection", ",", "msg", ")", ":", "if", "request", "is", "not", "None", ":", "connection", ".", "send_result", ...
[ 4, 0 ]
[ 67, 46 ]
python
en
['en', 'en', 'en']
True
test_eufycam_setup
(hass)
Test that a eufycam can be correctly setup in HA.
Test that a eufycam can be correctly setup in HA.
async def test_eufycam_setup(hass): """Test that a eufycam can be correctly setup in HA.""" accessories = await setup_accessories_from_file(hass, "anker_eufycam.json") config_entry, pairing = await setup_test_accessories(hass, accessories) entity_registry = await hass.helpers.entity_registry.async_get_...
[ "async", "def", "test_eufycam_setup", "(", "hass", ")", ":", "accessories", "=", "await", "setup_accessories_from_file", "(", "hass", ",", "\"anker_eufycam.json\"", ")", "config_entry", ",", "pairing", "=", "await", "setup_test_accessories", "(", "hass", ",", "acces...
[ 9, 0 ]
[ 52, 29 ]
python
en
['en', 'en', 'en']
True
bytes_to_unicode
()
Returns list of utf-8 byte and a mapping to unicode strings. We specifically avoids mapping to whitespace/control characters the bpe code barfs on. The reversible bpe codes work on unicode strings. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. When you're...
Returns list of utf-8 byte and a mapping to unicode strings. We specifically avoids mapping to whitespace/control characters the bpe code barfs on.
def bytes_to_unicode(): """ Returns list of utf-8 byte and a mapping to unicode strings. We specifically avoids mapping to whitespace/control characters the bpe code barfs on. The reversible bpe codes work on unicode strings. This means you need a large # of unicode characters in your vocab if you ...
[ "def", "bytes_to_unicode", "(", ")", ":", "bs", "=", "(", "list", "(", "range", "(", "ord", "(", "\"!\"", ")", ",", "ord", "(", "\"~\"", ")", "+", "1", ")", ")", "+", "list", "(", "range", "(", "ord", "(", "\"¡\")", ",", " ", "rd(", "\"", "¬\...
[ 65, 0 ]
[ 86, 28 ]
python
en
['en', 'error', 'th']
False
get_pairs
(word)
Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).
Return set of symbol pairs in a word.
def get_pairs(word): """ Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings). """ pairs = set() prev_char = word[0] for char in word[1:]: pairs.add((prev_char, char)) prev_char = char return pairs
[ "def", "get_pairs", "(", "word", ")", ":", "pairs", "=", "set", "(", ")", "prev_char", "=", "word", "[", "0", "]", "for", "char", "in", "word", "[", "1", ":", "]", ":", "pairs", ".", "add", "(", "(", "prev_char", ",", "char", ")", ")", "prev_ch...
[ 89, 0 ]
[ 100, 16 ]
python
en
['en', 'error', 'th']
False
GPT2Tokenizer._tokenize
(self, text)
Tokenize a string.
Tokenize a string.
def _tokenize(self, text): """ Tokenize a string. """ bpe_tokens = [] for token in re.findall(self.pat, text): token = "".join( self.byte_encoder[b] for b in token.encode("utf-8") ) # Maps all our bytes to unicode strings, avoiding controle tokens of the ...
[ "def", "_tokenize", "(", "self", ",", "text", ")", ":", "bpe_tokens", "=", "[", "]", "for", "token", "in", "re", ".", "findall", "(", "self", ".", "pat", ",", "text", ")", ":", "token", "=", "\"\"", ".", "join", "(", "self", ".", "byte_encoder", ...
[ 243, 4 ]
[ 251, 25 ]
python
en
['en', 'gl', 'en']
True
GPT2Tokenizer._convert_token_to_id
(self, token)
Converts a token (str) in an id using the vocab.
Converts a token (str) in an id using the vocab.
def _convert_token_to_id(self, token): """ Converts a token (str) in an id using the vocab. """ return self.encoder.get(token, self.encoder.get(self.unk_token))
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ")", ":", "return", "self", ".", "encoder", ".", "get", "(", "token", ",", "self", ".", "encoder", ".", "get", "(", "self", ".", "unk_token", ")", ")" ]
[ 253, 4 ]
[ 255, 72 ]
python
en
['en', 'en', 'en']
True