Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
test_entities_entity_ids_entity_id_false
()
Test entity ID policy.
Test entity ID policy.
def test_entities_entity_ids_entity_id_false(): """Test entity ID policy.""" policy = {"entity_ids": {"light.kitchen": False}} with pytest.raises(vol.Invalid): ENTITY_POLICY_SCHEMA(policy)
[ "def", "test_entities_entity_ids_entity_id_false", "(", ")", ":", "policy", "=", "{", "\"entity_ids\"", ":", "{", "\"light.kitchen\"", ":", "False", "}", "}", "with", "pytest", ".", "raises", "(", "vol", ".", "Invalid", ")", ":", "ENTITY_POLICY_SCHEMA", "(", "...
[ 93, 0 ]
[ 97, 36 ]
python
en
['en', 'cy', 'en']
True
test_entities_control_only
()
Test policy granting control only.
Test policy granting control only.
def test_entities_control_only(): """Test policy granting control only.""" policy = {"entity_ids": {"light.kitchen": {"read": True}}} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True assert compiled("light.kitchen", "control"...
[ "def", "test_entities_control_only", "(", ")", ":", "policy", "=", "{", "\"entity_ids\"", ":", "{", "\"light.kitchen\"", ":", "{", "\"read\"", ":", "True", "}", "}", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "po...
[ 100, 0 ]
[ 107, 53 ]
python
en
['en', 'en', 'en']
True
test_entities_read_control
()
Test policy granting control only.
Test policy granting control only.
def test_entities_read_control(): """Test policy granting control only.""" policy = {"domains": {"light": {"read": True, "control": True}}} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True assert compiled("light.kitchen", "co...
[ "def", "test_entities_read_control", "(", ")", ":", "policy", "=", "{", "\"domains\"", ":", "{", "\"light\"", ":", "{", "\"read\"", ":", "True", ",", "\"control\"", ":", "True", "}", "}", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "c...
[ 110, 0 ]
[ 117, 53 ]
python
en
['en', 'en', 'en']
True
test_entities_all_allow
()
Test policy allowing all entities.
Test policy allowing all entities.
def test_entities_all_allow(): """Test policy allowing all entities.""" policy = {"all": True} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True assert compiled("light.kitchen", "control") is True assert compiled("switch.k...
[ "def", "test_entities_all_allow", "(", ")", ":", "policy", "=", "{", "\"all\"", ":", "True", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "compiled", "(", "\"light.kitchen\"", ...
[ 120, 0 ]
[ 127, 53 ]
python
en
['en', 'en', 'en']
True
test_entities_all_read
()
Test policy applying read to all entities.
Test policy applying read to all entities.
def test_entities_all_read(): """Test policy applying read to all entities.""" policy = {"all": {"read": True}} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True assert compiled("light.kitchen", "control") is False assert ...
[ "def", "test_entities_all_read", "(", ")", ":", "policy", "=", "{", "\"all\"", ":", "{", "\"read\"", ":", "True", "}", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "compiled"...
[ 130, 0 ]
[ 137, 53 ]
python
en
['en', 'en', 'en']
True
test_entities_all_control
()
Test entity ID policy applying control to all.
Test entity ID policy applying control to all.
def test_entities_all_control(): """Test entity ID policy applying control to all.""" policy = {"all": {"control": True}} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is False assert compiled("light.kitchen", "control") is True ...
[ "def", "test_entities_all_control", "(", ")", ":", "policy", "=", "{", "\"all\"", ":", "{", "\"control\"", ":", "True", "}", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "com...
[ 140, 0 ]
[ 148, 56 ]
python
en
['en', 'en', 'en']
True
test_entities_device_id_boolean
(hass)
Test entity ID policy applying control on device id.
Test entity ID policy applying control on device id.
def test_entities_device_id_boolean(hass): """Test entity ID policy applying control on device id.""" entity_registry = mock_registry( hass, { "test_domain.allowed": RegistryEntry( entity_id="test_domain.allowed", unique_id="1234", plat...
[ "def", "test_entities_device_id_boolean", "(", "hass", ")", ":", "entity_registry", "=", "mock_registry", "(", "hass", ",", "{", "\"test_domain.allowed\"", ":", "RegistryEntry", "(", "entity_id", "=", "\"test_domain.allowed\"", ",", "unique_id", "=", "\"1234\"", ",", ...
[ 151, 0 ]
[ 180, 66 ]
python
en
['en', 'cy', 'en']
True
test_entities_areas_true
()
Test entity ID policy for areas.
Test entity ID policy for areas.
def test_entities_areas_true(): """Test entity ID policy for areas.""" policy = {"area_ids": True} ENTITY_POLICY_SCHEMA(policy) compiled = compile_entities(policy, None) assert compiled("light.kitchen", "read") is True
[ "def", "test_entities_areas_true", "(", ")", ":", "policy", "=", "{", "\"area_ids\"", ":", "True", "}", "ENTITY_POLICY_SCHEMA", "(", "policy", ")", "compiled", "=", "compile_entities", "(", "policy", ",", "None", ")", "assert", "compiled", "(", "\"light.kitchen\...
[ 183, 0 ]
[ 188, 52 ]
python
en
['en', 'en', 'en']
True
test_entities_areas_area_true
(hass)
Test entity ID policy for areas with specific area.
Test entity ID policy for areas with specific area.
def test_entities_areas_area_true(hass): """Test entity ID policy for areas with specific area.""" entity_registry = mock_registry( hass, { "light.kitchen": RegistryEntry( entity_id="light.kitchen", unique_id="1234", platform="test_plat...
[ "def", "test_entities_areas_area_true", "(", "hass", ")", ":", "entity_registry", "=", "mock_registry", "(", "hass", ",", "{", "\"light.kitchen\"", ":", "RegistryEntry", "(", "entity_id", "=", "\"light.kitchen\"", ",", "unique_id", "=", "\"1234\"", ",", "platform", ...
[ 191, 0 ]
[ 216, 54 ]
python
en
['en', 'en', 'en']
True
CamembertTokenizerFast.build_inputs_with_special_tokens
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An CamemBERT sequence has the following format: - single sequence: ``<s> X </s>`` - pair of sequences: ``<s> A </s></s> B </s>`` Args: ...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An CamemBERT sequence has the following format:
def build_inputs_with_special_tokens( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. An CamemBERT sequence...
[ "def", "build_inputs_with_special_tokens", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "if", "token_ids_1", ...
[ 138, 4 ]
[ 162, 64 ]
python
en
['en', 'error', 'th']
False
CamembertTokenizerFast.get_special_tokens_mask
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False )
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_ids_1 (:obj:`List[int]`,...
Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` method.
def get_special_tokens_mask( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False ) -> List[int]: """ Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding special tokens ...
[ "def", "get_special_tokens_mask", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ",", "already_has_special_tokens", ":", "bool", "=", "False", ")", "->", ...
[ 164, 4 ]
[ 192, 87 ]
python
en
['en', 'error', 'th']
False
CamembertTokenizerFast.create_token_type_ids_from_sequences
( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None )
Create a mask from the two sequences passed to be used in a sequence-pair classification task. CamemBERT, like RoBERTa, does not make use of token type ids, therefore a list of zeros is returned. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_i...
Create a mask from the two sequences passed to be used in a sequence-pair classification task. CamemBERT, like RoBERTa, does not make use of token type ids, therefore a list of zeros is returned.
def create_token_type_ids_from_sequences( self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None ) -> List[int]: """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. CamemBERT, like RoBERTa, does not make use of token type ...
[ "def", "create_token_type_ids_from_sequences", "(", "self", ",", "token_ids_0", ":", "List", "[", "int", "]", ",", "token_ids_1", ":", "Optional", "[", "List", "[", "int", "]", "]", "=", "None", ")", "->", "List", "[", "int", "]", ":", "sep", "=", "[",...
[ 194, 4 ]
[ 215, 75 ]
python
en
['en', 'error', 'th']
False
get_experiments
()
Get a list of existing experiments. Returns: json: List of existing experiments.
Get a list of existing experiments.
def get_experiments(): """Get a list of existing experiments. Returns: json: List of existing experiments. """ get_exps_params = { "query": "select name from maro.experiments", } exps = requests.get( url=request_settings.request_url.value, headers=request_settin...
[ "def", "get_experiments", "(", ")", ":", "get_exps_params", "=", "{", "\"query\"", ":", "\"select name from maro.experiments\"", ",", "}", "exps", "=", "requests", ".", "get", "(", "url", "=", "request_settings", ".", "request_url", ".", "value", ",", "headers",...
[ 12, 0 ]
[ 28, 19 ]
python
en
['en', 'en', 'en']
True
get_experiment_info
()
Get basic information of experiment.
Get basic information of experiment.
def get_experiment_info(): """Get basic information of experiment. """ get_exp_name_params = { "query": "select name from pending_experiments order by time desc limit 1", } exp_name = requests.get( url=request_settings.request_url.value, headers=request_settings.request_heade...
[ "def", "get_experiment_info", "(", ")", ":", "get_exp_name_params", "=", "{", "\"query\"", ":", "\"select name from pending_experiments order by time desc limit 1\"", ",", "}", "exp_name", "=", "requests", ".", "get", "(", "url", "=", "request_settings", ".", "request_u...
[ 31, 0 ]
[ 106, 19 ]
python
en
['en', 'en', 'en']
True
GensimTfidfVectorizer.__init__
(self, dirpath=".", tofull=False)
Pass in a directory that holds the lexicon in corpus.dict and the TFIDF model in tfidf.model (for now). Set tofull = True if the next thing is a Scikit-Learn estimator otherwise keep False if the next thing is a Gensim model.
Pass in a directory that holds the lexicon in corpus.dict and the TFIDF model in tfidf.model (for now).
def __init__(self, dirpath=".", tofull=False): """ Pass in a directory that holds the lexicon in corpus.dict and the TFIDF model in tfidf.model (for now). Set tofull = True if the next thing is a Scikit-Learn estimator otherwise keep False if the next thing is a Gensim model. ...
[ "def", "__init__", "(", "self", ",", "dirpath", "=", "\".\"", ",", "tofull", "=", "False", ")", ":", "self", ".", "_lexicon_path", "=", "os", ".", "path", ".", "join", "(", "dirpath", ",", "\"corpus.dict\"", ")", "self", ".", "_tfidf_path", "=", "os", ...
[ 61, 4 ]
[ 76, 19 ]
python
en
['en', 'error', 'th']
False
async_migrator
( hass, old_path, store, *, old_conf_load_func=None, old_conf_migrate_func=None, )
Migrate old data to a store and then load data. async def old_conf_migrate_func(old_data)
Migrate old data to a store and then load data.
async def async_migrator( hass, old_path, store, *, old_conf_load_func=None, old_conf_migrate_func=None, ): """Migrate old data to a store and then load data. async def old_conf_migrate_func(old_data) """ store_data = await store.async_load() # If we already have store data...
[ "async", "def", "async_migrator", "(", "hass", ",", "old_path", ",", "store", ",", "*", ",", "old_conf_load_func", "=", "None", ",", "old_conf_migrate_func", "=", "None", ",", ")", ":", "store_data", "=", "await", "store", ".", "async_load", "(", ")", "# I...
[ 21, 0 ]
[ 59, 17 ]
python
en
['en', 'en', 'en']
True
keras_dropout
(layer, rate)
Keras dropout layer.
Keras dropout layer.
def keras_dropout(layer, rate): """ Keras dropout layer. """ from keras import layers input_dim = len(layer.input.shape) if input_dim == 2: return layers.SpatialDropout1D(rate) elif input_dim == 3: return layers.SpatialDropout2D(rate) elif input_dim == 4: return...
[ "def", "keras_dropout", "(", "layer", ",", "rate", ")", ":", "from", "keras", "import", "layers", "input_dim", "=", "len", "(", "layer", ".", "input", ".", "shape", ")", "if", "input_dim", "==", "2", ":", "return", "layers", ".", "SpatialDropout1D", "(",...
[ 593, 0 ]
[ 608, 35 ]
python
en
['en', 'error', 'th']
False
to_real_keras_layer
(layer)
Real keras layer.
Real keras layer.
def to_real_keras_layer(layer): """ Real keras layer. """ from keras import layers if is_layer(layer, "Dense"): return layers.Dense(layer.units, input_shape=(layer.input_units,)) if is_layer(layer, "Conv"): return layers.Conv2D( layer.filters, layer.kerne...
[ "def", "to_real_keras_layer", "(", "layer", ")", ":", "from", "keras", "import", "layers", "if", "is_layer", "(", "layer", ",", "\"Dense\"", ")", ":", "return", "layers", ".", "Dense", "(", "layer", ".", "units", ",", "input_shape", "=", "(", "layer", "....
[ 611, 0 ]
[ 644, 15 ]
python
en
['en', 'error', 'th']
False
is_layer
(layer, layer_type)
Judge the layer type. Returns ------- bool boolean -- True or False
Judge the layer type.
def is_layer(layer, layer_type): """ Judge the layer type. Returns ------- bool boolean -- True or False """ if layer_type == "Input": return isinstance(layer, StubInput) elif layer_type == "Conv": return isinstance(layer, StubConv) elif layer_type == "Dense...
[ "def", "is_layer", "(", "layer", ",", "layer_type", ")", ":", "if", "layer_type", "==", "\"Input\"", ":", "return", "isinstance", "(", "layer", ",", "StubInput", ")", "elif", "layer_type", "==", "\"Conv\"", ":", "return", "isinstance", "(", "layer", ",", "...
[ 647, 0 ]
[ 681, 15 ]
python
en
['en', 'error', 'th']
False
layer_description_extractor
(layer, node_to_id)
Get layer description.
Get layer description.
def layer_description_extractor(layer, node_to_id): """ Get layer description. """ layer_input = layer.input layer_output = layer.output if layer_input is not None: if isinstance(layer_input, Iterable): layer_input = list(map(lambda x: node_to_id[x], layer_input)) el...
[ "def", "layer_description_extractor", "(", "layer", ",", "node_to_id", ")", ":", "layer_input", "=", "layer", ".", "input", "layer_output", "=", "layer", ".", "output", "if", "layer_input", "is", "not", "None", ":", "if", "isinstance", "(", "layer_input", ",",...
[ 684, 0 ]
[ 734, 64 ]
python
en
['en', 'error', 'th']
False
layer_description_builder
(layer_information, id_to_node)
build layer from description.
build layer from description.
def layer_description_builder(layer_information, id_to_node): """build layer from description. """ layer_type = layer_information[0] layer_input_ids = layer_information[1] if isinstance(layer_input_ids, Iterable): layer_input = list(map(lambda x: id_to_node[x], layer_input_ids)) else: ...
[ "def", "layer_description_builder", "(", "layer_information", ",", "id_to_node", ")", ":", "layer_type", "=", "layer_information", "[", "0", "]", "layer_input_ids", "=", "layer_information", "[", "1", "]", "if", "isinstance", "(", "layer_input_ids", ",", "Iterable",...
[ 737, 0 ]
[ 772, 63 ]
python
en
['en', 'en', 'en']
True
layer_width
(layer)
Get layer width.
Get layer width.
def layer_width(layer): """ Get layer width. """ if is_layer(layer, "Dense"): return layer.units if is_layer(layer, "Conv"): return layer.filters raise TypeError("The layer should be either Dense or Conv layer.")
[ "def", "layer_width", "(", "layer", ")", ":", "if", "is_layer", "(", "layer", ",", "\"Dense\"", ")", ":", "return", "layer", ".", "units", "if", "is_layer", "(", "layer", ",", "\"Conv\"", ")", ":", "return", "layer", ".", "filters", "raise", "TypeError",...
[ 775, 0 ]
[ 784, 70 ]
python
en
['en', 'error', 'th']
False
StubLayer.build
(self, shape)
build shape.
build shape.
def build(self, shape): """ build shape. """
[ "def", "build", "(", "self", ",", "shape", ")", ":" ]
[ 68, 4 ]
[ 71, 11 ]
python
en
['en', 'error', 'th']
False
StubLayer.set_weights
(self, weights)
set weights.
set weights.
def set_weights(self, weights): """ set weights. """ self.weights = weights
[ "def", "set_weights", "(", "self", ",", "weights", ")", ":", "self", ".", "weights", "=", "weights" ]
[ 73, 4 ]
[ 77, 30 ]
python
en
['en', 'error', 'th']
False
StubLayer.import_weights
(self, torch_layer)
import weights.
import weights.
def import_weights(self, torch_layer): """ import weights. """
[ "def", "import_weights", "(", "self", ",", "torch_layer", ")", ":" ]
[ 79, 4 ]
[ 82, 11 ]
python
en
['en', 'error', 'th']
False
StubLayer.import_weights_keras
(self, keras_layer)
import weights from keras layer.
import weights from keras layer.
def import_weights_keras(self, keras_layer): """ import weights from keras layer. """
[ "def", "import_weights_keras", "(", "self", ",", "keras_layer", ")", ":" ]
[ 84, 4 ]
[ 87, 11 ]
python
en
['en', 'error', 'th']
False
StubLayer.export_weights
(self, torch_layer)
export weights.
export weights.
def export_weights(self, torch_layer): """ export weights. """
[ "def", "export_weights", "(", "self", ",", "torch_layer", ")", ":" ]
[ 89, 4 ]
[ 92, 11 ]
python
en
['en', 'error', 'th']
False
StubLayer.export_weights_keras
(self, keras_layer)
export weights to keras layer.
export weights to keras layer.
def export_weights_keras(self, keras_layer): """ export weights to keras layer. """
[ "def", "export_weights_keras", "(", "self", ",", "keras_layer", ")", ":" ]
[ 94, 4 ]
[ 97, 11 ]
python
en
['en', 'error', 'th']
False
StubLayer.get_weights
(self)
get weights.
get weights.
def get_weights(self): """ get weights. """ return self.weights
[ "def", "get_weights", "(", "self", ")", ":", "return", "self", ".", "weights" ]
[ 99, 4 ]
[ 103, 27 ]
python
en
['en', 'error', 'th']
False
StubLayer.size
(self)
size().
size().
def size(self): """ size(). """ return 0
[ "def", "size", "(", "self", ")", ":", "return", "0" ]
[ 105, 4 ]
[ 109, 16 ]
python
en
['en', 'error', 'th']
False
StubLayer.output_shape
(self)
output shape.
output shape.
def output_shape(self): """ output shape. """ return self.input.shape
[ "def", "output_shape", "(", "self", ")", ":", "return", "self", ".", "input", ".", "shape" ]
[ 112, 4 ]
[ 116, 31 ]
python
en
['en', 'error', 'th']
False
StubLayer.to_real_layer
(self)
to real layer.
to real layer.
def to_real_layer(self): """ to real layer. """
[ "def", "to_real_layer", "(", "self", ")", ":" ]
[ 118, 4 ]
[ 121, 11 ]
python
en
['en', 'error', 'th']
False
StubLayer.__str__
(self)
str() function to print.
str() function to print.
def __str__(self): """ str() function to print. """ return type(self).__name__[4:]
[ "def", "__str__", "(", "self", ")", ":", "return", "type", "(", "self", ")", ".", "__name__", "[", "4", ":", "]" ]
[ 123, 4 ]
[ 127, 38 ]
python
en
['en', 'error', 'th']
False
test_aqara_switch_setup
(hass)
Test that a Aqara Switch can be correctly setup in HA.
Test that a Aqara Switch can be correctly setup in HA.
async def test_aqara_switch_setup(hass): """Test that a Aqara Switch can be correctly setup in HA.""" accessories = await setup_accessories_from_file(hass, "aqara_switch.json") config_entry, pairing = await setup_test_accessories(hass, accessories) entity_registry = await hass.helpers.entity_registry.a...
[ "async", "def", "test_aqara_switch_setup", "(", "hass", ")", ":", "accessories", "=", "await", "setup_accessories_from_file", "(", "hass", ",", "\"aqara_switch.json\"", ")", "config_entry", ",", "pairing", "=", "await", "setup_test_accessories", "(", "hass", ",", "a...
[ 16, 0 ]
[ 51, 41 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], )
Set up BSBLan device based on a config entry.
Set up BSBLan device based on a config entry.
async def async_setup_entry( hass: HomeAssistantType, entry: ConfigEntry, async_add_entities: Callable[[List[Entity], bool], None], ) -> None: """Set up BSBLan device based on a config entry.""" bsblan: BSBLan = hass.data[DOMAIN][entry.entry_id][DATA_BSBLAN_CLIENT] info = await bsblan.info() ...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistantType", ",", "entry", ":", "ConfigEntry", ",", "async_add_entities", ":", "Callable", "[", "[", "List", "[", "Entity", "]", ",", "bool", "]", ",", "None", "]", ",", ")", "->", "None", ":...
[ 73, 0 ]
[ 81, 75 ]
python
en
['en', 'en', 'en']
True
BSBLanClimate.__init__
( self, entry_id: str, bsblan: BSBLan, info: Info, )
Initialize BSBLan climate device.
Initialize BSBLan climate device.
def __init__( self, entry_id: str, bsblan: BSBLan, info: Info, ): """Initialize BSBLan climate device.""" self._current_temperature: Optional[float] = None self._available = True self._hvac_mode: Optional[str] = None self._target_temperature: O...
[ "def", "__init__", "(", "self", ",", "entry_id", ":", "str", ",", "bsblan", ":", "BSBLan", ",", "info", ":", "Info", ",", ")", ":", "self", ".", "_current_temperature", ":", "Optional", "[", "float", "]", "=", "None", "self", ".", "_available", "=", ...
[ 87, 4 ]
[ 102, 28 ]
python
en
['fr', 'en', 'it']
False
BSBLanClimate.name
(self)
Return the name of the entity.
Return the name of the entity.
def name(self) -> str: """Return the name of the entity.""" return self._info.device_identification
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_info", ".", "device_identification" ]
[ 105, 4 ]
[ 107, 47 ]
python
en
['en', 'en', 'en']
True
BSBLanClimate.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self) -> bool: """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "_available" ]
[ 110, 4 ]
[ 112, 30 ]
python
en
['en', 'en', 'en']
True
BSBLanClimate.unique_id
(self)
Return the unique ID for this sensor.
Return the unique ID for this sensor.
def unique_id(self) -> str: """Return the unique ID for this sensor.""" return self._info.device_identification
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_info", ".", "device_identification" ]
[ 115, 4 ]
[ 117, 47 ]
python
en
['en', 'la', 'en']
True
BSBLanClimate.temperature_unit
(self)
Return the unit of measurement which this thermostat uses.
Return the unit of measurement which this thermostat uses.
def temperature_unit(self) -> str: """Return the unit of measurement which this thermostat uses.""" if self._temperature_unit == "&deg;C": return TEMP_CELSIUS return TEMP_FAHRENHEIT
[ "def", "temperature_unit", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_temperature_unit", "==", "\"&deg;C\"", ":", "return", "TEMP_CELSIUS", "return", "TEMP_FAHRENHEIT" ]
[ 120, 4 ]
[ 124, 30 ]
python
en
['en', 'en', 'en']
True
BSBLanClimate.supported_features
(self)
Flag supported features.
Flag supported features.
def supported_features(self) -> int: """Flag supported features.""" return SUPPORT_FLAGS
[ "def", "supported_features", "(", "self", ")", "->", "int", ":", "return", "SUPPORT_FLAGS" ]
[ 127, 4 ]
[ 129, 28 ]
python
en
['da', 'en', 'en']
True
BSBLanClimate.current_temperature
(self)
Return the current temperature.
Return the current temperature.
def current_temperature(self): """Return the current temperature.""" return self._current_temperature
[ "def", "current_temperature", "(", "self", ")", ":", "return", "self", ".", "_current_temperature" ]
[ 132, 4 ]
[ 134, 40 ]
python
en
['en', 'la', 'en']
True
BSBLanClimate.hvac_mode
(self)
Return the current operation mode.
Return the current operation mode.
def hvac_mode(self): """Return the current operation mode.""" return self._hvac_mode
[ "def", "hvac_mode", "(", "self", ")", ":", "return", "self", ".", "_hvac_mode" ]
[ 137, 4 ]
[ 139, 30 ]
python
en
['en', 'en', 'en']
True
BSBLanClimate.hvac_modes
(self)
Return the list of available operation modes.
Return the list of available operation modes.
def hvac_modes(self): """Return the list of available operation modes.""" return HVAC_MODES
[ "def", "hvac_modes", "(", "self", ")", ":", "return", "HVAC_MODES" ]
[ 142, 4 ]
[ 144, 25 ]
python
en
['en', 'en', 'en']
True
BSBLanClimate.target_temperature
(self)
Return the temperature we try to reach.
Return the temperature we try to reach.
def target_temperature(self): """Return the temperature we try to reach.""" return self._target_temperature
[ "def", "target_temperature", "(", "self", ")", ":", "return", "self", ".", "_target_temperature" ]
[ 147, 4 ]
[ 149, 39 ]
python
en
['en', 'en', 'en']
True
BSBLanClimate.preset_modes
(self)
List of available preset modes.
List of available preset modes.
def preset_modes(self): """List of available preset modes.""" return PRESET_MODES
[ "def", "preset_modes", "(", "self", ")", ":", "return", "PRESET_MODES" ]
[ 152, 4 ]
[ 154, 27 ]
python
en
['en', 'en', 'en']
True
BSBLanClimate.preset_mode
(self)
Return the preset_mode.
Return the preset_mode.
def preset_mode(self): """Return the preset_mode.""" return self._preset_mode
[ "def", "preset_mode", "(", "self", ")", ":", "return", "self", ".", "_preset_mode" ]
[ 157, 4 ]
[ 159, 32 ]
python
en
['en', 'no', 'en']
True
BSBLanClimate.async_set_preset_mode
(self, preset_mode)
Set preset mode.
Set preset mode.
async def async_set_preset_mode(self, preset_mode): """Set preset mode.""" _LOGGER.debug("Setting preset mode to: %s", preset_mode) if preset_mode == PRESET_NONE: # restore previous hvac mode self._hvac_mode = self._store_hvac_mode else: # Store hvac m...
[ "async", "def", "async_set_preset_mode", "(", "self", ",", "preset_mode", ")", ":", "_LOGGER", ".", "debug", "(", "\"Setting preset mode to: %s\"", ",", "preset_mode", ")", "if", "preset_mode", "==", "PRESET_NONE", ":", "# restore previous hvac mode", "self", ".", "...
[ 161, 4 ]
[ 170, 62 ]
python
de
['de', 'pt', 'it']
False
BSBLanClimate.async_set_hvac_mode
(self, hvac_mode)
Set HVAC mode.
Set HVAC mode.
async def async_set_hvac_mode(self, hvac_mode): """Set HVAC mode.""" _LOGGER.debug("Setting HVAC mode to: %s", hvac_mode) # preset should be none when hvac mode is set self._preset_mode = PRESET_NONE await self.async_set_data(hvac_mode=hvac_mode)
[ "async", "def", "async_set_hvac_mode", "(", "self", ",", "hvac_mode", ")", ":", "_LOGGER", ".", "debug", "(", "\"Setting HVAC mode to: %s\"", ",", "hvac_mode", ")", "# preset should be none when hvac mode is set", "self", ".", "_preset_mode", "=", "PRESET_NONE", "await"...
[ 172, 4 ]
[ 177, 54 ]
python
en
['en', 'pt', 'en']
True
BSBLanClimate.async_set_temperature
(self, **kwargs)
Set new target temperatures.
Set new target temperatures.
async def async_set_temperature(self, **kwargs): """Set new target temperatures.""" await self.async_set_data(**kwargs)
[ "async", "def", "async_set_temperature", "(", "self", ",", "*", "*", "kwargs", ")", ":", "await", "self", ".", "async_set_data", "(", "*", "*", "kwargs", ")" ]
[ 179, 4 ]
[ 181, 43 ]
python
en
['en', 'ca', 'en']
True
BSBLanClimate.async_set_data
(self, **kwargs: Any)
Set device settings using BSBLan.
Set device settings using BSBLan.
async def async_set_data(self, **kwargs: Any) -> None: """Set device settings using BSBLan.""" data = {} if ATTR_TEMPERATURE in kwargs: data[ATTR_TARGET_TEMPERATURE] = kwargs[ATTR_TEMPERATURE] _LOGGER.debug("Set temperature data = %s", data) if ATTR_HVAC_MODE in...
[ "async", "def", "async_set_data", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "None", ":", "data", "=", "{", "}", "if", "ATTR_TEMPERATURE", "in", "kwargs", ":", "data", "[", "ATTR_TARGET_TEMPERATURE", "]", "=", "kwargs", "[", "ATTR_TEMPE...
[ 183, 4 ]
[ 203, 35 ]
python
en
['fr', 'en', 'en']
True
BSBLanClimate.async_update
(self)
Update BSBlan entity.
Update BSBlan entity.
async def async_update(self) -> None: """Update BSBlan entity.""" try: state: State = await self.bsblan.state() except BSBLanError: if self._available: _LOGGER.error("An error occurred while updating the BSBLan device") self._available = False ...
[ "async", "def", "async_update", "(", "self", ")", "->", "None", ":", "try", ":", "state", ":", "State", "=", "await", "self", ".", "bsblan", ".", "state", "(", ")", "except", "BSBLanError", ":", "if", "self", ".", "_available", ":", "_LOGGER", ".", "...
[ 205, 4 ]
[ 228, 63 ]
python
af
['nl', 'af', 'en']
False
BSBLanClimate.device_info
(self)
Return device information about this BSBLan device.
Return device information about this BSBLan device.
def device_info(self) -> Dict[str, Any]: """Return device information about this BSBLan device.""" return { ATTR_IDENTIFIERS: {(DOMAIN, self._info.device_identification)}, ATTR_NAME: "BSBLan Device", ATTR_MANUFACTURER: "BSBLan", ATTR_MODEL: self._info.cont...
[ "def", "device_info", "(", "self", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "ATTR_IDENTIFIERS", ":", "{", "(", "DOMAIN", ",", "self", ".", "_info", ".", "device_identification", ")", "}", ",", "ATTR_NAME", ":", "\"BSBLan Device...
[ 231, 4 ]
[ 238, 9 ]
python
en
['en', 'en', 'en']
True
problem2_7
()
computes area of triangle using Heron's formula.
computes area of triangle using Heron's formula.
def problem2_7(): """ computes area of triangle using Heron's formula. """ a = float(input('Enter length of side one: ')) b = float(input('Enter length of side two: ')) c = float(input('Enter length of side three: ')) s = .5*(a+b+c) area = (s*(s-a)*(s-b)*(s-c)) ** .5 print('Area of a triangl...
[ "def", "problem2_7", "(", ")", ":", "a", "=", "float", "(", "input", "(", "'Enter length of side one: '", ")", ")", "b", "=", "float", "(", "input", "(", "'Enter length of side two: '", ")", ")", "c", "=", "float", "(", "input", "(", "'Enter length of side t...
[ 22, 0 ]
[ 29, 79 ]
python
en
['en', 'sm', 'en']
True
async_setup_platform
( hass: HomeAssistantType, config, async_add_entities, discovery_info=None )
Old way of setting up UPnP/IGD sensors.
Old way of setting up UPnP/IGD sensors.
async def async_setup_platform( hass: HomeAssistantType, config, async_add_entities, discovery_info=None ) -> None: """Old way of setting up UPnP/IGD sensors.""" _LOGGER.debug( "async_setup_platform: config: %s, discovery: %s", config, discovery_info )
[ "async", "def", "async_setup_platform", "(", "hass", ":", "HomeAssistantType", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", "->", "None", ":", "_LOGGER", ".", "debug", "(", "\"async_setup_platform: config: %s, discovery: %s\"", ",...
[ 72, 0 ]
[ 78, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass, config_entry: ConfigEntry, async_add_entities )
Set up the UPnP/IGD sensors.
Set up the UPnP/IGD sensors.
async def async_setup_entry( hass, config_entry: ConfigEntry, async_add_entities ) -> None: """Set up the UPnP/IGD sensors.""" data = config_entry.data if CONFIG_ENTRY_UDN in data: udn = data[CONFIG_ENTRY_UDN] else: # any device will do udn = list(hass.data[DOMAIN][DOMAIN_DEV...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ":", "ConfigEntry", ",", "async_add_entities", ")", "->", "None", ":", "data", "=", "config_entry", ".", "data", "if", "CONFIG_ENTRY_UDN", "in", "data", ":", "udn", "=", "data", "[", "CON...
[ 81, 0 ]
[ 120, 37 ]
python
en
['en', 'bg', 'en']
True
UpnpSensor.__init__
( self, coordinator: DataUpdateCoordinator[Mapping[str, Any]], device: Device, sensor_type: Mapping[str, str], update_multiplier: int = 2, )
Initialize the base sensor.
Initialize the base sensor.
def __init__( self, coordinator: DataUpdateCoordinator[Mapping[str, Any]], device: Device, sensor_type: Mapping[str, str], update_multiplier: int = 2, ) -> None: """Initialize the base sensor.""" super().__init__(coordinator) self._device = device ...
[ "def", "__init__", "(", "self", ",", "coordinator", ":", "DataUpdateCoordinator", "[", "Mapping", "[", "str", ",", "Any", "]", "]", ",", "device", ":", "Device", ",", "sensor_type", ":", "Mapping", "[", "str", ",", "str", "]", ",", "update_multiplier", "...
[ 126, 4 ]
[ 138, 32 ]
python
en
['en', 'zu', 'en']
True
UpnpSensor.icon
(self)
Icon to use in the frontend, if any.
Icon to use in the frontend, if any.
def icon(self) -> str: """Icon to use in the frontend, if any.""" return "mdi:server-network"
[ "def", "icon", "(", "self", ")", "->", "str", ":", "return", "\"mdi:server-network\"" ]
[ 141, 4 ]
[ 143, 35 ]
python
en
['en', 'en', 'en']
True
UpnpSensor.available
(self)
Return if entity is available.
Return if entity is available.
def available(self) -> bool: """Return if entity is available.""" device_value_key = self._sensor_type["device_value_key"] return ( self.coordinator.last_update_success and device_value_key in self.coordinator.data )
[ "def", "available", "(", "self", ")", "->", "bool", ":", "device_value_key", "=", "self", ".", "_sensor_type", "[", "\"device_value_key\"", "]", "return", "(", "self", ".", "coordinator", ".", "last_update_success", "and", "device_value_key", "in", "self", ".", ...
[ 146, 4 ]
[ 152, 9 ]
python
en
['en', 'en', 'en']
True
UpnpSensor.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 f"{self._device.name} {self._sensor_type['name']}"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.name} {self._sensor_type['name']}\"" ]
[ 155, 4 ]
[ 157, 65 ]
python
en
['en', 'mi', 'en']
True
UpnpSensor.unique_id
(self)
Return an unique ID.
Return an unique ID.
def unique_id(self) -> str: """Return an unique ID.""" return f"{self._device.udn}_{self._sensor_type['unique_id']}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.udn}_{self._sensor_type['unique_id']}\"" ]
[ 160, 4 ]
[ 162, 69 ]
python
fr
['fr', 'fr', 'en']
True
UpnpSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self) -> str: """Return the unit of measurement of this entity, if any.""" return self._sensor_type["unit"]
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_sensor_type", "[", "\"unit\"", "]" ]
[ 165, 4 ]
[ 167, 40 ]
python
en
['en', 'en', 'en']
True
UpnpSensor.device_info
(self)
Get device info.
Get device info.
def device_info(self) -> Mapping[str, Any]: """Get device info.""" return { "connections": {(dr.CONNECTION_UPNP, self._device.udn)}, "name": self._device.name, "manufacturer": self._device.manufacturer, "model": self._device.model_name, }
[ "def", "device_info", "(", "self", ")", "->", "Mapping", "[", "str", ",", "Any", "]", ":", "return", "{", "\"connections\"", ":", "{", "(", "dr", ".", "CONNECTION_UPNP", ",", "self", ".", "_device", ".", "udn", ")", "}", ",", "\"name\"", ":", "self",...
[ 170, 4 ]
[ 177, 9 ]
python
en
['fr', 'en', 'en']
True
RawUpnpSensor.state
(self)
Return the state of the device.
Return the state of the device.
def state(self) -> str: """Return the state of the device.""" device_value_key = self._sensor_type["device_value_key"] value = self.coordinator.data[device_value_key] if value is None: return None return format(value, "d")
[ "def", "state", "(", "self", ")", "->", "str", ":", "device_value_key", "=", "self", ".", "_sensor_type", "[", "\"device_value_key\"", "]", "value", "=", "self", ".", "coordinator", ".", "data", "[", "device_value_key", "]", "if", "value", "is", "None", ":...
[ 184, 4 ]
[ 190, 33 ]
python
en
['en', 'en', 'en']
True
DerivedUpnpSensor.__init__
(self, coordinator, device, sensor_type)
Initialize sensor.
Initialize sensor.
def __init__(self, coordinator, device, sensor_type) -> None: """Initialize sensor.""" super().__init__(coordinator, device, sensor_type) self._last_value = None self._last_timestamp = None
[ "def", "__init__", "(", "self", ",", "coordinator", ",", "device", ",", "sensor_type", ")", "->", "None", ":", "super", "(", ")", ".", "__init__", "(", "coordinator", ",", "device", ",", "sensor_type", ")", "self", ".", "_last_value", "=", "None", "self"...
[ 196, 4 ]
[ 200, 35 ]
python
en
['en', 'ro', 'it']
False
DerivedUpnpSensor.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 f"{self._device.name} {self._sensor_type['derived_name']}"
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.name} {self._sensor_type['derived_name']}\"" ]
[ 203, 4 ]
[ 205, 73 ]
python
en
['en', 'mi', 'en']
True
DerivedUpnpSensor.unique_id
(self)
Return an unique ID.
Return an unique ID.
def unique_id(self) -> str: """Return an unique ID.""" return f"{self._device.udn}_{self._sensor_type['derived_unique_id']}"
[ "def", "unique_id", "(", "self", ")", "->", "str", ":", "return", "f\"{self._device.udn}_{self._sensor_type['derived_unique_id']}\"" ]
[ 208, 4 ]
[ 210, 77 ]
python
fr
['fr', 'fr', 'en']
True
DerivedUpnpSensor.unit_of_measurement
(self)
Return the unit of measurement of this entity, if any.
Return the unit of measurement of this entity, if any.
def unit_of_measurement(self) -> str: """Return the unit of measurement of this entity, if any.""" return self._sensor_type["derived_unit"]
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_sensor_type", "[", "\"derived_unit\"", "]" ]
[ 213, 4 ]
[ 215, 48 ]
python
en
['en', 'en', 'en']
True
DerivedUpnpSensor._has_overflowed
(self, current_value)
Check if value has overflowed.
Check if value has overflowed.
def _has_overflowed(self, current_value) -> bool: """Check if value has overflowed.""" return current_value < self._last_value
[ "def", "_has_overflowed", "(", "self", ",", "current_value", ")", "->", "bool", ":", "return", "current_value", "<", "self", ".", "_last_value" ]
[ 217, 4 ]
[ 219, 47 ]
python
en
['en', 'en', 'en']
True
DerivedUpnpSensor.state
(self)
Return the state of the device.
Return the state of the device.
def state(self) -> str: """Return the state of the device.""" # Can't calculate any derivative if we have only one value. device_value_key = self._sensor_type["device_value_key"] current_value = self.coordinator.data[device_value_key] if current_value is None: return ...
[ "def", "state", "(", "self", ")", "->", "str", ":", "# Can't calculate any derivative if we have only one value.", "device_value_key", "=", "self", ".", "_sensor_type", "[", "\"device_value_key\"", "]", "current_value", "=", "self", ".", "coordinator", ".", "data", "[...
[ 222, 4 ]
[ 249, 37 ]
python
en
['en', 'en', 'en']
True
turn_on
( hass, entity_id=ENTITY_MATCH_ALL, transition=None, brightness=None, brightness_pct=None, rgb_color=None, xy_color=None, hs_color=None, color_temp=None, kelvin=None, white_value=None, profile=None, flash=None, effect=None, color_name=None, )
Turn all or specified light on.
Turn all or specified light on.
def turn_on( hass, entity_id=ENTITY_MATCH_ALL, transition=None, brightness=None, brightness_pct=None, rgb_color=None, xy_color=None, hs_color=None, color_temp=None, kelvin=None, white_value=None, profile=None, flash=None, effect=None, color_name=None, ): "...
[ "def", "turn_on", "(", "hass", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ",", "transition", "=", "None", ",", "brightness", "=", "None", ",", "brightness_pct", "=", "None", ",", "rgb_color", "=", "None", ",", "xy_color", "=", "None", ",", "hs_color", "=",...
[ 32, 0 ]
[ 67, 5 ]
python
en
['en', 'en', 'en']
True
async_turn_on
( hass, entity_id=ENTITY_MATCH_ALL, transition=None, brightness=None, brightness_pct=None, rgb_color=None, xy_color=None, hs_color=None, color_temp=None, kelvin=None, white_value=None, profile=None, flash=None, effect=None, color_name=None, )
Turn all or specified light on.
Turn all or specified light on.
async def async_turn_on( hass, entity_id=ENTITY_MATCH_ALL, transition=None, brightness=None, brightness_pct=None, rgb_color=None, xy_color=None, hs_color=None, color_temp=None, kelvin=None, white_value=None, profile=None, flash=None, effect=None, color_name=No...
[ "async", "def", "async_turn_on", "(", "hass", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ",", "transition", "=", "None", ",", "brightness", "=", "None", ",", "brightness_pct", "=", "None", ",", "rgb_color", "=", "None", ",", "xy_color", "=", "None", ",", "...
[ 70, 0 ]
[ 109, 80 ]
python
en
['en', 'en', 'en']
True
turn_off
(hass, entity_id=ENTITY_MATCH_ALL, transition=None)
Turn all or specified light off.
Turn all or specified light off.
def turn_off(hass, entity_id=ENTITY_MATCH_ALL, transition=None): """Turn all or specified light off.""" hass.add_job(async_turn_off, hass, entity_id, transition)
[ "def", "turn_off", "(", "hass", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ",", "transition", "=", "None", ")", ":", "hass", ".", "add_job", "(", "async_turn_off", ",", "hass", ",", "entity_id", ",", "transition", ")" ]
[ 113, 0 ]
[ 115, 61 ]
python
en
['en', 'en', 'en']
True
async_turn_off
(hass, entity_id=ENTITY_MATCH_ALL, transition=None)
Turn all or specified light off.
Turn all or specified light off.
async def async_turn_off(hass, entity_id=ENTITY_MATCH_ALL, transition=None): """Turn all or specified light off.""" data = { key: value for key, value in [(ATTR_ENTITY_ID, entity_id), (ATTR_TRANSITION, transition)] if value is not None } await hass.services.async_call(DOMAIN, SE...
[ "async", "def", "async_turn_off", "(", "hass", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ",", "transition", "=", "None", ")", ":", "data", "=", "{", "key", ":", "value", "for", "key", ",", "value", "in", "[", "(", "ATTR_ENTITY_ID", ",", "entity_id", ")"...
[ 118, 0 ]
[ 126, 81 ]
python
en
['en', 'en', 'en']
True
toggle
( hass, entity_id=ENTITY_MATCH_ALL, transition=None, brightness=None, brightness_pct=None, rgb_color=None, xy_color=None, hs_color=None, color_temp=None, kelvin=None, white_value=None, profile=None, flash=None, effect=None, color_name=None, )
Toggle all or specified light.
Toggle all or specified light.
def toggle( hass, entity_id=ENTITY_MATCH_ALL, transition=None, brightness=None, brightness_pct=None, rgb_color=None, xy_color=None, hs_color=None, color_temp=None, kelvin=None, white_value=None, profile=None, flash=None, effect=None, color_name=None, ): ""...
[ "def", "toggle", "(", "hass", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ",", "transition", "=", "None", ",", "brightness", "=", "None", ",", "brightness_pct", "=", "None", ",", "rgb_color", "=", "None", ",", "xy_color", "=", "None", ",", "hs_color", "=", ...
[ 130, 0 ]
[ 165, 5 ]
python
en
['en', 'en', 'en']
True
async_toggle
( hass, entity_id=ENTITY_MATCH_ALL, transition=None, brightness=None, brightness_pct=None, rgb_color=None, xy_color=None, hs_color=None, color_temp=None, kelvin=None, white_value=None, profile=None, flash=None, effect=None, color_name=None, )
Turn all or specified light on.
Turn all or specified light on.
async def async_toggle( hass, entity_id=ENTITY_MATCH_ALL, transition=None, brightness=None, brightness_pct=None, rgb_color=None, xy_color=None, hs_color=None, color_temp=None, kelvin=None, white_value=None, profile=None, flash=None, effect=None, color_name=Non...
[ "async", "def", "async_toggle", "(", "hass", ",", "entity_id", "=", "ENTITY_MATCH_ALL", ",", "transition", "=", "None", ",", "brightness", "=", "None", ",", "brightness_pct", "=", "None", ",", "rgb_color", "=", "None", ",", "xy_color", "=", "None", ",", "h...
[ 168, 0 ]
[ 207, 79 ]
python
en
['en', 'en', 'en']
True
BaseTransformer.__init__
( self, hparams: argparse.Namespace, num_labels=None, mode="base", config=None, tokenizer=None, model=None, **config_kwargs )
Initialize a model, tokenizer and config.
Initialize a model, tokenizer and config.
def __init__( self, hparams: argparse.Namespace, num_labels=None, mode="base", config=None, tokenizer=None, model=None, **config_kwargs ): """Initialize a model, tokenizer and config.""" super().__init__() # TODO: move to self.s...
[ "def", "__init__", "(", "self", ",", "hparams", ":", "argparse", ".", "Namespace", ",", "num_labels", "=", "None", ",", "mode", "=", "\"base\"", ",", "config", "=", "None", ",", "tokenizer", "=", "None", ",", "model", "=", "None", ",", "*", "*", "con...
[ 63, 4 ]
[ 115, 30 ]
python
en
['en', 'en', 'en']
True
BaseTransformer.configure_optimizers
(self)
Prepare optimizer and schedule (linear warmup and decay)
Prepare optimizer and schedule (linear warmup and decay)
def configure_optimizers(self): """Prepare optimizer and schedule (linear warmup and decay)""" model = self.model no_decay = ["bias", "LayerNorm.weight"] optimizer_grouped_parameters = [ { "params": [p for n, p in model.named_parameters() if not any(nd in n fo...
[ "def", "configure_optimizers", "(", "self", ")", ":", "model", "=", "self", ".", "model", "no_decay", "=", "[", "\"bias\"", ",", "\"LayerNorm.weight\"", "]", "optimizer_grouped_parameters", "=", "[", "{", "\"params\"", ":", "[", "p", "for", "n", ",", "p", ...
[ 128, 4 ]
[ 155, 39 ]
python
en
['en', 'en', 'en']
True
BaseTransformer.total_steps
(self)
The number of total training steps that will be run. Used for lr scheduler purposes.
The number of total training steps that will be run. Used for lr scheduler purposes.
def total_steps(self) -> int: """The number of total training steps that will be run. Used for lr scheduler purposes.""" num_devices = max(1, self.hparams.gpus) # TODO: consider num_tpu_cores effective_batch_size = self.hparams.train_batch_size * self.hparams.accumulate_grad_batches * num_devic...
[ "def", "total_steps", "(", "self", ")", "->", "int", ":", "num_devices", "=", "max", "(", "1", ",", "self", ".", "hparams", ".", "gpus", ")", "# TODO: consider num_tpu_cores", "effective_batch_size", "=", "self", ".", "hparams", ".", "train_batch_size", "*", ...
[ 163, 4 ]
[ 167, 83 ]
python
en
['en', 'en', 'en']
True
async_handle_message
(hass, config, user_id, message, source)
Handle incoming API messages.
Handle incoming API messages.
async def async_handle_message(hass, config, user_id, message, source): """Handle incoming API messages.""" data = RequestData( config, user_id, source, message["requestId"], message.get("devices") ) response = await _process(hass, data, message) if response and "errorCode" in response["pa...
[ "async", "def", "async_handle_message", "(", "hass", ",", "config", ",", "user_id", ",", "message", ",", "source", ")", ":", "data", "=", "RequestData", "(", "config", ",", "user_id", ",", "source", ",", "message", "[", "\"requestId\"", "]", ",", "message"...
[ 23, 0 ]
[ 34, 19 ]
python
en
['en', 'en', 'en']
True
_process
(hass, data, message)
Process a message.
Process a message.
async def _process(hass, data, message): """Process a message.""" inputs: list = message.get("inputs") if len(inputs) != 1: return { "requestId": data.request_id, "payload": {"errorCode": ERR_PROTOCOL_ERROR}, } handler = HANDLERS.get(inputs[0].get("intent")) ...
[ "async", "def", "_process", "(", "hass", ",", "data", ",", "message", ")", ":", "inputs", ":", "list", "=", "message", ".", "get", "(", "\"inputs\"", ")", "if", "len", "(", "inputs", ")", "!=", "1", ":", "return", "{", "\"requestId\"", ":", "data", ...
[ 37, 0 ]
[ 69, 60 ]
python
en
['en', 'mk', 'en']
True
async_devices_sync
(hass, data, payload)
Handle action.devices.SYNC request. https://developers.google.com/assistant/smarthome/develop/process-intents#SYNC
Handle action.devices.SYNC request.
async def async_devices_sync(hass, data, payload): """Handle action.devices.SYNC request. https://developers.google.com/assistant/smarthome/develop/process-intents#SYNC """ hass.bus.async_fire( EVENT_SYNC_RECEIVED, {"request_id": data.request_id, "source": data.source}, context=...
[ "async", "def", "async_devices_sync", "(", "hass", ",", "data", ",", "payload", ")", ":", "hass", ".", "bus", ".", "async_fire", "(", "EVENT_SYNC_RECEIVED", ",", "{", "\"request_id\"", ":", "data", ".", "request_id", ",", "\"source\"", ":", "data", ".", "s...
[ 73, 0 ]
[ 109, 19 ]
python
en
['en', 'en', 'en']
True
async_devices_query
(hass, data, payload)
Handle action.devices.QUERY request. https://developers.google.com/assistant/smarthome/develop/process-intents#QUERY
Handle action.devices.QUERY request.
async def async_devices_query(hass, data, payload): """Handle action.devices.QUERY request. https://developers.google.com/assistant/smarthome/develop/process-intents#QUERY """ devices = {} for device in payload.get("devices", []): devid = device["id"] state = hass.states.get(devid) ...
[ "async", "def", "async_devices_query", "(", "hass", ",", "data", ",", "payload", ")", ":", "devices", "=", "{", "}", "for", "device", "in", "payload", ".", "get", "(", "\"devices\"", ",", "[", "]", ")", ":", "devid", "=", "device", "[", "\"id\"", "]"...
[ 113, 0 ]
[ 145, 31 ]
python
en
['en', 'en', 'en']
True
_entity_execute
(entity, data, executions)
Execute all commands for an entity. Returns a dict if a special result needs to be set.
Execute all commands for an entity.
async def _entity_execute(entity, data, executions): """Execute all commands for an entity. Returns a dict if a special result needs to be set. """ for execution in executions: try: await entity.execute(data, execution) except SmartHomeError as err: return { ...
[ "async", "def", "_entity_execute", "(", "entity", ",", "data", ",", "executions", ")", ":", "for", "execution", "in", "executions", ":", "try", ":", "await", "entity", ".", "execute", "(", "data", ",", "execution", ")", "except", "SmartHomeError", "as", "e...
[ 148, 0 ]
[ 163, 15 ]
python
en
['en', 'en', 'en']
True
handle_devices_execute
(hass, data, payload)
Handle action.devices.EXECUTE request. https://developers.google.com/assistant/smarthome/develop/process-intents#EXECUTE
Handle action.devices.EXECUTE request.
async def handle_devices_execute(hass, data, payload): """Handle action.devices.EXECUTE request. https://developers.google.com/assistant/smarthome/develop/process-intents#EXECUTE """ entities = {} executions = {} results = {} for command in payload["commands"]: for device, executio...
[ "async", "def", "handle_devices_execute", "(", "hass", ",", "data", ",", "payload", ")", ":", "entities", "=", "{", "}", "executions", "=", "{", "}", "results", "=", "{", "}", "for", "command", "in", "payload", "[", "\"commands\"", "]", ":", "for", "de...
[ 167, 0 ]
[ 239, 38 ]
python
en
['en', 'en', 'en']
True
async_devices_disconnect
(hass, data: RequestData, payload)
Handle action.devices.DISCONNECT request. https://developers.google.com/assistant/smarthome/develop/process-intents#DISCONNECT
Handle action.devices.DISCONNECT request.
async def async_devices_disconnect(hass, data: RequestData, payload): """Handle action.devices.DISCONNECT request. https://developers.google.com/assistant/smarthome/develop/process-intents#DISCONNECT """ await data.config.async_disconnect_agent_user(data.context.user_id) return None
[ "async", "def", "async_devices_disconnect", "(", "hass", ",", "data", ":", "RequestData", ",", "payload", ")", ":", "await", "data", ".", "config", ".", "async_disconnect_agent_user", "(", "data", ".", "context", ".", "user_id", ")", "return", "None" ]
[ 243, 0 ]
[ 249, 15 ]
python
en
['en', 'en', 'en']
True
async_devices_identify
(hass, data: RequestData, payload)
Handle action.devices.IDENTIFY request. https://developers.google.com/assistant/smarthome/develop/local#implement_the_identify_handler
Handle action.devices.IDENTIFY request.
async def async_devices_identify(hass, data: RequestData, payload): """Handle action.devices.IDENTIFY request. https://developers.google.com/assistant/smarthome/develop/local#implement_the_identify_handler """ return { "device": { "id": data.config.get_agent_user_id(data.context), ...
[ "async", "def", "async_devices_identify", "(", "hass", ",", "data", ":", "RequestData", ",", "payload", ")", ":", "return", "{", "\"device\"", ":", "{", "\"id\"", ":", "data", ".", "config", ".", "get_agent_user_id", "(", "data", ".", "context", ")", ",", ...
[ 253, 0 ]
[ 270, 5 ]
python
en
['en', 'en', 'en']
True
async_devices_reachable
(hass, data: RequestData, payload)
Handle action.devices.REACHABLE_DEVICES request. https://developers.google.com/actions/smarthome/create#actiondevicesdisconnect
Handle action.devices.REACHABLE_DEVICES request.
async def async_devices_reachable(hass, data: RequestData, payload): """Handle action.devices.REACHABLE_DEVICES request. https://developers.google.com/actions/smarthome/create#actiondevicesdisconnect """ google_ids = {dev["id"] for dev in (data.devices or [])} return { "devices": [ ...
[ "async", "def", "async_devices_reachable", "(", "hass", ",", "data", ":", "RequestData", ",", "payload", ")", ":", "google_ids", "=", "{", "dev", "[", "\"id\"", "]", "for", "dev", "in", "(", "data", ".", "devices", "or", "[", "]", ")", "}", "return", ...
[ 274, 0 ]
[ 287, 5 ]
python
en
['en', 'en', 'en']
True
turned_off_response
(message)
Return a device turned off response.
Return a device turned off response.
def turned_off_response(message): """Return a device turned off response.""" return { "requestId": message.get("requestId"), "payload": {"errorCode": "deviceTurnedOff"}, }
[ "def", "turned_off_response", "(", "message", ")", ":", "return", "{", "\"requestId\"", ":", "message", ".", "get", "(", "\"requestId\"", ")", ",", "\"payload\"", ":", "{", "\"errorCode\"", ":", "\"deviceTurnedOff\"", "}", ",", "}" ]
[ 290, 0 ]
[ 295, 5 ]
python
en
['en', 'en', 'en']
True
async_setup_platform
(hass, config, async_add_entities, discovery_info=None)
Set up the HTU21D sensor.
Set up the HTU21D sensor.
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): """Set up the HTU21D sensor.""" name = config.get(CONF_NAME) bus_number = config.get(CONF_I2C_BUS) temp_unit = hass.config.units.temperature_unit bus = smbus.SMBus(config.get(CONF_I2C_BUS)) sensor = await has...
[ "async", "def", "async_setup_platform", "(", "hass", ",", "config", ",", "async_add_entities", ",", "discovery_info", "=", "None", ")", ":", "name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "bus_number", "=", "config", ".", "get", "(", "CONF_I2C_BUS...
[ 36, 0 ]
[ 55, 27 ]
python
en
['en', 'ca', 'en']
True
HTU21DHandler.__init__
(self, sensor)
Initialize the sensor handler.
Initialize the sensor handler.
def __init__(self, sensor): """Initialize the sensor handler.""" self.sensor = sensor self.sensor.update()
[ "def", "__init__", "(", "self", ",", "sensor", ")", ":", "self", ".", "sensor", "=", "sensor", "self", ".", "sensor", ".", "update", "(", ")" ]
[ 61, 4 ]
[ 64, 28 ]
python
en
['en', 'pt', 'en']
True
HTU21DHandler.update
(self)
Read raw data and calculate temperature and humidity.
Read raw data and calculate temperature and humidity.
def update(self): """Read raw data and calculate temperature and humidity.""" self.sensor.update()
[ "def", "update", "(", "self", ")", ":", "self", ".", "sensor", ".", "update", "(", ")" ]
[ 67, 4 ]
[ 69, 28 ]
python
en
['en', 'en', 'en']
True
HTU21DSensor.__init__
(self, htu21d_client, name, variable, unit)
Initialize the sensor.
Initialize the sensor.
def __init__(self, htu21d_client, name, variable, unit): """Initialize the sensor.""" self._name = f"{name}_{variable}" self._variable = variable self._unit_of_measurement = unit self._client = htu21d_client self._state = None
[ "def", "__init__", "(", "self", ",", "htu21d_client", ",", "name", ",", "variable", ",", "unit", ")", ":", "self", ".", "_name", "=", "f\"{name}_{variable}\"", "self", ".", "_variable", "=", "variable", "self", ".", "_unit_of_measurement", "=", "unit", "self...
[ 75, 4 ]
[ 81, 26 ]
python
en
['en', 'en', 'en']
True
HTU21DSensor.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._name
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_name" ]
[ 84, 4 ]
[ 86, 25 ]
python
en
['en', 'mi', 'en']
True
HTU21DSensor.state
(self)
Return the state of the sensor.
Return the state of the sensor.
def state(self) -> int: """Return the state of the sensor.""" return self._state
[ "def", "state", "(", "self", ")", "->", "int", ":", "return", "self", ".", "_state" ]
[ 89, 4 ]
[ 91, 26 ]
python
en
['en', 'en', 'en']
True
HTU21DSensor.unit_of_measurement
(self)
Return the unit of measurement of the sensor.
Return the unit of measurement of the sensor.
def unit_of_measurement(self) -> str: """Return the unit of measurement of the sensor.""" return self._unit_of_measurement
[ "def", "unit_of_measurement", "(", "self", ")", "->", "str", ":", "return", "self", ".", "_unit_of_measurement" ]
[ 94, 4 ]
[ 96, 40 ]
python
en
['en', 'bg', 'en']
True
HTU21DSensor.async_update
(self)
Get the latest data from the HTU21D sensor and update the state.
Get the latest data from the HTU21D sensor and update the state.
async def async_update(self): """Get the latest data from the HTU21D sensor and update the state.""" await self.hass.async_add_executor_job(self._client.update) if self._client.sensor.sample_ok: if self._variable == SENSOR_TEMPERATURE: value = round(self._client.senso...
[ "async", "def", "async_update", "(", "self", ")", ":", "await", "self", ".", "hass", ".", "async_add_executor_job", "(", "self", ".", "_client", ".", "update", ")", "if", "self", ".", "_client", ".", "sensor", ".", "sample_ok", ":", "if", "self", ".", ...
[ 98, 4 ]
[ 110, 41 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
( hass: HomeAssistant, config_entry: config_entries.ConfigEntry, async_add_entities )
Set up the electricity price sensor from config_entry.
Set up the electricity price sensor from config_entry.
async def async_setup_entry( hass: HomeAssistant, config_entry: config_entries.ConfigEntry, async_add_entities ): """Set up the electricity price sensor from config_entry.""" name = config_entry.data[CONF_NAME] pvpc_data_handler = PVPCData( tariff=config_entry.data[ATTR_TARIFF], local_ti...
[ "async", "def", "async_setup_entry", "(", "hass", ":", "HomeAssistant", ",", "config_entry", ":", "config_entries", ".", "ConfigEntry", ",", "async_add_entities", ")", ":", "name", "=", "config_entry", ".", "data", "[", "CONF_NAME", "]", "pvpc_data_handler", "=", ...
[ 26, 0 ]
[ 40, 5 ]
python
en
['en', 'en', 'en']
True
ElecPriceSensor.__init__
(self, name, unique_id, pvpc_data_handler)
Initialize the sensor object.
Initialize the sensor object.
def __init__(self, name, unique_id, pvpc_data_handler): """Initialize the sensor object.""" self._name = name self._unique_id = unique_id self._pvpc_data = pvpc_data_handler self._num_retries = 0 self._hourly_tracker = None self._price_tracker = None
[ "def", "__init__", "(", "self", ",", "name", ",", "unique_id", ",", "pvpc_data_handler", ")", ":", "self", ".", "_name", "=", "name", "self", ".", "_unique_id", "=", "unique_id", "self", ".", "_pvpc_data", "=", "pvpc_data_handler", "self", ".", "_num_retries...
[ 50, 4 ]
[ 58, 34 ]
python
en
['en', 'en', 'en']
True
ElecPriceSensor.async_will_remove_from_hass
(self)
Cancel listeners for sensor updates.
Cancel listeners for sensor updates.
async def async_will_remove_from_hass(self) -> None: """Cancel listeners for sensor updates.""" self._hourly_tracker() self._price_tracker()
[ "async", "def", "async_will_remove_from_hass", "(", "self", ")", "->", "None", ":", "self", ".", "_hourly_tracker", "(", ")", "self", ".", "_price_tracker", "(", ")" ]
[ 60, 4 ]
[ 63, 29 ]
python
en
['en', 'bg', 'en']
True