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
AlexaDoorbellEventSource.name
(self)
Return the Alexa API name of this interface.
Return the Alexa API name of this interface.
def name(self): """Return the Alexa API name of this interface.""" return "Alexa.DoorbellEventSource"
[ "def", "name", "(", "self", ")", ":", "return", "\"Alexa.DoorbellEventSource\"" ]
[ 1781, 4 ]
[ 1783, 42 ]
python
en
['en', 'mi', 'en']
True
AlexaDoorbellEventSource.capability_proactively_reported
(self)
Return True for proactively reported capability.
Return True for proactively reported capability.
def capability_proactively_reported(self): """Return True for proactively reported capability.""" return True
[ "def", "capability_proactively_reported", "(", "self", ")", ":", "return", "True" ]
[ 1785, 4 ]
[ 1787, 19 ]
python
en
['en', 'en', 'en']
True
AlexaPlaybackStateReporter.name
(self)
Return the Alexa API name of this interface.
Return the Alexa API name of this interface.
def name(self): """Return the Alexa API name of this interface.""" return "Alexa.PlaybackStateReporter"
[ "def", "name", "(", "self", ")", ":", "return", "\"Alexa.PlaybackStateReporter\"" ]
[ 1798, 4 ]
[ 1800, 44 ]
python
en
['en', 'mi', 'en']
True
AlexaPlaybackStateReporter.properties_supported
(self)
Return what properties this entity supports.
Return what properties this entity supports.
def properties_supported(self): """Return what properties this entity supports.""" return [{"name": "playbackState"}]
[ "def", "properties_supported", "(", "self", ")", ":", "return", "[", "{", "\"name\"", ":", "\"playbackState\"", "}", "]" ]
[ 1802, 4 ]
[ 1804, 42 ]
python
en
['en', 'en', 'en']
True
AlexaPlaybackStateReporter.properties_proactively_reported
(self)
Return True if properties asynchronously reported.
Return True if properties asynchronously reported.
def properties_proactively_reported(self): """Return True if properties asynchronously reported.""" return True
[ "def", "properties_proactively_reported", "(", "self", ")", ":", "return", "True" ]
[ 1806, 4 ]
[ 1808, 19 ]
python
en
['en', 'en', 'en']
True
AlexaPlaybackStateReporter.properties_retrievable
(self)
Return True if properties can be retrieved.
Return True if properties can be retrieved.
def properties_retrievable(self): """Return True if properties can be retrieved.""" return True
[ "def", "properties_retrievable", "(", "self", ")", ":", "return", "True" ]
[ 1810, 4 ]
[ 1812, 19 ]
python
en
['en', 'af', 'en']
True
AlexaPlaybackStateReporter.get_property
(self, name)
Read and return a property.
Read and return a property.
def get_property(self, name): """Read and return a property.""" if name != "playbackState": raise UnsupportedProperty(name) playback_state = self.entity.state if playback_state == STATE_PLAYING: return {"state": "PLAYING"} if playback_state == STATE_PAUSE...
[ "def", "get_property", "(", "self", ",", "name", ")", ":", "if", "name", "!=", "\"playbackState\"", ":", "raise", "UnsupportedProperty", "(", "name", ")", "playback_state", "=", "self", ".", "entity", ".", "state", "if", "playback_state", "==", "STATE_PLAYING"...
[ 1814, 4 ]
[ 1825, 35 ]
python
en
['en', 'en', 'en']
True
AlexaSeekController.name
(self)
Return the Alexa API name of this interface.
Return the Alexa API name of this interface.
def name(self): """Return the Alexa API name of this interface.""" return "Alexa.SeekController"
[ "def", "name", "(", "self", ")", ":", "return", "\"Alexa.SeekController\"" ]
[ 1836, 4 ]
[ 1838, 37 ]
python
en
['en', 'mi', 'en']
True
AlexaEventDetectionSensor.__init__
(self, hass, entity)
Initialize the entity.
Initialize the entity.
def __init__(self, hass, entity): """Initialize the entity.""" super().__init__(entity) self.hass = hass
[ "def", "__init__", "(", "self", ",", "hass", ",", "entity", ")", ":", "super", "(", ")", ".", "__init__", "(", "entity", ")", "self", ".", "hass", "=", "hass" ]
[ 1849, 4 ]
[ 1852, 24 ]
python
en
['en', 'en', 'en']
True
AlexaEventDetectionSensor.name
(self)
Return the Alexa API name of this interface.
Return the Alexa API name of this interface.
def name(self): """Return the Alexa API name of this interface.""" return "Alexa.EventDetectionSensor"
[ "def", "name", "(", "self", ")", ":", "return", "\"Alexa.EventDetectionSensor\"" ]
[ 1854, 4 ]
[ 1856, 43 ]
python
en
['en', 'mi', 'en']
True
AlexaEventDetectionSensor.properties_supported
(self)
Return what properties this entity supports.
Return what properties this entity supports.
def properties_supported(self): """Return what properties this entity supports.""" return [{"name": "humanPresenceDetectionState"}]
[ "def", "properties_supported", "(", "self", ")", ":", "return", "[", "{", "\"name\"", ":", "\"humanPresenceDetectionState\"", "}", "]" ]
[ 1858, 4 ]
[ 1860, 56 ]
python
en
['en', 'en', 'en']
True
AlexaEventDetectionSensor.properties_proactively_reported
(self)
Return True if properties asynchronously reported.
Return True if properties asynchronously reported.
def properties_proactively_reported(self): """Return True if properties asynchronously reported.""" return True
[ "def", "properties_proactively_reported", "(", "self", ")", ":", "return", "True" ]
[ 1862, 4 ]
[ 1864, 19 ]
python
en
['en', 'en', 'en']
True
AlexaEventDetectionSensor.get_property
(self, name)
Read and return a property.
Read and return a property.
def get_property(self, name): """Read and return a property.""" if name != "humanPresenceDetectionState": raise UnsupportedProperty(name) human_presence = "NOT_DETECTED" state = self.entity.state # Return None for unavailable and unknown states. # Allows the...
[ "def", "get_property", "(", "self", ",", "name", ")", ":", "if", "name", "!=", "\"humanPresenceDetectionState\"", ":", "raise", "UnsupportedProperty", "(", "name", ")", "human_presence", "=", "\"NOT_DETECTED\"", "state", "=", "self", ".", "entity", ".", "state",...
[ 1866, 4 ]
[ 1885, 40 ]
python
en
['en', 'en', 'en']
True
AlexaEventDetectionSensor.configuration
(self)
Return supported detection types.
Return supported detection types.
def configuration(self): """Return supported detection types.""" return { "detectionMethods": ["AUDIO", "VIDEO"], "detectionModes": { "humanPresence": { "featureAvailability": "ENABLED", "supportsNotDetected": True, ...
[ "def", "configuration", "(", "self", ")", ":", "return", "{", "\"detectionMethods\"", ":", "[", "\"AUDIO\"", ",", "\"VIDEO\"", "]", ",", "\"detectionModes\"", ":", "{", "\"humanPresence\"", ":", "{", "\"featureAvailability\"", ":", "\"ENABLED\"", ",", "\"supportsN...
[ 1887, 4 ]
[ 1897, 9 ]
python
en
['en', 'en', 'en']
True
AlexaEqualizerController.name
(self)
Return the Alexa API name of this interface.
Return the Alexa API name of this interface.
def name(self): """Return the Alexa API name of this interface.""" return "Alexa.EqualizerController"
[ "def", "name", "(", "self", ")", ":", "return", "\"Alexa.EqualizerController\"" ]
[ 1915, 4 ]
[ 1917, 42 ]
python
en
['en', 'mi', 'en']
True
AlexaEqualizerController.properties_supported
(self)
Return what properties this entity supports. Either bands, mode or both can be specified. Only mode is supported at this time.
Return what properties this entity supports.
def properties_supported(self): """Return what properties this entity supports. Either bands, mode or both can be specified. Only mode is supported at this time. """ return [{"name": "mode"}]
[ "def", "properties_supported", "(", "self", ")", ":", "return", "[", "{", "\"name\"", ":", "\"mode\"", "}", "]" ]
[ 1919, 4 ]
[ 1924, 33 ]
python
en
['en', 'en', 'en']
True
AlexaEqualizerController.get_property
(self, name)
Read and return a property.
Read and return a property.
def get_property(self, name): """Read and return a property.""" if name != "mode": raise UnsupportedProperty(name) sound_mode = self.entity.attributes.get(media_player.ATTR_SOUND_MODE) if sound_mode and sound_mode.upper() in self.VALID_SOUND_MODES: return sound_m...
[ "def", "get_property", "(", "self", ",", "name", ")", ":", "if", "name", "!=", "\"mode\"", ":", "raise", "UnsupportedProperty", "(", "name", ")", "sound_mode", "=", "self", ".", "entity", ".", "attributes", ".", "get", "(", "media_player", ".", "ATTR_SOUND...
[ 1926, 4 ]
[ 1935, 19 ]
python
en
['en', 'en', 'en']
True
AlexaEqualizerController.configurations
(self)
Return the sound modes supported in the configurations object.
Return the sound modes supported in the configurations object.
def configurations(self): """Return the sound modes supported in the configurations object.""" configurations = None supported_sound_modes = self.get_valid_inputs( self.entity.attributes.get(media_player.ATTR_SOUND_MODE_LIST, []) ) if supported_sound_modes: ...
[ "def", "configurations", "(", "self", ")", ":", "configurations", "=", "None", "supported_sound_modes", "=", "self", ".", "get_valid_inputs", "(", "self", ".", "entity", ".", "attributes", ".", "get", "(", "media_player", ".", "ATTR_SOUND_MODE_LIST", ",", "[", ...
[ 1937, 4 ]
[ 1946, 29 ]
python
en
['en', 'en', 'en']
True
AlexaEqualizerController.get_valid_inputs
(cls, sound_mode_list)
Return list of supported inputs.
Return list of supported inputs.
def get_valid_inputs(cls, sound_mode_list): """Return list of supported inputs.""" input_list = [] for sound_mode in sound_mode_list: sound_mode = sound_mode.upper() if sound_mode in cls.VALID_SOUND_MODES: input_list.append({"name": sound_mode}) ...
[ "def", "get_valid_inputs", "(", "cls", ",", "sound_mode_list", ")", ":", "input_list", "=", "[", "]", "for", "sound_mode", "in", "sound_mode_list", ":", "sound_mode", "=", "sound_mode", ".", "upper", "(", ")", "if", "sound_mode", "in", "cls", ".", "VALID_SOU...
[ 1949, 4 ]
[ 1958, 25 ]
python
en
['en', 'en', 'en']
True
AlexaTimeHoldController.__init__
(self, entity, allow_remote_resume=False)
Initialize the entity.
Initialize the entity.
def __init__(self, entity, allow_remote_resume=False): """Initialize the entity.""" super().__init__(entity) self._allow_remote_resume = allow_remote_resume
[ "def", "__init__", "(", "self", ",", "entity", ",", "allow_remote_resume", "=", "False", ")", ":", "super", "(", ")", ".", "__init__", "(", "entity", ")", "self", ".", "_allow_remote_resume", "=", "allow_remote_resume" ]
[ 1969, 4 ]
[ 1972, 55 ]
python
en
['en', 'en', 'en']
True
AlexaTimeHoldController.name
(self)
Return the Alexa API name of this interface.
Return the Alexa API name of this interface.
def name(self): """Return the Alexa API name of this interface.""" return "Alexa.TimeHoldController"
[ "def", "name", "(", "self", ")", ":", "return", "\"Alexa.TimeHoldController\"" ]
[ 1974, 4 ]
[ 1976, 41 ]
python
en
['en', 'mi', 'en']
True
AlexaTimeHoldController.configuration
(self)
Return configuration object. Set allowRemoteResume to True if Alexa can restart the operation on the device. When false, Alexa does not send the Resume directive.
Return configuration object.
def configuration(self): """Return configuration object. Set allowRemoteResume to True if Alexa can restart the operation on the device. When false, Alexa does not send the Resume directive. """ return {"allowRemoteResume": self._allow_remote_resume}
[ "def", "configuration", "(", "self", ")", ":", "return", "{", "\"allowRemoteResume\"", ":", "self", ".", "_allow_remote_resume", "}" ]
[ 1978, 4 ]
[ 1984, 63 ]
python
en
['en', 'bg', 'en']
True
AlexaCameraStreamController.name
(self)
Return the Alexa API name of this interface.
Return the Alexa API name of this interface.
def name(self): """Return the Alexa API name of this interface.""" return "Alexa.CameraStreamController"
[ "def", "name", "(", "self", ")", ":", "return", "\"Alexa.CameraStreamController\"" ]
[ 2008, 4 ]
[ 2010, 45 ]
python
en
['en', 'mi', 'en']
True
AlexaCameraStreamController.camera_stream_configurations
(self)
Return cameraStreamConfigurations object.
Return cameraStreamConfigurations object.
def camera_stream_configurations(self): """Return cameraStreamConfigurations object.""" return [ { "protocols": ["HLS"], "resolutions": [{"width": 1280, "height": 720}], "authorizationTypes": ["NONE"], "videoCodecs": ["H264"], ...
[ "def", "camera_stream_configurations", "(", "self", ")", ":", "return", "[", "{", "\"protocols\"", ":", "[", "\"HLS\"", "]", ",", "\"resolutions\"", ":", "[", "{", "\"width\"", ":", "1280", ",", "\"height\"", ":", "720", "}", "]", ",", "\"authorizationTypes\...
[ 2012, 4 ]
[ 2022, 9 ]
python
en
['en', 'en', 'en']
True
require_distributed_retrieval
(test_case)
Decorator marking a test that requires a set of dependencies necessary for pefrorm retrieval with :class:`~transformers.RagRetriever`. These tests are skipped when respective libraries are not installed.
Decorator marking a test that requires a set of dependencies necessary for pefrorm retrieval with :class:`~transformers.RagRetriever`.
def require_distributed_retrieval(test_case): """ Decorator marking a test that requires a set of dependencies necessary for pefrorm retrieval with :class:`~transformers.RagRetriever`. These tests are skipped when respective libraries are not installed. """ if not (is_datasets_available() and ...
[ "def", "require_distributed_retrieval", "(", "test_case", ")", ":", "if", "not", "(", "is_datasets_available", "(", ")", "and", "is_faiss_available", "(", ")", "and", "is_psutil_available", "(", ")", ")", ":", "test_case", "=", "unittest", ".", "skip", "(", "\...
[ 38, 0 ]
[ 48, 20 ]
python
en
['en', 'error', 'th']
False
SpotifyFlowHandler.__init__
(self)
Instantiate config flow.
Instantiate config flow.
def __init__(self) -> None: """Instantiate config flow.""" super().__init__() self.entry: Optional[Dict[str, Any]] = None
[ "def", "__init__", "(", "self", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "entry", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None" ]
[ 23, 4 ]
[ 26, 51 ]
python
en
['en', 'nl', 'en']
True
SpotifyFlowHandler.logger
(self)
Return logger.
Return logger.
def logger(self) -> logging.Logger: """Return logger.""" return logging.getLogger(__name__)
[ "def", "logger", "(", "self", ")", "->", "logging", ".", "Logger", ":", "return", "logging", ".", "getLogger", "(", "__name__", ")" ]
[ 29, 4 ]
[ 31, 42 ]
python
en
['es', 'no', 'en']
False
SpotifyFlowHandler.extra_authorize_data
(self)
Extra data that needs to be appended to the authorize url.
Extra data that needs to be appended to the authorize url.
def extra_authorize_data(self) -> Dict[str, Any]: """Extra data that needs to be appended to the authorize url.""" return {"scope": ",".join(SPOTIFY_SCOPES)}
[ "def", "extra_authorize_data", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "\"scope\"", ":", "\",\"", ".", "join", "(", "SPOTIFY_SCOPES", ")", "}" ]
[ 34, 4 ]
[ 36, 50 ]
python
en
['en', 'en', 'en']
True
SpotifyFlowHandler.async_oauth_create_entry
(self, data: Dict[str, Any])
Create an entry for Spotify.
Create an entry for Spotify.
async def async_oauth_create_entry(self, data: Dict[str, Any]) -> Dict[str, Any]: """Create an entry for Spotify.""" spotify = Spotify(auth=data["token"]["access_token"]) try: current_user = await self.hass.async_add_executor_job(spotify.current_user) except Exception: # py...
[ "async", "def", "async_oauth_create_entry", "(", "self", ",", "data", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "spotify", "=", "Spotify", "(", "auth", "=", "data", "[", "\"token\"", "]", "[", "\...
[ 38, 4 ]
[ 58, 61 ]
python
en
['en', 'en', 'en']
True
SpotifyFlowHandler.async_step_reauth
(self, entry: Dict[str, Any])
Perform reauth upon migration of old entries.
Perform reauth upon migration of old entries.
async def async_step_reauth(self, entry: Dict[str, Any]) -> Dict[str, Any]: """Perform reauth upon migration of old entries.""" if entry: self.entry = entry assert self.hass persistent_notification.async_create( self.hass, f"Spotify integration for ac...
[ "async", "def", "async_step_reauth", "(", "self", ",", "entry", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "entry", ":", "self", ".", "entry", "=", "entry", "assert", "self", ".", "hass", ...
[ 60, 4 ]
[ 73, 53 ]
python
en
['en', 'en', 'en']
True
SpotifyFlowHandler.async_step_reauth_confirm
( self, user_input: Optional[Dict[str, Any]] = None )
Confirm reauth dialog.
Confirm reauth dialog.
async def async_step_reauth_confirm( self, user_input: Optional[Dict[str, Any]] = None ) -> Dict[str, Any]: """Confirm reauth dialog.""" if user_input is None: return self.async_show_form( step_id="reauth_confirm", description_placeholders={"accoun...
[ "async", "def", "async_step_reauth_confirm", "(", "self", ",", "user_input", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "user_input", "is", "None", ":", "ret...
[ 75, 4 ]
[ 92, 9 ]
python
de
['de', 'pt', 'en']
False
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Supla covers.
Set up the Supla covers.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Supla covers.""" if discovery_info is None: return _LOGGER.debug("Discovery: %s", pformat(discovery_info)) entities = [] for device in discovery_info: device_name = device["function...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "_LOGGER", ".", "debug", "(", "\"Discovery: %s\"", ",", "pformat", ...
[ 22, 0 ]
[ 52, 32 ]
python
en
['en', 'en', 'en']
True
SuplaCover.current_cover_position
(self)
Return current position of cover. 0 is closed, 100 is open.
Return current position of cover. 0 is closed, 100 is open.
def current_cover_position(self): """Return current position of cover. 0 is closed, 100 is open.""" state = self.channel_data.get("state") if state: return 100 - state["shut"] return None
[ "def", "current_cover_position", "(", "self", ")", ":", "state", "=", "self", ".", "channel_data", ".", "get", "(", "\"state\"", ")", "if", "state", ":", "return", "100", "-", "state", "[", "\"shut\"", "]", "return", "None" ]
[ 59, 4 ]
[ 64, 19 ]
python
en
['en', 'en', 'en']
True
SuplaCover.async_set_cover_position
(self, **kwargs)
Move the cover to a specific position.
Move the cover to a specific position.
async def async_set_cover_position(self, **kwargs): """Move the cover to a specific position.""" await self.async_action("REVEAL", percentage=kwargs.get(ATTR_POSITION))
[ "async", "def", "async_set_cover_position", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_action", "(", "\"REVEAL\"", ",", "percentage", "=", "kwargs", ".", "get", "(", "ATTR_POSITION", ")", ")" ]
[ 66, 4 ]
[ 68, 79 ]
python
en
['en', 'en', 'en']
True
SuplaCover.is_closed
(self)
Return if the cover is closed.
Return if the cover is closed.
def is_closed(self): """Return if the cover is closed.""" if self.current_cover_position is None: return None return self.current_cover_position == 0
[ "def", "is_closed", "(", "self", ")", ":", "if", "self", ".", "current_cover_position", "is", "None", ":", "return", "None", "return", "self", ".", "current_cover_position", "==", "0" ]
[ 71, 4 ]
[ 75, 47 ]
python
en
['en', 'en', 'en']
True
SuplaCover.async_open_cover
(self, **kwargs)
Open the cover.
Open the cover.
async def async_open_cover(self, **kwargs): """Open the cover.""" await self.async_action("REVEAL")
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_action", "(", "\"REVEAL\"", ")" ]
[ 77, 4 ]
[ 79, 41 ]
python
en
['en', 'en', 'en']
True
SuplaCover.async_close_cover
(self, **kwargs)
Close the cover.
Close the cover.
async def async_close_cover(self, **kwargs): """Close the cover.""" await self.async_action("SHUT")
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_action", "(", "\"SHUT\"", ")" ]
[ 81, 4 ]
[ 83, 39 ]
python
en
['en', 'en', 'en']
True
SuplaCover.async_stop_cover
(self, **kwargs)
Stop the cover.
Stop the cover.
async def async_stop_cover(self, **kwargs): """Stop the cover.""" await self.async_action("STOP")
[ "async", "def", "async_stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_action", "(", "\"STOP\"", ")" ]
[ 85, 4 ]
[ 87, 39 ]
python
en
['en', 'en', 'en']
True
SuplaGateDoor.is_closed
(self)
Return if the gate is closed or not.
Return if the gate is closed or not.
def is_closed(self): """Return if the gate is closed or not.""" state = self.channel_data.get("state") if state and "hi" in state: return state.get("hi") return None
[ "def", "is_closed", "(", "self", ")", ":", "state", "=", "self", ".", "channel_data", ".", "get", "(", "\"state\"", ")", "if", "state", "and", "\"hi\"", "in", "state", ":", "return", "state", ".", "get", "(", "\"hi\"", ")", "return", "None" ]
[ 94, 4 ]
[ 99, 19 ]
python
en
['en', 'en', 'en']
True
SuplaGateDoor.async_open_cover
(self, **kwargs)
Open the gate.
Open the gate.
async def async_open_cover(self, **kwargs) -> None: """Open the gate.""" if self.is_closed: await self.async_action("OPEN_CLOSE")
[ "async", "def", "async_open_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "self", ".", "is_closed", ":", "await", "self", ".", "async_action", "(", "\"OPEN_CLOSE\"", ")" ]
[ 101, 4 ]
[ 104, 49 ]
python
en
['en', 'en', 'en']
True
SuplaGateDoor.async_close_cover
(self, **kwargs)
Close the gate.
Close the gate.
async def async_close_cover(self, **kwargs) -> None: """Close the gate.""" if not self.is_closed: await self.async_action("OPEN_CLOSE")
[ "async", "def", "async_close_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "if", "not", "self", ".", "is_closed", ":", "await", "self", ".", "async_action", "(", "\"OPEN_CLOSE\"", ")" ]
[ 106, 4 ]
[ 109, 49 ]
python
en
['en', 'co', 'en']
True
SuplaGateDoor.async_stop_cover
(self, **kwargs)
Stop the gate.
Stop the gate.
async def async_stop_cover(self, **kwargs) -> None: """Stop the gate.""" await self.async_action("OPEN_CLOSE")
[ "async", "def", "async_stop_cover", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "async_action", "(", "\"OPEN_CLOSE\"", ")" ]
[ 111, 4 ]
[ 113, 45 ]
python
en
['en', 'en', 'en']
True
SuplaGateDoor.async_toggle
(self, **kwargs)
Toggle the gate.
Toggle the gate.
async def async_toggle(self, **kwargs) -> None: """Toggle the gate.""" await self.async_action("OPEN_CLOSE")
[ "async", "def", "async_toggle", "(", "self", ",", "*", "*", "kwargs", ")", "->", "None", ":", "await", "self", ".", "async_action", "(", "\"OPEN_CLOSE\"", ")" ]
[ 115, 4 ]
[ 117, 45 ]
python
en
['en', 'sm', 'en']
True
SuplaGateDoor.device_class
(self)
Return the class of this device, from component DEVICE_CLASSES.
Return the class of this device, from component DEVICE_CLASSES.
def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" return DEVICE_CLASS_GARAGE
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_GARAGE" ]
[ 120, 4 ]
[ 122, 34 ]
python
en
['en', 'en', 'en']
True
FinishedIndividual.__init__
(self, parameter_id, parameters, result)
Parameters ---------- parameter_id: int the index of the parameter parameters : dict chosen architecture and parameters result : float final metric of the chosen one
Parameters ---------- parameter_id: int the index of the parameter parameters : dict chosen architecture and parameters result : float final metric of the chosen one
def __init__(self, parameter_id, parameters, result): """ Parameters ---------- parameter_id: int the index of the parameter parameters : dict chosen architecture and parameters result : float final metric of the chosen one """ ...
[ "def", "__init__", "(", "self", ",", "parameter_id", ",", "parameters", ",", "result", ")", ":", "self", ".", "parameter_id", "=", "parameter_id", "self", ".", "parameters", "=", "parameters", "self", ".", "result", "=", "result" ]
[ 15, 4 ]
[ 28, 28 ]
python
en
['en', 'error', 'th']
False
RegularizedEvolutionTuner.generate_parameters
(self, parameter_id, **kwargs)
This function will returns a dict of trial (hyper-)parameters, as a serializable object. Parameters --- parameter_id: int the index of current set of parameters
This function will returns a dict of trial (hyper-)parameters, as a serializable object.
def generate_parameters(self, parameter_id, **kwargs): """ This function will returns a dict of trial (hyper-)parameters, as a serializable object. Parameters --- parameter_id: int the index of current set of parameters """ if self.initial_population:...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "initial_population", ":", "arch", "=", "self", ".", "initial_population", ".", "popleft", "(", ")", "self", ".", "history", "[", "paramet...
[ 65, 4 ]
[ 90, 38 ]
python
en
['en', 'error', 'th']
False
RegularizedEvolutionTuner.receive_trial_result
(self, parameter_id, parameters, value, **kwargs)
Record the result from a trial Parameters ---------- parameter_id : int parameters : dict value : dict/float if value is dict, it should have "default" key. value is final metrics of the trial.
Record the result from a trial
def receive_trial_result(self, parameter_id, parameters, value, **kwargs): """ Record the result from a trial Parameters ---------- parameter_id : int parameters : dict value : dict/float if value is dict, it should have "default" key. val...
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ",", "*", "*", "kwargs", ")", ":", "reward", "=", "extract_scalar_reward", "(", "value", ")", "if", "parameter_id", "not", "in", "self", ".", "history", ":", ...
[ 92, 4 ]
[ 114, 37 ]
python
en
['en', 'error', 'th']
False
RegularizedEvolutionTuner.update_search_space
(self, search_space)
Update search space. Search_space contains the information that user pre-defined. Parameters ---------- search_space : dict
Update search space. Search_space contains the information that user pre-defined.
def update_search_space(self, search_space): """ Update search space. Search_space contains the information that user pre-defined. Parameters ---------- search_space : dict """ logger.info('update search space %s', search_space) assert self.search...
[ "def", "update_search_space", "(", "self", ",", "search_space", ")", ":", "logger", ".", "info", "(", "'update search space %s'", ",", "search_space", ")", "assert", "self", ".", "search_space", "is", "None", "self", ".", "search_space", "=", "search_space", "fo...
[ 116, 4 ]
[ 133, 43 ]
python
en
['en', 'error', 'th']
False
ConfigBase.__init__
(self, *, _base_path: Optional[Path] = None, **kwargs)
Initialize a config object and set some fields. Name of keyword arguments can either be snake_case or camelCase. They will be converted to snake_case automatically. If a field is missing and don't have default value, it will be set to `dataclasses.MISSING`.
Initialize a config object and set some fields. Name of keyword arguments can either be snake_case or camelCase. They will be converted to snake_case automatically. If a field is missing and don't have default value, it will be set to `dataclasses.MISSING`.
def __init__(self, *, _base_path: Optional[Path] = None, **kwargs): """ Initialize a config object and set some fields. Name of keyword arguments can either be snake_case or camelCase. They will be converted to snake_case automatically. If a field is missing and don't have defaul...
[ "def", "__init__", "(", "self", ",", "*", ",", "_base_path", ":", "Optional", "[", "Path", "]", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "'basepath'", "in", "kwargs", ":", "_base_path", "=", "kwargs", ".", "pop", "(", "'basepath'", ")", ...
[ 42, 4 ]
[ 66, 68 ]
python
en
['en', 'error', 'th']
False
ConfigBase.load
(cls: Type[T], path: PathLike)
Load config from YAML (or JSON) file. Keys in YAML file can either be camelCase or snake_case.
Load config from YAML (or JSON) file. Keys in YAML file can either be camelCase or snake_case.
def load(cls: Type[T], path: PathLike) -> T: """ Load config from YAML (or JSON) file. Keys in YAML file can either be camelCase or snake_case. """ data = yaml.safe_load(open(path)) if not isinstance(data, dict): raise ValueError(f'Content of config file {path...
[ "def", "load", "(", "cls", ":", "Type", "[", "T", "]", ",", "path", ":", "PathLike", ")", "->", "T", ":", "data", "=", "yaml", ".", "safe_load", "(", "open", "(", "path", ")", ")", "if", "not", "isinstance", "(", "data", ",", "dict", ")", ":", ...
[ 69, 4 ]
[ 77, 56 ]
python
en
['en', 'error', 'th']
False
ConfigBase.json
(self)
Convert config to JSON object. The keys of returned object will be camelCase.
Convert config to JSON object. The keys of returned object will be camelCase.
def json(self) -> Dict[str, Any]: """ Convert config to JSON object. The keys of returned object will be camelCase. """ self.validate() return dataclasses.asdict( self.canonical(), dict_factory=lambda items: dict((util.camel_case(k), v) for k, v in...
[ "def", "json", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "self", ".", "validate", "(", ")", "return", "dataclasses", ".", "asdict", "(", "self", ".", "canonical", "(", ")", ",", "dict_factory", "=", "lambda", "items", ":", "...
[ 79, 4 ]
[ 88, 9 ]
python
en
['en', 'error', 'th']
False
ConfigBase.canonical
(self: T)
Returns a deep copy, where the fields supporting multiple formats are converted to the canonical format. Noticeably, relative path may be converted to absolute path.
Returns a deep copy, where the fields supporting multiple formats are converted to the canonical format. Noticeably, relative path may be converted to absolute path.
def canonical(self: T) -> T: """ Returns a deep copy, where the fields supporting multiple formats are converted to the canonical format. Noticeably, relative path may be converted to absolute path. """ ret = copy.deepcopy(self) for field in dataclasses.fields(ret): ...
[ "def", "canonical", "(", "self", ":", "T", ")", "->", "T", ":", "ret", "=", "copy", ".", "deepcopy", "(", "self", ")", "for", "field", "in", "dataclasses", ".", "fields", "(", "ret", ")", ":", "key", ",", "value", "=", "field", ".", "name", ",", ...
[ 90, 4 ]
[ 106, 18 ]
python
en
['en', 'error', 'th']
False
ConfigBase.validate
(self)
Validate the config object and raise Exception if it's ill-formed.
Validate the config object and raise Exception if it's ill-formed.
def validate(self) -> None: """ Validate the config object and raise Exception if it's ill-formed. """ class_name = type(self).__name__ config = self.canonical() for field in dataclasses.fields(config): key, value = field.name, getattr(config, field.name) ...
[ "def", "validate", "(", "self", ")", "->", "None", ":", "class_name", "=", "type", "(", "self", ")", ".", "__name__", "config", "=", "self", ".", "canonical", "(", ")", "for", "field", "in", "dataclasses", ".", "fields", "(", "config", ")", ":", "key...
[ 108, 4 ]
[ 152, 32 ]
python
en
['en', 'error', 'th']
False
AutoConfigTest.test_pattern_matching_fallback
(self)
In cases where config.json doesn't include a model_type, perform a few safety checks on the config mapping's order.
In cases where config.json doesn't include a model_type, perform a few safety checks on the config mapping's order.
def test_pattern_matching_fallback(self): """ In cases where config.json doesn't include a model_type, perform a few safety checks on the config mapping's order. """ # no key string should be included in a later key string (typical failure case) keys = list(CONFIG_MAPPING...
[ "def", "test_pattern_matching_fallback", "(", "self", ")", ":", "# no key string should be included in a later key string (typical failure case)", "keys", "=", "list", "(", "CONFIG_MAPPING", ".", "keys", "(", ")", ")", "for", "i", ",", "key", "in", "enumerate", "(", "...
[ 44, 4 ]
[ 52, 82 ]
python
en
['en', 'error', 'th']
False
shape
(tensor)
Get shape of variable. Return type is tuple.
Get shape of variable. Return type is tuple.
def shape(tensor): ''' Get shape of variable. Return type is tuple. ''' temp_s = tensor.get_shape() return tuple([temp_s[i].value for i in range(0, len(temp_s))])
[ "def", "shape", "(", "tensor", ")", ":", "temp_s", "=", "tensor", ".", "get_shape", "(", ")", "return", "tuple", "(", "[", "temp_s", "[", "i", "]", ".", "value", "for", "i", "in", "range", "(", "0", ",", "len", "(", "temp_s", ")", ")", "]", ")"...
[ 29, 0 ]
[ 35, 66 ]
python
en
['en', 'error', 'th']
False
get_variable
(name, temp_s)
Get variable by name.
Get variable by name.
def get_variable(name, temp_s): ''' Get variable by name. ''' return tf.Variable(tf.zeros(temp_s), name=name)
[ "def", "get_variable", "(", "name", ",", "temp_s", ")", ":", "return", "tf", ".", "Variable", "(", "tf", ".", "zeros", "(", "temp_s", ")", ",", "name", "=", "name", ")" ]
[ 38, 0 ]
[ 42, 51 ]
python
en
['en', 'error', 'th']
False
dropout
(tensor, drop_prob, is_training)
Dropout except test.
Dropout except test.
def dropout(tensor, drop_prob, is_training): ''' Dropout except test. ''' if not is_training: return tensor return tf.nn.dropout(tensor, 1.0 - drop_prob)
[ "def", "dropout", "(", "tensor", ",", "drop_prob", ",", "is_training", ")", ":", "if", "not", "is_training", ":", "return", "tensor", "return", "tf", ".", "nn", ".", "dropout", "(", "tensor", ",", "1.0", "-", "drop_prob", ")" ]
[ 45, 0 ]
[ 51, 49 ]
python
en
['en', 'error', 'th']
False
Timer.start
(self)
Start to calculate time.
Start to calculate time.
def start(self): ''' Start to calculate time. ''' self.__start = time.time()
[ "def", "start", "(", "self", ")", ":", "self", ".", "__start", "=", "time", ".", "time", "(", ")" ]
[ 61, 4 ]
[ 65, 34 ]
python
en
['en', 'error', 'th']
False
Timer.get_elapsed
(self, restart=True)
Calculate time span.
Calculate time span.
def get_elapsed(self, restart=True): ''' Calculate time span. ''' end = time.time() span = end - self.__start if restart: self.__start = end return span
[ "def", "get_elapsed", "(", "self", ",", "restart", "=", "True", ")", ":", "end", "=", "time", ".", "time", "(", ")", "span", "=", "end", "-", "self", ".", "__start", "if", "restart", ":", "self", ".", "__start", "=", "end", "return", "span" ]
[ 67, 4 ]
[ 75, 19 ]
python
en
['en', 'error', 'th']
False
require_deepspeed
(test_case)
Decorator marking a test that requires deepspeed
Decorator marking a test that requires deepspeed
def require_deepspeed(test_case): """ Decorator marking a test that requires deepspeed """ if not is_deepspeed_available(): return unittest.skip("test requires deepspeed")(test_case) else: return test_case
[ "def", "require_deepspeed", "(", "test_case", ")", ":", "if", "not", "is_deepspeed_available", "(", ")", ":", "return", "unittest", ".", "skip", "(", "\"test requires deepspeed\"", ")", "(", "test_case", ")", "else", ":", "return", "test_case" ]
[ 53, 0 ]
[ 60, 24 ]
python
en
['en', 'error', 'th']
False
test_cannot_connect
(hass)
Test connection error.
Test connection error.
async def test_cannot_connect(hass): """Test connection error.""" with patch( "homeassistant.components.risco.RiscoAPI.login", side_effect=CannotConnectError, ): config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG) config_entry.add_to_hass(hass) await hass...
[ "async", "def", "test_cannot_connect", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.risco.RiscoAPI.login\"", ",", "side_effect", "=", "CannotConnectError", ",", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN",...
[ 107, 0 ]
[ 121, 51 ]
python
de
['eu', 'de', 'en']
False
test_unauthorized
(hass)
Test unauthorized error.
Test unauthorized error.
async def test_unauthorized(hass): """Test unauthorized error.""" with patch( "homeassistant.components.risco.RiscoAPI.login", side_effect=UnauthorizedError, ): config_entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG) config_entry.add_to_hass(hass) await hass....
[ "async", "def", "test_unauthorized", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.risco.RiscoAPI.login\"", ",", "side_effect", "=", "UnauthorizedError", ",", ")", ":", "config_entry", "=", "MockConfigEntry", "(", "domain", "=", "DOMAIN", ...
[ 124, 0 ]
[ 138, 51 ]
python
ca
['ca', 'de', 'it']
False
test_setup
(hass, two_zone_alarm)
Test entity setup.
Test entity setup.
async def test_setup(hass, two_zone_alarm): # noqa: F811 """Test entity setup.""" registry = await hass.helpers.entity_registry.async_get_registry() for id in ENTITY_IDS.values(): assert not registry.async_is_registered(id) with patch( "homeassistant.components.risco.RiscoAPI.get_even...
[ "async", "def", "test_setup", "(", "hass", ",", "two_zone_alarm", ")", ":", "# noqa: F811", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "for", "id", "in", "ENTITY_IDS", ".", "values", "(", ")...
[ 164, 0 ]
[ 201, 47 ]
python
en
['en', 'zu', 'en']
True
test_form
(hass)
Test user config.
Test user config.
async def test_form(hass): """Test user config.""" # First get the form result = await hass.config_entries.flow.async_init( SRP_ENERGY_DOMAIN, context={"source": "user"} ) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user" assert result["erro...
[ "async", "def", "test_form", "(", "hass", ")", ":", "# First get the form", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "SRP_ENERGY_DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\"", "}", ")", "a...
[ 9, 0 ]
[ 29, 51 ]
python
en
['en', 'da', 'en']
True
test_form_invalid_auth
(hass)
Test user config with invalid auth.
Test user config with invalid auth.
async def test_form_invalid_auth(hass): """Test user config with invalid auth.""" result = await hass.config_entries.flow.async_init( SRP_ENERGY_DOMAIN, context={"source": "user"} ) with patch( "homeassistant.components.srp_energy.config_flow.SrpEnergyClient.validate", return_va...
[ "async", "def", "test_form_invalid_auth", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "SRP_ENERGY_DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\"", "}", ")", "with", "patc...
[ 32, 0 ]
[ 47, 57 ]
python
en
['en', 'en', 'en']
True
test_form_value_error
(hass)
Test user config that throws a value error.
Test user config that throws a value error.
async def test_form_value_error(hass): """Test user config that throws a value error.""" result = await hass.config_entries.flow.async_init( SRP_ENERGY_DOMAIN, context={"source": "user"} ) with patch( "homeassistant.components.srp_energy.config_flow.SrpEnergyClient", side_effect...
[ "async", "def", "test_form_value_error", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "SRP_ENERGY_DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\"", "}", ")", "with", "patch...
[ 50, 0 ]
[ 65, 60 ]
python
en
['en', 'en', 'en']
True
test_form_unknown_exception
(hass)
Test user config that throws an unknown exception.
Test user config that throws an unknown exception.
async def test_form_unknown_exception(hass): """Test user config that throws an unknown exception.""" result = await hass.config_entries.flow.async_init( SRP_ENERGY_DOMAIN, context={"source": "user"} ) with patch( "homeassistant.components.srp_energy.config_flow.SrpEnergyClient", ...
[ "async", "def", "test_form_unknown_exception", "(", "hass", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "SRP_ENERGY_DOMAIN", ",", "context", "=", "{", "\"source\"", ":", "\"user\"", "}", ")", "with", ...
[ 68, 0 ]
[ 83, 52 ]
python
en
['en', 'en', 'en']
True
test_config
(hass)
Test handling of configuration imported.
Test handling of configuration imported.
async def test_config(hass): """Test handling of configuration imported.""" with patch("homeassistant.components.srp_energy.config_flow.SrpEnergyClient"): result = await hass.config_entries.flow.async_init( SRP_ENERGY_DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, ...
[ "async", "def", "test_config", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.srp_energy.config_flow.SrpEnergyClient\"", ")", ":", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "SRP_ENERGY_DOMAIN"...
[ 86, 0 ]
[ 94, 73 ]
python
en
['en', 'en', 'en']
True
test_integration_already_configured
(hass)
Test integration is already configured.
Test integration is already configured.
async def test_integration_already_configured(hass): """Test integration is already configured.""" await init_integration(hass) result = await hass.config_entries.flow.async_init( SRP_ENERGY_DOMAIN, context={"source": "user"} ) assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT a...
[ "async", "def", "test_integration_already_configured", "(", "hass", ")", ":", "await", "init_integration", "(", "hass", ")", "result", "=", "await", "hass", ".", "config_entries", ".", "flow", ".", "async_init", "(", "SRP_ENERGY_DOMAIN", ",", "context", "=", "{"...
[ 97, 0 ]
[ 104, 56 ]
python
en
['en', 'en', 'en']
True
convert_bort_checkpoint_to_pytorch
(bort_checkpoint_path: str, pytorch_dump_folder_path: str)
Convert the original Bort checkpoint (based on MXNET and Gluonnlp) to our BERT structure-
Convert the original Bort checkpoint (based on MXNET and Gluonnlp) to our BERT structure-
def convert_bort_checkpoint_to_pytorch(bort_checkpoint_path: str, pytorch_dump_folder_path: str): """ Convert the original Bort checkpoint (based on MXNET and Gluonnlp) to our BERT structure- """ # Original Bort configuration bort_4_8_768_1024_hparams = { "attention_cell": "multi_head", ...
[ "def", "convert_bort_checkpoint_to_pytorch", "(", "bort_checkpoint_path", ":", "str", ",", "pytorch_dump_folder_path", ":", "str", ")", ":", "# Original Bort configuration", "bort_4_8_768_1024_hparams", "=", "{", "\"attention_cell\"", ":", "\"multi_head\"", ",", "\"num_layers...
[ 53, 0 ]
[ 304, 59 ]
python
en
['en', 'error', 'th']
False
get_scanner
(_hass, config)
Validate the configuration and return a Hitron CODA-4582U scanner.
Validate the configuration and return a Hitron CODA-4582U scanner.
def get_scanner(_hass, config): """Validate the configuration and return a Hitron CODA-4582U scanner.""" scanner = HitronCODADeviceScanner(config[DOMAIN]) return scanner if scanner.success_init else None
[ "def", "get_scanner", "(", "_hass", ",", "config", ")", ":", "scanner", "=", "HitronCODADeviceScanner", "(", "config", "[", "DOMAIN", "]", ")", "return", "scanner", "if", "scanner", ".", "success_init", "else", "None" ]
[ 35, 0 ]
[ 39, 52 ]
python
en
['en', 'en', 'en']
True
HitronCODADeviceScanner.__init__
(self, config)
Initialize the scanner.
Initialize the scanner.
def __init__(self, config): """Initialize the scanner.""" self.last_results = [] host = config[CONF_HOST] self._url = f"http://{host}/data/getConnectInfo.asp" self._loginurl = f"http://{host}/goform/login" self._username = config.get(CONF_USERNAME) self._password...
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "last_results", "=", "[", "]", "host", "=", "config", "[", "CONF_HOST", "]", "self", ".", "_url", "=", "f\"http://{host}/data/getConnectInfo.asp\"", "self", ".", "_loginurl", "=", "f\"http...
[ 48, 4 ]
[ 66, 43 ]
python
en
['en', 'en', 'en']
True
HitronCODADeviceScanner.scan_devices
(self)
Scan for new devices and return a list with found device IDs.
Scan for new devices and return a list with found device IDs.
def scan_devices(self): """Scan for new devices and return a list with found device IDs.""" self._update_info() return [device.mac for device in self.last_results]
[ "def", "scan_devices", "(", "self", ")", ":", "self", ".", "_update_info", "(", ")", "return", "[", "device", ".", "mac", "for", "device", "in", "self", ".", "last_results", "]" ]
[ 68, 4 ]
[ 72, 59 ]
python
en
['en', 'en', 'en']
True
HitronCODADeviceScanner.get_device_name
(self, device)
Return the name of the device with the given MAC address.
Return the name of the device with the given MAC address.
def get_device_name(self, device): """Return the name of the device with the given MAC address.""" name = next( (result.name for result in self.last_results if result.mac == device), None ) return name
[ "def", "get_device_name", "(", "self", ",", "device", ")", ":", "name", "=", "next", "(", "(", "result", ".", "name", "for", "result", "in", "self", ".", "last_results", "if", "result", ".", "mac", "==", "device", ")", ",", "None", ")", "return", "na...
[ 74, 4 ]
[ 79, 19 ]
python
en
['en', 'en', 'en']
True
HitronCODADeviceScanner._login
(self)
Log in to the router. This is required for subsequent api calls.
Log in to the router. This is required for subsequent api calls.
def _login(self): """Log in to the router. This is required for subsequent api calls.""" _LOGGER.info("Logging in to CODA...") try: data = [("user", self._username), (self._type, self._password)] res = requests.post(self._loginurl, data=data, timeout=10) except r...
[ "def", "_login", "(", "self", ")", ":", "_LOGGER", ".", "info", "(", "\"Logging in to CODA...\"", ")", "try", ":", "data", "=", "[", "(", "\"user\"", ",", "self", ".", "_username", ")", ",", "(", "self", ".", "_type", ",", "self", ".", "_password", "...
[ 81, 4 ]
[ 99, 24 ]
python
en
['en', 'en', 'en']
True
HitronCODADeviceScanner._update_info
(self)
Get ARP from router.
Get ARP from router.
def _update_info(self): """Get ARP from router.""" _LOGGER.info("Fetching...") if self._userid is None: if not self._login(): _LOGGER.error("Could not obtain a user ID from the router") return False last_results = [] # doing a request...
[ "def", "_update_info", "(", "self", ")", ":", "_LOGGER", ".", "info", "(", "\"Fetching...\"", ")", "if", "self", ".", "_userid", "is", "None", ":", "if", "not", "self", ".", "_login", "(", ")", ":", "_LOGGER", ".", "error", "(", "\"Could not obtain a use...
[ 101, 4 ]
[ 140, 19 ]
python
en
['en', 'en', 'en']
True
prevent_io
()
Fixture to prevent certain I/O from happening.
Fixture to prevent certain I/O from happening.
def prevent_io(): """Fixture to prevent certain I/O from happening.""" with patch( "homeassistant.components.http.ban.async_load_ip_bans_config", return_value=[], ): yield
[ "def", "prevent_io", "(", ")", ":", "with", "patch", "(", "\"homeassistant.components.http.ban.async_load_ip_bans_config\"", ",", "return_value", "=", "[", "]", ",", ")", ":", "yield" ]
[ 14, 0 ]
[ 20, 13 ]
python
en
['en', 'en', 'en']
True
test_setup_missing_config
(hass)
Test setup with missing configuration.
Test setup with missing configuration.
async def test_setup_missing_config(hass): """Test setup with missing configuration.""" with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client: config = {"sensor": {"platform": "mfi"}} assert await async_setup_component(hass, "sensor", config) assert not mock_cli...
[ "async", "def", "test_setup_missing_config", "(", "hass", ")", ":", "with", "mock", ".", "patch", "(", "\"homeassistant.components.mfi.sensor.MFiClient\"", ")", "as", "mock_client", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"mfi\"", "...
[ 28, 0 ]
[ 33, 37 ]
python
en
['en', 'en', 'en']
True
test_setup_failed_login
(hass)
Test setup with login failure.
Test setup with login failure.
async def test_setup_failed_login(hass): """Test setup with login failure.""" with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client: mock_client.side_effect = FailedToLogin assert not PLATFORM.setup_platform(hass, dict(GOOD_CONFIG), None)
[ "async", "def", "test_setup_failed_login", "(", "hass", ")", ":", "with", "mock", ".", "patch", "(", "\"homeassistant.components.mfi.sensor.MFiClient\"", ")", "as", "mock_client", ":", "mock_client", ".", "side_effect", "=", "FailedToLogin", "assert", "not", "PLATFORM...
[ 36, 0 ]
[ 40, 73 ]
python
en
['en', 'sm', 'en']
True
test_setup_failed_connect
(hass)
Test setup with connection failure.
Test setup with connection failure.
async def test_setup_failed_connect(hass): """Test setup with connection failure.""" with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client: mock_client.side_effect = requests.exceptions.ConnectionError assert not PLATFORM.setup_platform(hass, dict(GOOD_CONFIG), None)
[ "async", "def", "test_setup_failed_connect", "(", "hass", ")", ":", "with", "mock", ".", "patch", "(", "\"homeassistant.components.mfi.sensor.MFiClient\"", ")", "as", "mock_client", ":", "mock_client", ".", "side_effect", "=", "requests", ".", "exceptions", ".", "Co...
[ 43, 0 ]
[ 47, 73 ]
python
en
['en', 'en', 'en']
True
test_setup_minimum
(hass)
Test setup with minimum configuration.
Test setup with minimum configuration.
async def test_setup_minimum(hass): """Test setup with minimum configuration.""" with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client: config = dict(GOOD_CONFIG) del config[THING]["port"] assert await async_setup_component(hass, COMPONENT.DOMAIN, config) ...
[ "async", "def", "test_setup_minimum", "(", "hass", ")", ":", "with", "mock", ".", "patch", "(", "\"homeassistant.components.mfi.sensor.MFiClient\"", ")", "as", "mock_client", ":", "config", "=", "dict", "(", "GOOD_CONFIG", ")", "del", "config", "[", "THING", "]"...
[ 50, 0 ]
[ 60, 9 ]
python
en
['en', 'zu', 'en']
True
test_setup_with_port
(hass)
Test setup with port.
Test setup with port.
async def test_setup_with_port(hass): """Test setup with port.""" with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client: config = dict(GOOD_CONFIG) config[THING]["port"] = 6123 assert await async_setup_component(hass, COMPONENT.DOMAIN, config) await hass...
[ "async", "def", "test_setup_with_port", "(", "hass", ")", ":", "with", "mock", ".", "patch", "(", "\"homeassistant.components.mfi.sensor.MFiClient\"", ")", "as", "mock_client", ":", "config", "=", "dict", "(", "GOOD_CONFIG", ")", "config", "[", "THING", "]", "["...
[ 63, 0 ]
[ 73, 9 ]
python
en
['en', 'haw', 'en']
True
test_setup_with_tls_disabled
(hass)
Test setup without TLS.
Test setup without TLS.
async def test_setup_with_tls_disabled(hass): """Test setup without TLS.""" with mock.patch("homeassistant.components.mfi.sensor.MFiClient") as mock_client: config = dict(GOOD_CONFIG) del config[THING]["port"] config[THING]["ssl"] = False config[THING]["verify_ssl"] = False ...
[ "async", "def", "test_setup_with_tls_disabled", "(", "hass", ")", ":", "with", "mock", ".", "patch", "(", "\"homeassistant.components.mfi.sensor.MFiClient\"", ")", "as", "mock_client", ":", "config", "=", "dict", "(", "GOOD_CONFIG", ")", "del", "config", "[", "THI...
[ 76, 0 ]
[ 88, 9 ]
python
en
['en', 'zu', 'en']
True
test_setup_adds_proper_devices
(hass)
Test if setup adds devices.
Test if setup adds devices.
async def test_setup_adds_proper_devices(hass): """Test if setup adds devices.""" with mock.patch( "homeassistant.components.mfi.sensor.MFiClient" ) as mock_client, mock.patch( "homeassistant.components.mfi.sensor.MfiSensor", side_effect=mfi.MfiSensor ) as mock_sensor: ports = { ...
[ "async", "def", "test_setup_adds_proper_devices", "(", "hass", ")", ":", "with", "mock", ".", "patch", "(", "\"homeassistant.components.mfi.sensor.MFiClient\"", ")", "as", "mock_client", ",", "mock", ".", "patch", "(", "\"homeassistant.components.mfi.sensor.MfiSensor\"", ...
[ 91, 0 ]
[ 111, 74 ]
python
en
['es', 'en', 'en']
True
port_fixture
()
Port fixture.
Port fixture.
def port_fixture(): """Port fixture.""" return mock.MagicMock()
[ "def", "port_fixture", "(", ")", ":", "return", "mock", ".", "MagicMock", "(", ")" ]
[ 115, 0 ]
[ 117, 27 ]
python
en
['en', 'nl', 'en']
False
sensor_fixture
(hass, port)
Sensor fixture.
Sensor fixture.
def sensor_fixture(hass, port): """Sensor fixture.""" return mfi.MfiSensor(port, hass)
[ "def", "sensor_fixture", "(", "hass", ",", "port", ")", ":", "return", "mfi", ".", "MfiSensor", "(", "port", ",", "hass", ")" ]
[ 121, 0 ]
[ 123, 36 ]
python
en
['en', 'ca', 'en']
False
test_name
(port, sensor)
Test the name.
Test the name.
async def test_name(port, sensor): """Test the name.""" assert port.label == sensor.name
[ "async", "def", "test_name", "(", "port", ",", "sensor", ")", ":", "assert", "port", ".", "label", "==", "sensor", ".", "name" ]
[ 126, 0 ]
[ 128, 36 ]
python
en
['en', 'en', 'en']
True
test_uom_temp
(port, sensor)
Test the UOM temperature.
Test the UOM temperature.
async def test_uom_temp(port, sensor): """Test the UOM temperature.""" port.tag = "temperature" assert TEMP_CELSIUS == sensor.unit_of_measurement
[ "async", "def", "test_uom_temp", "(", "port", ",", "sensor", ")", ":", "port", ".", "tag", "=", "\"temperature\"", "assert", "TEMP_CELSIUS", "==", "sensor", ".", "unit_of_measurement" ]
[ 131, 0 ]
[ 134, 53 ]
python
en
['en', 'la', 'en']
True
test_uom_power
(port, sensor)
Test the UOEM power.
Test the UOEM power.
async def test_uom_power(port, sensor): """Test the UOEM power.""" port.tag = "active_pwr" assert sensor.unit_of_measurement == "Watts"
[ "async", "def", "test_uom_power", "(", "port", ",", "sensor", ")", ":", "port", ".", "tag", "=", "\"active_pwr\"", "assert", "sensor", ".", "unit_of_measurement", "==", "\"Watts\"" ]
[ 137, 0 ]
[ 140, 48 ]
python
en
['en', 'en', 'en']
True
test_uom_digital
(port, sensor)
Test the UOM digital input.
Test the UOM digital input.
async def test_uom_digital(port, sensor): """Test the UOM digital input.""" port.model = "Input Digital" assert sensor.unit_of_measurement == "State"
[ "async", "def", "test_uom_digital", "(", "port", ",", "sensor", ")", ":", "port", ".", "model", "=", "\"Input Digital\"", "assert", "sensor", ".", "unit_of_measurement", "==", "\"State\"" ]
[ 143, 0 ]
[ 146, 48 ]
python
en
['en', 'pl', 'en']
True
test_uom_unknown
(port, sensor)
Test the UOM.
Test the UOM.
async def test_uom_unknown(port, sensor): """Test the UOM.""" port.tag = "balloons" assert sensor.unit_of_measurement == "balloons"
[ "async", "def", "test_uom_unknown", "(", "port", ",", "sensor", ")", ":", "port", ".", "tag", "=", "\"balloons\"", "assert", "sensor", ".", "unit_of_measurement", "==", "\"balloons\"" ]
[ 149, 0 ]
[ 152, 51 ]
python
en
['en', 'en', 'en']
True
test_uom_uninitialized
(port, sensor)
Test that the UOM defaults if not initialized.
Test that the UOM defaults if not initialized.
async def test_uom_uninitialized(port, sensor): """Test that the UOM defaults if not initialized.""" type(port).tag = mock.PropertyMock(side_effect=ValueError) assert sensor.unit_of_measurement == "State"
[ "async", "def", "test_uom_uninitialized", "(", "port", ",", "sensor", ")", ":", "type", "(", "port", ")", ".", "tag", "=", "mock", ".", "PropertyMock", "(", "side_effect", "=", "ValueError", ")", "assert", "sensor", ".", "unit_of_measurement", "==", "\"State...
[ 155, 0 ]
[ 158, 48 ]
python
en
['en', 'en', 'en']
True
test_state_digital
(port, sensor)
Test the digital input.
Test the digital input.
async def test_state_digital(port, sensor): """Test the digital input.""" port.model = "Input Digital" port.value = 0 assert mfi.STATE_OFF == sensor.state port.value = 1 assert mfi.STATE_ON == sensor.state port.value = 2 assert mfi.STATE_ON == sensor.state
[ "async", "def", "test_state_digital", "(", "port", ",", "sensor", ")", ":", "port", ".", "model", "=", "\"Input Digital\"", "port", ".", "value", "=", "0", "assert", "mfi", ".", "STATE_OFF", "==", "sensor", ".", "state", "port", ".", "value", "=", "1", ...
[ 161, 0 ]
[ 169, 39 ]
python
en
['en', 'mt', 'en']
True
test_state_digits
(port, sensor)
Test the state of digits.
Test the state of digits.
async def test_state_digits(port, sensor): """Test the state of digits.""" port.tag = "didyoucheckthedict?" port.value = 1.25 with mock.patch.dict(mfi.DIGITS, {"didyoucheckthedict?": 1}): assert sensor.state == 1.2 with mock.patch.dict(mfi.DIGITS, {}): assert sensor.state == 1.0
[ "async", "def", "test_state_digits", "(", "port", ",", "sensor", ")", ":", "port", ".", "tag", "=", "\"didyoucheckthedict?\"", "port", ".", "value", "=", "1.25", "with", "mock", ".", "patch", ".", "dict", "(", "mfi", ".", "DIGITS", ",", "{", "\"didyouche...
[ 172, 0 ]
[ 179, 34 ]
python
en
['en', 'en', 'en']
True
test_state_uninitialized
(port, sensor)
Test the state of uninitialized sensorfs.
Test the state of uninitialized sensorfs.
async def test_state_uninitialized(port, sensor): """Test the state of uninitialized sensorfs.""" type(port).tag = mock.PropertyMock(side_effect=ValueError) assert mfi.STATE_OFF == sensor.state
[ "async", "def", "test_state_uninitialized", "(", "port", ",", "sensor", ")", ":", "type", "(", "port", ")", ".", "tag", "=", "mock", ".", "PropertyMock", "(", "side_effect", "=", "ValueError", ")", "assert", "mfi", ".", "STATE_OFF", "==", "sensor", ".", ...
[ 182, 0 ]
[ 185, 40 ]
python
en
['en', 'en', 'en']
True
test_update
(port, sensor)
Test the update.
Test the update.
async def test_update(port, sensor): """Test the update.""" sensor.update() assert port.refresh.call_count == 1 assert port.refresh.call_args == mock.call()
[ "async", "def", "test_update", "(", "port", ",", "sensor", ")", ":", "sensor", ".", "update", "(", ")", "assert", "port", ".", "refresh", ".", "call_count", "==", "1", "assert", "port", ".", "refresh", ".", "call_args", "==", "mock", ".", "call", "(", ...
[ 188, 0 ]
[ 192, 48 ]
python
en
['en', 'en', 'en']
True
GuardianDataUpdateCoordinator.__init__
( self, hass: HomeAssistant, *, client: Client, api_name: str, api_coro: Callable[..., Awaitable], api_lock: asyncio.Lock, valve_controller_uid: str, )
Initialize.
Initialize.
def __init__( self, hass: HomeAssistant, *, client: Client, api_name: str, api_coro: Callable[..., Awaitable], api_lock: asyncio.Lock, valve_controller_uid: str, ): """Initialize.""" super().__init__( hass, LOGGE...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "*", ",", "client", ":", "Client", ",", "api_name", ":", "str", ",", "api_coro", ":", "Callable", "[", "...", ",", "Awaitable", "]", ",", "api_lock", ":", "asyncio", ".", "Lock", ...
[ 19, 4 ]
[ 39, 29 ]
python
en
['en', 'en', 'it']
False
GuardianDataUpdateCoordinator._async_update_data
(self)
Execute a "locked" API request against the valve controller.
Execute a "locked" API request against the valve controller.
async def _async_update_data(self) -> dict: """Execute a "locked" API request against the valve controller.""" async with self._api_lock, self._client: try: resp = await self._api_coro() except GuardianError as err: raise UpdateFailed(err) from err...
[ "async", "def", "_async_update_data", "(", "self", ")", "->", "dict", ":", "async", "with", "self", ".", "_api_lock", ",", "self", ".", "_client", ":", "try", ":", "resp", "=", "await", "self", ".", "_api_coro", "(", ")", "except", "GuardianError", "as",...
[ 41, 4 ]
[ 48, 27 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the Fast.com sensor.
Set up the Fast.com sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the Fast.com sensor.""" async_add_entities([SpeedtestSensor(hass.data[FASTDOTCOM_DOMAIN])])
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "async_add_entities", "(", "[", "SpeedtestSensor", "(", "hass", ".", "data", "[", "FASTDOTCOM_DOMAIN", "]", ")", "]", "...
[ 11, 0 ]
[ 13, 71 ]
python
en
['en', 'pt', 'en']
True
SpeedtestSensor.__init__
(self, speedtest_data)
Initialize the sensor.
Initialize the sensor.
def __init__(self, speedtest_data): """Initialize the sensor.""" self._name = "Fast.com Download" self.speedtest_client = speedtest_data self._state = None
[ "def", "__init__", "(", "self", ",", "speedtest_data", ")", ":", "self", ".", "_name", "=", "\"Fast.com Download\"", "self", ".", "speedtest_client", "=", "speedtest_data", "self", ".", "_state", "=", "None" ]
[ 19, 4 ]
[ 23, 26 ]
python
en
['en', 'en', 'en']
True