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
AbstractAutoCompressionModule.post_compress_finetuning_epochs
(cls, compress_algorithm_name: str)
The epochs in post-compress finetuning process. Parameters ---------- compress_algorithm_name: str The name of pruner and quantizer, i.e. 'level', 'l1', 'qat'. Returns ------- int The finetuning epoch number.
The epochs in post-compress finetuning process.
def post_compress_finetuning_epochs(cls, compress_algorithm_name: str) -> int: """ The epochs in post-compress finetuning process. Parameters ---------- compress_algorithm_name: str The name of pruner and quantizer, i.e. 'level', 'l1', 'qat'. Returns ...
[ "def", "post_compress_finetuning_epochs", "(", "cls", ",", "compress_algorithm_name", ":", "str", ")", "->", "int", ":", "pass" ]
[ 107, 4 ]
[ 121, 12 ]
python
en
['en', 'error', 'th']
False
StreamOutput.__init__
(self, stream, timeout: int = 300)
Initialize a stream output.
Initialize a stream output.
def __init__(self, stream, timeout: int = 300) -> None: """Initialize a stream output.""" self.idle = False self.timeout = timeout self._stream = stream self._cursor = None self._event = asyncio.Event() self._segments = deque(maxlen=MAX_SEGMENTS) self._uns...
[ "def", "__init__", "(", "self", ",", "stream", ",", "timeout", ":", "int", "=", "300", ")", "->", "None", ":", "self", ".", "idle", "=", "False", "self", ".", "timeout", "=", "timeout", "self", ".", "_stream", "=", "stream", "self", ".", "_cursor", ...
[ 41, 4 ]
[ 49, 26 ]
python
en
['en', 'pt', 'en']
True
StreamOutput.name
(self)
Return provider name.
Return provider name.
def name(self) -> str: """Return provider name.""" return None
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "None" ]
[ 52, 4 ]
[ 54, 19 ]
python
en
['en', 'no', 'en']
True
StreamOutput.format
(self)
Return container format.
Return container format.
def format(self) -> str: """Return container format.""" return None
[ "def", "format", "(", "self", ")", "->", "str", ":", "return", "None" ]
[ 57, 4 ]
[ 59, 19 ]
python
da
['da', 'la', 'en']
False
StreamOutput.audio_codecs
(self)
Return desired audio codecs.
Return desired audio codecs.
def audio_codecs(self) -> str: """Return desired audio codecs.""" return None
[ "def", "audio_codecs", "(", "self", ")", "->", "str", ":", "return", "None" ]
[ 62, 4 ]
[ 64, 19 ]
python
en
['en', 'la', 'en']
True
StreamOutput.video_codecs
(self)
Return desired video codecs.
Return desired video codecs.
def video_codecs(self) -> tuple: """Return desired video codecs.""" return None
[ "def", "video_codecs", "(", "self", ")", "->", "tuple", ":", "return", "None" ]
[ 67, 4 ]
[ 69, 19 ]
python
af
['es', 'af', 'en']
False
StreamOutput.container_options
(self)
Return Callable which takes a sequence number and returns container options.
Return Callable which takes a sequence number and returns container options.
def container_options(self) -> Callable[[int], dict]: """Return Callable which takes a sequence number and returns container options.""" return None
[ "def", "container_options", "(", "self", ")", "->", "Callable", "[", "[", "int", "]", ",", "dict", "]", ":", "return", "None" ]
[ 72, 4 ]
[ 74, 19 ]
python
en
['en', 'en', 'en']
True
StreamOutput.segments
(self)
Return current sequence from segments.
Return current sequence from segments.
def segments(self) -> List[int]: """Return current sequence from segments.""" return [s.sequence for s in self._segments]
[ "def", "segments", "(", "self", ")", "->", "List", "[", "int", "]", ":", "return", "[", "s", ".", "sequence", "for", "s", "in", "self", ".", "_segments", "]" ]
[ 77, 4 ]
[ 79, 51 ]
python
en
['en', 'en', 'en']
True
StreamOutput.target_duration
(self)
Return the max duration of any given segment in seconds.
Return the max duration of any given segment in seconds.
def target_duration(self) -> int: """Return the max duration of any given segment in seconds.""" segment_length = len(self._segments) if not segment_length: return 1 durations = [s.duration for s in self._segments] return round(max(durations)) or 1
[ "def", "target_duration", "(", "self", ")", "->", "int", ":", "segment_length", "=", "len", "(", "self", ".", "_segments", ")", "if", "not", "segment_length", ":", "return", "1", "durations", "=", "[", "s", ".", "duration", "for", "s", "in", "self", "....
[ 82, 4 ]
[ 88, 41 ]
python
en
['en', 'en', 'en']
True
StreamOutput.get_segment
(self, sequence: int = None)
Retrieve a specific segment, or the whole list.
Retrieve a specific segment, or the whole list.
def get_segment(self, sequence: int = None) -> Any: """Retrieve a specific segment, or the whole list.""" self.idle = False # Reset idle timeout if self._unsub is not None: self._unsub() self._unsub = async_call_later(self._stream.hass, self.timeout, self._timeout) ...
[ "def", "get_segment", "(", "self", ",", "sequence", ":", "int", "=", "None", ")", "->", "Any", ":", "self", ".", "idle", "=", "False", "# Reset idle timeout", "if", "self", ".", "_unsub", "is", "not", "None", ":", "self", ".", "_unsub", "(", ")", "se...
[ 90, 4 ]
[ 104, 19 ]
python
en
['en', 'en', 'en']
True
StreamOutput.recv
(self)
Wait for and retrieve the latest segment.
Wait for and retrieve the latest segment.
async def recv(self) -> Segment: """Wait for and retrieve the latest segment.""" last_segment = max(self.segments, default=0) if self._cursor is None or self._cursor <= last_segment: await self._event.wait() if not self._segments: return None segment = s...
[ "async", "def", "recv", "(", "self", ")", "->", "Segment", ":", "last_segment", "=", "max", "(", "self", ".", "segments", ",", "default", "=", "0", ")", "if", "self", ".", "_cursor", "is", "None", "or", "self", ".", "_cursor", "<=", "last_segment", "...
[ 106, 4 ]
[ 117, 22 ]
python
en
['en', 'en', 'en']
True
StreamOutput.put
(self, segment: Segment)
Store output.
Store output.
def put(self, segment: Segment) -> None: """Store output.""" # Start idle timeout when we start receiving data if self._unsub is None: self._unsub = async_call_later( self._stream.hass, self.timeout, self._timeout ) if segment is None: ...
[ "def", "put", "(", "self", ",", "segment", ":", "Segment", ")", "->", "None", ":", "# Start idle timeout when we start receiving data", "if", "self", ".", "_unsub", "is", "None", ":", "self", ".", "_unsub", "=", "async_call_later", "(", "self", ".", "_stream",...
[ 120, 4 ]
[ 138, 27 ]
python
en
['en', 'en', 'en']
False
StreamOutput._timeout
(self, _now=None)
Handle stream timeout.
Handle stream timeout.
def _timeout(self, _now=None): """Handle stream timeout.""" self._unsub = None if self._stream.keepalive: self.idle = True self._stream.check_idle() else: self.cleanup()
[ "def", "_timeout", "(", "self", ",", "_now", "=", "None", ")", ":", "self", ".", "_unsub", "=", "None", "if", "self", ".", "_stream", ".", "keepalive", ":", "self", ".", "idle", "=", "True", "self", ".", "_stream", ".", "check_idle", "(", ")", "els...
[ 141, 4 ]
[ 148, 26 ]
python
en
['en', 'en', 'en']
True
StreamOutput.cleanup
(self)
Handle cleanup.
Handle cleanup.
def cleanup(self): """Handle cleanup.""" self._segments = deque(maxlen=MAX_SEGMENTS) self._stream.remove_provider(self)
[ "def", "cleanup", "(", "self", ")", ":", "self", ".", "_segments", "=", "deque", "(", "maxlen", "=", "MAX_SEGMENTS", ")", "self", ".", "_stream", ".", "remove_provider", "(", "self", ")" ]
[ 150, 4 ]
[ 153, 42 ]
python
en
['en', 'en', 'en']
False
StreamView.get
(self, request, token, sequence=None)
Start a GET request.
Start a GET request.
async def get(self, request, token, sequence=None): """Start a GET request.""" hass = request.app["hass"] stream = next( ( s for s in hass.data[DOMAIN][ATTR_STREAMS].values() if s.access_token == token ), None, ...
[ "async", "def", "get", "(", "self", ",", "request", ",", "token", ",", "sequence", "=", "None", ")", ":", "hass", "=", "request", ".", "app", "[", "\"hass\"", "]", "stream", "=", "next", "(", "(", "s", "for", "s", "in", "hass", ".", "data", "[", ...
[ 167, 4 ]
[ 186, 59 ]
python
en
['en', 'lb', 'en']
True
StreamView.handle
(self, request, stream, sequence)
Handle the stream request.
Handle the stream request.
async def handle(self, request, stream, sequence): """Handle the stream request.""" raise NotImplementedError()
[ "async", "def", "handle", "(", "self", ",", "request", ",", "stream", ",", "sequence", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 188, 4 ]
[ 190, 35 ]
python
en
['en', 'en', 'en']
True
test_duplicate_error
(hass)
Test that errors are shown when duplicates are added.
Test that errors are shown when duplicates are added.
async def test_duplicate_error(hass): """Test that errors are shown when duplicates are added.""" conf = {CONF_ZIP_CODE: "12345"} MockConfigEntry(domain=DOMAIN, unique_id="12345", data=conf).add_to_hass(hass) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE...
[ "async", "def", "test_duplicate_error", "(", "hass", ")", ":", "conf", "=", "{", "CONF_ZIP_CODE", ":", "\"12345\"", "}", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ",", "unique_id", "=", "\"12345\"", ",", "data", "=", "conf", ")", ".", "add_to_hass", ...
[ 9, 0 ]
[ 20, 51 ]
python
en
['en', 'en', 'en']
True
test_invalid_zip_code
(hass)
Test that an invalid ZIP code key throws an error.
Test that an invalid ZIP code key throws an error.
async def test_invalid_zip_code(hass): """Test that an invalid ZIP code key throws an error.""" conf = {CONF_ZIP_CODE: "abcde"} result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER}, data=conf ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM...
[ "async", "def", "test_invalid_zip_code", "(", "hass", ")", ":", "conf", "=", "{", "CONF_ZIP_CODE", ":", "\"abcde\"", "}", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"sou...
[ 23, 0 ]
[ 32, 66 ]
python
en
['en', 'gd', 'en']
True
test_show_form
(hass)
Test that the form is served with no input.
Test that the form is served with no input.
async def test_show_form(hass): """Test that the form is served with no input.""" result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user"
[ "async", "def", "test_show_form", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "SOURCE_USER", "}", ")", "assert", "result", "[", ...
[ 35, 0 ]
[ 42, 38 ]
python
en
['en', 'en', 'en']
True
test_step_user
(hass)
Test that the user step works (without MFA).
Test that the user step works (without MFA).
async def test_step_user(hass): """Test that the user step works (without MFA).""" conf = {CONF_ZIP_CODE: "12345"} with patch("homeassistant.components.iqvia.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USE...
[ "async", "def", "test_step_user", "(", "hass", ")", ":", "conf", "=", "{", "CONF_ZIP_CODE", ":", "\"12345\"", "}", "with", "patch", "(", "\"homeassistant.components.iqvia.async_setup_entry\"", ",", "return_value", "=", "True", ")", ":", "result", "=", "await", "...
[ 45, 0 ]
[ 56, 57 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable )
Set up Guardian switches based on a config entry.
Set up Guardian switches based on a config entry.
async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable ) -> None: """Set up Guardian switches based on a config entry.""" platform = entity_platform.current_platform.get() for service_name, schema, method in [ (SERVICE_DISABLE_AP, {}, "async_disable_a...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", ")", "->", "None", ":", "platform", "=", "entity_platform", ".", "current_platform", ".", "get", "(", ")", "fo...
[ 39, 0 ]
[ 76, 5 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.__init__
( self, entry: ConfigEntry, client: Client, coordinators: Dict[str, DataUpdateCoordinator], )
Initialize.
Initialize.
def __init__( self, entry: ConfigEntry, client: Client, coordinators: Dict[str, DataUpdateCoordinator], ): """Initialize.""" super().__init__( entry, coordinators, "valve", "Valve Controller", None, "mdi:water" ) self._client = client ...
[ "def", "__init__", "(", "self", ",", "entry", ":", "ConfigEntry", ",", "client", ":", "Client", ",", "coordinators", ":", "Dict", "[", "str", ",", "DataUpdateCoordinator", "]", ",", ")", ":", "super", "(", ")", ".", "__init__", "(", "entry", ",", "coor...
[ 82, 4 ]
[ 94, 26 ]
python
en
['en', 'en', 'it']
False
ValveControllerSwitch.available
(self)
Return whether the entity is available.
Return whether the entity is available.
def available(self) -> bool: """Return whether the entity is available.""" return self.coordinators[API_VALVE_STATUS].last_update_success
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "coordinators", "[", "API_VALVE_STATUS", "]", ".", "last_update_success" ]
[ 97, 4 ]
[ 99, 70 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.is_on
(self)
Return True if the valve is open.
Return True if the valve is open.
def is_on(self) -> bool: """Return True if the valve is open.""" return self._is_on
[ "def", "is_on", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_is_on" ]
[ 102, 4 ]
[ 104, 26 ]
python
en
['en', 'nl', 'en']
True
ValveControllerSwitch._async_continue_entity_setup
(self)
Register API interest (and related tasks) when the entity is added.
Register API interest (and related tasks) when the entity is added.
async def _async_continue_entity_setup(self): """Register API interest (and related tasks) when the entity is added.""" self.async_add_coordinator_update_listener(API_VALVE_STATUS)
[ "async", "def", "_async_continue_entity_setup", "(", "self", ")", ":", "self", ".", "async_add_coordinator_update_listener", "(", "API_VALVE_STATUS", ")" ]
[ 106, 4 ]
[ 108, 68 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch._async_update_from_latest_data
(self)
Update the entity.
Update the entity.
def _async_update_from_latest_data(self) -> None: """Update the entity.""" self._is_on = self.coordinators[API_VALVE_STATUS].data["state"] in ( "start_opening", "opening", "finish_opening", "opened", ) self._attrs.update( { ...
[ "def", "_async_update_from_latest_data", "(", "self", ")", "->", "None", ":", "self", ".", "_is_on", "=", "self", ".", "coordinators", "[", "API_VALVE_STATUS", "]", ".", "data", "[", "\"state\"", "]", "in", "(", "\"start_opening\"", ",", "\"opening\"", ",", ...
[ 111, 4 ]
[ 135, 9 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.async_disable_ap
(self)
Disable the device's onboard access point.
Disable the device's onboard access point.
async def async_disable_ap(self): """Disable the device's onboard access point.""" try: async with self._client: await self._client.wifi.disable_ap() except GuardianError as err: LOGGER.error("Error while disabling valve controller AP: %s", err)
[ "async", "def", "async_disable_ap", "(", "self", ")", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "wifi", ".", "disable_ap", "(", ")", "except", "GuardianError", "as", "err", ":", "LOGGER", ".", ...
[ 137, 4 ]
[ 143, 78 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.async_enable_ap
(self)
Enable the device's onboard access point.
Enable the device's onboard access point.
async def async_enable_ap(self): """Enable the device's onboard access point.""" try: async with self._client: await self._client.wifi.enable_ap() except GuardianError as err: LOGGER.error("Error while enabling valve controller AP: %s", err)
[ "async", "def", "async_enable_ap", "(", "self", ")", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "wifi", ".", "enable_ap", "(", ")", "except", "GuardianError", "as", "err", ":", "LOGGER", ".", "e...
[ 145, 4 ]
[ 151, 77 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.async_pair_sensor
(self, *, uid)
Add a new paired sensor.
Add a new paired sensor.
async def async_pair_sensor(self, *, uid): """Add a new paired sensor.""" try: async with self._client: await self._client.sensor.pair_sensor(uid) except GuardianError as err: LOGGER.error("Error while adding paired sensor: %s", err) return ...
[ "async", "def", "async_pair_sensor", "(", "self", ",", "*", ",", "uid", ")", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "sensor", ".", "pair_sensor", "(", "uid", ")", "except", "GuardianError", ...
[ 153, 4 ]
[ 164, 32 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.async_reboot
(self)
Reboot the device.
Reboot the device.
async def async_reboot(self): """Reboot the device.""" try: async with self._client: await self._client.system.reboot() except GuardianError as err: LOGGER.error("Error while rebooting valve controller: %s", err)
[ "async", "def", "async_reboot", "(", "self", ")", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "system", ".", "reboot", "(", ")", "except", "GuardianError", "as", "err", ":", "LOGGER", ".", "error...
[ 166, 4 ]
[ 172, 75 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.async_reset_valve_diagnostics
(self)
Fully reset system motor diagnostics.
Fully reset system motor diagnostics.
async def async_reset_valve_diagnostics(self): """Fully reset system motor diagnostics.""" try: async with self._client: await self._client.valve.reset() except GuardianError as err: LOGGER.error("Error while resetting valve diagnostics: %s", err)
[ "async", "def", "async_reset_valve_diagnostics", "(", "self", ")", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "valve", ".", "reset", "(", ")", "except", "GuardianError", "as", "err", ":", "LOGGER", ...
[ 174, 4 ]
[ 180, 76 ]
python
en
['en', 'sv', 'en']
True
ValveControllerSwitch.async_unpair_sensor
(self, *, uid)
Add a new paired sensor.
Add a new paired sensor.
async def async_unpair_sensor(self, *, uid): """Add a new paired sensor.""" try: async with self._client: await self._client.sensor.unpair_sensor(uid) except GuardianError as err: LOGGER.error("Error while removing paired sensor: %s", err) retu...
[ "async", "def", "async_unpair_sensor", "(", "self", ",", "*", ",", "uid", ")", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "sensor", ".", "unpair_sensor", "(", "uid", ")", "except", "GuardianError"...
[ 182, 4 ]
[ 193, 34 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.async_upgrade_firmware
(self, *, url, port, filename)
Upgrade the device firmware.
Upgrade the device firmware.
async def async_upgrade_firmware(self, *, url, port, filename): """Upgrade the device firmware.""" try: async with self._client: await self._client.system.upgrade_firmware( url=url, port=port, filename=filename, ...
[ "async", "def", "async_upgrade_firmware", "(", "self", ",", "*", ",", "url", ",", "port", ",", "filename", ")", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "system", ".", "upgrade_firmware", "(", ...
[ 195, 4 ]
[ 205, 67 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.async_turn_off
(self, **kwargs)
Turn the valve off (closed).
Turn the valve off (closed).
async def async_turn_off(self, **kwargs) -> None: """Turn the valve off (closed).""" try: async with self._client: await self._client.valve.close() except GuardianError as err: LOGGER.error("Error while closing the valve: %s", err) return ...
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "valve", ".", "close", "(", ")", "except", "GuardianError", ...
[ 207, 4 ]
[ 217, 35 ]
python
en
['en', 'en', 'en']
True
ValveControllerSwitch.async_turn_on
(self, **kwargs)
Turn the valve on (open).
Turn the valve on (open).
async def async_turn_on(self, **kwargs) -> None: """Turn the valve on (open).""" try: async with self._client: await self._client.valve.open() except GuardianError as err: LOGGER.error("Error while opening the valve: %s", err) return s...
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "try", ":", "async", "with", "self", ".", "_client", ":", "await", "self", ".", "_client", ".", "valve", ".", "open", "(", ")", "except", "GuardianError", ...
[ 219, 4 ]
[ 229, 35 ]
python
en
['en', 'fi', 'en']
True
discover_mysensors_platform
(hass, hass_config, platform, new_devices)
Discover a MySensors platform.
Discover a MySensors platform.
def discover_mysensors_platform(hass, hass_config, platform, new_devices): """Discover a MySensors platform.""" task = hass.async_create_task( discovery.async_load_platform( hass, platform, DOMAIN, {ATTR_DEVICES: new_devices, CONF_NAME: DOMAIN}, ...
[ "def", "discover_mysensors_platform", "(", "hass", ",", "hass_config", ",", "platform", ",", "new_devices", ")", ":", "task", "=", "hass", ".", "async_create_task", "(", "discovery", ".", "async_load_platform", "(", "hass", ",", "platform", ",", "DOMAIN", ",", ...
[ 19, 0 ]
[ 30, 15 ]
python
en
['en', 'da', 'en']
True
default_schema
(gateway, child, value_type_name)
Return a default validation schema for value types.
Return a default validation schema for value types.
def default_schema(gateway, child, value_type_name): """Return a default validation schema for value types.""" schema = {value_type_name: cv.string} return get_child_schema(gateway, child, value_type_name, schema)
[ "def", "default_schema", "(", "gateway", ",", "child", ",", "value_type_name", ")", ":", "schema", "=", "{", "value_type_name", ":", "cv", ".", "string", "}", "return", "get_child_schema", "(", "gateway", ",", "child", ",", "value_type_name", ",", "schema", ...
[ 33, 0 ]
[ 36, 68 ]
python
en
['en', 'de', 'en']
True
light_dimmer_schema
(gateway, child, value_type_name)
Return a validation schema for V_DIMMER.
Return a validation schema for V_DIMMER.
def light_dimmer_schema(gateway, child, value_type_name): """Return a validation schema for V_DIMMER.""" schema = {"V_DIMMER": cv.string, "V_LIGHT": cv.string} return get_child_schema(gateway, child, value_type_name, schema)
[ "def", "light_dimmer_schema", "(", "gateway", ",", "child", ",", "value_type_name", ")", ":", "schema", "=", "{", "\"V_DIMMER\"", ":", "cv", ".", "string", ",", "\"V_LIGHT\"", ":", "cv", ".", "string", "}", "return", "get_child_schema", "(", "gateway", ",", ...
[ 40, 0 ]
[ 43, 68 ]
python
en
['en', 'da', 'en']
True
light_percentage_schema
(gateway, child, value_type_name)
Return a validation schema for V_PERCENTAGE.
Return a validation schema for V_PERCENTAGE.
def light_percentage_schema(gateway, child, value_type_name): """Return a validation schema for V_PERCENTAGE.""" schema = {"V_PERCENTAGE": cv.string, "V_STATUS": cv.string} return get_child_schema(gateway, child, value_type_name, schema)
[ "def", "light_percentage_schema", "(", "gateway", ",", "child", ",", "value_type_name", ")", ":", "schema", "=", "{", "\"V_PERCENTAGE\"", ":", "cv", ".", "string", ",", "\"V_STATUS\"", ":", "cv", ".", "string", "}", "return", "get_child_schema", "(", "gateway"...
[ 47, 0 ]
[ 50, 68 ]
python
en
['en', 'da', 'en']
True
light_rgb_schema
(gateway, child, value_type_name)
Return a validation schema for V_RGB.
Return a validation schema for V_RGB.
def light_rgb_schema(gateway, child, value_type_name): """Return a validation schema for V_RGB.""" schema = {"V_RGB": cv.string, "V_STATUS": cv.string} return get_child_schema(gateway, child, value_type_name, schema)
[ "def", "light_rgb_schema", "(", "gateway", ",", "child", ",", "value_type_name", ")", ":", "schema", "=", "{", "\"V_RGB\"", ":", "cv", ".", "string", ",", "\"V_STATUS\"", ":", "cv", ".", "string", "}", "return", "get_child_schema", "(", "gateway", ",", "ch...
[ 54, 0 ]
[ 57, 68 ]
python
en
['en', 'cy', 'en']
True
light_rgbw_schema
(gateway, child, value_type_name)
Return a validation schema for V_RGBW.
Return a validation schema for V_RGBW.
def light_rgbw_schema(gateway, child, value_type_name): """Return a validation schema for V_RGBW.""" schema = {"V_RGBW": cv.string, "V_STATUS": cv.string} return get_child_schema(gateway, child, value_type_name, schema)
[ "def", "light_rgbw_schema", "(", "gateway", ",", "child", ",", "value_type_name", ")", ":", "schema", "=", "{", "\"V_RGBW\"", ":", "cv", ".", "string", ",", "\"V_STATUS\"", ":", "cv", ".", "string", "}", "return", "get_child_schema", "(", "gateway", ",", "...
[ 61, 0 ]
[ 64, 68 ]
python
en
['en', 'cy', 'en']
True
switch_ir_send_schema
(gateway, child, value_type_name)
Return a validation schema for V_IR_SEND.
Return a validation schema for V_IR_SEND.
def switch_ir_send_schema(gateway, child, value_type_name): """Return a validation schema for V_IR_SEND.""" schema = {"V_IR_SEND": cv.string, "V_LIGHT": cv.string} return get_child_schema(gateway, child, value_type_name, schema)
[ "def", "switch_ir_send_schema", "(", "gateway", ",", "child", ",", "value_type_name", ")", ":", "schema", "=", "{", "\"V_IR_SEND\"", ":", "cv", ".", "string", ",", "\"V_LIGHT\"", ":", "cv", ".", "string", "}", "return", "get_child_schema", "(", "gateway", ",...
[ 68, 0 ]
[ 71, 68 ]
python
en
['en', 'sk', 'en']
True
get_child_schema
(gateway, child, value_type_name, schema)
Return a child schema.
Return a child schema.
def get_child_schema(gateway, child, value_type_name, schema): """Return a child schema.""" set_req = gateway.const.SetReq child_schema = child.get_schema(gateway.protocol_version) schema = child_schema.extend( { vol.Required( set_req[name].value, msg=invalid_msg(gate...
[ "def", "get_child_schema", "(", "gateway", ",", "child", ",", "value_type_name", ",", "schema", ")", ":", "set_req", "=", "gateway", ".", "const", ".", "SetReq", "child_schema", "=", "child", ".", "get_schema", "(", "gateway", ".", "protocol_version", ")", "...
[ 74, 0 ]
[ 87, 17 ]
python
en
['en', 'de', 'en']
True
invalid_msg
(gateway, child, value_type_name)
Return a message for an invalid child during schema validation.
Return a message for an invalid child during schema validation.
def invalid_msg(gateway, child, value_type_name): """Return a message for an invalid child during schema validation.""" pres = gateway.const.Presentation set_req = gateway.const.SetReq return ( f"{pres(child.type).name} requires value_type {set_req[value_type_name].name}" )
[ "def", "invalid_msg", "(", "gateway", ",", "child", ",", "value_type_name", ")", ":", "pres", "=", "gateway", ".", "const", ".", "Presentation", "set_req", "=", "gateway", ".", "const", ".", "SetReq", "return", "(", "f\"{pres(child.type).name} requires value_type ...
[ 90, 0 ]
[ 96, 5 ]
python
en
['en', 'en', 'en']
True
validate_set_msg
(msg)
Validate a set message.
Validate a set message.
def validate_set_msg(msg): """Validate a set message.""" if not validate_node(msg.gateway, msg.node_id): return {} child = msg.gateway.sensors[msg.node_id].children[msg.child_id] return validate_child(msg.gateway, msg.node_id, child, msg.sub_type)
[ "def", "validate_set_msg", "(", "msg", ")", ":", "if", "not", "validate_node", "(", "msg", ".", "gateway", ",", "msg", ".", "node_id", ")", ":", "return", "{", "}", "child", "=", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]",...
[ 99, 0 ]
[ 104, 72 ]
python
en
['en', 'en', 'en']
True
validate_node
(gateway, node_id)
Validate a node.
Validate a node.
def validate_node(gateway, node_id): """Validate a node.""" if gateway.sensors[node_id].sketch_name is None: _LOGGER.debug("Node %s is missing sketch name", node_id) return False return True
[ "def", "validate_node", "(", "gateway", ",", "node_id", ")", ":", "if", "gateway", ".", "sensors", "[", "node_id", "]", ".", "sketch_name", "is", "None", ":", "_LOGGER", ".", "debug", "(", "\"Node %s is missing sketch name\"", ",", "node_id", ")", "return", ...
[ 107, 0 ]
[ 112, 15 ]
python
en
['en', 'lb', 'pt']
False
validate_child
(gateway, node_id, child, value_type=None)
Validate a child.
Validate a child.
def validate_child(gateway, node_id, child, value_type=None): """Validate a child.""" validated = defaultdict(list) pres = gateway.const.Presentation set_req = gateway.const.SetReq child_type_name = next( (member.name for member in pres if member.value == child.type), None ) value_ty...
[ "def", "validate_child", "(", "gateway", ",", "node_id", ",", "child", ",", "value_type", "=", "None", ")", ":", "validated", "=", "defaultdict", "(", "list", ")", "pres", "=", "gateway", ".", "const", ".", "Presentation", "set_req", "=", "gateway", ".", ...
[ 115, 0 ]
[ 158, 20 ]
python
en
['it', 'en', 'en']
True
read_init
()
Read the init and extracts PyTorch, TensorFlow, SentencePiece and Tokenizers objects.
Read the init and extracts PyTorch, TensorFlow, SentencePiece and Tokenizers objects.
def read_init(): """ Read the init and extracts PyTorch, TensorFlow, SentencePiece and Tokenizers objects. """ with open(os.path.join(PATH_TO_TRANSFORMERS, "__init__.py"), "r", encoding="utf-8", newline="\n") as f: lines = f.readlines() # Get to the point we do the actual imports for type checking ...
[ "def", "read_init", "(", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "PATH_TO_TRANSFORMERS", ",", "\"__init__.py\"", ")", ",", "\"r\"", ",", "encoding", "=", "\"utf-8\"", ",", "newline", "=", "\"\\n\"", ")", "as", "f", ":", "lin...
[ 57, 0 ]
[ 94, 35 ]
python
en
['en', 'en', 'en']
True
create_dummy_object
(name, backend_name)
Create the code for the dummy object corresponding to `name`.
Create the code for the dummy object corresponding to `name`.
def create_dummy_object(name, backend_name): """ Create the code for the dummy object corresponding to `name`.""" _pretrained = [ "Config" "ForCausalLM", "ForConditionalGeneration", "ForMaskedLM", "ForMultipleChoice", "ForQuestionAnswering", "ForSequenceClassifica...
[ "def", "create_dummy_object", "(", "name", ",", "backend_name", ")", ":", "_pretrained", "=", "[", "\"Config\"", "\"ForCausalLM\"", ",", "\"ForConditionalGeneration\"", ",", "\"ForMaskedLM\"", ",", "\"ForMultipleChoice\"", ",", "\"ForQuestionAnswering\"", ",", "\"ForSeque...
[ 97, 0 ]
[ 123, 57 ]
python
en
['en', 'en', 'en']
True
create_dummy_files
()
Create the content of the dummy files.
Create the content of the dummy files.
def create_dummy_files(): """ Create the content of the dummy files. """ backend_specific_objects = read_init() # For special correspondence backend to module name as used in the function requires_modulename module_names = {"torch": "pytorch"} dummy_files = {} for backend, objects in backend_sp...
[ "def", "create_dummy_files", "(", ")", ":", "backend_specific_objects", "=", "read_init", "(", ")", "# For special correspondence backend to module name as used in the function requires_modulename", "module_names", "=", "{", "\"torch\"", ":", "\"pytorch\"", "}", "dummy_files", ...
[ 126, 0 ]
[ 140, 22 ]
python
en
['en', 'en', 'en']
True
check_dummies
(overwrite=False)
Check if the dummy files are up to date and maybe `overwrite` with the right content.
Check if the dummy files are up to date and maybe `overwrite` with the right content.
def check_dummies(overwrite=False): """ Check if the dummy files are up to date and maybe `overwrite` with the right content. """ dummy_files = create_dummy_files() # For special correspondence backend to shortcut as used in utils/dummy_xxx_objects.py short_names = {"torch": "pt"} # Locate actual d...
[ "def", "check_dummies", "(", "overwrite", "=", "False", ")", ":", "dummy_files", "=", "create_dummy_files", "(", ")", "# For special correspondence backend to shortcut as used in utils/dummy_xxx_objects.py", "short_names", "=", "{", "\"torch\"", ":", "\"pt\"", "}", "# Locat...
[ 143, 0 ]
[ 175, 17 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: dict)
Set up the NEW_NAME component.
Set up the NEW_NAME component.
async def async_setup(hass: HomeAssistant, config: dict): """Set up the NEW_NAME component.""" hass.data[DOMAIN] = {} if DOMAIN not in config: return True config_flow.OAuth2FlowHandler.async_register_implementation( hass, config_entry_oauth2_flow.LocalOAuth2Implementation( ...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "dict", ")", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "config_flow", ".", "OAuth2Flo...
[ 34, 0 ]
[ 53, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up NEW_NAME from a config entry.
Set up NEW_NAME from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up NEW_NAME from a config entry.""" implementation = ( await config_entry_oauth2_flow.async_get_config_entry_implementation( hass, entry ) ) session = config_entry_oauth2_flow.OAuth2Session(hass, en...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "implementation", "=", "(", "await", "config_entry_oauth2_flow", ".", "async_get_config_entry_implementation", "(", "hass", ",", "entry", ")", ")", ...
[ 56, 0 ]
[ 79, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" unload_ok = all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component) for component in PLATFORMS ] ) ...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "unload_ok", "=", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload...
[ 82, 0 ]
[ 95, 20 ]
python
en
['en', 'es', 'en']
True
MsgDispatcher.handle_initialize
(self, data)
Data is search space
Data is search space
def handle_initialize(self, data): """Data is search space """ self.tuner.update_search_space(data) send(CommandType.Initialized, '')
[ "def", "handle_initialize", "(", "self", ",", "data", ")", ":", "self", ".", "tuner", ".", "update_search_space", "(", "data", ")", "send", "(", "CommandType", ".", "Initialized", ",", "''", ")" ]
[ 85, 4 ]
[ 89, 41 ]
python
en
['en', 'en', 'en']
True
MsgDispatcher.send_trial_callback
(self, id_, params)
For tuner to issue trial config when the config is generated
For tuner to issue trial config when the config is generated
def send_trial_callback(self, id_, params): """For tuner to issue trial config when the config is generated """ send(CommandType.NewTrialJob, _pack_parameter(id_, params))
[ "def", "send_trial_callback", "(", "self", ",", "id_", ",", "params", ")", ":", "send", "(", "CommandType", ".", "NewTrialJob", ",", "_pack_parameter", "(", "id_", ",", "params", ")", ")" ]
[ 91, 4 ]
[ 94, 67 ]
python
en
['en', 'en', 'en']
True
MsgDispatcher.handle_import_data
(self, data)
Import additional data for tuning data: a list of dictionaries, each of which has at least two keys, 'parameter' and 'value'
Import additional data for tuning data: a list of dictionaries, each of which has at least two keys, 'parameter' and 'value'
def handle_import_data(self, data): """Import additional data for tuning data: a list of dictionaries, each of which has at least two keys, 'parameter' and 'value' """ for entry in data: entry['value'] = entry['value'] if type(entry['value']) is str else json_tricks.dumps(ent...
[ "def", "handle_import_data", "(", "self", ",", "data", ")", ":", "for", "entry", "in", "data", ":", "entry", "[", "'value'", "]", "=", "entry", "[", "'value'", "]", "if", "type", "(", "entry", "[", "'value'", "]", ")", "is", "str", "else", "json_tric...
[ 111, 4 ]
[ 118, 36 ]
python
en
['en', 'en', 'en']
True
MsgDispatcher.handle_report_metric_data
(self, data)
data: a dict received from nni_manager, which contains: - 'parameter_id': id of the trial - 'value': metric value reported by nni.report_final_result() - 'type': report type, support {'FINAL', 'PERIODICAL'}
data: a dict received from nni_manager, which contains: - 'parameter_id': id of the trial - 'value': metric value reported by nni.report_final_result() - 'type': report type, support {'FINAL', 'PERIODICAL'}
def handle_report_metric_data(self, data): """ data: a dict received from nni_manager, which contains: - 'parameter_id': id of the trial - 'value': metric value reported by nni.report_final_result() - 'type': report type, support {'FINAL', 'PERIODICAL'} ...
[ "def", "handle_report_metric_data", "(", "self", ",", "data", ")", ":", "# metrics value is dumped as json string in trial, so we need to decode it here", "if", "'value'", "in", "data", ":", "data", "[", "'value'", "]", "=", "json_tricks", ".", "loads", "(", "data", "...
[ 125, 4 ]
[ 152, 80 ]
python
en
['en', 'error', 'th']
False
MsgDispatcher.handle_trial_end
(self, data)
data: it has three keys: trial_job_id, event, hyper_params - trial_job_id: the id generated by training service - event: the job's state - hyper_params: the hyperparameters generated and returned by tuner
data: it has three keys: trial_job_id, event, hyper_params - trial_job_id: the id generated by training service - event: the job's state - hyper_params: the hyperparameters generated and returned by tuner
def handle_trial_end(self, data): """ data: it has three keys: trial_job_id, event, hyper_params - trial_job_id: the id generated by training service - event: the job's state - hyper_params: the hyperparameters generated and returned by tuner """ tr...
[ "def", "handle_trial_end", "(", "self", ",", "data", ")", ":", "trial_job_id", "=", "data", "[", "'trial_job_id'", "]", "_ended_trials", ".", "add", "(", "trial_job_id", ")", "if", "trial_job_id", "in", "_trial_history", ":", "_trial_history", ".", "pop", "(",...
[ 154, 4 ]
[ 168, 119 ]
python
en
['en', 'error', 'th']
False
MsgDispatcher._handle_final_metric_data
(self, data)
Call tuner to process final results
Call tuner to process final results
def _handle_final_metric_data(self, data): """Call tuner to process final results """ id_ = data['parameter_id'] value = data['value'] if id_ is None or id_ in _customized_parameter_ids: if not hasattr(self.tuner, '_accept_customized'): self.tuner._acc...
[ "def", "_handle_final_metric_data", "(", "self", ",", "data", ")", ":", "id_", "=", "data", "[", "'parameter_id'", "]", "value", "=", "data", "[", "'value'", "]", "if", "id_", "is", "None", "or", "id_", "in", "_customized_parameter_ids", ":", "if", "not", ...
[ 170, 4 ]
[ 188, 112 ]
python
en
['en', 'en', 'en']
True
MsgDispatcher._handle_intermediate_metric_data
(self, data)
Call assessor to process intermediate results
Call assessor to process intermediate results
def _handle_intermediate_metric_data(self, data): """Call assessor to process intermediate results """ if data['type'] != MetricType.PERIODICAL: return if self.assessor is None: return trial_job_id = data['trial_job_id'] if trial_job_id in _ended_...
[ "def", "_handle_intermediate_metric_data", "(", "self", ",", "data", ")", ":", "if", "data", "[", "'type'", "]", "!=", "MetricType", ".", "PERIODICAL", ":", "return", "if", "self", ".", "assessor", "is", "None", ":", "return", "trial_job_id", "=", "data", ...
[ 190, 4 ]
[ 229, 33 ]
python
en
['en', 'en', 'en']
True
MsgDispatcher._earlystop_notify_tuner
(self, data)
Send last intermediate result as final result to tuner in case the trial is early stopped.
Send last intermediate result as final result to tuner in case the trial is early stopped.
def _earlystop_notify_tuner(self, data): """Send last intermediate result as final result to tuner in case the trial is early stopped. """ _logger.debug('Early stop notify tuner data: [%s]', data) data['type'] = MetricType.FINAL if multi_thread_enabled(): self...
[ "def", "_earlystop_notify_tuner", "(", "self", ",", "data", ")", ":", "_logger", ".", "debug", "(", "'Early stop notify tuner data: [%s]'", ",", "data", ")", "data", "[", "'type'", "]", "=", "MetricType", ".", "FINAL", "if", "multi_thread_enabled", "(", ")", "...
[ 231, 4 ]
[ 241, 68 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up a Logi Circle Camera. Obsolete.
Set up a Logi Circle Camera. Obsolete.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up a Logi Circle Camera. Obsolete.""" _LOGGER.warning("Logi Circle no longer works with camera platform configuration")
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "_LOGGER", ".", "warning", "(", "\"Logi Circle no longer works with camera platform configuration\"", ")" ]
[ 31, 0 ]
[ 33, 85 ]
python
en
['en', 'jv', 'en']
True
async_setup_entry
(hass, entry, async_add_entities)
Set up a Logi Circle Camera based on a config entry.
Set up a Logi Circle Camera based on a config entry.
async def async_setup_entry(hass, entry, async_add_entities): """Set up a Logi Circle Camera based on a config entry.""" devices = await hass.data[LOGI_CIRCLE_DOMAIN].cameras ffmpeg = hass.data[DATA_FFMPEG] cameras = [LogiCam(device, entry, ffmpeg) for device in devices] async_add_entities(cameras...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ",", "async_add_entities", ")", ":", "devices", "=", "await", "hass", ".", "data", "[", "LOGI_CIRCLE_DOMAIN", "]", ".", "cameras", "ffmpeg", "=", "hass", ".", "data", "[", "DATA_FFMPEG", "]", ...
[ 36, 0 ]
[ 43, 37 ]
python
en
['en', 'zu', 'en']
True
LogiCam.__init__
(self, camera, device_info, ffmpeg)
Initialize Logi Circle camera.
Initialize Logi Circle camera.
def __init__(self, camera, device_info, ffmpeg): """Initialize Logi Circle camera.""" super().__init__() self._camera = camera self._name = self._camera.name self._id = self._camera.mac_address self._has_battery = self._camera.supports_feature("battery_level") sel...
[ "def", "__init__", "(", "self", ",", "camera", ",", "device_info", ",", "ffmpeg", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "_camera", "=", "camera", "self", ".", "_name", "=", "self", ".", "_camera", ".", "name", "self", ...
[ 49, 4 ]
[ 57, 28 ]
python
co
['en', 'co', 'it']
False
LogiCam.async_added_to_hass
(self)
Connect camera methods to signals.
Connect camera methods to signals.
async def async_added_to_hass(self): """Connect camera methods to signals.""" def _dispatch_proxy(method): """Expand parameters & filter entity IDs.""" async def _call(params): entity_ids = params.get(ATTR_ENTITY_ID) filtered_params = { ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "def", "_dispatch_proxy", "(", "method", ")", ":", "\"\"\"Expand parameters & filter entity IDs.\"\"\"", "async", "def", "_call", "(", "params", ")", ":", "entity_ids", "=", "params", ".", "get", "(", ...
[ 59, 4 ]
[ 93, 9 ]
python
en
['en', 'en', 'en']
True
LogiCam.async_will_remove_from_hass
(self)
Disconnect dispatcher listeners when removed.
Disconnect dispatcher listeners when removed.
async def async_will_remove_from_hass(self): """Disconnect dispatcher listeners when removed.""" for detach in self._listeners: detach()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", ":", "for", "detach", "in", "self", ".", "_listeners", ":", "detach", "(", ")" ]
[ 95, 4 ]
[ 98, 20 ]
python
en
['en', 'en', 'en']
True
LogiCam.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_id" ]
[ 101, 4 ]
[ 103, 23 ]
python
ca
['fr', 'ca', 'en']
False
LogiCam.name
(self)
Return the name of this camera.
Return the name of this camera.
def name(self): """Return the name of this camera.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 106, 4 ]
[ 108, 25 ]
python
en
['en', 'en', 'en']
True
LogiCam.supported_features
(self)
Logi Circle camera's support turning on and off ("soft" switch).
Logi Circle camera's support turning on and off ("soft" switch).
def supported_features(self): """Logi Circle camera's support turning on and off ("soft" switch).""" return SUPPORT_ON_OFF
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_ON_OFF" ]
[ 111, 4 ]
[ 113, 29 ]
python
en
['en', 'en', 'en']
True
LogiCam.device_info
(self)
Return information about the device.
Return information about the device.
def device_info(self): """Return information about the device.""" return { "name": self._camera.name, "identifiers": {(LOGI_CIRCLE_DOMAIN, self._camera.id)}, "model": self._camera.model_name, "sw_version": self._camera.firmware, "manufacturer":...
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"name\"", ":", "self", ".", "_camera", ".", "name", ",", "\"identifiers\"", ":", "{", "(", "LOGI_CIRCLE_DOMAIN", ",", "self", ".", "_camera", ".", "id", ")", "}", ",", "\"model\"", ":", "sel...
[ 116, 4 ]
[ 124, 9 ]
python
en
['en', 'en', 'en']
True
LogiCam.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" state = { ATTR_ATTRIBUTION: ATTRIBUTION, "battery_saving_mode": ( STATE_ON if self._camera.battery_saving else STATE_OFF ), "microphone_gain": self._camera.microphone_gai...
[ "def", "device_state_attributes", "(", "self", ")", ":", "state", "=", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", ",", "\"battery_saving_mode\"", ":", "(", "STATE_ON", "if", "self", ".", "_camera", ".", "battery_saving", "else", "STATE_OFF", ")", ",", "\"micro...
[ 127, 4 ]
[ 142, 20 ]
python
en
['en', 'en', 'en']
True
LogiCam.async_camera_image
(self)
Return a still image from the camera.
Return a still image from the camera.
async def async_camera_image(self): """Return a still image from the camera.""" return await self._camera.live_stream.download_jpeg()
[ "async", "def", "async_camera_image", "(", "self", ")", ":", "return", "await", "self", ".", "_camera", ".", "live_stream", ".", "download_jpeg", "(", ")" ]
[ 144, 4 ]
[ 146, 61 ]
python
en
['en', 'en', 'en']
True
LogiCam.async_turn_off
(self)
Disable streaming mode for this camera.
Disable streaming mode for this camera.
async def async_turn_off(self): """Disable streaming mode for this camera.""" await self._camera.set_config("streaming", False)
[ "async", "def", "async_turn_off", "(", "self", ")", ":", "await", "self", ".", "_camera", ".", "set_config", "(", "\"streaming\"", ",", "False", ")" ]
[ 148, 4 ]
[ 150, 57 ]
python
en
['en', 'en', 'en']
True
LogiCam.async_turn_on
(self)
Enable streaming mode for this camera.
Enable streaming mode for this camera.
async def async_turn_on(self): """Enable streaming mode for this camera.""" await self._camera.set_config("streaming", True)
[ "async", "def", "async_turn_on", "(", "self", ")", ":", "await", "self", ".", "_camera", ".", "set_config", "(", "\"streaming\"", ",", "True", ")" ]
[ 152, 4 ]
[ 154, 56 ]
python
en
['en', 'en', 'en']
True
LogiCam.should_poll
(self)
Update the image periodically.
Update the image periodically.
def should_poll(self): """Update the image periodically.""" return True
[ "def", "should_poll", "(", "self", ")", ":", "return", "True" ]
[ 157, 4 ]
[ 159, 19 ]
python
en
['en', 'en', 'en']
True
LogiCam.set_config
(self, mode, value)
Set an configuration property for the target camera.
Set an configuration property for the target camera.
async def set_config(self, mode, value): """Set an configuration property for the target camera.""" if mode == LED_MODE_KEY: await self._camera.set_config("led", value) if mode == RECORDING_MODE_KEY: await self._camera.set_config("recording_disabled", not value)
[ "async", "def", "set_config", "(", "self", ",", "mode", ",", "value", ")", ":", "if", "mode", "==", "LED_MODE_KEY", ":", "await", "self", ".", "_camera", ".", "set_config", "(", "\"led\"", ",", "value", ")", "if", "mode", "==", "RECORDING_MODE_KEY", ":",...
[ 161, 4 ]
[ 166, 74 ]
python
en
['en', 'en', 'en']
True
LogiCam.download_livestream
(self, filename, duration)
Download a recording from the camera's livestream.
Download a recording from the camera's livestream.
async def download_livestream(self, filename, duration): """Download a recording from the camera's livestream.""" # Render filename from template. filename.hass = self.hass stream_file = filename.async_render(variables={ATTR_ENTITY_ID: self.entity_id}) # Respect configured allow...
[ "async", "def", "download_livestream", "(", "self", ",", "filename", ",", "duration", ")", ":", "# Render filename from template.", "filename", ".", "hass", "=", "self", ".", "hass", "stream_file", "=", "filename", ".", "async_render", "(", "variables", "=", "{"...
[ 168, 4 ]
[ 183, 9 ]
python
en
['en', 'en', 'en']
True
LogiCam.livestream_snapshot
(self, filename)
Download a still frame from the camera's livestream.
Download a still frame from the camera's livestream.
async def livestream_snapshot(self, filename): """Download a still frame from the camera's livestream.""" # Render filename from template. filename.hass = self.hass snapshot_file = filename.async_render( variables={ATTR_ENTITY_ID: self.entity_id} ) # Respect ...
[ "async", "def", "livestream_snapshot", "(", "self", ",", "filename", ")", ":", "# Render filename from template.", "filename", ".", "hass", "=", "self", ".", "hass", "snapshot_file", "=", "filename", ".", "async_render", "(", "variables", "=", "{", "ATTR_ENTITY_ID...
[ 185, 4 ]
[ 200, 9 ]
python
en
['en', 'en', 'en']
True
LogiCam.async_update
(self)
Update camera entity and refresh attributes.
Update camera entity and refresh attributes.
async def async_update(self): """Update camera entity and refresh attributes.""" await self._camera.update()
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "_camera", ".", "update", "(", ")" ]
[ 202, 4 ]
[ 204, 35 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_devices, discovery_info=None)
Set up the Sterling Bank sensor platform.
Set up the Sterling Bank sensor platform.
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Sterling Bank sensor platform.""" sensors = [] for account in config[CONF_ACCOUNTS]: try: starling_account = StarlingAccount( account[CONF_ACCESS_TOKEN], sandbox=account[CONF_SANDBOX] ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_devices", ",", "discovery_info", "=", "None", ")", ":", "sensors", "=", "[", "]", "for", "account", "in", "config", "[", "CONF_ACCOUNTS", "]", ":", "try", ":", "starling_account", "=", "Starlin...
[ 41, 0 ]
[ 61, 30 ]
python
en
['en', 'da', 'en']
True
StarlingBalanceSensor.__init__
(self, starling_account, account_name, balance_data_type)
Initialize the sensor.
Initialize the sensor.
def __init__(self, starling_account, account_name, balance_data_type): """Initialize the sensor.""" self._starling_account = starling_account self._balance_data_type = balance_data_type self._state = None self._account_name = account_name
[ "def", "__init__", "(", "self", ",", "starling_account", ",", "account_name", ",", "balance_data_type", ")", ":", "self", ".", "_starling_account", "=", "starling_account", "self", ".", "_balance_data_type", "=", "balance_data_type", "self", ".", "_state", "=", "N...
[ 67, 4 ]
[ 72, 41 ]
python
en
['en', 'en', 'en']
True
StarlingBalanceSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return "{} {}".format( self._account_name, self._balance_data_type.replace("_", " ").capitalize() )
[ "def", "name", "(", "self", ")", ":", "return", "\"{} {}\"", ".", "format", "(", "self", ".", "_account_name", ",", "self", ".", "_balance_data_type", ".", "replace", "(", "\"_\"", ",", "\" \"", ")", ".", "capitalize", "(", ")", ")" ]
[ 75, 4 ]
[ 79, 9 ]
python
en
['en', 'mi', 'en']
True
StarlingBalanceSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self): """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 82, 4 ]
[ 84, 26 ]
python
en
['en', 'en', 'en']
True
StarlingBalanceSensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return self._starling_account.currency
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_starling_account", ".", "currency" ]
[ 87, 4 ]
[ 89, 46 ]
python
en
['en', 'la', 'en']
True
StarlingBalanceSensor.icon
(self)
Return the entity icon.
Return the entity icon.
def icon(self): """Return the entity icon.""" return ICON
[ "def", "icon", "(", "self", ")", ":", "return", "ICON" ]
[ 92, 4 ]
[ 94, 19 ]
python
en
['en', 'cy', 'en']
True
StarlingBalanceSensor.update
(self)
Fetch new state data for the sensor.
Fetch new state data for the sensor.
def update(self): """Fetch new state data for the sensor.""" self._starling_account.update_balance_data() if self._balance_data_type == "cleared_balance": self._state = self._starling_account.cleared_balance / 100 elif self._balance_data_type == "effective_balance": ...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_starling_account", ".", "update_balance_data", "(", ")", "if", "self", ".", "_balance_data_type", "==", "\"cleared_balance\"", ":", "self", ".", "_state", "=", "self", ".", "_starling_account", ".", "clear...
[ 96, 4 ]
[ 102, 72 ]
python
en
['en', 'en', 'en']
True
set_seed
(seed: int)
Helper function for reproducible behavior to set the seed in ``random``, ``numpy``, ``torch`` and/or ``tf`` (if installed). Args: seed (:obj:`int`): The seed to set.
Helper function for reproducible behavior to set the seed in ``random``, ``numpy``, ``torch`` and/or ``tf`` (if installed).
def set_seed(seed: int): """ Helper function for reproducible behavior to set the seed in ``random``, ``numpy``, ``torch`` and/or ``tf`` (if installed). Args: seed (:obj:`int`): The seed to set. """ random.seed(seed) np.random.seed(seed) if is_torch_available(): torch.ma...
[ "def", "set_seed", "(", "seed", ":", "int", ")", ":", "random", ".", "seed", "(", "seed", ")", "np", ".", "random", ".", "seed", "(", "seed", ")", "if", "is_torch_available", "(", ")", ":", "torch", ".", "manual_seed", "(", "seed", ")", "torch", "....
[ 48, 0 ]
[ 63, 32 ]
python
en
['en', 'error', 'th']
False
default_compute_objective
(metrics: Dict[str, float])
The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise. Args: metrics (:obj:`Dict[str, float]`): The metrics returned by the evaluate method. R...
The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise.
def default_compute_objective(metrics: Dict[str, float]) -> float: """ The default objective to maximize/minimize when doing an hyperparameter search. It is the evaluation loss if no metrics are provided to the :class:`~transformers.Trainer`, the sum of all metrics otherwise. Args: metrics (:ob...
[ "def", "default_compute_objective", "(", "metrics", ":", "Dict", "[", "str", ",", "float", "]", ")", "->", "float", ":", "metrics", "=", "copy", ".", "deepcopy", "(", "metrics", ")", "loss", "=", "metrics", ".", "pop", "(", "\"eval_loss\"", ",", "None", ...
[ 138, 0 ]
[ 156, 63 ]
python
en
['en', 'error', 'th']
False
is_main_process
(local_rank)
Whether or not the current process is the local process, based on `xm.get_ordinal()` (for TPUs) first, then on `local_rank`.
Whether or not the current process is the local process, based on `xm.get_ordinal()` (for TPUs) first, then on `local_rank`.
def is_main_process(local_rank): """ Whether or not the current process is the local process, based on `xm.get_ordinal()` (for TPUs) first, then on `local_rank`. """ if is_torch_tpu_available(): import torch_xla.core.xla_model as xm return xm.get_ordinal() == 0 return local_rank...
[ "def", "is_main_process", "(", "local_rank", ")", ":", "if", "is_torch_tpu_available", "(", ")", ":", "import", "torch_xla", ".", "core", ".", "xla_model", "as", "xm", "return", "xm", ".", "get_ordinal", "(", ")", "==", "0", "return", "local_rank", "in", "...
[ 196, 0 ]
[ 205, 32 ]
python
en
['en', 'error', 'th']
False
total_processes_number
(local_rank)
Return the number of processes launched in parallel. Works with `torch.distributed` and TPUs.
Return the number of processes launched in parallel. Works with `torch.distributed` and TPUs.
def total_processes_number(local_rank): """ Return the number of processes launched in parallel. Works with `torch.distributed` and TPUs. """ if is_torch_tpu_available(): import torch_xla.core.xla_model as xm return xm.xrt_world_size() elif is_sagemaker_distributed_available(): ...
[ "def", "total_processes_number", "(", "local_rank", ")", ":", "if", "is_torch_tpu_available", "(", ")", ":", "import", "torch_xla", ".", "core", ".", "xla_model", "as", "xm", "return", "xm", ".", "xrt_world_size", "(", ")", "elif", "is_sagemaker_distributed_availa...
[ 208, 0 ]
[ 224, 12 ]
python
en
['en', 'error', 'th']
False
speed_metrics
(split, start_time, num_samples=None)
Measure and return speed performance metrics. This function requires a time snapshot `start_time` before the operation to be measured starts and this function should be run immediately after the operation to be measured has completed. Args: - split: name to prefix metric (like train, eval, test....
Measure and return speed performance metrics.
def speed_metrics(split, start_time, num_samples=None): """ Measure and return speed performance metrics. This function requires a time snapshot `start_time` before the operation to be measured starts and this function should be run immediately after the operation to be measured has completed. Arg...
[ "def", "speed_metrics", "(", "split", ",", "start_time", ",", "num_samples", "=", "None", ")", ":", "runtime", "=", "time", ".", "time", "(", ")", "-", "start_time", "result", "=", "{", "f\"{split}_runtime\"", ":", "round", "(", "runtime", ",", "4", ")",...
[ 227, 0 ]
[ 245, 17 ]
python
en
['en', 'error', 'th']
False
denumpify_detensorize
(metrics)
Recursively calls `.item()` on the element of the dictionary passed
Recursively calls `.item()` on the element of the dictionary passed
def denumpify_detensorize(metrics): """ Recursively calls `.item()` on the element of the dictionary passed """ if isinstance(metrics, (list, tuple)): return type(metrics)(denumpify_detensorize(m) for m in metrics) elif isinstance(metrics, dict): return type(metrics)({k: denumpify_de...
[ "def", "denumpify_detensorize", "(", "metrics", ")", ":", "if", "isinstance", "(", "metrics", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "type", "(", "metrics", ")", "(", "denumpify_detensorize", "(", "m", ")", "for", "m", "in", "metrics", ...
[ 445, 0 ]
[ 457, 18 ]
python
en
['en', 'error', 'th']
False
TrainerMemoryTracker.derive_stage
(self)
derives the stage/caller name automatically
derives the stage/caller name automatically
def derive_stage(self): """ derives the stage/caller name automatically """ caller = inspect.currentframe().f_back.f_back.f_code.co_name if caller in self.stages: return self.stages[caller] else: raise ValueError( f"was called from {caller}, but on...
[ "def", "derive_stage", "(", "self", ")", ":", "caller", "=", "inspect", ".", "currentframe", "(", ")", ".", "f_back", ".", "f_back", ".", "f_code", ".", "co_name", "if", "caller", "in", "self", ".", "stages", ":", "return", "self", ".", "stages", "[", ...
[ 314, 4 ]
[ 322, 13 ]
python
en
['en', 'en', 'en']
True
TrainerMemoryTracker.cpu_mem_used
(self)
get resident set size memory for the current process
get resident set size memory for the current process
def cpu_mem_used(self): """ get resident set size memory for the current process """ return self.process.memory_info().rss
[ "def", "cpu_mem_used", "(", "self", ")", ":", "return", "self", ".", "process", ".", "memory_info", "(", ")", ".", "rss" ]
[ 324, 4 ]
[ 326, 45 ]
python
en
['en', 'en', 'en']
True
TrainerMemoryTracker.start
(self)
start tracking for the caller's stage
start tracking for the caller's stage
def start(self): """ start tracking for the caller's stage """ if self.skip_memory_metrics: return stage = self.derive_stage() # deal with nested calls of eval during train - simply ignore those if self.cur_stage is not None and self.cur_stage != stage: r...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "skip_memory_metrics", ":", "return", "stage", "=", "self", ".", "derive_stage", "(", ")", "# deal with nested calls of eval during train - simply ignore those", "if", "self", ".", "cur_stage", "is", "not", ...
[ 340, 4 ]
[ 368, 35 ]
python
en
['en', 'en', 'en']
True
TrainerMemoryTracker.stop
(self, stage)
stop tracking for the passed stage
stop tracking for the passed stage
def stop(self, stage): """ stop tracking for the passed stage """ # deal with nested calls of eval during train - simply ignore those if self.cur_stage is not None and self.cur_stage != stage: return # this sends a signal to peak_monitor_func to complete its loop se...
[ "def", "stop", "(", "self", ",", "stage", ")", ":", "# deal with nested calls of eval during train - simply ignore those", "if", "self", ".", "cur_stage", "is", "not", "None", "and", "self", ".", "cur_stage", "!=", "stage", ":", "return", "# this sends a signal to pea...
[ 370, 4 ]
[ 408, 29 ]
python
en
['en', 'en', 'en']
True
TrainerMemoryTracker.update_metrics
(self, stage, metrics)
stop tracking for the passed stage
stop tracking for the passed stage
def update_metrics(self, stage, metrics): """ stop tracking for the passed stage """ if self.skip_memory_metrics: return # deal with nested calls of eval during train - simply ignore those if self.cur_stage is not None and self.cur_stage != stage: return ...
[ "def", "update_metrics", "(", "self", ",", "stage", ",", "metrics", ")", ":", "if", "self", ".", "skip_memory_metrics", ":", "return", "# deal with nested calls of eval during train - simply ignore those", "if", "self", ".", "cur_stage", "is", "not", "None", "and", ...
[ 410, 4 ]
[ 430, 78 ]
python
en
['en', 'en', 'en']
True
TrainerMemoryTracker.stop_and_update_metrics
(self, metrics=None)
combine stop + update in one call for simpler code
combine stop + update in one call for simpler code
def stop_and_update_metrics(self, metrics=None): """ combine stop + update in one call for simpler code """ if self.skip_memory_metrics: return stage = self.derive_stage() self.stop(stage) # init doesn't have metrics to update so we just save that data for later sta...
[ "def", "stop_and_update_metrics", "(", "self", ",", "metrics", "=", "None", ")", ":", "if", "self", ".", "skip_memory_metrics", ":", "return", "stage", "=", "self", ".", "derive_stage", "(", ")", "self", ".", "stop", "(", "stage", ")", "# init doesn't have m...
[ 432, 4 ]
[ 442, 47 ]
python
en
['en', 'en', 'en']
True
test_doorsense
(hass)
Test creation of a lock with doorsense and bridge.
Test creation of a lock with doorsense and bridge.
async def test_doorsense(hass): """Test creation of a lock with doorsense and bridge.""" lock_one = await _mock_lock_from_fixture( hass, "get_lock.online_with_doorsense.json" ) await _create_august_with_devices(hass, [lock_one]) binary_sensor_online_with_doorsense_name = hass.states.get( ...
[ "async", "def", "test_doorsense", "(", "hass", ")", ":", "lock_one", "=", "await", "_mock_lock_from_fixture", "(", "hass", ",", "\"get_lock.online_with_doorsense.json\"", ")", "await", "_create_august_with_devices", "(", "hass", ",", "[", "lock_one", "]", ")", "bina...
[ 20, 0 ]
[ 51, 70 ]
python
en
['en', 'en', 'en']
True