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
test_as_utc_with_local_object
()
Test the UTC time with local object.
Test the UTC time with local object.
def test_as_utc_with_local_object(): """Test the UTC time with local object.""" dt_util.set_default_time_zone(dt_util.get_time_zone(TEST_TIME_ZONE)) localnow = dt_util.now() utcnow = dt_util.as_utc(localnow) assert localnow == utcnow assert localnow.tzinfo != utcnow.tzinfo
[ "def", "test_as_utc_with_local_object", "(", ")", ":", "dt_util", ".", "set_default_time_zone", "(", "dt_util", ".", "get_time_zone", "(", "TEST_TIME_ZONE", ")", ")", "localnow", "=", "dt_util", ".", "now", "(", ")", "utcnow", "=", "dt_util", ".", "as_utc", "(...
[ 71, 0 ]
[ 78, 43 ]
python
en
['en', 'en', 'en']
True
test_as_local_with_naive_object
()
Test local time with native object.
Test local time with native object.
def test_as_local_with_naive_object(): """Test local time with native object.""" now = dt_util.now() assert abs(now - dt_util.as_local(datetime.utcnow())) < timedelta(seconds=1)
[ "def", "test_as_local_with_naive_object", "(", ")", ":", "now", "=", "dt_util", ".", "now", "(", ")", "assert", "abs", "(", "now", "-", "dt_util", ".", "as_local", "(", "datetime", ".", "utcnow", "(", ")", ")", ")", "<", "timedelta", "(", "seconds", "=...
[ 81, 0 ]
[ 84, 80 ]
python
en
['en', 'en', 'en']
True
test_as_local_with_local_object
()
Test local with local object.
Test local with local object.
def test_as_local_with_local_object(): """Test local with local object.""" now = dt_util.now() assert now == now
[ "def", "test_as_local_with_local_object", "(", ")", ":", "now", "=", "dt_util", ".", "now", "(", ")", "assert", "now", "==", "now" ]
[ 87, 0 ]
[ 90, 21 ]
python
en
['en', 'en', 'en']
True
test_as_local_with_utc_object
()
Test local time with UTC object.
Test local time with UTC object.
def test_as_local_with_utc_object(): """Test local time with UTC object.""" dt_util.set_default_time_zone(dt_util.get_time_zone(TEST_TIME_ZONE)) utcnow = dt_util.utcnow() localnow = dt_util.as_local(utcnow) assert localnow == utcnow assert localnow.tzinfo != utcnow.tzinfo
[ "def", "test_as_local_with_utc_object", "(", ")", ":", "dt_util", ".", "set_default_time_zone", "(", "dt_util", ".", "get_time_zone", "(", "TEST_TIME_ZONE", ")", ")", "utcnow", "=", "dt_util", ".", "utcnow", "(", ")", "localnow", "=", "dt_util", ".", "as_local",...
[ 93, 0 ]
[ 101, 43 ]
python
en
['en', 'en', 'en']
True
test_utc_from_timestamp
()
Test utc_from_timestamp method.
Test utc_from_timestamp method.
def test_utc_from_timestamp(): """Test utc_from_timestamp method.""" assert datetime(1986, 7, 9, tzinfo=dt_util.UTC) == dt_util.utc_from_timestamp( 521251200 )
[ "def", "test_utc_from_timestamp", "(", ")", ":", "assert", "datetime", "(", "1986", ",", "7", ",", "9", ",", "tzinfo", "=", "dt_util", ".", "UTC", ")", "==", "dt_util", ".", "utc_from_timestamp", "(", "521251200", ")" ]
[ 104, 0 ]
[ 108, 5 ]
python
en
['en', 'jv', 'en']
True
test_as_timestamp
()
Test as_timestamp method.
Test as_timestamp method.
def test_as_timestamp(): """Test as_timestamp method.""" ts = 1462401234 utc_dt = dt_util.utc_from_timestamp(ts) assert ts == dt_util.as_timestamp(utc_dt) utc_iso = utc_dt.isoformat() assert ts == dt_util.as_timestamp(utc_iso) # confirm the ability to handle a string passed in delta = d...
[ "def", "test_as_timestamp", "(", ")", ":", "ts", "=", "1462401234", "utc_dt", "=", "dt_util", ".", "utc_from_timestamp", "(", "ts", ")", "assert", "ts", "==", "dt_util", ".", "as_timestamp", "(", "utc_dt", ")", "utc_iso", "=", "utc_dt", ".", "isoformat", "...
[ 111, 0 ]
[ 122, 21 ]
python
en
['et', 'jv', 'en']
False
test_parse_datetime_converts_correctly
()
Test parse_datetime converts strings.
Test parse_datetime converts strings.
def test_parse_datetime_converts_correctly(): """Test parse_datetime converts strings.""" assert datetime(1986, 7, 9, 12, 0, 0, tzinfo=dt_util.UTC) == dt_util.parse_datetime( "1986-07-09T12:00:00Z" ) utcnow = dt_util.utcnow() assert utcnow == dt_util.parse_datetime(utcnow.isoformat())
[ "def", "test_parse_datetime_converts_correctly", "(", ")", ":", "assert", "datetime", "(", "1986", ",", "7", ",", "9", ",", "12", ",", "0", ",", "0", ",", "tzinfo", "=", "dt_util", ".", "UTC", ")", "==", "dt_util", ".", "parse_datetime", "(", "\"1986-07-...
[ 125, 0 ]
[ 133, 63 ]
python
en
['fr', 'en', 'en']
True
test_parse_datetime_returns_none_for_incorrect_format
()
Test parse_datetime returns None if incorrect format.
Test parse_datetime returns None if incorrect format.
def test_parse_datetime_returns_none_for_incorrect_format(): """Test parse_datetime returns None if incorrect format.""" assert dt_util.parse_datetime("not a datetime string") is None
[ "def", "test_parse_datetime_returns_none_for_incorrect_format", "(", ")", ":", "assert", "dt_util", ".", "parse_datetime", "(", "\"not a datetime string\"", ")", "is", "None" ]
[ 136, 0 ]
[ 138, 66 ]
python
en
['fr', 'en', 'en']
True
test_get_age
()
Test get_age.
Test get_age.
def test_get_age(): """Test get_age.""" diff = dt_util.now() - timedelta(seconds=0) assert dt_util.get_age(diff) == "0 seconds" diff = dt_util.now() - timedelta(seconds=1) assert dt_util.get_age(diff) == "1 second" diff = dt_util.now() - timedelta(seconds=30) assert dt_util.get_age(diff) =...
[ "def", "test_get_age", "(", ")", ":", "diff", "=", "dt_util", ".", "now", "(", ")", "-", "timedelta", "(", "seconds", "=", "0", ")", "assert", "dt_util", ".", "get_age", "(", "diff", ")", "==", "\"0 seconds\"", "diff", "=", "dt_util", ".", "now", "("...
[ 141, 0 ]
[ 174, 44 ]
python
de
['nl', 'de', 'en']
False
test_parse_time_expression
()
Test parse_time_expression.
Test parse_time_expression.
def test_parse_time_expression(): """Test parse_time_expression.""" assert [x for x in range(60)] == dt_util.parse_time_expression("*", 0, 59) assert [x for x in range(60)] == dt_util.parse_time_expression(None, 0, 59) assert [x for x in range(0, 60, 5)] == dt_util.parse_time_expression("/5", 0, 59) ...
[ "def", "test_parse_time_expression", "(", ")", ":", "assert", "[", "x", "for", "x", "in", "range", "(", "60", ")", "]", "==", "dt_util", ".", "parse_time_expression", "(", "\"*\"", ",", "0", ",", "59", ")", "assert", "[", "x", "for", "x", "in", "rang...
[ 177, 0 ]
[ 192, 48 ]
python
en
['fr', 'en', 'en']
False
test_find_next_time_expression_time_basic
()
Test basic stuff for find_next_time_expression_time.
Test basic stuff for find_next_time_expression_time.
def test_find_next_time_expression_time_basic(): """Test basic stuff for find_next_time_expression_time.""" def find(dt, hour, minute, second): """Call test_find_next_time_expression_time.""" seconds = dt_util.parse_time_expression(second, 0, 59) minutes = dt_util.parse_time_expression(...
[ "def", "test_find_next_time_expression_time_basic", "(", ")", ":", "def", "find", "(", "dt", ",", "hour", ",", "minute", ",", "second", ")", ":", "\"\"\"Call test_find_next_time_expression_time.\"\"\"", "seconds", "=", "dt_util", ".", "parse_time_expression", "(", "se...
[ 195, 0 ]
[ 224, 5 ]
python
en
['en', 'en', 'en']
True
test_find_next_time_expression_time_dst
()
Test daylight saving time for find_next_time_expression_time.
Test daylight saving time for find_next_time_expression_time.
def test_find_next_time_expression_time_dst(): """Test daylight saving time for find_next_time_expression_time.""" tz = dt_util.get_time_zone("Europe/Vienna") dt_util.set_default_time_zone(tz) def find(dt, hour, minute, second): """Call test_find_next_time_expression_time.""" seconds = ...
[ "def", "test_find_next_time_expression_time_dst", "(", ")", ":", "tz", "=", "dt_util", ".", "get_time_zone", "(", "\"Europe/Vienna\"", ")", "dt_util", ".", "set_default_time_zone", "(", "tz", ")", "def", "find", "(", "dt", ",", "hour", ",", "minute", ",", "sec...
[ 227, 0 ]
[ 272, 5 ]
python
en
['en', 'en', 'en']
True
N_A2C.update_search_space
(self, search_space)
Update the self.bounds and self.types by the search_space.json file. Override of the abstract method in :class:`~nni.tuner.Tuner`.
Update the self.bounds and self.types by the search_space.json file.
def update_search_space(self, search_space): """Update the self.bounds and self.types by the search_space.json file. Override of the abstract method in :class:`~nni.tuner.Tuner`. """ if not isinstance(search_space, dict): self.logger.info("The format of search space is not a...
[ "def", "update_search_space", "(", "self", ",", "search_space", ")", ":", "if", "not", "isinstance", "(", "search_space", ",", "dict", ")", ":", "self", ".", "logger", ".", "info", "(", "\"The format of search space is not a dict.\"", ")", "raise", "RuntimeError",...
[ 299, 4 ]
[ 319, 56 ]
python
en
['en', 'en', 'en']
True
N_A2C.generate_multiple_parameters
(self, parameter_id_list, **kwargs)
Returns multiple sets of trial (hyper-)parameters, as iterable of serializable objects.
Returns multiple sets of trial (hyper-)parameters, as iterable of serializable objects.
def generate_multiple_parameters(self, parameter_id_list, **kwargs): """Returns multiple sets of trial (hyper-)parameters, as iterable of serializable objects. """ result = [] self.send_trial_callback = kwargs['st_callback'] for parameter_id in parameter_id_list: ...
[ "def", "generate_multiple_parameters", "(", "self", ",", "parameter_id_list", ",", "*", "*", "kwargs", ")", ":", "result", "=", "[", "]", "self", ".", "send_trial_callback", "=", "kwargs", "[", "'st_callback'", "]", "for", "parameter_id", "in", "parameter_id_lis...
[ 321, 4 ]
[ 336, 21 ]
python
en
['en', 'af', 'en']
True
N_A2C.generate_parameters
(self, parameter_id, **kwargs)
Method which provides one set of hyper-parameters. Override of the abstract method in :class:`~nni.tuner.Tuner`.
Method which provides one set of hyper-parameters.
def generate_parameters(self, parameter_id, **kwargs): """Method which provides one set of hyper-parameters. Override of the abstract method in :class:`~nni.tuner.Tuner`. """ if self.serve_list: self.wait_dict[parameter_id] = self.serve_list.pop() return self.wai...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "serve_list", ":", "self", ".", "wait_dict", "[", "parameter_id", "]", "=", "self", ".", "serve_list", ".", "pop", "(", ")", "return", ...
[ 338, 4 ]
[ 348, 65 ]
python
en
['en', 'en', 'en']
True
N_A2C.receive_trial_result
(self, parameter_id, parameters, value, **kwargs)
Method invoked when a trial reports its final result. Override of the abstract method in :class:`~nni.tuner.Tuner`.
Method invoked when a trial reports its final result.
def receive_trial_result(self, parameter_id, parameters, value, **kwargs): """Method invoked when a trial reports its final result. Override of the abstract method in :class:`~nni.tuner.Tuner`. """ if isinstance(value, dict): value = value['default'] self.population...
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "value", "=", "value", "[", "'default'", "]", "self", ".", "po...
[ 350, 4 ]
[ 371, 36 ]
python
en
['en', 'en', 'en']
True
N_A2C.trial_end
(self, parameter_id, success, **kwargs)
Method invoked when a trial is completed or terminated. Override of the abstract method in :class:`~nni.tuner.Tuner`.
Method invoked when a trial is completed or terminated.
def trial_end(self, parameter_id, success, **kwargs): """Method invoked when a trial is completed or terminated. Override of the abstract method in :class:`~nni.tuner.Tuner`. """ if not success: self.population.append(self.wait_dict[parameter_id], 0.0) del self.w...
[ "def", "trial_end", "(", "self", ",", "parameter_id", ",", "success", ",", "*", "*", "kwargs", ")", ":", "if", "not", "success", ":", "self", ".", "population", ".", "append", "(", "self", ".", "wait_dict", "[", "parameter_id", "]", ",", "0.0", ")", ...
[ 377, 4 ]
[ 396, 40 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Perform the setup for Xiaomi devices.
Perform the setup for Xiaomi devices.
async def async_setup_entry(hass, config_entry, async_add_entities): """Perform the setup for Xiaomi devices.""" entities = [] gateway = hass.data[DOMAIN][GATEWAYS_KEY][config_entry.entry_id] for device in gateway.devices["lock"]: model = device["model"] if model == "lock.aq1": ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "entities", "=", "[", "]", "gateway", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "GATEWAYS_KEY", "]", "[", "config_entry", ".", "entry_id", ...
[ 19, 0 ]
[ 27, 32 ]
python
en
['en', 'en', 'en']
True
XiaomiAqaraLock.__init__
(self, device, name, xiaomi_hub, config_entry)
Initialize the XiaomiAqaraLock.
Initialize the XiaomiAqaraLock.
def __init__(self, device, name, xiaomi_hub, config_entry): """Initialize the XiaomiAqaraLock.""" self._changed_by = 0 self._verified_wrong_times = 0 super().__init__(device, name, xiaomi_hub, config_entry)
[ "def", "__init__", "(", "self", ",", "device", ",", "name", ",", "xiaomi_hub", ",", "config_entry", ")", ":", "self", ".", "_changed_by", "=", "0", "self", ".", "_verified_wrong_times", "=", "0", "super", "(", ")", ".", "__init__", "(", "device", ",", ...
[ 33, 4 ]
[ 38, 64 ]
python
en
['en', 'pl', 'en']
True
XiaomiAqaraLock.is_locked
(self)
Return true if lock is locked.
Return true if lock is locked.
def is_locked(self) -> bool: """Return true if lock is locked.""" if self._state is not None: return self._state == STATE_LOCKED
[ "def", "is_locked", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_state", "is", "not", "None", ":", "return", "self", ".", "_state", "==", "STATE_LOCKED" ]
[ 41, 4 ]
[ 44, 46 ]
python
en
['en', 'mt', 'en']
True
XiaomiAqaraLock.changed_by
(self)
Last change triggered by.
Last change triggered by.
def changed_by(self) -> int: """Last change triggered by.""" return self._changed_by
[ "def", "changed_by", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_changed_by" ]
[ 47, 4 ]
[ 49, 31 ]
python
en
['en', 'en', 'en']
True
XiaomiAqaraLock.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self) -> dict: """Return the state attributes.""" attributes = {ATTR_VERIFIED_WRONG_TIMES: self._verified_wrong_times} return attributes
[ "def", "device_state_attributes", "(", "self", ")", "->", "dict", ":", "attributes", "=", "{", "ATTR_VERIFIED_WRONG_TIMES", ":", "self", ".", "_verified_wrong_times", "}", "return", "attributes" ]
[ 52, 4 ]
[ 55, 25 ]
python
en
['en', 'en', 'en']
True
XiaomiAqaraLock.clear_unlock_state
(self, _)
Clear unlock state automatically.
Clear unlock state automatically.
def clear_unlock_state(self, _): """Clear unlock state automatically.""" self._state = STATE_LOCKED self.async_write_ha_state()
[ "def", "clear_unlock_state", "(", "self", ",", "_", ")", ":", "self", ".", "_state", "=", "STATE_LOCKED", "self", ".", "async_write_ha_state", "(", ")" ]
[ 58, 4 ]
[ 61, 35 ]
python
en
['en', 'en', 'en']
True
XiaomiAqaraLock.parse_data
(self, data, raw_data)
Parse data sent by gateway.
Parse data sent by gateway.
def parse_data(self, data, raw_data): """Parse data sent by gateway.""" value = data.get(VERIFIED_WRONG_KEY) if value is not None: self._verified_wrong_times = int(value) return True for key in (FINGER_KEY, PASSWORD_KEY, CARD_KEY): value = data.get(ke...
[ "def", "parse_data", "(", "self", ",", "data", ",", "raw_data", ")", ":", "value", "=", "data", ".", "get", "(", "VERIFIED_WRONG_KEY", ")", "if", "value", "is", "not", "None", ":", "self", ".", "_verified_wrong_times", "=", "int", "(", "value", ")", "r...
[ 63, 4 ]
[ 81, 20 ]
python
en
['en', 'de', 'en']
True
setup_decrypt
()
Return decryption function and length of key. Async friendly.
Return decryption function and length of key.
def setup_decrypt() -> Tuple[int, Callable]: """Return decryption function and length of key. Async friendly. """ def decrypt(ciphertext, key): """Decrypt ciphertext using key.""" return SecretBox(key).decrypt(ciphertext, encoder=Base64Encoder) return (SecretBox.KEY_SIZE, decrypt)
[ "def", "setup_decrypt", "(", ")", "->", "Tuple", "[", "int", ",", "Callable", "]", ":", "def", "decrypt", "(", "ciphertext", ",", "key", ")", ":", "\"\"\"Decrypt ciphertext using key.\"\"\"", "return", "SecretBox", "(", "key", ")", ".", "decrypt", "(", "ciph...
[ 36, 0 ]
[ 46, 40 ]
python
en
['en', 'en', 'en']
True
setup_encrypt
()
Return encryption function and length of key. Async friendly.
Return encryption function and length of key.
def setup_encrypt() -> Tuple[int, Callable]: """Return encryption function and length of key. Async friendly. """ def encrypt(ciphertext, key): """Encrypt ciphertext using key.""" return SecretBox(key).encrypt(ciphertext, encoder=Base64Encoder) return (SecretBox.KEY_SIZE, encrypt)
[ "def", "setup_encrypt", "(", ")", "->", "Tuple", "[", "int", ",", "Callable", "]", ":", "def", "encrypt", "(", "ciphertext", ",", "key", ")", ":", "\"\"\"Encrypt ciphertext using key.\"\"\"", "return", "SecretBox", "(", "key", ")", ".", "encrypt", "(", "ciph...
[ 49, 0 ]
[ 59, 40 ]
python
en
['en', 'en', 'en']
True
_decrypt_payload
(key: str, ciphertext: str)
Decrypt encrypted payload.
Decrypt encrypted payload.
def _decrypt_payload(key: str, ciphertext: str) -> Dict[str, str]: """Decrypt encrypted payload.""" try: keylen, decrypt = setup_decrypt() except OSError: _LOGGER.warning("Ignoring encrypted payload because libsodium not installed") return None if key is None: _LOGGER.wa...
[ "def", "_decrypt_payload", "(", "key", ":", "str", ",", "ciphertext", ":", "str", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "try", ":", "keylen", ",", "decrypt", "=", "setup_decrypt", "(", ")", "except", "OSError", ":", "_LOGGER", ".", "wa...
[ 62, 0 ]
[ 85, 19 ]
python
en
['fr', 'en', 'en']
True
registration_context
(registration: Dict)
Generate a context from a request.
Generate a context from a request.
def registration_context(registration: Dict) -> Context: """Generate a context from a request.""" return Context(user_id=registration[CONF_USER_ID])
[ "def", "registration_context", "(", "registration", ":", "Dict", ")", "->", "Context", ":", "return", "Context", "(", "user_id", "=", "registration", "[", "CONF_USER_ID", "]", ")" ]
[ 88, 0 ]
[ 90, 54 ]
python
en
['en', 'en', 'en']
True
empty_okay_response
(headers: Dict = None, status: int = HTTP_OK)
Return a Response with empty JSON object and a 200.
Return a Response with empty JSON object and a 200.
def empty_okay_response(headers: Dict = None, status: int = HTTP_OK) -> Response: """Return a Response with empty JSON object and a 200.""" return Response( text="{}", status=status, content_type=CONTENT_TYPE_JSON, headers=headers )
[ "def", "empty_okay_response", "(", "headers", ":", "Dict", "=", "None", ",", "status", ":", "int", "=", "HTTP_OK", ")", "->", "Response", ":", "return", "Response", "(", "text", "=", "\"{}\"", ",", "status", "=", "status", ",", "content_type", "=", "CONT...
[ 93, 0 ]
[ 97, 5 ]
python
en
['en', 'en', 'en']
True
error_response
( code: str, message: str, status: int = HTTP_BAD_REQUEST, headers: dict = None )
Return an error Response.
Return an error Response.
def error_response( code: str, message: str, status: int = HTTP_BAD_REQUEST, headers: dict = None ) -> Response: """Return an error Response.""" return json_response( {"success": False, "error": {"code": code, "message": message}}, status=status, headers=headers, )
[ "def", "error_response", "(", "code", ":", "str", ",", "message", ":", "str", ",", "status", ":", "int", "=", "HTTP_BAD_REQUEST", ",", "headers", ":", "dict", "=", "None", ")", "->", "Response", ":", "return", "json_response", "(", "{", "\"success\"", ":...
[ 100, 0 ]
[ 108, 5 ]
python
be
['br', 'be', 'en']
False
supports_encryption
()
Test if we support encryption.
Test if we support encryption.
def supports_encryption() -> bool: """Test if we support encryption.""" try: import nacl # noqa: F401 pylint: disable=unused-import, import-outside-toplevel return True except OSError: return False
[ "def", "supports_encryption", "(", ")", "->", "bool", ":", "try", ":", "import", "nacl", "# noqa: F401 pylint: disable=unused-import, import-outside-toplevel", "return", "True", "except", "OSError", ":", "return", "False" ]
[ 111, 0 ]
[ 118, 20 ]
python
en
['fr', 'en', 'en']
True
safe_registration
(registration: Dict)
Return a registration without sensitive values.
Return a registration without sensitive values.
def safe_registration(registration: Dict) -> Dict: """Return a registration without sensitive values.""" # Sensitive values: webhook_id, secret, cloudhook_url return { ATTR_APP_DATA: registration[ATTR_APP_DATA], ATTR_APP_ID: registration[ATTR_APP_ID], ATTR_APP_NAME: registration[ATTR...
[ "def", "safe_registration", "(", "registration", ":", "Dict", ")", "->", "Dict", ":", "# Sensitive values: webhook_id, secret, cloudhook_url", "return", "{", "ATTR_APP_DATA", ":", "registration", "[", "ATTR_APP_DATA", "]", ",", "ATTR_APP_ID", ":", "registration", "[", ...
[ 121, 0 ]
[ 134, 5 ]
python
en
['en', 'fr', 'en']
True
savable_state
(hass: HomeAssistantType)
Return a clean object containing things that should be saved.
Return a clean object containing things that should be saved.
def savable_state(hass: HomeAssistantType) -> Dict: """Return a clean object containing things that should be saved.""" return { DATA_BINARY_SENSOR: hass.data[DOMAIN][DATA_BINARY_SENSOR], DATA_DELETED_IDS: hass.data[DOMAIN][DATA_DELETED_IDS], DATA_SENSOR: hass.data[DOMAIN][DATA_SENSOR], ...
[ "def", "savable_state", "(", "hass", ":", "HomeAssistantType", ")", "->", "Dict", ":", "return", "{", "DATA_BINARY_SENSOR", ":", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_BINARY_SENSOR", "]", ",", "DATA_DELETED_IDS", ":", "hass", ".", "data", "[", ...
[ 137, 0 ]
[ 143, 5 ]
python
en
['en', 'en', 'en']
True
webhook_response
( data, *, registration: Dict, status: int = HTTP_OK, headers: Dict = None )
Return a encrypted response if registration supports it.
Return a encrypted response if registration supports it.
def webhook_response( data, *, registration: Dict, status: int = HTTP_OK, headers: Dict = None ) -> Response: """Return a encrypted response if registration supports it.""" data = json.dumps(data, cls=JSONEncoder) if registration[ATTR_SUPPORTS_ENCRYPTION]: keylen, encrypt = setup_encrypt() ...
[ "def", "webhook_response", "(", "data", ",", "*", ",", "registration", ":", "Dict", ",", "status", ":", "int", "=", "HTTP_OK", ",", "headers", ":", "Dict", "=", "None", ")", "->", "Response", ":", "data", "=", "json", ".", "dumps", "(", "data", ",", ...
[ 146, 0 ]
[ 164, 5 ]
python
en
['ca', 'en', 'en']
True
device_info
(registration: Dict)
Return the device info for this registration.
Return the device info for this registration.
def device_info(registration: Dict) -> Dict: """Return the device info for this registration.""" return { "identifiers": {(DOMAIN, registration[ATTR_DEVICE_ID])}, "manufacturer": registration[ATTR_MANUFACTURER], "model": registration[ATTR_MODEL], "device_name": registration[ATTR_...
[ "def", "device_info", "(", "registration", ":", "Dict", ")", "->", "Dict", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "registration", "[", "ATTR_DEVICE_ID", "]", ")", "}", ",", "\"manufacturer\"", ":", "registration", "[", "ATTR_MAN...
[ 167, 0 ]
[ 175, 5 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_devices, discovery_info=None)
Set up the cartridge sensor.
Set up the cartridge sensor.
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the cartridge sensor.""" host = config.get(CONF_HOST) api = EpsonPrinterAPI(host) if not api.available: raise PlatformNotReady() sensors = [ EpsonPrinterCartridge(api, condition) for condition in ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_devices", ",", "discovery_info", "=", "None", ")", ":", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")", "api", "=", "EpsonPrinterAPI", "(", "host", ")", "if", "not", "api", ".", "...
[ 31, 0 ]
[ 44, 30 ]
python
en
['en', 'su', 'en']
True
EpsonPrinterCartridge.__init__
(self, api, cartridgeidx)
Initialize a cartridge sensor.
Initialize a cartridge sensor.
def __init__(self, api, cartridgeidx): """Initialize a cartridge sensor.""" self._api = api self._id = cartridgeidx self._name = MONITORED_CONDITIONS[self._id][0] self._unit = MONITORED_CONDITIONS[self._id][1] self._icon = MONITORED_CONDITIONS[self._id][2]
[ "def", "__init__", "(", "self", ",", "api", ",", "cartridgeidx", ")", ":", "self", ".", "_api", "=", "api", "self", ".", "_id", "=", "cartridgeidx", "self", ".", "_name", "=", "MONITORED_CONDITIONS", "[", "self", ".", "_id", "]", "[", "0", "]", "self...
[ 50, 4 ]
[ 57, 54 ]
python
co
['es', 'co', 'en']
False
EpsonPrinterCartridge.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 60, 4 ]
[ 62, 25 ]
python
en
['en', 'mi', 'en']
True
EpsonPrinterCartridge.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self): """Icon to use in the frontend, if any.""" return self._icon
[ "def", "icon", "(", "self", ")", ":", "return", "self", ".", "_icon" ]
[ 65, 4 ]
[ 67, 25 ]
python
en
['en', 'en', 'en']
True
EpsonPrinterCartridge.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): """Return the unit the value is expressed in.""" return self._unit
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "_unit" ]
[ 70, 4 ]
[ 72, 25 ]
python
en
['en', 'en', 'en']
True
EpsonPrinterCartridge.state
(self)
Return the state of the device.
Return the state of the device.
def state(self): """Return the state of the device.""" return self._api.getSensorValue(self._id)
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "getSensorValue", "(", "self", ".", "_id", ")" ]
[ 75, 4 ]
[ 77, 49 ]
python
en
['en', 'en', 'en']
True
EpsonPrinterCartridge.available
(self)
Could the device be accessed during the last update call.
Could the device be accessed during the last update call.
def available(self): """Could the device be accessed during the last update call.""" return self._api.available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_api", ".", "available" ]
[ 80, 4 ]
[ 82, 34 ]
python
en
['en', 'en', 'en']
True
EpsonPrinterCartridge.update
(self)
Get the latest data from the Epson printer.
Get the latest data from the Epson printer.
def update(self): """Get the latest data from the Epson printer.""" self._api.update()
[ "def", "update", "(", "self", ")", ":", "self", ".", "_api", ".", "update", "(", ")" ]
[ 84, 4 ]
[ 86, 26 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the Twilio component.
Set up the Twilio component.
async def async_setup(hass, config): """Set up the Twilio component.""" if DOMAIN not in config: return True conf = config[DOMAIN] hass.data[DATA_TWILIO] = Client( conf.get(CONF_ACCOUNT_SID), conf.get(CONF_AUTH_TOKEN) ) return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "conf", "=", "config", "[", "DOMAIN", "]", "hass", ".", "data", "[", "DATA_TWILIO", "]", "=", "Client", "(", "conf", "....
[ 31, 0 ]
[ 40, 15 ]
python
en
['en', 'sr', 'en']
True
handle_webhook
(hass, webhook_id, request)
Handle incoming webhook from Twilio for inbound messages and calls.
Handle incoming webhook from Twilio for inbound messages and calls.
async def handle_webhook(hass, webhook_id, request): """Handle incoming webhook from Twilio for inbound messages and calls.""" data = dict(await request.post()) data["webhook_id"] = webhook_id hass.bus.async_fire(RECEIVED_DATA, dict(data)) return TwiML().to_xml()
[ "async", "def", "handle_webhook", "(", "hass", ",", "webhook_id", ",", "request", ")", ":", "data", "=", "dict", "(", "await", "request", ".", "post", "(", ")", ")", "data", "[", "\"webhook_id\"", "]", "=", "webhook_id", "hass", ".", "bus", ".", "async...
[ 43, 0 ]
[ 49, 27 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, entry)
Configure based on config entry.
Configure based on config entry.
async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, "Twilio", entry.data[CONF_WEBHOOK_ID], handle_webhook ) return True
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "components", ".", "webhook", ".", "async_register", "(", "DOMAIN", ",", "\"Twilio\"", ",", "entry", ".", "data", "[", "CONF_WEBHOOK_ID", "]", ",", "handle_webhook", ")", ...
[ 52, 0 ]
[ 57, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "components", ".", "webhook", ".", "async_unregister", "(", "entry", ".", "data", "[", "CONF_WEBHOOK_ID", "]", ")", "return", "True" ]
[ 60, 0 ]
[ 63, 15 ]
python
en
['en', 'es', 'en']
True
masked_softmax
(vector: torch.Tensor, mask: torch.Tensor, dim: int = -1)
``torch.nn.functional.softmax(vector)`` does not work if some elements of ``vector`` should be masked. This performs a softmax on just the non-masked portions of ``vector``. Passing ``None`` in for the mask is also acceptable; you'll just get a regular softmax. ``vector`` can have an arbitrary numbe...
``torch.nn.functional.softmax(vector)`` does not work if some elements of ``vector`` should be masked. This performs a softmax on just the non-masked portions of ``vector``. Passing ``None`` in for the mask is also acceptable; you'll just get a regular softmax.
def masked_softmax(vector: torch.Tensor, mask: torch.Tensor, dim: int = -1) -> torch.Tensor: """ ``torch.nn.functional.softmax(vector)`` does not work if some elements of ``vector`` should be masked. This performs a softmax on just the non-masked portions of ``vector``. Passing ``None`` in for the mas...
[ "def", "masked_softmax", "(", "vector", ":", "torch", ".", "Tensor", ",", "mask", ":", "torch", ".", "Tensor", ",", "dim", ":", "int", "=", "-", "1", ")", "->", "torch", ".", "Tensor", ":", "if", "mask", "is", "None", ":", "result", "=", "torch", ...
[ 3, 0 ]
[ 28, 17 ]
python
en
['en', 'error', 'th']
False
test_services
(hass, light_data, sent_messages)
Test services on lock.
Test services on lock.
async def test_services(hass, light_data, sent_messages): """Test services on lock.""" await setup_ozw(hass, fixture=light_data) # Test set_config_parameter list by label await hass.services.async_call( "ozw", "set_config_parameter", {"node_id": 39, "parameter": 1, "value": "Dis...
[ "async", "def", "test_services", "(", "hass", ",", "light_data", ",", "sent_messages", ")", ":", "await", "setup_ozw", "(", "hass", ",", "fixture", "=", "light_data", ")", "# Test set_config_parameter list by label", "await", "hass", ".", "services", ".", "async_c...
[ 8, 0 ]
[ 114, 74 ]
python
en
['en', 'en', 'en']
True
test_adam_climate_entity_attributes
(hass, mock_smile_adam)
Test creation of adam climate device environment.
Test creation of adam climate device environment.
async def test_adam_climate_entity_attributes(hass, mock_smile_adam): """Test creation of adam climate device environment.""" entry = await async_init_integration(hass, mock_smile_adam) assert entry.state == ENTRY_STATE_LOADED state = hass.states.get("climate.zone_lisa_wk") attrs = state.attributes...
[ "async", "def", "test_adam_climate_entity_attributes", "(", "hass", ",", "mock_smile_adam", ")", ":", "entry", "=", "await", "async_init_integration", "(", "hass", ",", "mock_smile_adam", ")", "assert", "entry", ".", "state", "==", "ENTRY_STATE_LOADED", "state", "="...
[ 7, 0 ]
[ 40, 43 ]
python
en
['en', 'en', 'en']
True
test_adam_climate_entity_climate_changes
(hass, mock_smile_adam)
Test handling of user requests in adam climate device environment.
Test handling of user requests in adam climate device environment.
async def test_adam_climate_entity_climate_changes(hass, mock_smile_adam): """Test handling of user requests in adam climate device environment.""" entry = await async_init_integration(hass, mock_smile_adam) assert entry.state == ENTRY_STATE_LOADED await hass.services.async_call( "climate", ...
[ "async", "def", "test_adam_climate_entity_climate_changes", "(", "hass", ",", "mock_smile_adam", ")", ":", "entry", "=", "await", "async_init_integration", "(", "hass", ",", "mock_smile_adam", ")", "assert", "entry", ".", "state", "==", "ENTRY_STATE_LOADED", "await", ...
[ 43, 0 ]
[ 93, 41 ]
python
en
['en', 'en', 'en']
True
test_anna_climate_entity_attributes
(hass, mock_smile_anna)
Test creation of anna climate device environment.
Test creation of anna climate device environment.
async def test_anna_climate_entity_attributes(hass, mock_smile_anna): """Test creation of anna climate device environment.""" entry = await async_init_integration(hass, mock_smile_anna) assert entry.state == ENTRY_STATE_LOADED state = hass.states.get("climate.anna") attrs = state.attributes as...
[ "async", "def", "test_anna_climate_entity_attributes", "(", "hass", ",", "mock_smile_anna", ")", ":", "entry", "=", "await", "async_init_integration", "(", "hass", ",", "mock_smile_anna", ")", "assert", "entry", ".", "state", "==", "ENTRY_STATE_LOADED", "state", "="...
[ 96, 0 ]
[ 118, 44 ]
python
en
['en', 'en', 'en']
True
test_anna_climate_entity_climate_changes
(hass, mock_smile_anna)
Test handling of user requests in anna climate device environment.
Test handling of user requests in anna climate device environment.
async def test_anna_climate_entity_climate_changes(hass, mock_smile_anna): """Test handling of user requests in anna climate device environment.""" entry = await async_init_integration(hass, mock_smile_anna) assert entry.state == ENTRY_STATE_LOADED await hass.services.async_call( "climate", ...
[ "async", "def", "test_anna_climate_entity_climate_changes", "(", "hass", ",", "mock_smile_anna", ")", ":", "entry", "=", "await", "async_init_integration", "(", "hass", ",", "mock_smile_anna", ")", "assert", "entry", ".", "state", "==", "ENTRY_STATE_LOADED", "await", ...
[ 121, 0 ]
[ 160, 37 ]
python
en
['en', 'en', 'en']
True
add_on_off_event_device
(hass, device)
Register an Insteon device as an on/off event device.
Register an Insteon device as an on/off event device.
def add_on_off_event_device(hass, device): """Register an Insteon device as an on/off event device.""" @callback def async_fire_group_on_off_event(name, address, group, button): # Firing an event when a button is pressed. if button and button[-2] == "_": button_id = button[-1].l...
[ "def", "add_on_off_event_device", "(", "hass", ",", "device", ")", ":", "@", "callback", "def", "async_fire_group_on_off_event", "(", "name", ",", "address", ",", "group", ",", "button", ")", ":", "# Firing an event when a button is pressed.", "if", "button", "and",...
[ 90, 0 ]
[ 132, 21 ]
python
en
['en', 'en', 'en']
True
register_new_device_callback
(hass)
Register callback for new Insteon device.
Register callback for new Insteon device.
def register_new_device_callback(hass): """Register callback for new Insteon device.""" @callback def async_new_insteon_device(address=None): """Detect device from transport to be delegated to platform.""" hass.async_create_task(async_create_new_entities(address)) async def async_creat...
[ "def", "register_new_device_callback", "(", "hass", ")", ":", "@", "callback", "def", "async_new_insteon_device", "(", "address", "=", "None", ")", ":", "\"\"\"Detect device from transport to be delegated to platform.\"\"\"", "hass", ".", "async_create_task", "(", "async_cr...
[ 135, 0 ]
[ 159, 70 ]
python
en
['de', 'en', 'en']
True
async_register_services
(hass)
Register services used by insteon component.
Register services used by insteon component.
def async_register_services(hass): """Register services used by insteon component.""" save_lock = asyncio.Lock() async def async_srv_add_all_link(service): """Add an INSTEON All-Link between two devices.""" group = service.data.get(SRV_ALL_LINK_GROUP) mode = service.data.get(SRV_AL...
[ "def", "async_register_services", "(", "hass", ")", ":", "save_lock", "=", "asyncio", ".", "Lock", "(", ")", "async", "def", "async_srv_add_all_link", "(", "service", ")", ":", "\"\"\"Add an INSTEON All-Link between two devices.\"\"\"", "group", "=", "service", ".", ...
[ 163, 0 ]
[ 355, 48 ]
python
en
['en', 'en', 'en']
True
print_aldb_to_log
(aldb)
Print the All-Link Database to the log file.
Print the All-Link Database to the log file.
def print_aldb_to_log(aldb): """Print the All-Link Database to the log file.""" logger = logging.getLogger(f"{__name__}.links") logger.info("%s ALDB load status is %s", aldb.address, aldb.status.name) if aldb.status not in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]: _LOGGER.warning("All-Link databa...
[ "def", "print_aldb_to_log", "(", "aldb", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "f\"{__name__}.links\"", ")", "logger", ".", "info", "(", "\"%s ALDB load status is %s\"", ",", "aldb", ".", "address", ",", "aldb", ".", "status", ".", "name",...
[ 358, 0 ]
[ 379, 28 ]
python
en
['en', 'en', 'en']
True
async_add_insteon_entities
( hass, platform, entity_type, async_add_entities, discovery_info )
Add Insteon devices to a platform.
Add Insteon devices to a platform.
def async_add_insteon_entities( hass, platform, entity_type, async_add_entities, discovery_info ): """Add Insteon devices to a platform.""" new_entities = [] device_list = [discovery_info.get("address")] if discovery_info else devices for address in device_list: device = devices[address] ...
[ "def", "async_add_insteon_entities", "(", "hass", ",", "platform", ",", "entity_type", ",", "async_add_entities", ",", "discovery_info", ")", ":", "new_entities", "=", "[", "]", "device_list", "=", "[", "discovery_info", ".", "get", "(", "\"address\"", ")", "]",...
[ 383, 0 ]
[ 396, 40 ]
python
en
['en', 'en', 'en']
True
test_blueprint_schema
(blueprint)
Test different schemas.
Test different schemas.
def test_blueprint_schema(blueprint): """Test different schemas.""" try: schemas.BLUEPRINT_SCHEMA(blueprint) except vol.Invalid: _LOGGER.exception("%s", blueprint) assert False, "Expected schema to be valid"
[ "def", "test_blueprint_schema", "(", "blueprint", ")", ":", "try", ":", "schemas", ".", "BLUEPRINT_SCHEMA", "(", "blueprint", ")", "except", "vol", ".", "Invalid", ":", "_LOGGER", ".", "exception", "(", "\"%s\"", ",", "blueprint", ")", "assert", "False", ","...
[ 55, 0 ]
[ 61, 51 ]
python
de
['de', 'de', 'en']
True
test_blueprint_schema_invalid
(blueprint)
Test different schemas.
Test different schemas.
def test_blueprint_schema_invalid(blueprint): """Test different schemas.""" with pytest.raises(vol.Invalid): schemas.BLUEPRINT_SCHEMA(blueprint)
[ "def", "test_blueprint_schema_invalid", "(", "blueprint", ")", ":", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "schemas", ".", "BLUEPRINT_SCHEMA", "(", "blueprint", ")" ]
[ 97, 0 ]
[ 100, 43 ]
python
de
['de', 'de', 'en']
True
test_blueprint_instance_fields
(bp_instance)
Test blueprint instance fields.
Test blueprint instance fields.
def test_blueprint_instance_fields(bp_instance): """Test blueprint instance fields.""" schemas.BLUEPRINT_INSTANCE_FIELDS({"use_blueprint": bp_instance})
[ "def", "test_blueprint_instance_fields", "(", "bp_instance", ")", ":", "schemas", ".", "BLUEPRINT_INSTANCE_FIELDS", "(", "{", "\"use_blueprint\"", ":", "bp_instance", "}", ")" ]
[ 111, 0 ]
[ 113, 69 ]
python
en
['en', 'lb', 'en']
True
CoolmasterConfigFlow.async_step_user
(self, user_input=None)
Handle a flow initialized by the user.
Handle a flow initialized by the user.
async def async_step_user(self, user_input=None): """Handle a flow initialized by the user.""" if user_input is None: return self.async_show_form(step_id="user", data_schema=DATA_SCHEMA) errors = {} host = user_input[CONF_HOST] try: result = await _vali...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "None", ":", "return", "self", ".", "async_show_form", "(", "step_id", "=", "\"user\"", ",", "data_schema", "=", "DATA_SCHEMA", ")", "errors",...
[ 42, 4 ]
[ 63, 48 ]
python
en
['en', 'en', 'en']
True
setup
(hass, config)
Set up the StatsD component.
Set up the StatsD component.
def setup(hass, config): """Set up the StatsD component.""" conf = config[DOMAIN] host = conf.get(CONF_HOST) port = conf.get(CONF_PORT) sample_rate = conf.get(CONF_RATE) prefix = conf.get(CONF_PREFIX) value_mapping = conf.get(CONF_VALUE_MAP) show_attribute_flag = conf.get(CONF_ATTR) ...
[ "def", "setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", "[", "DOMAIN", "]", "host", "=", "conf", ".", "get", "(", "CONF_HOST", ")", "port", "=", "conf", ".", "get", "(", "CONF_PORT", ")", "sample_rate", "=", "conf", ".", "get",...
[ 41, 0 ]
[ 93, 15 ]
python
en
['en', 'en', 'en']
True
export_model
(sym, params, input_shape, input_type=np.float32, onnx_file_path='model.onnx', verbose=False)
Exports the MXNet model file, passed as a parameter, into ONNX model. Accepts both symbol,parameter objects as well as json and params filepaths as input. Operator support and coverage - https://cwiki.apache.org/confluence/display/MXNET/ONNX+Operator+Coverage Parameters ---------- sym : str or ...
Exports the MXNet model file, passed as a parameter, into ONNX model. Accepts both symbol,parameter objects as well as json and params filepaths as input. Operator support and coverage - https://cwiki.apache.org/confluence/display/MXNET/ONNX+Operator+Coverage
def export_model(sym, params, input_shape, input_type=np.float32, onnx_file_path='model.onnx', verbose=False): """Exports the MXNet model file, passed as a parameter, into ONNX model. Accepts both symbol,parameter objects as well as json and params filepaths as input. Operator support and c...
[ "def", "export_model", "(", "sym", ",", "params", ",", "input_shape", ",", "input_type", "=", "np", ".", "float32", ",", "onnx_file_path", "=", "'model.onnx'", ",", "verbose", "=", "False", ")", ":", "try", ":", "from", "onnx", "import", "helper", ",", "...
[ 30, 0 ]
[ 96, 25 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up the VeSync fan platform.
Set up the VeSync fan platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up the VeSync fan platform.""" async def async_discover(devices): """Add new devices to platform.""" _async_setup_entities(devices, async_add_entities) disp = async_dispatcher_connect(hass, VS_DISCOVERY.format(VS_F...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "async", "def", "async_discover", "(", "devices", ")", ":", "\"\"\"Add new devices to platform.\"\"\"", "_async_setup_entities", "(", "devices", ",", "async_add_e...
[ 27, 0 ]
[ 37, 73 ]
python
en
['en', 'cs', 'en']
True
_async_setup_entities
(devices, async_add_entities)
Check if device is online and add entity.
Check if device is online and add entity.
def _async_setup_entities(devices, async_add_entities): """Check if device is online and add entity.""" dev_list = [] for dev in devices: if DEV_TYPE_TO_HA.get(dev.device_type) == "fan": dev_list.append(VeSyncFanHA(dev)) else: _LOGGER.warning( "%s - Un...
[ "def", "_async_setup_entities", "(", "devices", ",", "async_add_entities", ")", ":", "dev_list", "=", "[", "]", "for", "dev", "in", "devices", ":", "if", "DEV_TYPE_TO_HA", ".", "get", "(", "dev", ".", "device_type", ")", "==", "\"fan\"", ":", "dev_list", "...
[ 41, 0 ]
[ 53, 56 ]
python
en
['en', 'en', 'en']
True
VeSyncFanHA.__init__
(self, fan)
Initialize the VeSync fan device.
Initialize the VeSync fan device.
def __init__(self, fan): """Initialize the VeSync fan device.""" super().__init__(fan) self.smartfan = fan
[ "def", "__init__", "(", "self", ",", "fan", ")", ":", "super", "(", ")", ".", "__init__", "(", "fan", ")", "self", ".", "smartfan", "=", "fan" ]
[ 59, 4 ]
[ 62, 27 ]
python
en
['en', 'fy', 'en']
True
VeSyncFanHA.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_SET_SPEED
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_SET_SPEED" ]
[ 65, 4 ]
[ 67, 32 ]
python
en
['da', 'en', 'en']
True
VeSyncFanHA.speed
(self)
Return the current speed.
Return the current speed.
def speed(self): """Return the current speed.""" if self.smartfan.mode == FAN_MODE_AUTO: return None if self.smartfan.mode == "manual": current_level = self.smartfan.fan_level if current_level is not None: return FAN_SPEEDS[current_level] ...
[ "def", "speed", "(", "self", ")", ":", "if", "self", ".", "smartfan", ".", "mode", "==", "FAN_MODE_AUTO", ":", "return", "None", "if", "self", ".", "smartfan", ".", "mode", "==", "\"manual\"", ":", "current_level", "=", "self", ".", "smartfan", ".", "f...
[ 70, 4 ]
[ 78, 19 ]
python
en
['en', 'en', 'en']
True
VeSyncFanHA.speed_list
(self)
Get the list of available speeds.
Get the list of available speeds.
def speed_list(self): """Get the list of available speeds.""" return FAN_SPEEDS
[ "def", "speed_list", "(", "self", ")", ":", "return", "FAN_SPEEDS" ]
[ 81, 4 ]
[ 83, 25 ]
python
en
['en', 'en', 'en']
True
VeSyncFanHA.unique_info
(self)
Return the ID of this fan.
Return the ID of this fan.
def unique_info(self): """Return the ID of this fan.""" return self.smartfan.uuid
[ "def", "unique_info", "(", "self", ")", ":", "return", "self", ".", "smartfan", ".", "uuid" ]
[ 86, 4 ]
[ 88, 33 ]
python
en
['en', 'en', 'en']
True
VeSyncFanHA.device_state_attributes
(self)
Return the state attributes of the fan.
Return the state attributes of the fan.
def device_state_attributes(self): """Return the state attributes of the fan.""" return { "mode": self.smartfan.mode, "active_time": self.smartfan.active_time, "filter_life": self.smartfan.filter_life, "air_quality": self.smartfan.air_quality, ...
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "\"mode\"", ":", "self", ".", "smartfan", ".", "mode", ",", "\"active_time\"", ":", "self", ".", "smartfan", ".", "active_time", ",", "\"filter_life\"", ":", "self", ".", "smartfan", "."...
[ 91, 4 ]
[ 99, 9 ]
python
en
['en', 'en', 'en']
True
VeSyncFanHA.set_speed
(self, speed)
Set the speed of the device.
Set the speed of the device.
def set_speed(self, speed): """Set the speed of the device.""" if not self.smartfan.is_on: self.smartfan.turn_on() self.smartfan.manual_mode() self.smartfan.change_fan_speed(FAN_SPEEDS.index(speed))
[ "def", "set_speed", "(", "self", ",", "speed", ")", ":", "if", "not", "self", ".", "smartfan", ".", "is_on", ":", "self", ".", "smartfan", ".", "turn_on", "(", ")", "self", ".", "smartfan", ".", "manual_mode", "(", ")", "self", ".", "smartfan", ".", ...
[ 101, 4 ]
[ 107, 63 ]
python
en
['en', 'en', 'en']
True
VeSyncFanHA.turn_on
(self, speed: str = None, **kwargs)
Turn the device on.
Turn the device on.
def turn_on(self, speed: str = None, **kwargs) -> None: """Turn the device on.""" self.smartfan.turn_on() self.set_speed(speed)
[ "def", "turn_on", "(", "self", ",", "speed", ":", "str", "=", "None", ",", "*", "*", "kwargs", ")", "->", "None", ":", "self", ".", "smartfan", ".", "turn_on", "(", ")", "self", ".", "set_speed", "(", "speed", ")" ]
[ 109, 4 ]
[ 112, 29 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Random binary sensor.
Set up the Random binary sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Random binary sensor.""" name = config.get(CONF_NAME) device_class = config.get(CONF_DEVICE_CLASS) async_add_entities([RandomSensor(name, device_class)], True)
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "device_class", "=", "config", ".", "get", "(", "CONF_DEVIC...
[ 23, 0 ]
[ 28, 64 ]
python
en
['en', 'pt', 'en']
True
RandomSensor.__init__
(self, name, device_class)
Initialize the Random binary sensor.
Initialize the Random binary sensor.
def __init__(self, name, device_class): """Initialize the Random binary sensor.""" self._name = name self._device_class = device_class self._state = None
[ "def", "__init__", "(", "self", ",", "name", ",", "device_class", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_device_class", "=", "device_class", "self", ".", "_state", "=", "None" ]
[ 34, 4 ]
[ 38, 26 ]
python
en
['en', 'pt', 'en']
True
RandomSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self): """Return the name of the sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 41, 4 ]
[ 43, 25 ]
python
en
['en', 'mi', 'en']
True
RandomSensor.is_on
(self)
Return true if sensor is on.
Return true if sensor is on.
def is_on(self): """Return true if sensor is on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 46, 4 ]
[ 48, 26 ]
python
en
['en', 'et', 'en']
True
RandomSensor.device_class
(self)
Return the sensor class of the sensor.
Return the sensor class of the sensor.
def device_class(self): """Return the sensor class of the sensor.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 51, 4 ]
[ 53, 33 ]
python
en
['en', 'sq', 'en']
True
RandomSensor.async_update
(self)
Get new state and update the sensor's state.
Get new state and update the sensor's state.
async def async_update(self): """Get new state and update the sensor's state.""" self._state = bool(getrandbits(1))
[ "async", "def", "async_update", "(", "self", ")", ":", "self", ".", "_state", "=", "bool", "(", "getrandbits", "(", "1", ")", ")" ]
[ 55, 4 ]
[ 58, 42 ]
python
en
['en', 'en', 'en']
True
Assessor.assess_trial
(self, trial_job_id, trial_history)
Abstract method for determining whether a trial should be killed. Must override. The NNI framework has little guarantee on ``trial_history``. This method is not guaranteed to be invoked for each time ``trial_history`` get updated. It is also possible that a trial's history keeps updati...
Abstract method for determining whether a trial should be killed. Must override.
def assess_trial(self, trial_job_id, trial_history): """ Abstract method for determining whether a trial should be killed. Must override. The NNI framework has little guarantee on ``trial_history``. This method is not guaranteed to be invoked for each time ``trial_history`` get updated....
[ "def", "assess_trial", "(", "self", ",", "trial_job_id", ",", "trial_history", ")", ":", "raise", "NotImplementedError", "(", "'Assessor: assess_trial not implemented'", ")" ]
[ 56, 4 ]
[ 91, 75 ]
python
en
['en', 'error', 'th']
False
Assessor.trial_end
(self, trial_job_id, success)
Abstract method invoked when a trial is completed or terminated. Do nothing by default. Parameters ---------- trial_job_id : str Unique identifier of the trial. success : bool True if the trial successfully completed; False if failed or terminated. ...
Abstract method invoked when a trial is completed or terminated. Do nothing by default.
def trial_end(self, trial_job_id, success): """ Abstract method invoked when a trial is completed or terminated. Do nothing by default. Parameters ---------- trial_job_id : str Unique identifier of the trial. success : bool True if the trial succe...
[ "def", "trial_end", "(", "self", ",", "trial_job_id", ",", "success", ")", ":" ]
[ 93, 4 ]
[ 103, 11 ]
python
en
['en', 'error', 'th']
False
Assessor.load_checkpoint
(self)
Internal API under revising, not recommended for end users.
Internal API under revising, not recommended for end users.
def load_checkpoint(self): """ Internal API under revising, not recommended for end users. """ checkpoin_path = self.get_checkpoint_path() _logger.info('Load checkpoint ignored by assessor, checkpoint path: %s', checkpoin_path)
[ "def", "load_checkpoint", "(", "self", ")", ":", "checkpoin_path", "=", "self", ".", "get_checkpoint_path", "(", ")", "_logger", ".", "info", "(", "'Load checkpoint ignored by assessor, checkpoint path: %s'", ",", "checkpoin_path", ")" ]
[ 105, 4 ]
[ 110, 96 ]
python
en
['en', 'error', 'th']
False
Assessor.save_checkpoint
(self)
Internal API under revising, not recommended for end users.
Internal API under revising, not recommended for end users.
def save_checkpoint(self): """ Internal API under revising, not recommended for end users. """ checkpoin_path = self.get_checkpoint_path() _logger.info('Save checkpoint ignored by assessor, checkpoint path: %s', checkpoin_path)
[ "def", "save_checkpoint", "(", "self", ")", ":", "checkpoin_path", "=", "self", ".", "get_checkpoint_path", "(", ")", "_logger", ".", "info", "(", "'Save checkpoint ignored by assessor, checkpoint path: %s'", ",", "checkpoin_path", ")" ]
[ 112, 4 ]
[ 117, 96 ]
python
en
['en', 'error', 'th']
False
set_conv_prune_dim
(dim)
Parameters: dim: int 0: filter pruning 1: channel pruning
Parameters: dim: int 0: filter pruning 1: channel pruning
def set_conv_prune_dim(dim): """ Parameters: dim: int 0: filter pruning 1: channel pruning """ global conv_prune_dim conv_prune_dim = dim
[ "def", "set_conv_prune_dim", "(", "dim", ")", ":", "global", "conv_prune_dim", "conv_prune_dim", "=", "dim" ]
[ 16, 0 ]
[ 24, 24 ]
python
en
['en', 'error', 'th']
False
cat_inshape
(module_masks, mask, cat_info, last_visited)
Inference the output mask of the cat operation from the input mask. Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the Conv2d mask : CoarseMask The mask of its input tensor cat_info: dict Dict object that records the necessary informati...
Inference the output mask of the cat operation from the input mask.
def cat_inshape(module_masks, mask, cat_info, last_visited): """ Inference the output mask of the cat operation from the input mask. Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the Conv2d mask : CoarseMask The mask of its input tensor cat...
[ "def", "cat_inshape", "(", "module_masks", ",", "mask", ",", "cat_info", ",", "last_visited", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "out_shape", "=", "cat_info", "[", "'out_shape'", "]", "cat_dim", "=", "cat_info", "[", "'cat...
[ 347, 0 ]
[ 424, 35 ]
python
en
['en', 'error', 'th']
False
add_inshape
(module_masks, mask)
Inference the output mask of the add operation from the input mask.
Inference the output mask of the add operation from the input mask.
def add_inshape(module_masks, mask): """ Inference the output mask of the add operation from the input mask. """ assert isinstance(mask, CoarseMask) if module_masks.input_mask is None: module_masks.set_input_mask(mask) module_masks.set_output_mask(mask) # module_masks.inp...
[ "def", "add_inshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "if", "module_masks", ".", "input_mask", "is", "None", ":", "module_masks", ".", "set_input_mask", "(", "mask", ")", "module_masks", ...
[ 427, 0 ]
[ 443, 15 ]
python
en
['en', 'error', 'th']
False
add_outshape
(module_masks, mask)
Inference the input mask of the add operation from the output mask.
Inference the input mask of the add operation from the output mask.
def add_outshape(module_masks, mask): """ Inference the input mask of the add operation from the output mask. """ assert isinstance(mask, CoarseMask) if module_masks.output_mask is None: module_masks.set_output_mask(mask) module_masks.set_input_mask(mask) return mask ...
[ "def", "add_outshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "if", "module_masks", ".", "output_mask", "is", "None", ":", "module_masks", ".", "set_output_mask", "(", "mask", ")", "module_masks...
[ 446, 0 ]
[ 460, 15 ]
python
en
['en', 'error', 'th']
False
batchnorm2d_inshape
(module_masks, mask)
We assume only the second dimension has coarse grained mask Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the batchnorm2d mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its output tensor
We assume only the second dimension has coarse grained mask
def batchnorm2d_inshape(module_masks, mask): """ We assume only the second dimension has coarse grained mask Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the batchnorm2d mask : CoarseMask The mask of its input tensor Returns ------- C...
[ "def", "batchnorm2d_inshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "assert", "mask", ".", "mask_index", "[", "1", "]", "is", "not", "None", "assert", "mask", ".", "mask_index", "[", "0", ...
[ 463, 0 ]
[ 490, 15 ]
python
en
['en', 'error', 'th']
False
batchnorm2d_outshape
(module_masks, mask)
We assume only the second dimension has coarse grained mask Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the batchnorm2d mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its output tensor
We assume only the second dimension has coarse grained mask
def batchnorm2d_outshape(module_masks, mask): """ We assume only the second dimension has coarse grained mask Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the batchnorm2d mask : CoarseMask The mask of its input tensor Returns ------- ...
[ "def", "batchnorm2d_outshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "assert", "len", "(", "mask", ".", "mask_index", ")", "in", "[", "2", ",", "4", "]", "assert", "mask", ".", "mask_inde...
[ 493, 0 ]
[ 519, 15 ]
python
en
['en', 'error', 'th']
False
linear_inshape
(module_masks, mask)
Coarse grained input mask does not change the shape of weights and output tensor Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the linear mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its ou...
Coarse grained input mask does not change the shape of weights and output tensor
def linear_inshape(module_masks, mask): """ Coarse grained input mask does not change the shape of weights and output tensor Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the linear mask : CoarseMask The mask of its input tensor Returns --...
[ "def", "linear_inshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "assert", "mask", ".", "mask_index", "[", "0", "]", "is", "None", "if", "module_masks", ".", "input_mask", "is", "not", "None"...
[ 522, 0 ]
[ 543, 15 ]
python
en
['en', 'error', 'th']
False
view_inshape
(module_masks, mask, shape)
This is a limited support TODO: consider replace tensor.view with nn.Flatten, because tensor.view is not included in module, thus, cannot be replaced by our framework. Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the ```view``` op mask : CoarseMask ...
This is a limited support
def view_inshape(module_masks, mask, shape): """ This is a limited support TODO: consider replace tensor.view with nn.Flatten, because tensor.view is not included in module, thus, cannot be replaced by our framework. Parameters ---------- module_masks : ModuleMasks The ModuleMasks ...
[ "def", "view_inshape", "(", "module_masks", ",", "mask", ",", "shape", ")", ":", "# NOTE: the case constrained by the following four asserts", "assert", "shape", "[", "'in_shape'", "]", "[", "0", "]", "==", "shape", "[", "'out_shape'", "]", "[", "0", "]", "asser...
[ 546, 0 ]
[ 591, 23 ]
python
en
['en', 'error', 'th']
False
view_outshape
(module_masks, mask, shape)
Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the ```view``` op mask : CoarseMask The mask of its output tensor shape : dict Original shape of its input and output tensors Returns ------- CoarseMask The mask of its input ten...
Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the ```view``` op mask : CoarseMask The mask of its output tensor shape : dict Original shape of its input and output tensors Returns ------- CoarseMask The mask of its input ten...
def view_outshape(module_masks, mask, shape): """ Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the ```view``` op mask : CoarseMask The mask of its output tensor shape : dict Original shape of its input and output tensors Returns ---...
[ "def", "view_outshape", "(", "module_masks", ",", "mask", ",", "shape", ")", ":", "# NOTE: the case constrained by the following four asserts", "assert", "shape", "[", "'in_shape'", "]", "[", "0", "]", "==", "shape", "[", "'out_shape'", "]", "[", "0", "]", "asse...
[ 594, 0 ]
[ 630, 22 ]
python
en
['en', 'error', 'th']
False
size_inshape
(module_masks, mask)
No need to do anything for this ```size``` op
No need to do anything for this ```size``` op
def size_inshape(module_masks, mask): """ No need to do anything for this ```size``` op """ return None
[ "def", "size_inshape", "(", "module_masks", ",", "mask", ")", ":", "return", "None" ]
[ 633, 0 ]
[ 637, 15 ]
python
en
['en', 'error', 'th']
False
mean_inshape
(module_masks, mask, shape)
Similar to view operation, currently mask inference only supports the mean operation on the 3rd and 4th dimensions.
Similar to view operation, currently mask inference only supports the mean operation on the 3rd and 4th dimensions.
def mean_inshape(module_masks, mask, shape): """ Similar to view operation, currently mask inference only supports the mean operation on the 3rd and 4th dimensions. """ assert shape['in_shape'][0] == shape['out_shape'][0] assert shape['out_shape'][1] == shape['in_shape'][1] assert len(shape[...
[ "def", "mean_inshape", "(", "module_masks", ",", "mask", ",", "shape", ")", ":", "assert", "shape", "[", "'in_shape'", "]", "[", "0", "]", "==", "shape", "[", "'out_shape'", "]", "[", "0", "]", "assert", "shape", "[", "'out_shape'", "]", "[", "1", "]...
[ 640, 0 ]
[ 660, 23 ]
python
en
['en', 'error', 'th']
False
mean_outshape
(module_masks, mask, shape)
Similar to view operation, currently mask inference only supports the mean operation on the 3rd and 4th dimensions.
Similar to view operation, currently mask inference only supports the mean operation on the 3rd and 4th dimensions.
def mean_outshape(module_masks, mask, shape): """ Similar to view operation, currently mask inference only supports the mean operation on the 3rd and 4th dimensions. """ assert shape['in_shape'][0] == shape['out_shape'][0] assert shape['out_shape'][1] == shape['in_shape'][1] assert len(shape...
[ "def", "mean_outshape", "(", "module_masks", ",", "mask", ",", "shape", ")", ":", "assert", "shape", "[", "'in_shape'", "]", "[", "0", "]", "==", "shape", "[", "'out_shape'", "]", "[", "0", "]", "assert", "shape", "[", "'out_shape'", "]", "[", "1", "...
[ 663, 0 ]
[ 681, 22 ]
python
en
['en', 'error', 'th']
False
maxpool2d_inshape
(module_masks, mask)
Assume only the second dimension is masked Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the maxpool2d mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its output tensor
Assume only the second dimension is masked
def maxpool2d_inshape(module_masks, mask): """ Assume only the second dimension is masked Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the maxpool2d mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The...
[ "def", "maxpool2d_inshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "assert", "mask", ".", "mask_index", "[", "1", "]", "is", "not", "None", "assert", "mask", ".", "mask_index", "[", "0", "...
[ 684, 0 ]
[ 710, 15 ]
python
en
['en', 'error', 'th']
False
maxpool2d_outshape
(module_masks, mask)
Assume only the second dimension is masked Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the maxpool2d mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its output tensor
Assume only the second dimension is masked
def maxpool2d_outshape(module_masks, mask): """ Assume only the second dimension is masked Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the maxpool2d mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask Th...
[ "def", "maxpool2d_outshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "assert", "mask", ".", "mask_index", "[", "1", "]", "is", "not", "None", "assert", "mask", ".", "mask_index", "[", "0", ...
[ 713, 0 ]
[ 735, 15 ]
python
en
['en', 'error', 'th']
False
relu_inshape
(module_masks, mask)
Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the relu mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its output tensor
Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the relu mask : CoarseMask The mask of its input tensor
def relu_inshape(module_masks, mask): """ Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the relu mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its output tensor """ assert isinstance(m...
[ "def", "relu_inshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "if", "module_masks", ".", "input_mask", "is", "not", "None", ":", "# mask conflict should be solved before speedup", "assert", "module_ma...
[ 738, 0 ]
[ 759, 15 ]
python
en
['en', 'error', 'th']
False
relu_outshape
(module_masks, mask)
Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the relu mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its output tensor
Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the relu mask : CoarseMask The mask of its input tensor
def relu_outshape(module_masks, mask): """ Parameters ---------- module_masks : ModuleMasks The ModuleMasks instance of the relu mask : CoarseMask The mask of its input tensor Returns ------- CoarseMask The mask of its output tensor """ assert isinstance(...
[ "def", "relu_outshape", "(", "module_masks", ",", "mask", ")", ":", "assert", "isinstance", "(", "mask", ",", "CoarseMask", ")", "if", "module_masks", ".", "output_mask", "is", "not", "None", ":", "# mask conflict should be solved before speedup", "assert", "all", ...
[ 762, 0 ]
[ 783, 15 ]
python
en
['en', 'error', 'th']
False