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
_make_causal_mask
(input_ids_shape: tf.TensorShape, past_key_values_length: int = 0)
Make causal mask used for bi-directional self-attention.
Make causal mask used for bi-directional self-attention.
def _make_causal_mask(input_ids_shape: tf.TensorShape, past_key_values_length: int = 0): """ Make causal mask used for bi-directional self-attention. """ bsz, tgt_len = input_ids_shape mask = tf.ones((tgt_len, tgt_len)) * LARGE_NEGATIVE mask_cond = tf.range(shape_list(mask)[-1]) mask = tf.w...
[ "def", "_make_causal_mask", "(", "input_ids_shape", ":", "tf", ".", "TensorShape", ",", "past_key_values_length", ":", "int", "=", "0", ")", ":", "bsz", ",", "tgt_len", "=", "input_ids_shape", "mask", "=", "tf", ".", "ones", "(", "(", "tgt_len", ",", "tgt_...
[ 85, 0 ]
[ 98, 58 ]
python
en
['en', 'error', 'th']
False
_expand_mask
(mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0)
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
def _expand_mask(mask: tf.Tensor, tgt_len: Optional[int] = None, past_key_values_length: int = 0): """ Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`. """ src_len = shape_list(mask)[1] tgt_len = tgt_len if tgt_len is not None else src_len one_cst = tf.consta...
[ "def", "_expand_mask", "(", "mask", ":", "tf", ".", "Tensor", ",", "tgt_len", ":", "Optional", "[", "int", "]", "=", "None", ",", "past_key_values_length", ":", "int", "=", "0", ")", ":", "src_len", "=", "shape_list", "(", "mask", ")", "[", "1", "]",...
[ 102, 0 ]
[ 112, 53 ]
python
en
['en', 'error', 'th']
False
TFPegasusSinusoidalPositionalEmbedding.build
(self, input_shape: tf.TensorShape)
Build shared token embedding layer Shared weights logic adapted from https://github.com/tensorflow/models/blob/a009f4fb9d2fc4949e32192a944688925ef78659/official/transformer/v2/embedding_layer.py#L24
Build shared token embedding layer Shared weights logic adapted from https://github.com/tensorflow/models/blob/a009f4fb9d2fc4949e32192a944688925ef78659/official/transformer/v2/embedding_layer.py#L24
def build(self, input_shape: tf.TensorShape): """ Build shared token embedding layer Shared weights logic adapted from https://github.com/tensorflow/models/blob/a009f4fb9d2fc4949e32192a944688925ef78659/official/transformer/v2/embedding_layer.py#L24 """ weight = self._init_weight...
[ "def", "build", "(", "self", ",", "input_shape", ":", "tf", ".", "TensorShape", ")", ":", "weight", "=", "self", ".", "_init_weight", "(", "self", ".", "num_positions", ",", "self", ".", "embedding_dim", ")", "self", ".", "weight", "=", "self", ".", "a...
[ 128, 4 ]
[ 144, 34 ]
python
en
['en', 'error', 'th']
False
TFPegasusSinusoidalPositionalEmbedding._init_weight
(n_pos: int, dim: int)
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:]
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:]
def _init_weight(n_pos: int, dim: int): """ Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in the 2nd half of the vector. [dim // 2:] """ position_enc = np.array( [[pos / np.power(10000, 2 * (j // 2) / dim) ...
[ "def", "_init_weight", "(", "n_pos", ":", "int", ",", "dim", ":", "int", ")", ":", "position_enc", "=", "np", ".", "array", "(", "[", "[", "pos", "/", "np", ".", "power", "(", "10000", ",", "2", "*", "(", "j", "//", "2", ")", "/", "dim", ")",...
[ 147, 4 ]
[ 161, 20 ]
python
en
['en', 'error', 'th']
False
TFPegasusSinusoidalPositionalEmbedding.call
(self, input_shape: tf.TensorShape, past_key_values_length: int = 0)
Input is expected to be of size [bsz x seqlen].
Input is expected to be of size [bsz x seqlen].
def call(self, input_shape: tf.TensorShape, past_key_values_length: int = 0): """Input is expected to be of size [bsz x seqlen].""" bsz, seq_len = input_shape[:2] positions = tf.range(past_key_values_length, seq_len + past_key_values_length, delta=1, name="range") return tf.gather(self....
[ "def", "call", "(", "self", ",", "input_shape", ":", "tf", ".", "TensorShape", ",", "past_key_values_length", ":", "int", "=", "0", ")", ":", "bsz", ",", "seq_len", "=", "input_shape", "[", ":", "2", "]", "positions", "=", "tf", ".", "range", "(", "p...
[ 163, 4 ]
[ 168, 48 ]
python
en
['en', 'en', 'en']
True
TFPegasusAttention.call
( self, hidden_states: tf.Tensor, key_value_states: Optional[tf.Tensor] = None, past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None, attention_mask: Optional[tf.Tensor] = None, layer_head_mask: Optional[tf.Tensor] = None, training=False, )
Input shape: Batch x Time x Channel
Input shape: Batch x Time x Channel
def call( self, hidden_states: tf.Tensor, key_value_states: Optional[tf.Tensor] = None, past_key_value: Optional[Tuple[Tuple[tf.Tensor]]] = None, attention_mask: Optional[tf.Tensor] = None, layer_head_mask: Optional[tf.Tensor] = None, training=False, ) -> Tupl...
[ "def", "call", "(", "self", ",", "hidden_states", ":", "tf", ".", "Tensor", ",", "key_value_states", ":", "Optional", "[", "tf", ".", "Tensor", "]", "=", "None", ",", "past_key_value", ":", "Optional", "[", "Tuple", "[", "Tuple", "[", "tf", ".", "Tenso...
[ 202, 4 ]
[ 318, 56 ]
python
en
['en', 'pl', 'en']
True
TFPegasusEncoderLayer.call
(self, hidden_states: tf.Tensor, attention_mask: tf.Tensor, layer_head_mask: tf.Tensor, training=False)
Args: hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`tf.Tensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. laye...
Args: hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`tf.Tensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. laye...
def call(self, hidden_states: tf.Tensor, attention_mask: tf.Tensor, layer_head_mask: tf.Tensor, training=False): """ Args: hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`tf.Tensor`): attention mask of size ...
[ "def", "call", "(", "self", ",", "hidden_states", ":", "tf", ".", "Tensor", ",", "attention_mask", ":", "tf", ".", "Tensor", ",", "layer_head_mask", ":", "tf", ".", "Tensor", ",", "training", "=", "False", ")", ":", "residual", "=", "hidden_states", "hid...
[ 337, 4 ]
[ 372, 47 ]
python
en
['en', 'error', 'th']
False
TFPegasusDecoderLayer.call
( self, hidden_states, attention_mask: Optional[tf.Tensor] = None, encoder_hidden_states: Optional[tf.Tensor] = None, encoder_attention_mask: Optional[tf.Tensor] = None, layer_head_mask: Optional[tf.Tensor] = None, encoder_layer_head_mask: Optional[tf.Tensor] = No...
Args: hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`tf.Tensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. enco...
Args: hidden_states (:obj:`tf.Tensor`): input to the layer of shape `(seq_len, batch, embed_dim)` attention_mask (:obj:`tf.Tensor`): attention mask of size `(batch, 1, tgt_len, src_len)` where padding elements are indicated by very large negative values. enco...
def call( self, hidden_states, attention_mask: Optional[tf.Tensor] = None, encoder_hidden_states: Optional[tf.Tensor] = None, encoder_attention_mask: Optional[tf.Tensor] = None, layer_head_mask: Optional[tf.Tensor] = None, encoder_layer_head_mask: Optional[tf.Tens...
[ "def", "call", "(", "self", ",", "hidden_states", ",", "attention_mask", ":", "Optional", "[", "tf", ".", "Tensor", "]", "=", "None", ",", "encoder_hidden_states", ":", "Optional", "[", "tf", ".", "Tensor", "]", "=", "None", ",", "encoder_attention_mask", ...
[ 404, 4 ]
[ 479, 9 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the configured Numato USB GPIO switch ports.
Set up the configured Numato USB GPIO switch ports.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the configured Numato USB GPIO switch ports.""" if discovery_info is None: return api = hass.data[DOMAIN][DATA_API] switches = [] devices = hass.data[DOMAIN][CONF_DEVICES] for device in [d for d in devices if...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "if", "discovery_info", "is", "None", ":", "return", "api", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_API", "]", "switc...
[ 18, 0 ]
[ 53, 32 ]
python
en
['en', 'zu', 'en']
True
NumatoGpioSwitch.__init__
(self, name, device_id, port, invert_logic, api)
Initialize the port.
Initialize the port.
def __init__(self, name, device_id, port, invert_logic, api): """Initialize the port.""" self._name = name or DEVICE_DEFAULT_NAME self._device_id = device_id self._port = port self._invert_logic = invert_logic self._state = False self._api = api
[ "def", "__init__", "(", "self", ",", "name", ",", "device_id", ",", "port", ",", "invert_logic", ",", "api", ")", ":", "self", ".", "_name", "=", "name", "or", "DEVICE_DEFAULT_NAME", "self", ".", "_device_id", "=", "device_id", "self", ".", "_port", "=",...
[ 59, 4 ]
[ 66, 23 ]
python
en
['en', 'en', 'en']
True
NumatoGpioSwitch.name
(self)
Return the name of the switch.
Return the name of the switch.
def name(self): """Return the name of the switch.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 69, 4 ]
[ 71, 25 ]
python
en
['en', 'en', 'en']
True
NumatoGpioSwitch.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self): """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 74, 4 ]
[ 76, 20 ]
python
en
['en', 'en', 'en']
True
NumatoGpioSwitch.is_on
(self)
Return true if port is turned on.
Return true if port is turned on.
def is_on(self): """Return true if port is turned on.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 79, 4 ]
[ 81, 26 ]
python
en
['en', 'et', 'en']
True
NumatoGpioSwitch.turn_on
(self, **kwargs)
Turn the port on.
Turn the port on.
def turn_on(self, **kwargs): """Turn the port on.""" try: self._api.write_output( self._device_id, self._port, 0 if self._invert_logic else 1 ) self._state = True self.schedule_update_ha_state() except NumatoGpioError as err: ...
[ "def", "turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_api", ".", "write_output", "(", "self", ".", "_device_id", ",", "self", ".", "_port", ",", "0", "if", "self", ".", "_invert_logic", "else", "1", ")", "self...
[ 83, 4 ]
[ 97, 13 ]
python
en
['en', 'en', 'en']
True
NumatoGpioSwitch.turn_off
(self, **kwargs)
Turn the port off.
Turn the port off.
def turn_off(self, **kwargs): """Turn the port off.""" try: self._api.write_output( self._device_id, self._port, 1 if self._invert_logic else 0 ) self._state = False self.schedule_update_ha_state() except NumatoGpioError as err: ...
[ "def", "turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "_api", ".", "write_output", "(", "self", ".", "_device_id", ",", "self", ".", "_port", ",", "1", "if", "self", ".", "_invert_logic", "else", "0", ")", "sel...
[ 99, 4 ]
[ 113, 13 ]
python
en
['en', 'en', 'en']
True
test_record_service_invalid_file
(hass)
Test record service call with invalid file.
Test record service call with invalid file.
async def test_record_service_invalid_file(hass): """Test record service call with invalid file.""" await async_setup_component(hass, "stream", {"stream": {}}) data = {CONF_STREAM_SOURCE: "rtsp://my.video", CONF_FILENAME: "/my/invalid/path"} with pytest.raises(HomeAssistantError): await hass.ser...
[ "async", "def", "test_record_service_invalid_file", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "data", "=", "{", "CONF_STREAM_SOURCE", ":", "\"rtsp://my.video\"", ",",...
[ 17, 0 ]
[ 22, 83 ]
python
en
['en', 'en', 'en']
True
test_record_service_init_stream
(hass)
Test record service call with invalid file.
Test record service call with invalid file.
async def test_record_service_init_stream(hass): """Test record service call with invalid file.""" await async_setup_component(hass, "stream", {"stream": {}}) data = {CONF_STREAM_SOURCE: "rtsp://my.video", CONF_FILENAME: "/my/invalid/path"} with patch("homeassistant.components.stream.Stream") as stream_...
[ "async", "def", "test_record_service_init_stream", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "data", "=", "{", "CONF_STREAM_SOURCE", ":", "\"rtsp://my.video\"", ",", ...
[ 25, 0 ]
[ 39, 33 ]
python
en
['en', 'en', 'en']
True
test_record_service_existing_record_session
(hass)
Test record service call with invalid file.
Test record service call with invalid file.
async def test_record_service_existing_record_session(hass): """Test record service call with invalid file.""" await async_setup_component(hass, "stream", {"stream": {}}) source = "rtsp://my.video" data = {CONF_STREAM_SOURCE: source, CONF_FILENAME: "/my/invalid/path"} # Setup stubs stream_mock ...
[ "async", "def", "test_record_service_existing_record_session", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "source", "=", "\"rtsp://my.video\"", "data", "=", "{", "CONF...
[ 42, 0 ]
[ 57, 83 ]
python
en
['en', 'en', 'en']
True
test_record_service_lookback
(hass)
Test record service call with invalid file.
Test record service call with invalid file.
async def test_record_service_lookback(hass): """Test record service call with invalid file.""" await async_setup_component(hass, "stream", {"stream": {}}) data = { CONF_STREAM_SOURCE: "rtsp://my.video", CONF_FILENAME: "/my/invalid/path", CONF_LOOKBACK: 4, } with patch("home...
[ "async", "def", "test_record_service_lookback", "(", "hass", ")", ":", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "{", "\"stream\"", ":", "{", "}", "}", ")", "data", "=", "{", "CONF_STREAM_SOURCE", ":", "\"rtsp://my.video\"", ",", "...
[ 60, 0 ]
[ 83, 35 ]
python
en
['en', 'en', 'en']
True
connect_client
(hass, user_input)
Connect the HLK-SW16 client.
Connect the HLK-SW16 client.
async def connect_client(hass, user_input): """Connect the HLK-SW16 client.""" client_aw = create_hlk_sw16_connection( host=user_input[CONF_HOST], port=user_input[CONF_PORT], loop=hass.loop, timeout=CONNECTION_TIMEOUT, reconnect_interval=DEFAULT_RECONNECT_INTERVAL, ...
[ "async", "def", "connect_client", "(", "hass", ",", "user_input", ")", ":", "client_aw", "=", "create_hlk_sw16_connection", "(", "host", "=", "user_input", "[", "CONF_HOST", "]", ",", "port", "=", "user_input", "[", "CONF_PORT", "]", ",", "loop", "=", "hass"...
[ 27, 0 ]
[ 37, 72 ]
python
en
['en', 'fr', 'en']
True
validate_input
(hass: HomeAssistant, user_input)
Validate the user input allows us to connect.
Validate the user input allows us to connect.
async def validate_input(hass: HomeAssistant, user_input): """Validate the user input allows us to connect.""" for entry in hass.config_entries.async_entries(DOMAIN): if ( entry.data[CONF_HOST] == user_input[CONF_HOST] and entry.data[CONF_PORT] == user_input[CONF_PORT] ):...
[ "async", "def", "validate_input", "(", "hass", ":", "HomeAssistant", ",", "user_input", ")", ":", "for", "entry", "in", "hass", ".", "config_entries", ".", "async_entries", "(", "DOMAIN", ")", ":", "if", "(", "entry", ".", "data", "[", "CONF_HOST", "]", ...
[ 40, 0 ]
[ 67, 21 ]
python
en
['en', 'en', 'en']
True
SW16FlowHandler.async_step_import
(self, user_input)
Handle import.
Handle import.
async def async_step_import(self, user_input): """Handle import.""" return await self.async_step_user(user_input)
[ "async", "def", "async_step_import", "(", "self", ",", "user_input", ")", ":", "return", "await", "self", ".", "async_step_user", "(", "user_input", ")" ]
[ 76, 4 ]
[ 78, 53 ]
python
en
['en', 'ja', 'en']
False
SW16FlowHandler.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: try: await validate_input(self.hass, user_input) address = f"{user_input[CONF_HOST]}:{user_input[CONF_PORT]}" return...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "try", ":", "await", "validate_input", "(", "self", ".", "hass", ",", "user_input", ")", "a...
[ 80, 4 ]
[ 95, 9 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Initialize default configuration.
Initialize default configuration.
async def async_setup(hass, config): """Initialize default configuration.""" if av is None: return True return await async_setup_component(hass, "stream", config)
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "av", "is", "None", ":", "return", "True", "return", "await", "async_setup_component", "(", "hass", ",", "\"stream\"", ",", "config", ")" ]
[ 11, 0 ]
[ 16, 62 ]
python
fr
['fr', 'fr', 'en']
True
async_setup
(hass, config)
Old way of setting up deCONZ integrations.
Old way of setting up deCONZ integrations.
async def async_setup(hass, config): """Old way of setting up deCONZ integrations.""" return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "return", "True" ]
[ 16, 0 ]
[ 18, 15 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry)
Set up a deCONZ bridge for a config entry. Load config, group, light and sensor data for server information. Start websocket for push notification of state changes from deCONZ.
Set up a deCONZ bridge for a config entry.
async def async_setup_entry(hass, config_entry): """Set up a deCONZ bridge for a config entry. Load config, group, light and sensor data for server information. Start websocket for push notification of state changes from deCONZ. """ if DOMAIN not in hass.data: hass.data[DOMAIN] = {} if...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ")", ":", "if", "DOMAIN", "not", "in", "hass", ".", "data", ":", "hass", ".", "data", "[", "DOMAIN", "]", "=", "{", "}", "if", "not", "config_entry", ".", "options", ":", "await", ...
[ 21, 0 ]
[ 58, 15 ]
python
en
['en', 'fr', 'en']
True
async_unload_entry
(hass, config_entry)
Unload deCONZ config entry.
Unload deCONZ config entry.
async def async_unload_entry(hass, config_entry): """Unload deCONZ config entry.""" gateway = hass.data[DOMAIN].pop(config_entry.unique_id) if not hass.data[DOMAIN]: await async_unload_services(hass) elif gateway.master: await async_update_master_gateway(hass, config_entry) new...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "config_entry", ")", ":", "gateway", "=", "hass", ".", "data", "[", "DOMAIN", "]", ".", "pop", "(", "config_entry", ".", "unique_id", ")", "if", "not", "hass", ".", "data", "[", "DOMAIN", "]", ":"...
[ 61, 0 ]
[ 73, 38 ]
python
da
['da', 'es', 'pt']
False
async_update_master_gateway
(hass, config_entry)
Update master gateway boolean. Called by setup_entry and unload_entry. Makes sure there is always one master available.
Update master gateway boolean.
async def async_update_master_gateway(hass, config_entry): """Update master gateway boolean. Called by setup_entry and unload_entry. Makes sure there is always one master available. """ master = not get_master_gateway(hass) options = {**config_entry.options, CONF_MASTER_GATEWAY: master} ha...
[ "async", "def", "async_update_master_gateway", "(", "hass", ",", "config_entry", ")", ":", "master", "=", "not", "get_master_gateway", "(", "hass", ")", "options", "=", "{", "*", "*", "config_entry", ".", "options", ",", "CONF_MASTER_GATEWAY", ":", "master", "...
[ 76, 0 ]
[ 85, 73 ]
python
de
['de', 'de', 'en']
True
perturbation
(hyperparameter_type, value, resample_probablity, uv, ub, lv, lb, random_state)
Perturbation for hyperparameters Parameters ---------- hyperparameter_type : str type of hyperparameter value : list parameters for sampling hyperparameter resample_probability : float probability for resampling uv : float/int upper value after perturbation ...
Perturbation for hyperparameters
def perturbation(hyperparameter_type, value, resample_probablity, uv, ub, lv, lb, random_state): """ Perturbation for hyperparameters Parameters ---------- hyperparameter_type : str type of hyperparameter value : list parameters for sampling hyperparameter resample_probabili...
[ "def", "perturbation", "(", "hyperparameter_type", ",", "value", ",", "resample_probablity", ",", "uv", ",", "ub", ",", "lv", ",", "lb", ",", "random_state", ")", ":", "if", "random", ".", "random", "(", ")", "<", "resample_probablity", ":", "if", "hyperpa...
[ 20, 0 ]
[ 52, 30 ]
python
en
['en', 'error', 'th']
False
exploit_and_explore
(bot_trial_info, top_trial_info, factor, resample_probability, epoch, search_space)
Replace checkpoint of bot_trial with top, and perturb hyperparameters Parameters ---------- bot_trial_info : TrialInfo bottom model whose parameters should be replaced top_trial_info : TrialInfo better model factor : float factor for perturbation resample_probabilit...
Replace checkpoint of bot_trial with top, and perturb hyperparameters
def exploit_and_explore(bot_trial_info, top_trial_info, factor, resample_probability, epoch, search_space): """ Replace checkpoint of bot_trial with top, and perturb hyperparameters Parameters ---------- bot_trial_info : TrialInfo bottom model whose parameters should be replaced top_tri...
[ "def", "exploit_and_explore", "(", "bot_trial_info", ",", "top_trial_info", ",", "factor", ",", "resample_probability", ",", "epoch", ",", "search_space", ")", ":", "bot_checkpoint_dir", "=", "bot_trial_info", ".", "checkpoint_dir", "top_hyper_parameters", "=", "top_tri...
[ 55, 0 ]
[ 143, 29 ]
python
en
['en', 'error', 'th']
False
PBTTuner.__init__
(self, optimize_mode="maximize", all_checkpoint_dir=None, population_size=10, factor=0.2, resample_probability=0.25, fraction=0.2)
Initialization Parameters ---------- optimize_mode : str maximize or minimize all_checkpoint_dir : str directory to store training model checkpoint population_size : int number of trials for each epoch factor : float ...
Initialization
def __init__(self, optimize_mode="maximize", all_checkpoint_dir=None, population_size=10, factor=0.2, resample_probability=0.25, fraction=0.2): """ Initialization Parameters ---------- optimize_mode : str maximize or minimize all_checkpoint_d...
[ "def", "__init__", "(", "self", ",", "optimize_mode", "=", "\"maximize\"", ",", "all_checkpoint_dir", "=", "None", ",", "population_size", "=", "10", ",", "factor", "=", "0.2", ",", "resample_probability", "=", "0.25", ",", "fraction", "=", "0.2", ")", ":", ...
[ 172, 4 ]
[ 218, 47 ]
python
en
['en', 'error', 'th']
False
PBTTuner.update_search_space
(self, search_space)
Get search space Parameters ---------- search_space : dict Search space
Get search space
def update_search_space(self, search_space): """ Get search space Parameters ---------- search_space : dict Search space """ logger.info('Update search space %s', search_space) self.searchspace_json = search_space self.space = json2spa...
[ "def", "update_search_space", "(", "self", ",", "search_space", ")", ":", "logger", ".", "info", "(", "'Update search space %s'", ",", "search_space", ")", "self", ".", "searchspace_json", "=", "search_space", "self", ".", "space", "=", "json2space", "(", "self"...
[ 220, 4 ]
[ 247, 111 ]
python
en
['en', 'error', 'th']
False
PBTTuner.generate_multiple_parameters
(self, parameter_id_list, **kwargs)
Returns multiple sets of trial (hyper-)parameters, as iterable of serializable objects. Parameters ---------- parameter_id_list : list of int Unique identifiers for each set of requested hyper-parameters. These will later be used in :meth:`receive_trial_result`....
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. Parameters ---------- parameter_id_list : list of int Unique identifiers for each set of requested hyper-p...
[ "def", "generate_multiple_parameters", "(", "self", ",", "parameter_id_list", ",", "*", "*", "kwargs", ")", ":", "result", "=", "[", "]", "self", ".", "send_trial_callback", "=", "kwargs", "[", "'st_callback'", "]", "for", "parameter_id", "in", "parameter_id_lis...
[ 249, 4 ]
[ 277, 21 ]
python
en
['en', 'error', 'th']
False
PBTTuner.generate_parameters
(self, parameter_id, **kwargs)
Generate parameters, if no trial configration for now, self.credit plus 1 to send the config later Parameters ---------- parameter_id : int Unique identifier for requested hyper-parameters. This will later be used in :meth:`receive_trial_result`. **kwarg...
Generate parameters, if no trial configration for now, self.credit plus 1 to send the config later
def generate_parameters(self, parameter_id, **kwargs): """ Generate parameters, if no trial configration for now, self.credit plus 1 to send the config later Parameters ---------- parameter_id : int Unique identifier for requested hyper-parameters. This w...
[ "def", "generate_parameters", "(", "self", ",", "parameter_id", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "pos", "==", "self", ".", "population_size", "-", "1", ":", "logger", ".", "debug", "(", "'Credit added by one in parameters request'", ")", ...
[ 279, 4 ]
[ 307, 42 ]
python
en
['en', 'error', 'th']
False
PBTTuner.receive_trial_result
(self, parameter_id, parameters, value, **kwargs)
Receive trial's result. if the number of finished trials equals ``self.population_size``, start the next epoch to train the model. Parameters ---------- parameter_id : int Unique identifier of used hyper-parameters, same with :meth:`generate_parameters`. par...
Receive trial's result. if the number of finished trials equals ``self.population_size``, start the next epoch to train the model.
def receive_trial_result(self, parameter_id, parameters, value, **kwargs): """ Receive trial's result. if the number of finished trials equals ``self.population_size``, start the next epoch to train the model. Parameters ---------- parameter_id : int Unique i...
[ "def", "receive_trial_result", "(", "self", ",", "parameter_id", ",", "parameters", ",", "value", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "info", "(", "'Get one trial result, id = %d, value = %s'", ",", "parameter_id", ",", "value", ")", "value", "=", ...
[ 344, 4 ]
[ 365, 38 ]
python
en
['en', 'error', 'th']
False
PBTTuner.trial_end
(self, parameter_id, success, **kwargs)
Deal with trial failure Parameters ---------- parameter_id : int Unique identifier for hyper-parameters used by this trial. success : bool True if the trial successfully completed; False if failed or terminated. **kwargs Unstable para...
Deal with trial failure
def trial_end(self, parameter_id, success, **kwargs): """ Deal with trial failure Parameters ---------- parameter_id : int Unique identifier for hyper-parameters used by this trial. success : bool True if the trial successfully completed; False if...
[ "def", "trial_end", "(", "self", ",", "parameter_id", ",", "success", ",", "*", "*", "kwargs", ")", ":", "if", "success", ":", "return", "if", "self", ".", "optimize_mode", "==", "OptimizeMode", ".", "Minimize", ":", "value", "=", "float", "(", "'inf'", ...
[ 367, 4 ]
[ 391, 38 ]
python
en
['en', 'error', 'th']
False
PBTTuner.import_data
(self, data)
Parameters ---------- data : json obj imported data records Returns ------- int the start epoch number after data imported, only used for unittest
Parameters ---------- data : json obj imported data records
def import_data(self, data): """ Parameters ---------- data : json obj imported data records Returns ------- int the start epoch number after data imported, only used for unittest """ if self.running: logger.war...
[ "def", "import_data", "(", "self", ",", "data", ")", ":", "if", "self", ".", "running", ":", "logger", ".", "warning", "(", "\"Do not support importing data in the middle of experiment\"", ")", "return", "# the following is for experiment resume", "_completed_num", "=", ...
[ 393, 4 ]
[ 455, 25 ]
python
en
['en', 'error', 'th']
False
validate_input
(hass: core.HomeAssistant, data)
Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user.
Validate the user input allows us to connect.
async def validate_input(hass: core.HomeAssistant, data): """Validate the user input allows us to connect. Data has the keys from DATA_SCHEMA with values provided by the user. """ risco = RiscoAPI(data[CONF_USERNAME], data[CONF_PASSWORD], data[CONF_PIN]) try: await risco.login(async_get_cl...
[ "async", "def", "validate_input", "(", "hass", ":", "core", ".", "HomeAssistant", ",", "data", ")", ":", "risco", "=", "RiscoAPI", "(", "data", "[", "CONF_USERNAME", "]", ",", "data", "[", "CONF_PASSWORD", "]", ",", "data", "[", "CONF_PIN", "]", ")", "...
[ 41, 0 ]
[ 53, 37 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_get_options_flow
(config_entry)
Define the config flow to handle options.
Define the config flow to handle options.
def async_get_options_flow(config_entry): """Define the config flow to handle options.""" return RiscoOptionsFlowHandler(config_entry)
[ "def", "async_get_options_flow", "(", "config_entry", ")", ":", "return", "RiscoOptionsFlowHandler", "(", "config_entry", ")" ]
[ 64, 4 ]
[ 66, 52 ]
python
en
['en', 'en', 'en']
True
ConfigFlow.async_step_user
(self, user_input=None)
Handle the initial step.
Handle the initial step.
async def async_step_user(self, user_input=None): """Handle the initial step.""" errors = {} if user_input is not None: await self.async_set_unique_id(user_input[CONF_USERNAME]) self._abort_if_unique_id_configured() try: info = await validate_...
[ "async", "def", "async_step_user", "(", "self", ",", "user_input", "=", "None", ")", ":", "errors", "=", "{", "}", "if", "user_input", "is", "not", "None", ":", "await", "self", ".", "async_set_unique_id", "(", "user_input", "[", "CONF_USERNAME", "]", ")",...
[ 68, 4 ]
[ 89, 9 ]
python
en
['en', 'en', 'en']
True
RiscoOptionsFlowHandler.__init__
(self, config_entry)
Initialize.
Initialize.
def __init__(self, config_entry): """Initialize.""" self.config_entry = config_entry self._data = {**DEFAULT_OPTIONS, **config_entry.options}
[ "def", "__init__", "(", "self", ",", "config_entry", ")", ":", "self", ".", "config_entry", "=", "config_entry", "self", ".", "_data", "=", "{", "*", "*", "DEFAULT_OPTIONS", ",", "*", "*", "config_entry", ".", "options", "}" ]
[ 95, 4 ]
[ 98, 64 ]
python
en
['en', 'en', 'it']
False
RiscoOptionsFlowHandler.async_step_init
(self, user_input=None)
Manage the options.
Manage the options.
async def async_step_init(self, user_input=None): """Manage the options.""" if user_input is not None: self._data = {**self._data, **user_input} return await self.async_step_risco_to_ha() return self.async_show_form(step_id="init", data_schema=self._options_schema())
[ "async", "def", "async_step_init", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "self", ".", "_data", "=", "{", "*", "*", "self", ".", "_data", ",", "*", "*", "user_input", "}", "return", "await...
[ 116, 4 ]
[ 122, 87 ]
python
en
['en', 'en', 'en']
True
RiscoOptionsFlowHandler.async_step_risco_to_ha
(self, user_input=None)
Map Risco states to HA states.
Map Risco states to HA states.
async def async_step_risco_to_ha(self, user_input=None): """Map Risco states to HA states.""" if user_input is not None: self._data[CONF_RISCO_STATES_TO_HA] = user_input return await self.async_step_ha_to_risco() risco_to_ha = self._data[CONF_RISCO_STATES_TO_HA] ...
[ "async", "def", "async_step_risco_to_ha", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "self", ".", "_data", "[", "CONF_RISCO_STATES_TO_HA", "]", "=", "user_input", "return", "await", "self", ".", "asyn...
[ 124, 4 ]
[ 140, 79 ]
python
en
['en', 'en', 'en']
True
RiscoOptionsFlowHandler.async_step_ha_to_risco
(self, user_input=None)
Map HA states to Risco states.
Map HA states to Risco states.
async def async_step_ha_to_risco(self, user_input=None): """Map HA states to Risco states.""" if user_input is not None: self._data[CONF_HA_STATES_TO_RISCO] = user_input return self.async_create_entry(title="", data=self._data) options = {} risco_to_ha = self._da...
[ "async", "def", "async_step_ha_to_risco", "(", "self", ",", "user_input", "=", "None", ")", ":", "if", "user_input", "is", "not", "None", ":", "self", ".", "_data", "[", "CONF_HA_STATES_TO_RISCO", "]", "=", "user_input", "return", "self", ".", "async_create_en...
[ 142, 4 ]
[ 168, 9 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config: dict)
Set up the DSMR platform.
Set up the DSMR platform.
async def async_setup(hass, config: dict): """Set up the DSMR platform.""" return True
[ "async", "def", "async_setup", "(", "hass", ",", "config", ":", "dict", ")", ":", "return", "True" ]
[ 10, 0 ]
[ 12, 15 ]
python
en
['en', 'da', 'en']
True
async_setup_entry
(hass: HomeAssistant, entry: ConfigEntry)
Set up DSMR from a config entry.
Set up DSMR from a config entry.
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): """Set up DSMR from a config entry.""" hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][entry.entry_id] = {} for platform in PLATFORMS: hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", ...
[ 15, 0 ]
[ 28, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass: HomeAssistant, entry: ConfigEntry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" task = hass.data[DOMAIN][entry.entry_id][DATA_TASK] listener = hass.data[DOMAIN][entry.entry_id][DATA_LISTENER] # Cancel the reconnect task task.cancel() try: await task except Cancel...
[ "async", "def", "async_unload_entry", "(", "hass", ":", "HomeAssistant", ",", "entry", ":", "ConfigEntry", ")", ":", "task", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "entry", ".", "entry_id", "]", "[", "DATA_TASK", "]", "listener", "=", "hass",...
[ 31, 0 ]
[ 56, 20 ]
python
en
['en', 'es', 'en']
True
async_update_options
(hass: HomeAssistant, config_entry: ConfigEntry)
Update options.
Update options.
async def async_update_options(hass: HomeAssistant, config_entry: ConfigEntry): """Update options.""" await hass.config_entries.async_reload(config_entry.entry_id)
[ "async", "def", "async_update_options", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "ConfigEntry", ")", ":", "await", "hass", ".", "config_entries", ".", "async_reload", "(", "config_entry", ".", "entry_id", ")" ]
[ 59, 0 ]
[ 61, 65 ]
python
en
['en', 'en', 'en']
False
rs
(hass)
Return CommandCover instance.
Return CommandCover instance.
def rs(hass): """Return CommandCover instance.""" return cmd_rs.CommandCover( hass, "foo", "command_open", "command_close", "command_stop", "command_state", None, 15, )
[ "def", "rs", "(", "hass", ")", ":", "return", "cmd_rs", ".", "CommandCover", "(", "hass", ",", "\"foo\"", ",", "\"command_open\"", ",", "\"command_close\"", ",", "\"command_stop\"", ",", "\"command_state\"", ",", "None", ",", "15", ",", ")" ]
[ 24, 0 ]
[ 35, 5 ]
python
en
['en', 'en', 'en']
True
test_should_poll_new
(rs)
Test the setting of polling.
Test the setting of polling.
def test_should_poll_new(rs): """Test the setting of polling.""" assert rs.should_poll is True rs._command_state = None assert rs.should_poll is False
[ "def", "test_should_poll_new", "(", "rs", ")", ":", "assert", "rs", ".", "should_poll", "is", "True", "rs", ".", "_command_state", "=", "None", "assert", "rs", ".", "should_poll", "is", "False" ]
[ 38, 0 ]
[ 42, 34 ]
python
en
['en', 'en', 'en']
True
test_query_state_value
(rs)
Test with state value.
Test with state value.
def test_query_state_value(rs): """Test with state value.""" with mock.patch("subprocess.check_output") as mock_run: mock_run.return_value = b" foo bar " result = rs._query_state_value("runme") assert "foo bar" == result assert mock_run.call_count == 1 assert mock_run.cal...
[ "def", "test_query_state_value", "(", "rs", ")", ":", "with", "mock", ".", "patch", "(", "\"subprocess.check_output\"", ")", "as", "mock_run", ":", "mock_run", ".", "return_value", "=", "b\" foo bar \"", "result", "=", "rs", ".", "_query_state_value", "(", "\"ru...
[ 45, 0 ]
[ 54, 9 ]
python
en
['en', 'en', 'en']
True
test_state_value
(hass)
Test with state value.
Test with state value.
async def test_state_value(hass): """Test with state value.""" with tempfile.TemporaryDirectory() as tempdirname: path = os.path.join(tempdirname, "cover_status") test_cover = { "command_state": f"cat {path}", "command_open": f"echo 1 > {path}", "command_close...
[ "async", "def", "test_state_value", "(", "hass", ")", ":", "with", "tempfile", ".", "TemporaryDirectory", "(", ")", "as", "tempdirname", ":", "path", "=", "os", ".", "path", ".", "join", "(", "tempdirname", ",", "\"cover_status\"", ")", "test_cover", "=", ...
[ 57, 0 ]
[ 93, 62 ]
python
en
['en', 'en', 'en']
True
test_reload
(hass)
Verify we can reload command_line covers.
Verify we can reload command_line covers.
async def test_reload(hass): """Verify we can reload command_line covers.""" test_cover = { "command_state": "echo open", "value_template": "{{ value }}", } await async_setup_component( hass, DOMAIN, {"cover": {"platform": "command_line", "covers": {"test": test_...
[ "async", "def", "test_reload", "(", "hass", ")", ":", "test_cover", "=", "{", "\"command_state\"", ":", "\"echo open\"", ",", "\"value_template\"", ":", "\"{{ value }}\"", ",", "}", "await", "async_setup_component", "(", "hass", ",", "DOMAIN", ",", "{", "\"cover...
[ 96, 0 ]
[ 130, 45 ]
python
en
['en', 'en', 'en']
True
exit
(state: int = 0, msg: str = None)
Exit and show msg in sys.stderr
Exit and show msg in sys.stderr
def exit(state: int = 0, msg: str = None): """Exit and show msg in sys.stderr""" if msg is not None: sys.stderr.write(msg) sys.exit(state)
[ "def", "exit", "(", "state", ":", "int", "=", "0", ",", "msg", ":", "str", "=", "None", ")", ":", "if", "msg", "is", "not", "None", ":", "sys", ".", "stderr", ".", "write", "(", "msg", ")", "sys", ".", "exit", "(", "state", ")" ]
[ 6, 0 ]
[ 11, 19 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up switches for deCONZ component. Switches are based on the same device class as lights in deCONZ.
Set up switches for deCONZ component.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up switches for deCONZ component. Switches are based on the same device class as lights in deCONZ. """ gateway = get_gateway_from_config_entry(hass, config_entry) gateway.entities[DOMAIN] = set() @callback def asyn...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "gateway", "=", "get_gateway_from_config_entry", "(", "hass", ",", "config_entry", ")", "gateway", ".", "entities", "[", "DOMAIN", "]", "=", "set", "(", ...
[ 10, 0 ]
[ 45, 49 ]
python
en
['en', 'en', 'en']
True
DeconzPowerPlug.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self): """Return true if switch is on.""" return self._device.state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "state" ]
[ 54, 4 ]
[ 56, 33 ]
python
en
['en', 'fy', 'en']
True
DeconzPowerPlug.async_turn_on
(self, **kwargs)
Turn on switch.
Turn on switch.
async def async_turn_on(self, **kwargs): """Turn on switch.""" data = {"on": True} await self._device.async_set_state(data)
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"on\"", ":", "True", "}", "await", "self", ".", "_device", ".", "async_set_state", "(", "data", ")" ]
[ 58, 4 ]
[ 61, 48 ]
python
en
['en', 'en', 'en']
True
DeconzPowerPlug.async_turn_off
(self, **kwargs)
Turn off switch.
Turn off switch.
async def async_turn_off(self, **kwargs): """Turn off switch.""" data = {"on": False} await self._device.async_set_state(data)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"on\"", ":", "False", "}", "await", "self", ".", "_device", ".", "async_set_state", "(", "data", ")" ]
[ 63, 4 ]
[ 66, 48 ]
python
en
['en', 'en', 'en']
True
DeconzSiren.is_on
(self)
Return true if switch is on.
Return true if switch is on.
def is_on(self): """Return true if switch is on.""" return self._device.alert == "lselect"
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_device", ".", "alert", "==", "\"lselect\"" ]
[ 75, 4 ]
[ 77, 46 ]
python
en
['en', 'fy', 'en']
True
DeconzSiren.async_turn_on
(self, **kwargs)
Turn on switch.
Turn on switch.
async def async_turn_on(self, **kwargs): """Turn on switch.""" data = {"alert": "lselect"} await self._device.async_set_state(data)
[ "async", "def", "async_turn_on", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"alert\"", ":", "\"lselect\"", "}", "await", "self", ".", "_device", ".", "async_set_state", "(", "data", ")" ]
[ 79, 4 ]
[ 82, 48 ]
python
en
['en', 'en', 'en']
True
DeconzSiren.async_turn_off
(self, **kwargs)
Turn off switch.
Turn off switch.
async def async_turn_off(self, **kwargs): """Turn off switch.""" data = {"alert": "none"} await self._device.async_set_state(data)
[ "async", "def", "async_turn_off", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"alert\"", ":", "\"none\"", "}", "await", "self", ".", "_device", ".", "async_set_state", "(", "data", ")" ]
[ 84, 4 ]
[ 87, 48 ]
python
en
['en', 'en', 'en']
True
test_show_form
(hass)
Test that the form is served with no input.
Test that the form is served with no input.
async def test_show_form(hass): """Test that the form is served with no input.""" flow = config_flow.AbodeFlowHandler() flow.hass = hass result = await flow.async_step_user(user_input=None) assert result["type"] == data_entry_flow.RESULT_TYPE_FORM assert result["step_id"] == "user"
[ "async", "def", "test_show_form", "(", "hass", ")", ":", "flow", "=", "config_flow", ".", "AbodeFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "result", "=", "await", "flow", ".", "async_step_user", "(", "user_input", "=", "None", ")", "assert",...
[ 13, 0 ]
[ 21, 38 ]
python
en
['en', 'en', 'en']
True
test_one_config_allowed
(hass)
Test that only one Abode configuration is allowed.
Test that only one Abode configuration is allowed.
async def test_one_config_allowed(hass): """Test that only one Abode configuration is allowed.""" flow = config_flow.AbodeFlowHandler() flow.hass = hass MockConfigEntry( domain="abode", data={CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"}, ).add_to_hass(hass) step_...
[ "async", "def", "test_one_config_allowed", "(", "hass", ")", ":", "flow", "=", "config_flow", ".", "AbodeFlowHandler", "(", ")", "flow", ".", "hass", "=", "hass", "MockConfigEntry", "(", "domain", "=", "\"abode\"", ",", "data", "=", "{", "CONF_USERNAME", ":"...
[ 24, 0 ]
[ 48, 70 ]
python
en
['en', 'en', 'en']
True
test_invalid_credentials
(hass)
Test that invalid credentials throws an error.
Test that invalid credentials throws an error.
async def test_invalid_credentials(hass): """Test that invalid credentials throws an error.""" conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} flow = config_flow.AbodeFlowHandler() flow.hass = hass with patch( "homeassistant.components.abode.config_flow.Abode", ...
[ "async", "def", "test_invalid_credentials", "(", "hass", ")", ":", "conf", "=", "{", "CONF_USERNAME", ":", "\"user@email.com\"", ",", "CONF_PASSWORD", ":", "\"password\"", "}", "flow", "=", "config_flow", ".", "AbodeFlowHandler", "(", ")", "flow", ".", "hass", ...
[ 51, 0 ]
[ 63, 59 ]
python
en
['en', 'en', 'en']
True
test_connection_error
(hass)
Test other than invalid credentials throws an error.
Test other than invalid credentials throws an error.
async def test_connection_error(hass): """Test other than invalid credentials throws an error.""" conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} flow = config_flow.AbodeFlowHandler() flow.hass = hass with patch( "homeassistant.components.abode.config_flow.Abode", ...
[ "async", "def", "test_connection_error", "(", "hass", ")", ":", "conf", "=", "{", "CONF_USERNAME", ":", "\"user@email.com\"", ",", "CONF_PASSWORD", ":", "\"password\"", "}", "flow", "=", "config_flow", ".", "AbodeFlowHandler", "(", ")", "flow", ".", "hass", "=...
[ 66, 0 ]
[ 80, 61 ]
python
en
['en', 'en', 'en']
True
test_step_import
(hass)
Test that the import step works.
Test that the import step works.
async def test_step_import(hass): """Test that the import step works.""" conf = { CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password", CONF_POLLING: False, } flow = config_flow.AbodeFlowHandler() flow.hass = hass with patch("homeassistant.components.abode.config_...
[ "async", "def", "test_step_import", "(", "hass", ")", ":", "conf", "=", "{", "CONF_USERNAME", ":", "\"user@email.com\"", ",", "CONF_PASSWORD", ":", "\"password\"", ",", "CONF_POLLING", ":", "False", ",", "}", "flow", "=", "config_flow", ".", "AbodeFlowHandler", ...
[ 83, 0 ]
[ 103, 9 ]
python
en
['en', 'en', 'en']
True
test_step_user
(hass)
Test that the user step works.
Test that the user step works.
async def test_step_user(hass): """Test that the user step works.""" conf = {CONF_USERNAME: "user@email.com", CONF_PASSWORD: "password"} flow = config_flow.AbodeFlowHandler() flow.hass = hass with patch("homeassistant.components.abode.config_flow.Abode"): result = await flow.async_step_use...
[ "async", "def", "test_step_user", "(", "hass", ")", ":", "conf", "=", "{", "CONF_USERNAME", ":", "\"user@email.com\"", ",", "CONF_PASSWORD", ":", "\"password\"", "}", "flow", "=", "config_flow", ".", "AbodeFlowHandler", "(", ")", "flow", ".", "hass", "=", "h...
[ 106, 0 ]
[ 121, 9 ]
python
en
['en', 'en', 'en']
True
test_subscription_registry
(hass: HomeAssistant)
Test subscription registry polling.
Test subscription registry polling.
async def test_subscription_registry(hass: HomeAssistant) -> None: """Test subscription registry polling.""" subscription_registry = SubscriptionRegistry(hass) # pylint: disable=protected-access subscription_registry.poll_server_once = poll_server_once_mock = MagicMock() poll_server_once_mock.retur...
[ "async", "def", "test_subscription_registry", "(", "hass", ":", "HomeAssistant", ")", "->", "None", ":", "subscription_registry", "=", "SubscriptionRegistry", "(", "hass", ")", "# pylint: disable=protected-access", "subscription_registry", ".", "poll_server_once", "=", "p...
[ 11, 0 ]
[ 49, 45 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up AdvantageAir motion platform.
Set up AdvantageAir motion platform.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up AdvantageAir motion platform.""" instance = hass.data[ADVANTAGE_AIR_DOMAIN][config_entry.entry_id] entities = [] for ac_key, ac_device in instance["coordinator"].data["aircons"].items(): entities.append(AdvantageAir...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "instance", "=", "hass", ".", "data", "[", "ADVANTAGE_AIR_DOMAIN", "]", "[", "config_entry", ".", "entry_id", "]", "entities", "=", "[", "]", "for", "...
[ 14, 0 ]
[ 26, 32 ]
python
en
['en', 'lv', 'en']
True
AdvantageAirZoneFilter.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return f'{self._ac["name"]} Filter'
[ "def", "name", "(", "self", ")", ":", "return", "f'{self._ac[\"name\"]} Filter'" ]
[ 33, 4 ]
[ 35, 43 ]
python
en
['en', 'ig', 'en']
True
AdvantageAirZoneFilter.unique_id
(self)
Return a unique id.
Return a unique id.
def unique_id(self): """Return a unique id.""" return f'{self.coordinator.data["system"]["rid"]}-{self.ac_key}-filter'
[ "def", "unique_id", "(", "self", ")", ":", "return", "f'{self.coordinator.data[\"system\"][\"rid\"]}-{self.ac_key}-filter'" ]
[ 38, 4 ]
[ 40, 79 ]
python
ca
['fr', 'ca', 'en']
False
AdvantageAirZoneFilter.device_class
(self)
Return the device class of the vent.
Return the device class of the vent.
def device_class(self): """Return the device class of the vent.""" return DEVICE_CLASS_PROBLEM
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_PROBLEM" ]
[ 43, 4 ]
[ 45, 35 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneFilter.is_on
(self)
Return if filter needs cleaning.
Return if filter needs cleaning.
def is_on(self): """Return if filter needs cleaning.""" return self._ac["filterCleanStatus"]
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_ac", "[", "\"filterCleanStatus\"", "]" ]
[ 48, 4 ]
[ 50, 44 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneMotion.name
(self)
Return the name.
Return the name.
def name(self): """Return the name.""" return f'{self._zone["name"]} Motion'
[ "def", "name", "(", "self", ")", ":", "return", "f'{self._zone[\"name\"]} Motion'" ]
[ 57, 4 ]
[ 59, 45 ]
python
en
['en', 'ig', 'en']
True
AdvantageAirZoneMotion.unique_id
(self)
Return a unique id.
Return a unique id.
def unique_id(self): """Return a unique id.""" return f'{self.coordinator.data["system"]["rid"]}-{self.ac_key}-{self.zone_key}-motion'
[ "def", "unique_id", "(", "self", ")", ":", "return", "f'{self.coordinator.data[\"system\"][\"rid\"]}-{self.ac_key}-{self.zone_key}-motion'" ]
[ 62, 4 ]
[ 64, 95 ]
python
ca
['fr', 'ca', 'en']
False
AdvantageAirZoneMotion.device_class
(self)
Return the device class of the vent.
Return the device class of the vent.
def device_class(self): """Return the device class of the vent.""" return DEVICE_CLASS_MOTION
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS_MOTION" ]
[ 67, 4 ]
[ 69, 34 ]
python
en
['en', 'en', 'en']
True
AdvantageAirZoneMotion.is_on
(self)
Return if motion is detect.
Return if motion is detect.
def is_on(self): """Return if motion is detect.""" return self._zone["motion"]
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_zone", "[", "\"motion\"", "]" ]
[ 72, 4 ]
[ 74, 35 ]
python
en
['en', 'en', 'en']
True
FirmataEntity.__init__
(self, api)
Initialize the entity.
Initialize the entity.
def __init__(self, api): """Initialize the entity.""" self._api = api
[ "def", "__init__", "(", "self", ",", "api", ")", ":", "self", ".", "_api", "=", "api" ]
[ 13, 4 ]
[ 15, 23 ]
python
en
['en', 'en', 'en']
True
FirmataEntity.device_info
(self)
Return device info.
Return device info.
def device_info(self) -> dict: """Return device info.""" return { "connections": {}, "identifiers": {(DOMAIN, self._api.board.name)}, "manufacturer": FIRMATA_MANUFACTURER, "name": self._api.board.name, "sw_version": self._api.board.firmware_ver...
[ "def", "device_info", "(", "self", ")", "->", "dict", ":", "return", "{", "\"connections\"", ":", "{", "}", ",", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "self", ".", "_api", ".", "board", ".", "name", ")", "}", ",", "\"manufacturer\"", ":", ...
[ 18, 4 ]
[ 26, 9 ]
python
en
['es', 'hr', 'en']
False
FirmataPinEntity.__init__
( self, api: Type[FirmataBoardPin], config_entry: ConfigEntry, name: str, pin: FirmataPinType, )
Initialize the pin entity.
Initialize the pin entity.
def __init__( self, api: Type[FirmataBoardPin], config_entry: ConfigEntry, name: str, pin: FirmataPinType, ): """Initialize the pin entity.""" super().__init__(api) self._name = name location = (config_entry.entry_id, "pin", pin) self....
[ "def", "__init__", "(", "self", ",", "api", ":", "Type", "[", "FirmataBoardPin", "]", ",", "config_entry", ":", "ConfigEntry", ",", "name", ":", "str", ",", "pin", ":", "FirmataPinType", ",", ")", ":", "super", "(", ")", ".", "__init__", "(", "api", ...
[ 32, 4 ]
[ 44, 60 ]
python
en
['en', 'en', 'en']
True
FirmataPinEntity.name
(self)
Get the name of the pin.
Get the name of the pin.
def name(self) -> str: """Get the name of the pin.""" return self._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 47, 4 ]
[ 49, 25 ]
python
en
['en', 'en', 'en']
True
FirmataPinEntity.should_poll
(self)
No polling needed.
No polling needed.
def should_poll(self) -> bool: """No polling needed.""" return False
[ "def", "should_poll", "(", "self", ")", "->", "bool", ":", "return", "False" ]
[ 52, 4 ]
[ 54, 20 ]
python
en
['en', 'en', 'en']
True
FirmataPinEntity.unique_id
(self)
Return a unique identifier for this device.
Return a unique identifier for this device.
def unique_id(self) -> str: """Return a unique identifier for this device.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unique_id" ]
[ 57, 4 ]
[ 59, 30 ]
python
en
['en', 'en', 'en']
True
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",...
[ 16, 0 ]
[ 29, 65 ]
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", ...
[ 32, 0 ]
[ 45, 65 ]
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() assert not registry.async_is_registered(FIRST_ENTITY_ID) assert not registry.async_is_registered(SECOND_ENTITY_ID) await setup_risco(hass) asse...
[ "async", "def", "test_setup", "(", "hass", ",", "two_zone_alarm", ")", ":", "# noqa: F811", "registry", "=", "await", "hass", ".", "helpers", ".", "entity_registry", ".", "async_get_registry", "(", ")", "assert", "not", "registry", ".", "async_is_registered", "(...
[ 48, 0 ]
[ 67, 41 ]
python
en
['en', 'zu', 'en']
True
test_states
(hass, two_zone_alarm)
Test the various alarm states.
Test the various alarm states.
async def test_states(hass, two_zone_alarm): # noqa: F811 """Test the various alarm states.""" await setup_risco(hass) await _check_state(hass, two_zone_alarm, True, True, FIRST_ENTITY_ID, 0) await _check_state(hass, two_zone_alarm, True, False, FIRST_ENTITY_ID, 0) await _check_state(hass, two_zon...
[ "async", "def", "test_states", "(", "hass", ",", "two_zone_alarm", ")", ":", "# noqa: F811", "await", "setup_risco", "(", "hass", ")", "await", "_check_state", "(", "hass", ",", "two_zone_alarm", ",", "True", ",", "True", ",", "FIRST_ENTITY_ID", ",", "0", ")...
[ 89, 0 ]
[ 100, 79 ]
python
en
['en', 'el-Latn', 'en']
True
test_bypass
(hass, two_zone_alarm)
Test bypassing a zone.
Test bypassing a zone.
async def test_bypass(hass, two_zone_alarm): # noqa: F811 """Test bypassing a zone.""" await setup_risco(hass) with patch("homeassistant.components.risco.RiscoAPI.bypass_zone") as mock: data = {"entity_id": FIRST_ENTITY_ID} await hass.services.async_call( DOMAIN, "bypass_zone",...
[ "async", "def", "test_bypass", "(", "hass", ",", "two_zone_alarm", ")", ":", "# noqa: F811", "await", "setup_risco", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.components.risco.RiscoAPI.bypass_zone\"", ")", "as", "mock", ":", "data", "=", "{", "\"ent...
[ 103, 0 ]
[ 113, 46 ]
python
en
['en', 'en', 'en']
True
test_unbypass
(hass, two_zone_alarm)
Test unbypassing a zone.
Test unbypassing a zone.
async def test_unbypass(hass, two_zone_alarm): # noqa: F811 """Test unbypassing a zone.""" await setup_risco(hass) with patch("homeassistant.components.risco.RiscoAPI.bypass_zone") as mock: data = {"entity_id": FIRST_ENTITY_ID} await hass.services.async_call( DOMAIN, "unbypass_...
[ "async", "def", "test_unbypass", "(", "hass", ",", "two_zone_alarm", ")", ":", "# noqa: F811", "await", "setup_risco", "(", "hass", ")", "with", "patch", "(", "\"homeassistant.components.risco.RiscoAPI.bypass_zone\"", ")", "as", "mock", ":", "data", "=", "{", "\"e...
[ 116, 0 ]
[ 126, 47 ]
python
en
['en', 'en', 'it']
True
async_setup_entry
( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities )
Set up discovered sensors.
Set up discovered sensors.
async def async_setup_entry( hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up discovered sensors.""" devs = [] for dev in hass.data[AQUALINK_DOMAIN][DOMAIN]: devs.append(HassAqualinkSensor(dev)) async_add_entities(devs, True)
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "devs", "=", "[", "]", "for", "dev", "in", "hass", ".", "data", "[", "AQUALINK_DOMAIN", "]...
[ 14, 0 ]
[ 21, 34 ]
python
en
['en', 'da', 'en']
True
HassAqualinkSensor.name
(self)
Return the name of the sensor.
Return the name of the sensor.
def name(self) -> str: """Return the name of the sensor.""" return self.dev.label
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "dev", ".", "label" ]
[ 28, 4 ]
[ 30, 29 ]
python
en
['en', 'mi', 'en']
True
HassAqualinkSensor.unit_of_measurement
(self)
Return the measurement unit for the sensor.
Return the measurement unit for the sensor.
def unit_of_measurement(self) -> Optional[str]: """Return the measurement unit for the sensor.""" if self.dev.name.endswith("_temp"): if self.dev.system.temp_unit == "F": return TEMP_FAHRENHEIT return TEMP_CELSIUS return None
[ "def", "unit_of_measurement", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "dev", ".", "name", ".", "endswith", "(", "\"_temp\"", ")", ":", "if", "self", ".", "dev", ".", "system", ".", "temp_unit", "==", "\"F\"", ":",...
[ 33, 4 ]
[ 39, 19 ]
python
en
['en', 'sq', 'en']
True
HassAqualinkSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self) -> Optional[str]: """Return the state of the sensor.""" if self.dev.state == "": return None try: state = int(self.dev.state) except ValueError: state = float(self.dev.state) return state
[ "def", "state", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "dev", ".", "state", "==", "\"\"", ":", "return", "None", "try", ":", "state", "=", "int", "(", "self", ".", "dev", ".", "state", ")", "except", "ValueEr...
[ 42, 4 ]
[ 51, 20 ]
python
en
['en', 'en', 'en']
True
HassAqualinkSensor.device_class
(self)
Return the class of the sensor.
Return the class of the sensor.
def device_class(self) -> Optional[str]: """Return the class of the sensor.""" if self.dev.name.endswith("_temp"): return DEVICE_CLASS_TEMPERATURE return None
[ "def", "device_class", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "self", ".", "dev", ".", "name", ".", "endswith", "(", "\"_temp\"", ")", ":", "return", "DEVICE_CLASS_TEMPERATURE", "return", "None" ]
[ 54, 4 ]
[ 58, 19 ]
python
en
['en', 'pt', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the myStrom light integration.
Set up the myStrom light integration.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the myStrom light integration.""" host = config.get(CONF_HOST) mac = config.get(CONF_MAC) name = config.get(CONF_NAME) bulb = MyStromBulb(host, mac) try: await bulb.get_state() if bu...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "host", "=", "config", ".", "get", "(", "CONF_HOST", ")", "mac", "=", "config", ".", "get", "(", "CONF_MAC", ")", ...
[ 42, 0 ]
[ 58, 61 ]
python
en
['en', 'sv', 'en']
True
MyStromLight.__init__
(self, bulb, name, mac)
Initialize the light.
Initialize the light.
def __init__(self, bulb, name, mac): """Initialize the light.""" self._bulb = bulb self._name = name self._state = None self._available = False self._brightness = 0 self._color_h = 0 self._color_s = 0 self._mac = mac
[ "def", "__init__", "(", "self", ",", "bulb", ",", "name", ",", "mac", ")", ":", "self", ".", "_bulb", "=", "bulb", "self", ".", "_name", "=", "name", "self", ".", "_state", "=", "None", "self", ".", "_available", "=", "False", "self", ".", "_bright...
[ 64, 4 ]
[ 73, 23 ]
python
en
['en', 'en', 'en']
True
MyStromLight.name
(self)
Return the display name of this light.
Return the display name of this light.
def name(self): """Return the display name of this light.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 76, 4 ]
[ 78, 25 ]
python
en
['en', 'en', 'en']
True
MyStromLight.unique_id
(self)
Return a unique ID.
Return a unique ID.
def unique_id(self): """Return a unique ID.""" return self._mac
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_mac" ]
[ 81, 4 ]
[ 83, 24 ]
python
ca
['fr', 'ca', 'en']
False
MyStromLight.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self): """Flag supported features.""" return SUPPORT_MYSTROM
[ "def", "supported_features", "(", "self", ")", ":", "return", "SUPPORT_MYSTROM" ]
[ 86, 4 ]
[ 88, 30 ]
python
en
['da', 'en', 'en']
True
MyStromLight.brightness
(self)
Return the brightness of the light.
Return the brightness of the light.
def brightness(self): """Return the brightness of the light.""" return self._brightness
[ "def", "brightness", "(", "self", ")", ":", "return", "self", ".", "_brightness" ]
[ 91, 4 ]
[ 93, 31 ]
python
en
['en', 'no', 'en']
True