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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
update_quantization_param | (bits, rmin, rmax) |
calculate the `zero_point` and `scale`.
Parameters
----------
bits : int
quantization bits length
rmin : Tensor
min value of real value
rmax : Tensor
max value of real value
Returns
-------
float, float
|
calculate the `zero_point` and `scale`. | def update_quantization_param(bits, rmin, rmax):
"""
calculate the `zero_point` and `scale`.
Parameters
----------
bits : int
quantization bits length
rmin : Tensor
min value of real value
rmax : Tensor
max value of real value
Returns
-------
float, floa... | [
"def",
"update_quantization_param",
"(",
"bits",
",",
"rmin",
",",
"rmax",
")",
":",
"# extend the [min, max] interval to ensure that it contains 0.",
"# Otherwise, we would not meet the requirement that 0 be an exactly",
"# representable value.",
"rmin",
"=",
"torch",
".",
"min",
... | [
64,
0
] | [
103,
35
] | python | en | ['en', 'error', 'th'] | False |
QAT_Quantizer.__init__ | (self, model, config_list, optimizer=None) |
Parameters
----------
layer : LayerInfo
the layer to quantize
config_list : list of dict
list of configurations for quantization
supported keys for dict:
- quant_types : list of string
type of quantization you want ... |
Parameters
----------
layer : LayerInfo
the layer to quantize
config_list : list of dict
list of configurations for quantization
supported keys for dict:
- quant_types : list of string
type of quantization you want ... | def __init__(self, model, config_list, optimizer=None):
"""
Parameters
----------
layer : LayerInfo
the layer to quantize
config_list : list of dict
list of configurations for quantization
supported keys for dict:
- quant_types ... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"config_list",
",",
"optimizer",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"model",
",",
"config_list",
",",
"optimizer",
")",
"self",
".",
"quant_grad",
"=",
"QATGrad",
".",
"app... | [
127,
4
] | [
164,
35
] | python | en | ['en', 'error', 'th'] | False |
QAT_Quantizer._del_simulated_attr | (self, module) |
delete redundant parameters in quantize module
|
delete redundant parameters in quantize module
| def _del_simulated_attr(self, module):
"""
delete redundant parameters in quantize module
"""
del_attr_list = ['old_weight', 'ema_decay', 'tracked_min_activation', 'tracked_max_activation', 'tracked_min_input', \
'tracked_max_input', 'scale', 'zero_point', 'weight_bit', 'activati... | [
"def",
"_del_simulated_attr",
"(",
"self",
",",
"module",
")",
":",
"del_attr_list",
"=",
"[",
"'old_weight'",
",",
"'ema_decay'",
",",
"'tracked_min_activation'",
",",
"'tracked_max_activation'",
",",
"'tracked_min_input'",
",",
"'tracked_max_input'",
",",
"'scale'",
... | [
166,
4
] | [
174,
37
] | python | en | ['en', 'error', 'th'] | False |
QAT_Quantizer.validate_config | (self, model, config_list) |
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
|
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
| def validate_config(self, model, config_list):
"""
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
"""
schema = CompressorSchema([{
Optional('quant_types'): Sche... | [
"def",
"validate_config",
"(",
"self",
",",
"model",
",",
"config_list",
")",
":",
"schema",
"=",
"CompressorSchema",
"(",
"[",
"{",
"Optional",
"(",
"'quant_types'",
")",
":",
"Schema",
"(",
"[",
"lambda",
"x",
":",
"x",
"in",
"[",
"'weight'",
",",
"'... | [
176,
4
] | [
196,
36
] | python | en | ['en', 'error', 'th'] | False |
QAT_Quantizer._quantize | (self, bits, op, real_val) |
quantize real value.
Parameters
----------
bits : int
quantization bits length
op : torch.nn.Module
target module
real_val : Tensor
real value to be quantized
Returns
-------
Tensor
|
quantize real value. | def _quantize(self, bits, op, real_val):
"""
quantize real value.
Parameters
----------
bits : int
quantization bits length
op : torch.nn.Module
target module
real_val : Tensor
real value to be quantized
Returns
... | [
"def",
"_quantize",
"(",
"self",
",",
"bits",
",",
"op",
",",
"real_val",
")",
":",
"op",
".",
"zero_point",
"=",
"op",
".",
"zero_point",
".",
"to",
"(",
"real_val",
".",
"device",
")",
"op",
".",
"scale",
"=",
"op",
".",
"scale",
".",
"to",
"("... | [
198,
4
] | [
222,
28
] | python | en | ['en', 'error', 'th'] | False |
QAT_Quantizer._dequantize | (self, op, quantized_val) |
dequantize quantized value.
Because we simulate quantization in training process, all the computations still happen as float point computations, which means we
first quantize tensors then dequantize them. For more details, please refer to the paper.
Parameters
----------
... |
dequantize quantized value.
Because we simulate quantization in training process, all the computations still happen as float point computations, which means we
first quantize tensors then dequantize them. For more details, please refer to the paper. | def _dequantize(self, op, quantized_val):
"""
dequantize quantized value.
Because we simulate quantization in training process, all the computations still happen as float point computations, which means we
first quantize tensors then dequantize them. For more details, please refer to the... | [
"def",
"_dequantize",
"(",
"self",
",",
"op",
",",
"quantized_val",
")",
":",
"real_val",
"=",
"op",
".",
"scale",
"*",
"(",
"quantized_val",
"-",
"op",
".",
"zero_point",
")",
"return",
"real_val"
] | [
224,
4
] | [
242,
23
] | python | en | ['en', 'error', 'th'] | False |
QAT_Quantizer.export_model | (self, model_path, calibration_path=None, onnx_path=None, input_shape=None, device=None) |
Export quantized model weights and calibration parameters(optional)
Parameters
----------
model_path : str
path to save quantized model weight
calibration_path : str
(optional) path to save quantize parameters after calibration
onnx_path : str
... |
Export quantized model weights and calibration parameters(optional) | def export_model(self, model_path, calibration_path=None, onnx_path=None, input_shape=None, device=None):
"""
Export quantized model weights and calibration parameters(optional)
Parameters
----------
model_path : str
path to save quantized model weight
calibr... | [
"def",
"export_model",
"(",
"self",
",",
"model_path",
",",
"calibration_path",
"=",
"None",
",",
"onnx_path",
"=",
"None",
",",
"input_shape",
"=",
"None",
",",
"device",
"=",
"None",
")",
":",
"assert",
"model_path",
"is",
"not",
"None",
",",
"'model_pat... | [
311,
4
] | [
352,
33
] | python | en | ['en', 'error', 'th'] | False |
QAT_Quantizer.step_with_optimizer | (self) |
override `compressor` `step` method, quantization only happens after certain number of steps
|
override `compressor` `step` method, quantization only happens after certain number of steps
| def step_with_optimizer(self):
"""
override `compressor` `step` method, quantization only happens after certain number of steps
"""
self.bound_model.steps += 1 | [
"def",
"step_with_optimizer",
"(",
"self",
")",
":",
"self",
".",
"bound_model",
".",
"steps",
"+=",
"1"
] | [
358,
4
] | [
362,
35
] | python | en | ['en', 'error', 'th'] | False |
DoReFaQuantizer._del_simulated_attr | (self, module) |
delete redundant parameters in quantize module
|
delete redundant parameters in quantize module
| def _del_simulated_attr(self, module):
"""
delete redundant parameters in quantize module
"""
del_attr_list = ['old_weight', 'weight_bit']
for attr in del_attr_list:
if hasattr(module, attr):
delattr(module, attr) | [
"def",
"_del_simulated_attr",
"(",
"self",
",",
"module",
")",
":",
"del_attr_list",
"=",
"[",
"'old_weight'",
",",
"'weight_bit'",
"]",
"for",
"attr",
"in",
"del_attr_list",
":",
"if",
"hasattr",
"(",
"module",
",",
"attr",
")",
":",
"delattr",
"(",
"modu... | [
380,
4
] | [
387,
37
] | python | en | ['en', 'error', 'th'] | False |
DoReFaQuantizer.validate_config | (self, model, config_list) |
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
|
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
| def validate_config(self, model, config_list):
"""
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
"""
schema = CompressorSchema([{
Optional('quant_types'): Sche... | [
"def",
"validate_config",
"(",
"self",
",",
"model",
",",
"config_list",
")",
":",
"schema",
"=",
"CompressorSchema",
"(",
"[",
"{",
"Optional",
"(",
"'quant_types'",
")",
":",
"Schema",
"(",
"[",
"lambda",
"x",
":",
"x",
"in",
"[",
"'weight'",
"]",
"]... | [
389,
4
] | [
407,
36
] | python | en | ['en', 'error', 'th'] | False |
DoReFaQuantizer.export_model | (self, model_path, calibration_path=None, onnx_path=None, input_shape=None, device=None) |
Export quantized model weights and calibration parameters(optional)
Parameters
----------
model_path : str
path to save quantized model weight
calibration_path : str
(optional) path to save quantize parameters after calibration
onnx_path : str
... |
Export quantized model weights and calibration parameters(optional) | def export_model(self, model_path, calibration_path=None, onnx_path=None, input_shape=None, device=None):
"""
Export quantized model weights and calibration parameters(optional)
Parameters
----------
model_path : str
path to save quantized model weight
calibr... | [
"def",
"export_model",
"(",
"self",
",",
"model_path",
",",
"calibration_path",
"=",
"None",
",",
"onnx_path",
"=",
"None",
",",
"input_shape",
"=",
"None",
",",
"device",
"=",
"None",
")",
":",
"assert",
"model_path",
"is",
"not",
"None",
",",
"'model_pat... | [
426,
4
] | [
460,
33
] | python | en | ['en', 'error', 'th'] | False |
BNNQuantizer._del_simulated_attr | (self, module) |
delete redundant parameters in quantize module
|
delete redundant parameters in quantize module
| def _del_simulated_attr(self, module):
"""
delete redundant parameters in quantize module
"""
del_attr_list = ['old_weight', 'weight_bit']
for attr in del_attr_list:
if hasattr(module, attr):
delattr(module, attr) | [
"def",
"_del_simulated_attr",
"(",
"self",
",",
"module",
")",
":",
"del_attr_list",
"=",
"[",
"'old_weight'",
",",
"'weight_bit'",
"]",
"for",
"attr",
"in",
"del_attr_list",
":",
"if",
"hasattr",
"(",
"module",
",",
"attr",
")",
":",
"delattr",
"(",
"modu... | [
487,
4
] | [
494,
37
] | python | en | ['en', 'error', 'th'] | False |
BNNQuantizer.validate_config | (self, model, config_list) |
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
|
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
| def validate_config(self, model, config_list):
"""
Parameters
----------
model : torch.nn.Module
Model to be pruned
config_list : list of dict
List of configurations
"""
schema = CompressorSchema([{
Optional('quant_types'): Sche... | [
"def",
"validate_config",
"(",
"self",
",",
"model",
",",
"config_list",
")",
":",
"schema",
"=",
"CompressorSchema",
"(",
"[",
"{",
"Optional",
"(",
"'quant_types'",
")",
":",
"Schema",
"(",
"[",
"lambda",
"x",
":",
"x",
"in",
"[",
"'weight'",
",",
"'... | [
496,
4
] | [
515,
36
] | python | en | ['en', 'error', 'th'] | False |
BNNQuantizer.export_model | (self, model_path, calibration_path=None, onnx_path=None, input_shape=None, device=None) |
Export quantized model weights and calibration parameters(optional)
Parameters
----------
model_path : str
path to save quantized model weight
calibration_path : str
(optional) path to save quantize parameters after calibration
onnx_path : str
... |
Export quantized model weights and calibration parameters(optional) | def export_model(self, model_path, calibration_path=None, onnx_path=None, input_shape=None, device=None):
"""
Export quantized model weights and calibration parameters(optional)
Parameters
----------
model_path : str
path to save quantized model weight
calibr... | [
"def",
"export_model",
"(",
"self",
",",
"model_path",
",",
"calibration_path",
"=",
"None",
",",
"onnx_path",
"=",
"None",
",",
"input_shape",
"=",
"None",
",",
"device",
"=",
"None",
")",
":",
"assert",
"model_path",
"is",
"not",
"None",
",",
"'model_pat... | [
532,
4
] | [
566,
33
] | python | en | ['en', 'error', 'th'] | False |
LsqQuantizer.__init__ | (self, model, config_list, optimizer=None) |
Parameters
----------
model : torch.nn.Module
the model to be quantized
config_list : list of dict
list of configurations for quantization
supported keys for dict:
- quant_types : list of string
type of quantization... |
Parameters
----------
model : torch.nn.Module
the model to be quantized
config_list : list of dict
list of configurations for quantization
supported keys for dict:
- quant_types : list of string
type of quantization... | def __init__(self, model, config_list, optimizer=None):
"""
Parameters
----------
model : torch.nn.Module
the model to be quantized
config_list : list of dict
list of configurations for quantization
supported keys for dict:
- qu... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"config_list",
",",
"optimizer",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"model",
",",
"config_list",
",",
"optimizer",
")",
"device",
"=",
"next",
"(",
"model",
".",
"parameter... | [
575,
4
] | [
639,
35
] | python | en | ['en', 'error', 'th'] | False |
LsqQuantizer.grad_scale | (x, scale) |
Used to scale the gradient. Give tensor `x`, we have `y=grad_scale(x, scale)=x` in the forward pass,
which means that this function will not change the value of `x`. In the backward pass, we have:
:math:`\frac{\alpha_L}{\alpha_x}=\frac{\alpha_L}{\alpha_y}*\frac{\alpha_y}{\alpha_x}=... |
Used to scale the gradient. Give tensor `x`, we have `y=grad_scale(x, scale)=x` in the forward pass,
which means that this function will not change the value of `x`. In the backward pass, we have: | def grad_scale(x, scale):
"""
Used to scale the gradient. Give tensor `x`, we have `y=grad_scale(x, scale)=x` in the forward pass,
which means that this function will not change the value of `x`. In the backward pass, we have:
:math:`\frac{\alpha_L}{\alpha_x}=\frac{\alpha_L}... | [
"def",
"grad_scale",
"(",
"x",
",",
"scale",
")",
":",
"y",
"=",
"x",
"y_grad",
"=",
"x",
"*",
"scale",
"return",
"(",
"y",
"-",
"y_grad",
")",
".",
"detach",
"(",
")",
"+",
"y_grad"
] | [
642,
4
] | [
654,
45
] | python | en | ['en', 'error', 'th'] | False |
LsqQuantizer.round_pass | (x) |
A simple way to achieve STE operation.
|
A simple way to achieve STE operation.
| def round_pass(x):
"""
A simple way to achieve STE operation.
"""
y = x.round()
y_grad = x
return (y - y_grad).detach() + y_grad | [
"def",
"round_pass",
"(",
"x",
")",
":",
"y",
"=",
"x",
".",
"round",
"(",
")",
"y_grad",
"=",
"x",
"return",
"(",
"y",
"-",
"y_grad",
")",
".",
"detach",
"(",
")",
"+",
"y_grad"
] | [
657,
4
] | [
663,
45
] | python | en | ['en', 'error', 'th'] | False |
LsqQuantizer.export_model | (self, model_path, calibration_path=None, onnx_path=None, input_shape=None, device=None) |
Export quantized model weights and calibration parameters(optional)
Parameters
----------
model_path : str
path to save quantized model weight
calibration_path : str
(optional) path to save quantize parameters after calibration
onnx_path : str
... |
Export quantized model weights and calibration parameters(optional) | def export_model(self, model_path, calibration_path=None, onnx_path=None, input_shape=None, device=None):
"""
Export quantized model weights and calibration parameters(optional)
Parameters
----------
model_path : str
path to save quantized model weight
calibr... | [
"def",
"export_model",
"(",
"self",
",",
"model_path",
",",
"calibration_path",
"=",
"None",
",",
"onnx_path",
"=",
"None",
",",
"input_shape",
"=",
"None",
",",
"device",
"=",
"None",
")",
":",
"assert",
"model_path",
"is",
"not",
"None",
",",
"'model_pat... | [
711,
4
] | [
755,
33
] | python | en | ['en', 'error', 'th'] | False |
LsqQuantizer._del_simulated_attr | (self, module) |
delete redundant parameters in quantize module
|
delete redundant parameters in quantize module
| def _del_simulated_attr(self, module):
"""
delete redundant parameters in quantize module
"""
del_attr_list = ['old_weight', 'tracked_min_input', 'tracked_max_input', 'tracked_min_activation', \
'tracked_max_activation', 'output_scale', 'input_scale', 'weight_scale','weight_bit',... | [
"def",
"_del_simulated_attr",
"(",
"self",
",",
"module",
")",
":",
"del_attr_list",
"=",
"[",
"'old_weight'",
",",
"'tracked_min_input'",
",",
"'tracked_max_input'",
",",
"'tracked_min_activation'",
",",
"'tracked_max_activation'",
",",
"'output_scale'",
",",
"'input_s... | [
757,
4
] | [
765,
37
] | python | en | ['en', 'error', 'th'] | False |
LsqQuantizer.step_with_optimizer | (self) |
override `compressor` `step` method, quantization only happens after certain number of steps
|
override `compressor` `step` method, quantization only happens after certain number of steps
| def step_with_optimizer(self):
"""
override `compressor` `step` method, quantization only happens after certain number of steps
"""
self.bound_model.steps += 1 | [
"def",
"step_with_optimizer",
"(",
"self",
")",
":",
"self",
".",
"bound_model",
".",
"steps",
"+=",
"1"
] | [
767,
4
] | [
771,
35
] | python | en | ['en', 'error', 'th'] | False |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Steam platform. | Set up the Steam platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Steam platform."""
steam.api.key.set(config.get(CONF_API_KEY))
# Initialize steammods app list before creating sensors
# to benefit from internal caching of the list.
hass.data[APP_LIST_KEY] = steam.apps.app_list()
... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"steam",
".",
"api",
".",
"key",
".",
"set",
"(",
"config",
".",
"get",
"(",
"CONF_API_KEY",
")",
")",
"# Initialize steammods app list be... | [
48,
0
] | [
70,
55
] | python | en | ['en', 'da', 'en'] | True |
SteamSensor.__init__ | (self, account, steamod) | Initialize the sensor. | Initialize the sensor. | def __init__(self, account, steamod):
"""Initialize the sensor."""
self._steamod = steamod
self._account = account
self._profile = None
self._game = None
self._game_id = None
self._extra_game_info = None
self._state = None
self._name = None
... | [
"def",
"__init__",
"(",
"self",
",",
"account",
",",
"steamod",
")",
":",
"self",
".",
"_steamod",
"=",
"steamod",
"self",
".",
"_account",
"=",
"account",
"self",
".",
"_profile",
"=",
"None",
"self",
".",
"_game",
"=",
"None",
"self",
".",
"_game_id"... | [
76,
4
] | [
89,
32
] | python | en | ['en', 'en', 'en'] | True |
SteamSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
92,
4
] | [
94,
25
] | python | en | ['en', 'mi', 'en'] | True |
SteamSensor.entity_id | (self) | Return the entity ID. | Return the entity ID. | def entity_id(self):
"""Return the entity ID."""
return f"sensor.steam_{self._account}" | [
"def",
"entity_id",
"(",
"self",
")",
":",
"return",
"f\"sensor.steam_{self._account}\""
] | [
97,
4
] | [
99,
46
] | python | en | ['en', 'cy', 'en'] | True |
SteamSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
102,
4
] | [
104,
26
] | python | en | ['en', 'en', 'en'] | True |
SteamSensor.should_poll | (self) | Turn off polling, will do ourselves. | Turn off polling, will do ourselves. | def should_poll(self):
"""Turn off polling, will do ourselves."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
107,
4
] | [
109,
20
] | python | en | ['en', 'en', 'en'] | True |
SteamSensor.update | (self) | Update device state. | Update device state. | def update(self):
"""Update device state."""
try:
self._profile = self._steamod.user.profile(self._account)
# Only if need be, get the owned games
if not self._owned_games:
self._owned_games = self._steamod.api.interface(
"IPlayerSe... | [
"def",
"update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_profile",
"=",
"self",
".",
"_steamod",
".",
"user",
".",
"profile",
"(",
"self",
".",
"_account",
")",
"# Only if need be, get the owned games",
"if",
"not",
"self",
".",
"_owned_games",
"... | [
111,
4
] | [
144,
30
] | python | en | ['fr', 'en', 'en'] | True |
SteamSensor._get_current_game | (self) | Gather current game name from APP ID. | Gather current game name from APP ID. | def _get_current_game(self):
"""Gather current game name from APP ID."""
game_id = self._profile.current_game[0]
game_extra_info = self._profile.current_game[2]
if game_extra_info:
return game_extra_info
if not game_id:
return None
app_list = se... | [
"def",
"_get_current_game",
"(",
"self",
")",
":",
"game_id",
"=",
"self",
".",
"_profile",
".",
"current_game",
"[",
"0",
"]",
"game_extra_info",
"=",
"self",
".",
"_profile",
".",
"current_game",
"[",
"2",
"]",
"if",
"game_extra_info",
":",
"return",
"ga... | [
146,
4
] | [
174,
28
] | python | en | ['en', 'en', 'en'] | True |
SteamSensor._get_last_online | (self) | Convert last_online from the steam module into timestamp UTC. | Convert last_online from the steam module into timestamp UTC. | def _get_last_online(self):
"""Convert last_online from the steam module into timestamp UTC."""
last_online = utc_from_timestamp(mktime(self._profile.last_online))
if last_online:
return last_online
return None | [
"def",
"_get_last_online",
"(",
"self",
")",
":",
"last_online",
"=",
"utc_from_timestamp",
"(",
"mktime",
"(",
"self",
".",
"_profile",
".",
"last_online",
")",
")",
"if",
"last_online",
":",
"return",
"last_online",
"return",
"None"
] | [
186,
4
] | [
193,
19
] | python | en | ['en', 'en', 'en'] | True |
SteamSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
attr = {}
if self._game is not None:
attr["game"] = self._game
if self._game_id is not None:
attr["game_id"] = self._game_id
game_url = f"{STEAM_API_URL}{self._game_id}/"
... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"attr",
"=",
"{",
"}",
"if",
"self",
".",
"_game",
"is",
"not",
"None",
":",
"attr",
"[",
"\"game\"",
"]",
"=",
"self",
".",
"_game",
"if",
"self",
".",
"_game_id",
"is",
"not",
"None",
":",
... | [
196,
4
] | [
215,
19
] | python | en | ['en', 'en', 'en'] | True |
SteamSensor.entity_picture | (self) | Avatar of the account. | Avatar of the account. | def entity_picture(self):
"""Avatar of the account."""
return self._avatar | [
"def",
"entity_picture",
"(",
"self",
")",
":",
"return",
"self",
".",
"_avatar"
] | [
218,
4
] | [
220,
27
] | python | en | ['en', 'en', 'en'] | True |
SteamSensor.icon | (self) | Return the icon to use in the frontend. | Return the icon to use in the frontend. | def icon(self):
"""Return the icon to use in the frontend."""
return ICON | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"ICON"
] | [
223,
4
] | [
225,
19
] | python | en | ['en', 'en', 'en'] | True |
device_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def device_reg(hass):
"""Return an empty, loaded, registry."""
return mock_device_registry(hass) | [
"def",
"device_reg",
"(",
"hass",
")",
":",
"return",
"mock_device_registry",
"(",
"hass",
")"
] | [
20,
0
] | [
22,
37
] | python | en | ['en', 'fy', 'en'] | True |
entity_reg | (hass) | Return an empty, loaded, registry. | Return an empty, loaded, registry. | def entity_reg(hass):
"""Return an empty, loaded, registry."""
return mock_registry(hass) | [
"def",
"entity_reg",
"(",
"hass",
")",
":",
"return",
"mock_registry",
"(",
"hass",
")"
] | [
26,
0
] | [
28,
30
] | python | en | ['en', 'fy', 'en'] | True |
test_get_actions_support_open | (hass, device_reg, entity_reg) | Test we get the expected actions from a lock which supports open. | Test we get the expected actions from a lock which supports open. | async def test_get_actions_support_open(hass, device_reg, entity_reg):
"""Test we get the expected actions from a lock which supports open."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
awa... | [
"async",
"def",
"test_get_actions_support_open",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
"asy... | [
31,
0
] | [
72,
48
] | python | en | ['en', 'en', 'en'] | True |
test_get_actions_not_support_open | (hass, device_reg, entity_reg) | Test we get the expected actions from a lock which doesn't support open. | Test we get the expected actions from a lock which doesn't support open. | async def test_get_actions_not_support_open(hass, device_reg, entity_reg):
"""Test we get the expected actions from a lock which doesn't support open."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"... | [
"async",
"def",
"test_get_actions_not_support_open",
"(",
"hass",
",",
"device_reg",
",",
"entity_reg",
")",
":",
"platform",
"=",
"getattr",
"(",
"hass",
".",
"components",
",",
"f\"test.{DOMAIN}\"",
")",
"platform",
".",
"init",
"(",
")",
"assert",
"await",
... | [
75,
0
] | [
110,
48
] | python | en | ['en', 'en', 'en'] | True |
test_action | (hass) | Test for lock actions. | Test for lock actions. | async def test_action(hass):
"""Test for lock actions."""
assert await async_setup_component(
hass,
automation.DOMAIN,
{
automation.DOMAIN: [
{
"trigger": {"platform": "event", "event_type": "test_event_lock"},
"action":... | [
"async",
"def",
"test_action",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"automation",
".",
"DOMAIN",
",",
"{",
"automation",
".",
"DOMAIN",
":",
"[",
"{",
"\"trigger\"",
":",
"{",
"\"platform\"",
":",
"\"event\"",
... | [
113,
0
] | [
172,
31
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up Bond cover devices. | Set up Bond cover devices. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up Bond cover devices."""
hub: BondHub = hass.data[DOMAIN][entry.entry_id]
covers = [
BondCover(hub, device)
for device in hub.device... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
... | [
15,
0
] | [
29,
36
] | python | en | ['en', 'en', 'en'] | True |
BondCover.__init__ | (self, hub: BondHub, device: BondDevice) | Create HA entity representing Bond cover. | Create HA entity representing Bond cover. | def __init__(self, hub: BondHub, device: BondDevice):
"""Create HA entity representing Bond cover."""
super().__init__(hub, device)
self._closed: Optional[bool] = None | [
"def",
"__init__",
"(",
"self",
",",
"hub",
":",
"BondHub",
",",
"device",
":",
"BondDevice",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"hub",
",",
"device",
")",
"self",
".",
"_closed",
":",
"Optional",
"[",
"bool",
"]",
"=",
"None"
] | [
35,
4
] | [
39,
43
] | python | en | ['en', 'it', 'en'] | True |
BondCover.device_class | (self) | Get device class. | Get device class. | def device_class(self) -> Optional[str]:
"""Get device class."""
return DEVICE_CLASS_SHADE | [
"def",
"device_class",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"DEVICE_CLASS_SHADE"
] | [
46,
4
] | [
48,
33
] | python | en | ['fr', 'en', 'en'] | True |
BondCover.is_closed | (self) | Return if the cover is closed or not. | Return if the cover is closed or not. | def is_closed(self):
"""Return if the cover is closed or not."""
return self._closed | [
"def",
"is_closed",
"(",
"self",
")",
":",
"return",
"self",
".",
"_closed"
] | [
51,
4
] | [
53,
27
] | python | en | ['en', 'en', 'en'] | True |
BondCover.async_open_cover | (self, **kwargs: Any) | Open the cover. | Open the cover. | async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
await self._hub.bond.action(self._device.device_id, Action.open()) | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_hub",
".",
"bond",
".",
"action",
"(",
"self",
".",
"_device",
".",
"device_id",
",",
"Action",
".",
"open",
"(",
... | [
55,
4
] | [
57,
74
] | python | en | ['en', 'en', 'en'] | True |
BondCover.async_close_cover | (self, **kwargs: Any) | Close cover. | Close cover. | async def async_close_cover(self, **kwargs: Any) -> None:
"""Close cover."""
await self._hub.bond.action(self._device.device_id, Action.close()) | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_hub",
".",
"bond",
".",
"action",
"(",
"self",
".",
"_device",
".",
"device_id",
",",
"Action",
".",
"close",
"(",
... | [
59,
4
] | [
61,
75
] | python | en | ['en', 'la', 'en'] | False |
BondCover.async_stop_cover | (self, **kwargs) | Hold cover. | Hold cover. | async def async_stop_cover(self, **kwargs):
"""Hold cover."""
await self._hub.bond.action(self._device.device_id, Action.hold()) | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"_hub",
".",
"bond",
".",
"action",
"(",
"self",
".",
"_device",
".",
"device_id",
",",
"Action",
".",
"hold",
"(",
")",
")"
] | [
63,
4
] | [
65,
74
] | python | en | ['en', 'en', 'en'] | False |
validate_input | (hass: HomeAssistantType, data: dict) | 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. | def validate_input(hass: HomeAssistantType, data: dict) -> Dict[str, Any]:
"""Validate the user input allows us to connect.
Data has the keys from DATA_SCHEMA with values provided by the user.
"""
# constructor does login call
Api(
data[CONF_USERNAME],
data[CONF_PASSWORD],
d... | [
"def",
"validate_input",
"(",
"hass",
":",
"HomeAssistantType",
",",
"data",
":",
"dict",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"# constructor does login call",
"Api",
"(",
"data",
"[",
"CONF_USERNAME",
"]",
",",
"data",
"[",
"CONF_PASSWORD",
... | [
19,
0
] | [
31,
15
] | python | en | ['en', 'en', 'en'] | True |
CanaryConfigFlow.async_get_options_flow | (config_entry) | Get the options flow for this handler. | Get the options flow for this handler. | def async_get_options_flow(config_entry):
"""Get the options flow for this handler."""
return CanaryOptionsFlowHandler(config_entry) | [
"def",
"async_get_options_flow",
"(",
"config_entry",
")",
":",
"return",
"CanaryOptionsFlowHandler",
"(",
"config_entry",
")"
] | [
42,
4
] | [
44,
53
] | python | en | ['en', 'en', 'en'] | True |
CanaryConfigFlow.async_step_import | (
self, user_input: Optional[ConfigType] = None
) | Handle a flow initiated by configuration file. | Handle a flow initiated by configuration file. | async def async_step_import(
self, user_input: Optional[ConfigType] = None
) -> Dict[str, Any]:
"""Handle a flow initiated by configuration file."""
return await self.async_step_user(user_input) | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"ConfigType",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"return",
"await",
"self",
".",
"async_step_user",
"(",
"user_input",
")"
] | [
46,
4
] | [
50,
53
] | python | en | ['en', 'en', 'en'] | True |
CanaryConfigFlow.async_step_user | (
self, user_input: Optional[ConfigType] = None
) | Handle a flow initiated by the user. | Handle a flow initiated by the user. | async def async_step_user(
self, user_input: Optional[ConfigType] = None
) -> Dict[str, Any]:
"""Handle a flow initiated by the user."""
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
errors = {}
default_username = ""
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"ConfigType",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"if",
"self",
".",
"_async_current_entries",
"(",
")",
":",
"return",
"self",
... | [
52,
4
] | [
92,
9
] | python | en | ['en', 'en', 'en'] | True |
CanaryOptionsFlowHandler.__init__ | (self, config_entry) | Initialize options flow. | Initialize options flow. | def __init__(self, config_entry):
"""Initialize options flow."""
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"config_entry",
")",
":",
"self",
".",
"config_entry",
"=",
"config_entry"
] | [
98,
4
] | [
100,
40
] | python | en | ['en', 'en', 'en'] | True |
CanaryOptionsFlowHandler.async_step_init | (self, user_input: Optional[ConfigType] = None) | Manage Canary options. | Manage Canary options. | async def async_step_init(self, user_input: Optional[ConfigType] = None):
"""Manage Canary options."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
options = {
vol.Optional(
CONF_FFMPEG_ARGUMENTS,
de... | [
"async",
"def",
"async_step_init",
"(",
"self",
",",
"user_input",
":",
"Optional",
"[",
"ConfigType",
"]",
"=",
"None",
")",
":",
"if",
"user_input",
"is",
"not",
"None",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"\"\"",
",",
... | [
102,
4
] | [
120,
84
] | python | en | ['en', 'en', 'en'] | True |
test_form_user | (hass) | Test we can setup by the user. | Test we can setup by the user. | async def test_form_user(hass):
"""Test we can setup by the user."""
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
assert ... | [
"async",
"def",
"test_form_user",
"(",
"hass",
")",
":",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"{",
"}",
")",
"result",
"=",
"await",
"hass",
".",
"config_entries",
".",
"flow",
".",
"async_init",... | [
8,
0
] | [
33,
48
] | python | en | ['en', 'en', 'en'] | True |
test_form_user_only_once | (hass) | Test we can setup by the user only once. | Test we can setup by the user only once. | async def test_form_user_only_once(hass):
"""Test we can setup by the user only once."""
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
await setup.async_setup_component(hass, "persistent_notification", {})
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_e... | [
"async",
"def",
"test_form_user_only_once",
"(",
"hass",
")",
":",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
")",
".",
"add_to_hass",
"(",
"hass",
")",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"persistent_notification\"",
",",
"... | [
36,
0
] | [
44,
56
] | python | en | ['en', 'en', 'en'] | True |
test_platform_manually_configured | (hass) | Test that we do not discover anything or try to set up a controller. | Test that we do not discover anything or try to set up a controller. | async def test_platform_manually_configured(hass):
"""Test that we do not discover anything or try to set up a controller."""
assert (
await async_setup_component(
hass, SENSOR_DOMAIN, {SENSOR_DOMAIN: {"platform": UNIFI_DOMAIN}}
)
is True
)
assert UNIFI_DOMAIN not in ... | [
"async",
"def",
"test_platform_manually_configured",
"(",
"hass",
")",
":",
"assert",
"(",
"await",
"async_setup_component",
"(",
"hass",
",",
"SENSOR_DOMAIN",
",",
"{",
"SENSOR_DOMAIN",
":",
"{",
"\"platform\"",
":",
"UNIFI_DOMAIN",
"}",
"}",
")",
"is",
"True",... | [
52,
0
] | [
60,
40
] | python | en | ['en', 'en', 'en'] | True |
test_no_clients | (hass) | Test the update_clients function when no clients are found. | Test the update_clients function when no clients are found. | async def test_no_clients(hass):
"""Test the update_clients function when no clients are found."""
controller = await setup_unifi_integration(
hass,
options={
CONF_ALLOW_BANDWIDTH_SENSORS: True,
CONF_ALLOW_UPTIME_SENSORS: True,
},
)
assert len(controller.... | [
"async",
"def",
"test_no_clients",
"(",
"hass",
")",
":",
"controller",
"=",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"options",
"=",
"{",
"CONF_ALLOW_BANDWIDTH_SENSORS",
":",
"True",
",",
"CONF_ALLOW_UPTIME_SENSORS",
":",
"True",
",",
"}",
",",
")"... | [
63,
0
] | [
74,
64
] | python | en | ['en', 'en', 'en'] | True |
test_sensors | (hass) | Test the update_items function with some clients. | Test the update_items function with some clients. | async def test_sensors(hass):
"""Test the update_items function with some clients."""
controller = await setup_unifi_integration(
hass,
options={
CONF_ALLOW_BANDWIDTH_SENSORS: True,
CONF_ALLOW_UPTIME_SENSORS: True,
CONF_TRACK_CLIENTS: False,
CONF_T... | [
"async",
"def",
"test_sensors",
"(",
"hass",
")",
":",
"controller",
"=",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"options",
"=",
"{",
"CONF_ALLOW_BANDWIDTH_SENSORS",
":",
"True",
",",
"CONF_ALLOW_UPTIME_SENSORS",
":",
"True",
",",
"CONF_TRACK_CLIENTS"... | [
77,
0
] | [
188,
64
] | python | en | ['en', 'en', 'en'] | True |
test_remove_sensors | (hass) | Test the remove_items function with some clients. | Test the remove_items function with some clients. | async def test_remove_sensors(hass):
"""Test the remove_items function with some clients."""
controller = await setup_unifi_integration(
hass,
options={
CONF_ALLOW_BANDWIDTH_SENSORS: True,
CONF_ALLOW_UPTIME_SENSORS: True,
},
clients_response=CLIENTS,
)... | [
"async",
"def",
"test_remove_sensors",
"(",
"hass",
")",
":",
"controller",
"=",
"await",
"setup_unifi_integration",
"(",
"hass",
",",
"options",
"=",
"{",
"CONF_ALLOW_BANDWIDTH_SENSORS",
":",
"True",
",",
"CONF_ALLOW_UPTIME_SENSORS",
":",
"True",
",",
"}",
",",
... | [
191,
0
] | [
244,
45
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Danfoss Air HRV switch platform. | Set up the Danfoss Air HRV switch platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Danfoss Air HRV switch platform."""
data = hass.data[DANFOSS_AIR_DOMAIN]
switches = [
[
"Danfoss Air Boost",
ReadCommand.boost,
UpdateCommand.boost_activate,
UpdateComm... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"DANFOSS_AIR_DOMAIN",
"]",
"switches",
"=",
"[",
"[",
"\"Danfoss Air Boost\"",
",",
"ReadCommand",
... | [
12,
0
] | [
42,
21
] | python | en | ['en', 'lb', 'en'] | True |
DanfossAir.__init__ | (self, data, name, state_command, on_command, off_command) | Initialize the switch. | Initialize the switch. | def __init__(self, data, name, state_command, on_command, off_command):
"""Initialize the switch."""
self._data = data
self._name = name
self._state_command = state_command
self._on_command = on_command
self._off_command = off_command
self._state = None | [
"def",
"__init__",
"(",
"self",
",",
"data",
",",
"name",
",",
"state_command",
",",
"on_command",
",",
"off_command",
")",
":",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_name",
"=",
"name",
"self",
".",
"_state_command",
"=",
"state_command",
"s... | [
48,
4
] | [
55,
26
] | python | en | ['en', 'en', 'en'] | True |
DanfossAir.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"
] | [
58,
4
] | [
60,
25
] | python | en | ['en', 'en', 'en'] | True |
DanfossAir.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._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
63,
4
] | [
65,
26
] | python | en | ['en', 'fy', 'en'] | True |
DanfossAir.turn_on | (self, **kwargs) | Turn the switch on. | Turn the switch on. | def turn_on(self, **kwargs):
"""Turn the switch on."""
_LOGGER.debug("Turning on switch with command %s", self._on_command)
self._data.update_state(self._on_command, self._state_command) | [
"def",
"turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turning on switch with command %s\"",
",",
"self",
".",
"_on_command",
")",
"self",
".",
"_data",
".",
"update_state",
"(",
"self",
".",
"_on_command",
",",
... | [
67,
4
] | [
70,
70
] | python | en | ['en', 'en', 'en'] | True |
DanfossAir.turn_off | (self, **kwargs) | Turn the switch off. | Turn the switch off. | def turn_off(self, **kwargs):
"""Turn the switch off."""
_LOGGER.debug("Turning off switch with command %s", self._off_command)
self._data.update_state(self._off_command, self._state_command) | [
"def",
"turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Turning off switch with command %s\"",
",",
"self",
".",
"_off_command",
")",
"self",
".",
"_data",
".",
"update_state",
"(",
"self",
".",
"_off_command",
","... | [
72,
4
] | [
75,
71
] | python | en | ['en', 'en', 'en'] | True |
DanfossAir.update | (self) | Update the switch's state. | Update the switch's state. | def update(self):
"""Update the switch's state."""
self._data.update()
self._state = self._data.get_value(self._state_command)
if self._state is None:
_LOGGER.debug("Could not get data for %s", self._state_command) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_data",
".",
"update",
"(",
")",
"self",
".",
"_state",
"=",
"self",
".",
"_data",
".",
"get_value",
"(",
"self",
".",
"_state_command",
")",
"if",
"self",
".",
"_state",
"is",
"None",
":",
"_LO... | [
77,
4
] | [
83,
75
] | python | en | ['en', 'en', 'en'] | True |
run | (dataset_dir, small_object_area_threshold, foreground_class_of_interest) | Runs the download and conversion operation.
Args:
dataset_dir: The dataset directory where the dataset is stored.
small_object_area_threshold: Threshold of fraction of image area below which
small objects are filtered
foreground_class_of_interest: Build a binary classifier based on the
presen... | Runs the download and conversion operation. | def run(dataset_dir, small_object_area_threshold, foreground_class_of_interest):
"""Runs the download and conversion operation.
Args:
dataset_dir: The dataset directory where the dataset is stored.
small_object_area_threshold: Threshold of fraction of image area below which
small objects are filtered... | [
"def",
"run",
"(",
"dataset_dir",
",",
"small_object_area_threshold",
",",
"foreground_class_of_interest",
")",
":",
"# 1. Download the coco dataset into a subdirectory under the visualwakewords",
"# dataset directory",
"coco_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
... | [
92,
0
] | [
157,
20
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Nello lock platform. | Set up the Nello lock platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Nello lock platform."""
nello = Nello(config.get(CONF_USERNAME), config.get(CONF_PASSWORD))
add_entities([NelloLock(lock) for lock in nello.locations], True) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"nello",
"=",
"Nello",
"(",
"config",
".",
"get",
"(",
"CONF_USERNAME",
")",
",",
"config",
".",
"get",
"(",
"CONF_PASSWORD",
")",
")"... | [
22,
0
] | [
26,
69
] | python | en | ['en', 'de', 'en'] | True |
NelloLock.__init__ | (self, nello_lock) | Initialize the lock. | Initialize the lock. | def __init__(self, nello_lock):
"""Initialize the lock."""
self._nello_lock = nello_lock
self._device_attrs = None
self._activity = None
self._name = None | [
"def",
"__init__",
"(",
"self",
",",
"nello_lock",
")",
":",
"self",
".",
"_nello_lock",
"=",
"nello_lock",
"self",
".",
"_device_attrs",
"=",
"None",
"self",
".",
"_activity",
"=",
"None",
"self",
".",
"_name",
"=",
"None"
] | [
32,
4
] | [
37,
25
] | python | en | ['en', 'en', 'en'] | True |
NelloLock.name | (self) | Return the name of the lock. | Return the name of the lock. | def name(self):
"""Return the name of the lock."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
40,
4
] | [
42,
25
] | python | en | ['en', 'en', 'en'] | True |
NelloLock.is_locked | (self) | Return true if lock is locked. | Return true if lock is locked. | def is_locked(self):
"""Return true if lock is locked."""
return True | [
"def",
"is_locked",
"(",
"self",
")",
":",
"return",
"True"
] | [
45,
4
] | [
47,
19
] | python | en | ['en', 'mt', 'en'] | True |
NelloLock.device_state_attributes | (self) | Return the device specific state attributes. | Return the device specific state attributes. | def device_state_attributes(self):
"""Return the device specific state attributes."""
return self._device_attrs | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_attrs"
] | [
50,
4
] | [
52,
33
] | python | en | ['en', 'en', 'en'] | True |
NelloLock.update | (self) | Update the nello lock properties. | Update the nello lock properties. | def update(self):
"""Update the nello lock properties."""
self._nello_lock.update()
# Location identifiers
location_id = self._nello_lock.location_id
short_id = self._nello_lock.short_id
address = self._nello_lock.address
self._name = f"Nello {short_id}"
s... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_nello_lock",
".",
"update",
"(",
")",
"# Location identifiers",
"location_id",
"=",
"self",
".",
"_nello_lock",
".",
"location_id",
"short_id",
"=",
"self",
".",
"_nello_lock",
".",
"short_id",
"address",
... | [
54,
4
] | [
81,
33
] | python | en | ['en', 'sn', 'it'] | False |
NelloLock.unlock | (self, **kwargs) | Unlock the device. | Unlock the device. | def unlock(self, **kwargs):
"""Unlock the device."""
if not self._nello_lock.open_door():
_LOGGER.error("Failed to unlock") | [
"def",
"unlock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_nello_lock",
".",
"open_door",
"(",
")",
":",
"_LOGGER",
".",
"error",
"(",
"\"Failed to unlock\"",
")"
] | [
83,
4
] | [
86,
45
] | python | en | ['en', 'zh', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up binary sensors attached to a Konnected device from a config entry. | Set up binary sensors attached to a Konnected device from a config entry. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up binary sensors attached to a Konnected device from a config entry."""
data = hass.data[KONNECTED_DOMAIN]
device_id = config_entry.data["id"]
sensors = [
KonnectedBinarySensor(device_id, pin_num, pin_data)
for ... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"data",
"=",
"hass",
".",
"data",
"[",
"KONNECTED_DOMAIN",
"]",
"device_id",
"=",
"config_entry",
".",
"data",
"[",
"\"id\"",
"]",
"sensors",
"=",
"["... | [
16,
0
] | [
26,
31
] | python | en | ['en', 'en', 'en'] | True |
KonnectedBinarySensor.__init__ | (self, device_id, zone_num, data) | Initialize the Konnected binary sensor. | Initialize the Konnected binary sensor. | def __init__(self, device_id, zone_num, data):
"""Initialize the Konnected binary sensor."""
self._data = data
self._device_id = device_id
self._zone_num = zone_num
self._state = self._data.get(ATTR_STATE)
self._device_class = self._data.get(CONF_TYPE)
self._uniqu... | [
"def",
"__init__",
"(",
"self",
",",
"device_id",
",",
"zone_num",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"self",
".",
"_device_id",
"=",
"device_id",
"self",
".",
"_zone_num",
"=",
"zone_num",
"self",
".",
"_state",
"=",
"self",
"."... | [
32,
4
] | [
40,
46
] | python | en | ['en', 'en', 'en'] | True |
KonnectedBinarySensor.unique_id | (self) | Return the unique id. | Return the unique id. | def unique_id(self) -> str:
"""Return the unique id."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
43,
4
] | [
45,
30
] | python | en | ['en', 'la', 'en'] | True |
KonnectedBinarySensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
48,
4
] | [
50,
25
] | python | en | ['en', 'mi', 'en'] | True |
KonnectedBinarySensor.is_on | (self) | Return the state of the sensor. | Return the state of the sensor. | def is_on(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
53,
4
] | [
55,
26
] | python | en | ['en', 'en', 'en'] | True |
KonnectedBinarySensor.should_poll | (self) | No polling needed. | No polling needed. | def should_poll(self):
"""No polling needed."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
58,
4
] | [
60,
20
] | python | en | ['en', 'en', 'en'] | True |
KonnectedBinarySensor.device_class | (self) | Return the device class. | Return the device class. | def device_class(self):
"""Return the device class."""
return self._device_class | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_class"
] | [
63,
4
] | [
65,
33
] | python | en | ['en', 'en', 'en'] | True |
KonnectedBinarySensor.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {
"identifiers": {(KONNECTED_DOMAIN, self._device_id)},
} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"KONNECTED_DOMAIN",
",",
"self",
".",
"_device_id",
")",
"}",
",",
"}"
] | [
68,
4
] | [
72,
9
] | python | en | ['en', 'en', 'en'] | True |
KonnectedBinarySensor.async_added_to_hass | (self) | Store entity_id and register state change callback. | Store entity_id and register state change callback. | async def async_added_to_hass(self):
"""Store entity_id and register state change callback."""
self._data[ATTR_ENTITY_ID] = self.entity_id
self.async_on_remove(
async_dispatcher_connect(
self.hass, f"konnected.{self.entity_id}.update", self.async_set_state
... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_data",
"[",
"ATTR_ENTITY_ID",
"]",
"=",
"self",
".",
"entity_id",
"self",
".",
"async_on_remove",
"(",
"async_dispatcher_connect",
"(",
"self",
".",
"hass",
",",
"f\"konnected.{self.ent... | [
74,
4
] | [
81,
9
] | python | en | ['en', 'en', 'en'] | True |
KonnectedBinarySensor.async_set_state | (self, state) | Update the sensor's state. | Update the sensor's state. | def async_set_state(self, state):
"""Update the sensor's state."""
self._state = state
self.async_write_ha_state() | [
"def",
"async_set_state",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_state",
"=",
"state",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
84,
4
] | [
87,
35
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVBridge.get_bridge | (method, host, port=None, token=None) | Get Bridge instance. | Get Bridge instance. | def get_bridge(method, host, port=None, token=None):
"""Get Bridge instance."""
if method == METHOD_LEGACY:
return SamsungTVLegacyBridge(method, host, port)
return SamsungTVWSBridge(method, host, port, token) | [
"def",
"get_bridge",
"(",
"method",
",",
"host",
",",
"port",
"=",
"None",
",",
"token",
"=",
"None",
")",
":",
"if",
"method",
"==",
"METHOD_LEGACY",
":",
"return",
"SamsungTVLegacyBridge",
"(",
"method",
",",
"host",
",",
"port",
")",
"return",
"Samsun... | [
36,
4
] | [
40,
59
] | python | en | ['en', 'nl', 'en'] | True |
SamsungTVBridge.__init__ | (self, method, host, port) | Initialize Bridge. | Initialize Bridge. | def __init__(self, method, host, port):
"""Initialize Bridge."""
self.port = port
self.method = method
self.host = host
self.token = None
self.default_port = None
self._remote = None
self._callback = None | [
"def",
"__init__",
"(",
"self",
",",
"method",
",",
"host",
",",
"port",
")",
":",
"self",
".",
"port",
"=",
"port",
"self",
".",
"method",
"=",
"method",
"self",
".",
"host",
"=",
"host",
"self",
".",
"token",
"=",
"None",
"self",
".",
"default_po... | [
42,
4
] | [
50,
29
] | python | en | ['en', 'la', 'en'] | False |
SamsungTVBridge.register_reauth_callback | (self, func) | Register a callback function. | Register a callback function. | def register_reauth_callback(self, func):
"""Register a callback function."""
self._callback = func | [
"def",
"register_reauth_callback",
"(",
"self",
",",
"func",
")",
":",
"self",
".",
"_callback",
"=",
"func"
] | [
52,
4
] | [
54,
29
] | python | en | ['es', 'en', 'en'] | True |
SamsungTVBridge.try_connect | (self) | Try to connect to the TV. | Try to connect to the TV. | def try_connect(self):
"""Try to connect to the TV.""" | [
"def",
"try_connect",
"(",
"self",
")",
":"
] | [
57,
4
] | [
58,
39
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVBridge.is_on | (self) | Tells if the TV is on. | Tells if the TV is on. | def is_on(self):
"""Tells if the TV is on."""
self.close_remote()
try:
return self._get_remote() is not None
except (
UnhandledResponse,
AccessDenied,
ConnectionFailure,
):
# We got a response so it's working.
... | [
"def",
"is_on",
"(",
"self",
")",
":",
"self",
".",
"close_remote",
"(",
")",
"try",
":",
"return",
"self",
".",
"_get_remote",
"(",
")",
"is",
"not",
"None",
"except",
"(",
"UnhandledResponse",
",",
"AccessDenied",
",",
"ConnectionFailure",
",",
")",
":... | [
60,
4
] | [
75,
24
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVBridge.send_key | (self, key) | Send a key to the tv and handles exceptions. | Send a key to the tv and handles exceptions. | def send_key(self, key):
"""Send a key to the tv and handles exceptions."""
try:
# recreate connection if connection was dead
retry_count = 1
for _ in range(retry_count + 1):
try:
self._send_key(key)
break
... | [
"def",
"send_key",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"# recreate connection if connection was dead",
"retry_count",
"=",
"1",
"for",
"_",
"in",
"range",
"(",
"retry_count",
"+",
"1",
")",
":",
"try",
":",
"self",
".",
"_send_key",
"(",
"key",
... | [
77,
4
] | [
99,
16
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVBridge._send_key | (self, key) | Send the key. | Send the key. | def _send_key(self, key):
"""Send the key.""" | [
"def",
"_send_key",
"(",
"self",
",",
"key",
")",
":"
] | [
102,
4
] | [
103,
27
] | python | en | ['en', 'sk', 'en'] | True |
SamsungTVBridge._get_remote | (self) | Get Remote object. | Get Remote object. | def _get_remote(self):
"""Get Remote object.""" | [
"def",
"_get_remote",
"(",
"self",
")",
":"
] | [
106,
4
] | [
107,
32
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVBridge.close_remote | (self) | Close remote object. | Close remote object. | def close_remote(self):
"""Close remote object."""
try:
if self._remote is not None:
# Close the current remote connection
self._remote.close()
self._remote = None
except OSError:
LOGGER.debug("Could not establish connection") | [
"def",
"close_remote",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_remote",
"is",
"not",
"None",
":",
"# Close the current remote connection",
"self",
".",
"_remote",
".",
"close",
"(",
")",
"self",
".",
"_remote",
"=",
"None",
"except",
"OSErr... | [
109,
4
] | [
117,
58
] | python | en | ['en', 'it', 'en'] | True |
SamsungTVBridge._notify_callback | (self) | Notify access denied callback. | Notify access denied callback. | def _notify_callback(self):
"""Notify access denied callback."""
if self._callback:
self._callback() | [
"def",
"_notify_callback",
"(",
"self",
")",
":",
"if",
"self",
".",
"_callback",
":",
"self",
".",
"_callback",
"(",
")"
] | [
119,
4
] | [
122,
28
] | python | en | ['en', 'cy', 'en'] | True |
SamsungTVLegacyBridge.__init__ | (self, method, host, port) | Initialize Bridge. | Initialize Bridge. | def __init__(self, method, host, port):
"""Initialize Bridge."""
super().__init__(method, host, None)
self.config = {
CONF_NAME: VALUE_CONF_NAME,
CONF_DESCRIPTION: VALUE_CONF_NAME,
CONF_ID: VALUE_CONF_ID,
CONF_HOST: host,
CONF_METHOD: m... | [
"def",
"__init__",
"(",
"self",
",",
"method",
",",
"host",
",",
"port",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"method",
",",
"host",
",",
"None",
")",
"self",
".",
"config",
"=",
"{",
"CONF_NAME",
":",
"VALUE_CONF_NAME",
",",
"CONF_DESC... | [
128,
4
] | [
139,
9
] | python | en | ['en', 'la', 'en'] | False |
SamsungTVLegacyBridge.try_connect | (self) | Try to connect to the Legacy TV. | Try to connect to the Legacy TV. | def try_connect(self):
"""Try to connect to the Legacy TV."""
config = {
CONF_NAME: VALUE_CONF_NAME,
CONF_DESCRIPTION: VALUE_CONF_NAME,
CONF_ID: VALUE_CONF_ID,
CONF_HOST: self.host,
CONF_METHOD: self.method,
CONF_PORT: None,
... | [
"def",
"try_connect",
"(",
"self",
")",
":",
"config",
"=",
"{",
"CONF_NAME",
":",
"VALUE_CONF_NAME",
",",
"CONF_DESCRIPTION",
":",
"VALUE_CONF_NAME",
",",
"CONF_ID",
":",
"VALUE_CONF_ID",
",",
"CONF_HOST",
":",
"self",
".",
"host",
",",
"CONF_METHOD",
":",
... | [
141,
4
] | [
166,
40
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVLegacyBridge._get_remote | (self) | Create or return a remote control instance. | Create or return a remote control instance. | def _get_remote(self):
"""Create or return a remote control instance."""
if self._remote is None:
# We need to create a new instance to reconnect.
try:
LOGGER.debug("Create SamsungRemote")
self._remote = Remote(self.config.copy())
# Thi... | [
"def",
"_get_remote",
"(",
"self",
")",
":",
"if",
"self",
".",
"_remote",
"is",
"None",
":",
"# We need to create a new instance to reconnect.",
"try",
":",
"LOGGER",
".",
"debug",
"(",
"\"Create SamsungRemote\"",
")",
"self",
".",
"_remote",
"=",
"Remote",
"("... | [
168,
4
] | [
180,
27
] | python | en | ['en', 'co', 'en'] | True |
SamsungTVLegacyBridge._send_key | (self, key) | Send the key using legacy protocol. | Send the key using legacy protocol. | def _send_key(self, key):
"""Send the key using legacy protocol."""
self._get_remote().control(key) | [
"def",
"_send_key",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_get_remote",
"(",
")",
".",
"control",
"(",
"key",
")"
] | [
182,
4
] | [
184,
39
] | python | en | ['en', 'hmn', 'en'] | True |
SamsungTVWSBridge.__init__ | (self, method, host, port, token=None) | Initialize Bridge. | Initialize Bridge. | def __init__(self, method, host, port, token=None):
"""Initialize Bridge."""
super().__init__(method, host, port)
self.token = token
self.default_port = 8001 | [
"def",
"__init__",
"(",
"self",
",",
"method",
",",
"host",
",",
"port",
",",
"token",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"method",
",",
"host",
",",
"port",
")",
"self",
".",
"token",
"=",
"token",
"self",
".",
"defa... | [
190,
4
] | [
194,
32
] | python | en | ['en', 'la', 'en'] | False |
SamsungTVWSBridge.try_connect | (self) | Try to connect to the Websocket TV. | Try to connect to the Websocket TV. | def try_connect(self):
"""Try to connect to the Websocket TV."""
for self.port in (8001, 8002):
config = {
CONF_NAME: VALUE_CONF_NAME,
CONF_HOST: self.host,
CONF_METHOD: self.method,
CONF_PORT: self.port,
# We ne... | [
"def",
"try_connect",
"(",
"self",
")",
":",
"for",
"self",
".",
"port",
"in",
"(",
"8001",
",",
"8002",
")",
":",
"config",
"=",
"{",
"CONF_NAME",
":",
"VALUE_CONF_NAME",
",",
"CONF_HOST",
":",
"self",
".",
"host",
",",
"CONF_METHOD",
":",
"self",
"... | [
196,
4
] | [
234,
36
] | python | en | ['en', 'en', 'en'] | True |
SamsungTVWSBridge._send_key | (self, key) | Send the key using websocket protocol. | Send the key using websocket protocol. | def _send_key(self, key):
"""Send the key using websocket protocol."""
if key == "KEY_POWEROFF":
key = "KEY_POWER"
self._get_remote().send_key(key) | [
"def",
"_send_key",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"==",
"\"KEY_POWEROFF\"",
":",
"key",
"=",
"\"KEY_POWER\"",
"self",
".",
"_get_remote",
"(",
")",
".",
"send_key",
"(",
"key",
")"
] | [
236,
4
] | [
240,
40
] | python | en | ['en', 'cs', 'en'] | True |
SamsungTVWSBridge._get_remote | (self) | Create or return a remote control instance. | Create or return a remote control instance. | def _get_remote(self):
"""Create or return a remote control instance."""
if self._remote is None:
# We need to create a new instance to reconnect.
try:
LOGGER.debug("Create SamsungTVWS")
self._remote = SamsungTVWS(
host=self.hos... | [
"def",
"_get_remote",
"(",
"self",
")",
":",
"if",
"self",
".",
"_remote",
"is",
"None",
":",
"# We need to create a new instance to reconnect.",
"try",
":",
"LOGGER",
".",
"debug",
"(",
"\"Create SamsungTVWS\"",
")",
"self",
".",
"_remote",
"=",
"SamsungTVWS",
... | [
242,
4
] | [
263,
27
] | python | en | ['en', 'co', 'en'] | True |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up sensor(s) for KNX platform. | Set up sensor(s) for KNX platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up sensor(s) for KNX platform."""
entities = []
for device in hass.data[DOMAIN].xknx.devices:
if isinstance(device, XknxSensor):
entities.append(KNXSensor(device))
async_add_entities(entitie... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"entities",
"=",
"[",
"]",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"xknx",
".",
"dev... | [
10,
0
] | [
16,
32
] | python | en | ['en', 'da', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.