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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
batchnorm2d_mask | (module_masks, mask) |
Infer input and output shape from weight mask
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the batchnorm2d
mask : dict
The mask of its weights, from the user provided mask file
Returns
-------
CoarseMask, CoarseMask
The mask of its... |
Infer input and output shape from weight mask
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the batchnorm2d
mask : dict
The mask of its weights, from the user provided mask file
Returns
-------
CoarseMask, CoarseMask
The mask of its... | def batchnorm2d_mask(module_masks, mask):
"""
Infer input and output shape from weight mask
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the batchnorm2d
mask : dict
The mask of its weights, from the user provided mask file
Returns
-------
... | [
"def",
"batchnorm2d_mask",
"(",
"module_masks",
",",
"mask",
")",
":",
"assert",
"'weight'",
"in",
"mask",
"and",
"'bias'",
"in",
"mask",
"sum_mask",
"=",
"mask",
"[",
"'weight'",
"]",
"+",
"mask",
"[",
"'bias'",
"]",
"nonzero_index",
"=",
"torch",
".",
... | [
786,
0
] | [
817,
36
] | python | en | ['en', 'error', 'th'] | False |
linear_mask | (module_masks, mask, shape) |
Infer input and output shape from weight mask with limitations:
Only support infer input mask
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the Linear
mask : dict
The mask of its weights, from the user provided mask file
shape: dict
Sh... |
Infer input and output shape from weight mask with limitations:
Only support infer input mask | def linear_mask(module_masks, mask, shape):
"""
Infer input and output shape from weight mask with limitations:
Only support infer input mask
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the Linear
mask : dict
The mask of its weights, from the... | [
"def",
"linear_mask",
"(",
"module_masks",
",",
"mask",
",",
"shape",
")",
":",
"assert",
"'weight'",
"in",
"mask",
"num_input_dim",
"=",
"len",
"(",
"shape",
"[",
"'in_shape'",
"]",
")",
"# Input data of Linear module can have multiple dimensions.",
"# here we only s... | [
820,
0
] | [
851,
28
] | python | en | ['en', 'error', 'th'] | False |
conv2d_mask | (module_masks, mask) |
Infer input and output shape from weight mask
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : dict
The mask of its weights, from the user provided mask file
Returns
-------
CoarseMask, CoarseMask
The mask of its in... |
Infer input and output shape from weight mask | def conv2d_mask(module_masks, mask):
"""
Infer input and output shape from weight mask
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : dict
The mask of its weights, from the user provided mask file
Returns
-------
Coars... | [
"def",
"conv2d_mask",
"(",
"module_masks",
",",
"mask",
")",
":",
"def",
"convert_to_coarse_mask",
"(",
"mask",
",",
"dim",
"=",
"0",
")",
":",
"\"\"\"\n Parameters\n ----------\n mask : dict\n Weight mask from user provided mask file\n dim:... | [
854,
0
] | [
936,
44
] | python | en | ['en', 'error', 'th'] | False |
conv2d_inshape | (module_masks, mask) |
Shape change of input tensor does not affect the shape of its output tensor
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : CoarseMask
The mask of its input tensor
Returns
-------
CoarseMask
The mask of its output te... |
Shape change of input tensor does not affect the shape of its output tensor
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : CoarseMask
The mask of its input tensor
Returns
-------
CoarseMask
The mask of its output te... | def conv2d_inshape(module_masks, mask):
"""
Shape change of input tensor does not affect the shape of its output tensor
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : CoarseMask
The mask of its input tensor
Returns
-------
... | [
"def",
"conv2d_inshape",
"(",
"module_masks",
",",
"mask",
")",
":",
"assert",
"isinstance",
"(",
"mask",
",",
"CoarseMask",
")",
"if",
"module_masks",
".",
"input_mask",
"is",
"None",
":",
"module_masks",
".",
"set_input_mask",
"(",
"mask",
")",
"else",
":"... | [
939,
0
] | [
969,
15
] | python | en | ['en', 'error', 'th'] | False |
conv2d_outshape | (module_masks, mask) |
Assume only the second dimension is masked
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : CoarseMask
The mask of its output tensor
Returns
-------
CoarseMask
The mask of its input tensor
|
Assume only the second dimension is masked | def conv2d_outshape(module_masks, mask):
"""
Assume only the second dimension is masked
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : CoarseMask
The mask of its output tensor
Returns
-------
CoarseMask
The mas... | [
"def",
"conv2d_outshape",
"(",
"module_masks",
",",
"mask",
")",
":",
"assert",
"isinstance",
"(",
"mask",
",",
"CoarseMask",
")",
"assert",
"mask",
".",
"mask_index",
"[",
"1",
"]",
"is",
"not",
"None",
"assert",
"mask",
".",
"mask_index",
"[",
"0",
"]"... | [
972,
0
] | [
1016,
15
] | python | en | ['en', 'error', 'th'] | False |
convtranspose2d_inshape | (module_masks, mask) |
Shape change of input tensor does not affect the shape of its output tensor
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : CoarseMask
The mask of its input tensor
Returns
-------
CoarseMask
The mask of its output te... |
Shape change of input tensor does not affect the shape of its output tensor
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : CoarseMask
The mask of its input tensor
Returns
-------
CoarseMask
The mask of its output te... | def convtranspose2d_inshape(module_masks, mask):
"""
Shape change of input tensor does not affect the shape of its output tensor
Parameters
----------
module_masks : ModuleMasks
The ModuleMasks instance of the conv2d
mask : CoarseMask
The mask of its input tensor
Returns
... | [
"def",
"convtranspose2d_inshape",
"(",
"module_masks",
",",
"mask",
")",
":",
"assert",
"isinstance",
"(",
"mask",
",",
"CoarseMask",
")",
"if",
"module_masks",
".",
"input_mask",
"is",
"None",
":",
"module_masks",
".",
"set_input_mask",
"(",
"mask",
")",
"els... | [
1025,
0
] | [
1054,
15
] | python | en | ['en', 'error', 'th'] | False |
CoarseMask.__init__ | (self, num_dim) |
Parameters
----------
num_dim : int
The number of dimensions of the tensor that will be masked
|
Parameters
----------
num_dim : int
The number of dimensions of the tensor that will be masked
| def __init__(self, num_dim):
"""
Parameters
----------
num_dim : int
The number of dimensions of the tensor that will be masked
"""
self.mask_index = [None for _ in range(num_dim)] | [
"def",
"__init__",
"(",
"self",
",",
"num_dim",
")",
":",
"self",
".",
"mask_index",
"=",
"[",
"None",
"for",
"_",
"in",
"range",
"(",
"num_dim",
")",
"]"
] | [
33,
4
] | [
40,
56
] | python | en | ['en', 'error', 'th'] | False |
CoarseMask.add_index_mask | (self, dim, index) |
Add mask for the specified dimension
Parameters
----------
dim : int
The dimension to add mask
index : tensor
The mask for this dimension, its a 1 dimension tensor which specifies
the index of the elements that are not pruned
|
Add mask for the specified dimension | def add_index_mask(self, dim, index):
"""
Add mask for the specified dimension
Parameters
----------
dim : int
The dimension to add mask
index : tensor
The mask for this dimension, its a 1 dimension tensor which specifies
the index of ... | [
"def",
"add_index_mask",
"(",
"self",
",",
"dim",
",",
"index",
")",
":",
"self",
".",
"mask_index",
"[",
"dim",
"]",
"=",
"index"
] | [
42,
4
] | [
54,
36
] | python | en | ['en', 'error', 'th'] | False |
CoarseMask.merge_index | (index_a, index_b) |
Parameters
----------
index_a : tensor
One index (1-dimension) tensor
index_b : tensor
The other index (1-dimension) tensor
Returns
-------
tensor
The merged index (1-dimension) tensor
Note that: the output tensor ... |
Parameters
----------
index_a : tensor
One index (1-dimension) tensor
index_b : tensor
The other index (1-dimension) tensor | def merge_index(index_a, index_b):
"""
Parameters
----------
index_a : tensor
One index (1-dimension) tensor
index_b : tensor
The other index (1-dimension) tensor
Returns
-------
tensor
The merged index (1-dimension) te... | [
"def",
"merge_index",
"(",
"index_a",
",",
"index_b",
")",
":",
"device",
"=",
"index_a",
".",
"device",
"s",
"=",
"set",
"(",
")",
"for",
"num",
"in",
"index_a",
".",
"tolist",
"(",
")",
":",
"# we need to transfer the tensor to list here",
"# first, directly... | [
57,
4
] | [
89,
49
] | python | en | ['en', 'error', 'th'] | False |
CoarseMask.merge | (self, cmask) |
Merge another CoarseMask
Parameters
----------
cmask : CoarseMask
Another CoarseMask to merge
Returns
-------
list
The member variable ```mask_index```
|
Merge another CoarseMask | def merge(self, cmask):
"""
Merge another CoarseMask
Parameters
----------
cmask : CoarseMask
Another CoarseMask to merge
Returns
-------
list
The member variable ```mask_index```
"""
assert isinstance(cmask, Coars... | [
"def",
"merge",
"(",
"self",
",",
"cmask",
")",
":",
"assert",
"isinstance",
"(",
"cmask",
",",
"CoarseMask",
")",
"assert",
"len",
"(",
"self",
".",
"mask_index",
")",
"==",
"len",
"(",
"cmask",
".",
"mask_index",
")",
",",
"\"Only masks with the same num... | [
91,
4
] | [
114,
30
] | python | en | ['en', 'error', 'th'] | False |
CoarseMask.__lt__ | (self, other) |
Judge if the mask is a subset of another CoarseMask.
|
Judge if the mask is a subset of another CoarseMask.
| def __lt__(self, other):
"""
Judge if the mask is a subset of another CoarseMask.
"""
assert isinstance(other, CoarseMask)
for dim, _ in enumerate(self.mask_index):
# if self has more dimensions
if dim >= len(other.mask_index):
return False... | [
"def",
"__lt__",
"(",
"self",
",",
"other",
")",
":",
"assert",
"isinstance",
"(",
"other",
",",
"CoarseMask",
")",
"for",
"dim",
",",
"_",
"in",
"enumerate",
"(",
"self",
".",
"mask_index",
")",
":",
"# if self has more dimensions",
"if",
"dim",
">=",
"... | [
138,
4
] | [
158,
19
] | python | en | ['en', 'error', 'th'] | False |
CoarseMask.__le__ | (self, other) |
Return if self's mask is less or equal to other's mask.
|
Return if self's mask is less or equal to other's mask.
| def __le__(self, other):
"""
Return if self's mask is less or equal to other's mask.
"""
assert isinstance(other, CoarseMask)
if self.__lt__(other) or self.__eq__(other):
return True
return False | [
"def",
"__le__",
"(",
"self",
",",
"other",
")",
":",
"assert",
"isinstance",
"(",
"other",
",",
"CoarseMask",
")",
"if",
"self",
".",
"__lt__",
"(",
"other",
")",
"or",
"self",
".",
"__eq__",
"(",
"other",
")",
":",
"return",
"True",
"return",
"Fals... | [
160,
4
] | [
167,
20
] | python | en | ['en', 'error', 'th'] | False |
ModuleMasks.__init__ | (self, module_name, module=None) |
Parameters
----------
module_name : str
The name of the module or function
|
Parameters
----------
module_name : str
The name of the module or function
| def __init__(self, module_name, module=None):
"""
Parameters
----------
module_name : str
The name of the module or function
"""
self.module_name = module_name
self.module = module
self.param_masks = dict()
self.input_mask = None
... | [
"def",
"__init__",
"(",
"self",
",",
"module_name",
",",
"module",
"=",
"None",
")",
":",
"self",
".",
"module_name",
"=",
"module_name",
"self",
".",
"module",
"=",
"module",
"self",
".",
"param_masks",
"=",
"dict",
"(",
")",
"self",
".",
"input_mask",
... | [
178,
4
] | [
189,
31
] | python | en | ['en', 'error', 'th'] | False |
ModuleMasks.set_param_masks | (self, name, mask) |
Parameters
----------
name : str
The name of the weight
mask : CoarseMask
The mask for this weight
|
Parameters
----------
name : str
The name of the weight
mask : CoarseMask
The mask for this weight
| def set_param_masks(self, name, mask):
"""
Parameters
----------
name : str
The name of the weight
mask : CoarseMask
The mask for this weight
"""
self.param_masks[name] = mask | [
"def",
"set_param_masks",
"(",
"self",
",",
"name",
",",
"mask",
")",
":",
"self",
".",
"param_masks",
"[",
"name",
"]",
"=",
"mask"
] | [
191,
4
] | [
200,
37
] | python | en | ['en', 'error', 'th'] | False |
ModuleMasks.set_input_mask | (self, mask) |
Parameters
----------
mask : CoarseMask
The mask for input
|
Parameters
----------
mask : CoarseMask
The mask for input
| def set_input_mask(self, mask):
"""
Parameters
----------
mask : CoarseMask
The mask for input
"""
self.input_mask = mask | [
"def",
"set_input_mask",
"(",
"self",
",",
"mask",
")",
":",
"self",
".",
"input_mask",
"=",
"mask"
] | [
202,
4
] | [
209,
30
] | python | en | ['en', 'error', 'th'] | False |
ModuleMasks.set_output_mask | (self, mask) |
Parameters
----------
mask : CoarseMask
The mask for output
|
Parameters
----------
mask : CoarseMask
The mask for output
| def set_output_mask(self, mask):
"""
Parameters
----------
mask : CoarseMask
The mask for output
"""
self.output_mask = mask | [
"def",
"set_output_mask",
"(",
"self",
",",
"mask",
")",
":",
"self",
".",
"output_mask",
"=",
"mask"
] | [
211,
4
] | [
218,
31
] | python | en | ['en', 'error', 'th'] | False |
M2EEConfig.get_java_cmd | (self) |
Build complete JVM startup command line
|
Build complete JVM startup command line
| def get_java_cmd(self):
"""
Build complete JVM startup command line
"""
cmd = flatten(self._conf['m2ee'].get('javabin', 'java'))
if 'javaopts' in self._conf['m2ee']:
if isinstance(self._conf['m2ee']['javaopts'], list):
cmd.extend(self._conf['m2ee']['j... | [
"def",
"get_java_cmd",
"(",
"self",
")",
":",
"cmd",
"=",
"flatten",
"(",
"self",
".",
"_conf",
"[",
"'m2ee'",
"]",
".",
"get",
"(",
"'javabin'",
",",
"'java'",
")",
")",
"if",
"'javaopts'",
"in",
"self",
".",
"_conf",
"[",
"'m2ee'",
"]",
":",
"if"... | [
360,
4
] | [
388,
18
] | python | en | ['en', 'error', 'th'] | False |
M2EEConfig._setup_classpath_runtime_binary | (self) |
Returns the location of the mendix runtime files and the
java classpath or None if the classpath cannot be determined
(i.e. the Mendix Runtime is not available on this system)
|
Returns the location of the mendix runtime files and the
java classpath or None if the classpath cannot be determined
(i.e. the Mendix Runtime is not available on this system)
| def _setup_classpath_runtime_binary(self):
"""
Returns the location of the mendix runtime files and the
java classpath or None if the classpath cannot be determined
(i.e. the Mendix Runtime is not available on this system)
"""
logger.debug("Running from binary distributi... | [
"def",
"_setup_classpath_runtime_binary",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Running from binary distribution.\"",
")",
"classpath",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"_runtime_path",
":",
"logger",
".",
"debug",
"(",
"\"runtime_path is ... | [
520,
4
] | [
553,
24
] | python | en | ['en', 'error', 'th'] | False |
async_setup_auth | (
hass,
aiohttp_client,
provider_configs=BASE_CONFIG,
module_configs=EMPTY_CONFIG,
setup_api=False,
) | Set up authentication and create an HTTP client. | Set up authentication and create an HTTP client. | async def async_setup_auth(
hass,
aiohttp_client,
provider_configs=BASE_CONFIG,
module_configs=EMPTY_CONFIG,
setup_api=False,
):
"""Set up authentication and create an HTTP client."""
hass.auth = await auth.auth_manager_from_config(
hass, provider_configs, module_configs
)
en... | [
"async",
"def",
"async_setup_auth",
"(",
"hass",
",",
"aiohttp_client",
",",
"provider_configs",
"=",
"BASE_CONFIG",
",",
"module_configs",
"=",
"EMPTY_CONFIG",
",",
"setup_api",
"=",
"False",
",",
")",
":",
"hass",
".",
"auth",
"=",
"await",
"auth",
".",
"a... | [
19,
0
] | [
34,
46
] | python | en | ['en', 'en', 'en'] | True |
local_impl | (hass) | Local implementation. | Local implementation. | async def local_impl(hass):
"""Local implementation."""
assert await setup.async_setup_component(hass, "http", {})
return config_entry_oauth2_flow.LocalOAuth2Implementation(
hass, TEST_DOMAIN, CLIENT_ID, CLIENT_SECRET, AUTHORIZE_URL, TOKEN_URL
) | [
"async",
"def",
"local_impl",
"(",
"hass",
")",
":",
"assert",
"await",
"setup",
".",
"async_setup_component",
"(",
"hass",
",",
"\"http\"",
",",
"{",
"}",
")",
"return",
"config_entry_oauth2_flow",
".",
"LocalOAuth2Implementation",
"(",
"hass",
",",
"TEST_DOMAI... | [
26,
0
] | [
31,
5
] | python | en | ['en', 'en', 'en'] | False |
flow_handler | (hass) | Return a registered config flow. | Return a registered config flow. | def flow_handler(hass):
"""Return a registered config flow."""
mock_platform(hass, f"{TEST_DOMAIN}.config_flow")
class TestFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
"""Test flow handler."""
DOMAIN = TEST_DOMAIN
@property
def logger(self) -> logging.... | [
"def",
"flow_handler",
"(",
"hass",
")",
":",
"mock_platform",
"(",
"hass",
",",
"f\"{TEST_DOMAIN}.config_flow\"",
")",
"class",
"TestFlowHandler",
"(",
"config_entry_oauth2_flow",
".",
"AbstractOAuth2FlowHandler",
")",
":",
"\"\"\"Test flow handler.\"\"\"",
"DOMAIN",
"="... | [
35,
0
] | [
56,
29
] | python | en | ['en', 'da', 'en'] | True |
test_inherit_enforces_domain_set | () | Test we enforce setting DOMAIN. | Test we enforce setting DOMAIN. | def test_inherit_enforces_domain_set():
"""Test we enforce setting DOMAIN."""
class TestFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
"""Test flow handler."""
@property
def logger(self) -> logging.Logger:
"""Return logger."""
return logging.ge... | [
"def",
"test_inherit_enforces_domain_set",
"(",
")",
":",
"class",
"TestFlowHandler",
"(",
"config_entry_oauth2_flow",
".",
"AbstractOAuth2FlowHandler",
")",
":",
"\"\"\"Test flow handler.\"\"\"",
"@",
"property",
"def",
"logger",
"(",
"self",
")",
"->",
"logging",
".",... | [
90,
0
] | [
103,
29
] | python | en | ['en', 'bg', 'en'] | True |
test_abort_if_no_implementation | (hass, flow_handler) | Check flow abort when no implementations. | Check flow abort when no implementations. | async def test_abort_if_no_implementation(hass, flow_handler):
"""Check flow abort when no implementations."""
flow = flow_handler()
flow.hass = hass
result = await flow.async_step_user()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "missing_configuration... | [
"async",
"def",
"test_abort_if_no_implementation",
"(",
"hass",
",",
"flow_handler",
")",
":",
"flow",
"=",
"flow_handler",
"(",
")",
"flow",
".",
"hass",
"=",
"hass",
"result",
"=",
"await",
"flow",
".",
"async_step_user",
"(",
")",
"assert",
"result",
"[",... | [
106,
0
] | [
112,
54
] | python | en | ['en', 'en', 'en'] | True |
test_abort_if_authorization_timeout | (hass, flow_handler, local_impl) | Check timeout generating authorization url. | Check timeout generating authorization url. | async def test_abort_if_authorization_timeout(hass, flow_handler, local_impl):
"""Check timeout generating authorization url."""
flow_handler.async_register_implementation(hass, local_impl)
flow = flow_handler()
flow.hass = hass
with patch.object(
local_impl, "async_generate_authorize_url"... | [
"async",
"def",
"test_abort_if_authorization_timeout",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
")",
":",
"flow_handler",
".",
"async_register_implementation",
"(",
"hass",
",",
"local_impl",
")",
"flow",
"=",
"flow_handler",
"(",
")",
"flow",
".",
"ha... | [
115,
0
] | [
128,
54
] | python | de | ['de', 'ny', 'en'] | False |
test_abort_if_no_url_available | (hass, flow_handler, local_impl) | Check no_url_available generating authorization url. | Check no_url_available generating authorization url. | async def test_abort_if_no_url_available(hass, flow_handler, local_impl):
"""Check no_url_available generating authorization url."""
flow_handler.async_register_implementation(hass, local_impl)
flow = flow_handler()
flow.hass = hass
with patch.object(
local_impl, "async_generate_authorize_... | [
"async",
"def",
"test_abort_if_no_url_available",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
")",
":",
"flow_handler",
".",
"async_register_implementation",
"(",
"hass",
",",
"local_impl",
")",
"flow",
"=",
"flow_handler",
"(",
")",
"flow",
".",
"hass",
... | [
131,
0
] | [
144,
49
] | python | en | ['de', 'en', 'en'] | True |
test_abort_if_oauth_error | (
hass, flow_handler, local_impl, aiohttp_client, aioclient_mock, current_request
) | Check bad oauth token. | Check bad oauth token. | async def test_abort_if_oauth_error(
hass, flow_handler, local_impl, aiohttp_client, aioclient_mock, current_request
):
"""Check bad oauth token."""
await async_process_ha_core_config(
hass,
{"external_url": "https://example.com"},
)
flow_handler.async_register_implementation(hass, ... | [
"async",
"def",
"test_abort_if_oauth_error",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
",",
"aiohttp_client",
",",
"aioclient_mock",
",",
"current_request",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
... | [
147,
0
] | [
200,
44
] | python | en | ['en', 'en', 'en'] | True |
test_step_discovery | (hass, flow_handler, local_impl) | Check flow triggers from discovery. | Check flow triggers from discovery. | async def test_step_discovery(hass, flow_handler, local_impl):
"""Check flow triggers from discovery."""
await async_process_ha_core_config(
hass,
{"external_url": "https://example.com"},
)
flow_handler.async_register_implementation(hass, local_impl)
config_entry_oauth2_flow.async_re... | [
"async",
"def",
"test_step_discovery",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
"\"https://example.com\"",
"}",
",",
")",
"flow_handler",
".",
"async_regis... | [
203,
0
] | [
219,
53
] | python | en | ['en', 'en', 'en'] | True |
test_abort_discovered_multiple | (hass, flow_handler, local_impl) | Test if aborts when discovered multiple times. | Test if aborts when discovered multiple times. | async def test_abort_discovered_multiple(hass, flow_handler, local_impl):
"""Test if aborts when discovered multiple times."""
await async_process_ha_core_config(
hass,
{"external_url": "https://example.com"},
)
flow_handler.async_register_implementation(hass, local_impl)
config_ent... | [
"async",
"def",
"test_abort_discovered_multiple",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
"\"https://example.com\"",
"}",
",",
")",
"flow_handler",
".",
"... | [
222,
0
] | [
246,
52
] | python | en | ['en', 'en', 'en'] | True |
test_abort_discovered_existing_entries | (hass, flow_handler, local_impl) | Test if abort discovery when entries exists. | Test if abort discovery when entries exists. | async def test_abort_discovered_existing_entries(hass, flow_handler, local_impl):
"""Test if abort discovery when entries exists."""
await async_process_ha_core_config(
hass,
{"external_url": "https://example.com"},
)
flow_handler.async_register_implementation(hass, local_impl)
confi... | [
"async",
"def",
"test_abort_discovered_existing_entries",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
"\"https://example.com\"",
"}",
",",
")",
"flow_handler",
... | [
249,
0
] | [
271,
51
] | python | en | ['en', 'en', 'en'] | True |
test_full_flow | (
hass, flow_handler, local_impl, aiohttp_client, aioclient_mock, current_request
) | Check full flow. | Check full flow. | async def test_full_flow(
hass, flow_handler, local_impl, aiohttp_client, aioclient_mock, current_request
):
"""Check full flow."""
await async_process_ha_core_config(
hass,
{"external_url": "https://example.com"},
)
flow_handler.async_register_implementation(hass, local_impl)
c... | [
"async",
"def",
"test_full_flow",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
",",
"aiohttp_client",
",",
"aioclient_mock",
",",
"current_request",
")",
":",
"await",
"async_process_ha_core_config",
"(",
"hass",
",",
"{",
"\"external_url\"",
":",
"\"https:/... | [
274,
0
] | [
343,
5
] | python | en | ['sv', 'no', 'en'] | False |
test_local_refresh_token | (hass, local_impl, aioclient_mock) | Test we can refresh token. | Test we can refresh token. | async def test_local_refresh_token(hass, local_impl, aioclient_mock):
"""Test we can refresh token."""
aioclient_mock.post(
TOKEN_URL, json={"access_token": ACCESS_TOKEN_2, "expires_in": 100}
)
new_tokens = await local_impl.async_refresh_token(
{
"refresh_token": REFRESH_TOK... | [
"async",
"def",
"test_local_refresh_token",
"(",
"hass",
",",
"local_impl",
",",
"aioclient_mock",
")",
":",
"aioclient_mock",
".",
"post",
"(",
"TOKEN_URL",
",",
"json",
"=",
"{",
"\"access_token\"",
":",
"ACCESS_TOKEN_2",
",",
"\"expires_in\"",
":",
"100",
"}"... | [
346,
0
] | [
375,
5
] | python | en | ['en', 'en', 'en'] | True |
test_oauth_session | (hass, flow_handler, local_impl, aioclient_mock) | Test the OAuth2 session helper. | Test the OAuth2 session helper. | async def test_oauth_session(hass, flow_handler, local_impl, aioclient_mock):
"""Test the OAuth2 session helper."""
flow_handler.async_register_implementation(hass, local_impl)
aioclient_mock.post(
TOKEN_URL, json={"access_token": ACCESS_TOKEN_2, "expires_in": 100}
)
aioclient_mock.post("h... | [
"async",
"def",
"test_oauth_session",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
",",
"aioclient_mock",
")",
":",
"flow_handler",
".",
"async_register_implementation",
"(",
"hass",
",",
"local_impl",
")",
"aioclient_mock",
".",
"post",
"(",
"TOKEN_URL",
... | [
378,
0
] | [
419,
71
] | python | en | ['en', 'en', 'en'] | True |
test_oauth_session_with_clock_slightly_out_of_sync | (
hass, flow_handler, local_impl, aioclient_mock
) | Test the OAuth2 session helper when the remote clock is slightly out of sync. | Test the OAuth2 session helper when the remote clock is slightly out of sync. | async def test_oauth_session_with_clock_slightly_out_of_sync(
hass, flow_handler, local_impl, aioclient_mock
):
"""Test the OAuth2 session helper when the remote clock is slightly out of sync."""
flow_handler.async_register_implementation(hass, local_impl)
aioclient_mock.post(
TOKEN_URL, json={... | [
"async",
"def",
"test_oauth_session_with_clock_slightly_out_of_sync",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
",",
"aioclient_mock",
")",
":",
"flow_handler",
".",
"async_register_implementation",
"(",
"hass",
",",
"local_impl",
")",
"aioclient_mock",
".",
... | [
422,
0
] | [
465,
70
] | python | en | ['en', 'en', 'en'] | True |
test_oauth_session_no_token_refresh_needed | (
hass, flow_handler, local_impl, aioclient_mock
) | Test the OAuth2 session helper when no refresh is needed. | Test the OAuth2 session helper when no refresh is needed. | async def test_oauth_session_no_token_refresh_needed(
hass, flow_handler, local_impl, aioclient_mock
):
"""Test the OAuth2 session helper when no refresh is needed."""
flow_handler.async_register_implementation(hass, local_impl)
aioclient_mock.post("https://example.com", status=201)
config_entry =... | [
"async",
"def",
"test_oauth_session_no_token_refresh_needed",
"(",
"hass",
",",
"flow_handler",
",",
"local_impl",
",",
"aioclient_mock",
")",
":",
"flow_handler",
".",
"async_register_implementation",
"(",
"hass",
",",
"local_impl",
")",
"aioclient_mock",
".",
"post",
... | [
468,
0
] | [
507,
71
] | python | en | ['en', 'en', 'en'] | True |
test_implementation_provider | (hass, local_impl) | Test providing an implementation provider. | Test providing an implementation provider. | async def test_implementation_provider(hass, local_impl):
"""Test providing an implementation provider."""
assert (
await config_entry_oauth2_flow.async_get_implementations(hass, TEST_DOMAIN)
== {}
)
mock_domain_with_impl = "some_domain"
config_entry_oauth2_flow.async_register_impl... | [
"async",
"def",
"test_implementation_provider",
"(",
"hass",
",",
"local_impl",
")",
":",
"assert",
"(",
"await",
"config_entry_oauth2_flow",
".",
"async_get_implementations",
"(",
"hass",
",",
"TEST_DOMAIN",
")",
"==",
"{",
"}",
")",
"mock_domain_with_impl",
"=",
... | [
510,
0
] | [
549,
83
] | python | en | ['en', 'en', 'en'] | True |
MockOAuth2Implementation.name | (self) | Name of the implementation. | Name of the implementation. | def name(self) -> str:
"""Name of the implementation."""
return "Mock" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"Mock\""
] | [
63,
4
] | [
65,
21
] | python | en | ['en', 'en', 'en'] | True |
MockOAuth2Implementation.domain | (self) | Domain that is providing the implementation. | Domain that is providing the implementation. | def domain(self) -> str:
"""Domain that is providing the implementation."""
return "test" | [
"def",
"domain",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"test\""
] | [
68,
4
] | [
70,
21
] | python | en | ['en', 'en', 'en'] | True |
MockOAuth2Implementation.extra_authorize_data | (self) | Extra data that needs to be appended to the authorize url. | Extra data that needs to be appended to the authorize url. | def extra_authorize_data(self) -> dict:
"""Extra data that needs to be appended to the authorize url."""
return {"extra": "data"} | [
"def",
"extra_authorize_data",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"{",
"\"extra\"",
":",
"\"data\"",
"}"
] | [
73,
4
] | [
75,
32
] | python | en | ['en', 'en', 'en'] | True |
MockOAuth2Implementation.async_generate_authorize_url | (self, flow_id: str) | Generate a url for the user to authorize. | Generate a url for the user to authorize. | async def async_generate_authorize_url(self, flow_id: str) -> str:
"""Generate a url for the user to authorize."""
return "http://example.com/auth" | [
"async",
"def",
"async_generate_authorize_url",
"(",
"self",
",",
"flow_id",
":",
"str",
")",
"->",
"str",
":",
"return",
"\"http://example.com/auth\""
] | [
77,
4
] | [
79,
40
] | python | en | ['en', 'en', 'en'] | True |
MockOAuth2Implementation.async_resolve_external_data | (self, external_data) | Resolve external data to tokens. | Resolve external data to tokens. | async def async_resolve_external_data(self, external_data) -> dict:
"""Resolve external data to tokens."""
return external_data | [
"async",
"def",
"async_resolve_external_data",
"(",
"self",
",",
"external_data",
")",
"->",
"dict",
":",
"return",
"external_data"
] | [
81,
4
] | [
83,
28
] | python | en | ['en', 'en', 'en'] | True |
MockOAuth2Implementation._async_refresh_token | (self, token: dict) | Refresh a token. | Refresh a token. | async def _async_refresh_token(self, token: dict) -> dict:
"""Refresh a token."""
raise NotImplementedError() | [
"async",
"def",
"_async_refresh_token",
"(",
"self",
",",
"token",
":",
"dict",
")",
"->",
"dict",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
85,
4
] | [
87,
35
] | python | en | ['en', 'gl', 'en'] | True |
async_setup_platform | (
hass: HomeAssistant,
config: dict,
async_add_entities: Callable,
discovery_info: dict = None,
) | Import Awair configuration from YAML. | Import Awair configuration from YAML. | async def async_setup_platform(
hass: HomeAssistant,
config: dict,
async_add_entities: Callable,
discovery_info: dict = None,
):
"""Import Awair configuration from YAML."""
LOGGER.warning(
"Loading Recollect Waste via platform setup is deprecated. "
"Please remove it from your co... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"dict",
",",
"async_add_entities",
":",
"Callable",
",",
"discovery_info",
":",
"dict",
"=",
"None",
",",
")",
":",
"LOGGER",
".",
"warning",
"(",
"\"Loading Recolle... | [
37,
0
] | [
54,
5
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
) | Set up Recollect Waste sensors based on a config entry. | Set up Recollect Waste sensors based on a config entry. | async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: Callable
) -> None:
"""Set up Recollect Waste sensors based on a config entry."""
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id]
async_add_entities([RecollectWasteSensor(coordinator, entry)]) | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
")",
"->",
"None",
":",
"coordinator",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_COORDINATOR",
... | [
57,
0
] | [
62,
66
] | python | en | ['en', 'en', 'en'] | True |
RecollectWasteSensor.__init__ | (self, coordinator: DataUpdateCoordinator, entry: ConfigEntry) | Initialize the sensor. | Initialize the sensor. | def __init__(self, coordinator: DataUpdateCoordinator, entry: ConfigEntry) -> None:
"""Initialize the sensor."""
super().__init__(coordinator)
self._attributes = {ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION}
self._place_id = entry.data[CONF_PLACE_ID]
self._service_id = entry.data[CONF_... | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
":",
"DataUpdateCoordinator",
",",
"entry",
":",
"ConfigEntry",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"_attributes",
"=",
"{",
"ATTR_ATTRIBUTION",... | [
68,
4
] | [
74,
26
] | python | en | ['en', 'en', 'en'] | True |
RecollectWasteSensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self) -> dict:
"""Return the state attributes."""
return self._attributes | [
"def",
"device_state_attributes",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"self",
".",
"_attributes"
] | [
77,
4
] | [
79,
31
] | python | en | ['en', 'en', 'en'] | True |
RecollectWasteSensor.icon | (self) | Icon to use in the frontend. | Icon to use in the frontend. | def icon(self) -> str:
"""Icon to use in the frontend."""
return DEFAULT_ICON | [
"def",
"icon",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEFAULT_ICON"
] | [
82,
4
] | [
84,
27
] | python | en | ['en', 'en', 'en'] | True |
RecollectWasteSensor.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 DEFAULT_NAME | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"DEFAULT_NAME"
] | [
87,
4
] | [
89,
27
] | python | en | ['en', 'mi', 'en'] | True |
RecollectWasteSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self) -> str:
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_state"
] | [
92,
4
] | [
94,
26
] | python | en | ['en', 'en', 'en'] | True |
RecollectWasteSensor.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self) -> str:
"""Return a unique ID."""
return f"{self._place_id}{self._service_id}" | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"f\"{self._place_id}{self._service_id}\""
] | [
97,
4
] | [
99,
52
] | python | ca | ['fr', 'ca', 'en'] | False |
RecollectWasteSensor._handle_coordinator_update | (self) | Respond to a DataUpdateCoordinator update. | Respond to a DataUpdateCoordinator update. | def _handle_coordinator_update(self) -> None:
"""Respond to a DataUpdateCoordinator update."""
self.update_from_latest_data()
self.async_write_ha_state() | [
"def",
"_handle_coordinator_update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"update_from_latest_data",
"(",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
102,
4
] | [
105,
35
] | python | en | ['en', 'de', 'en'] | True |
RecollectWasteSensor.async_added_to_hass | (self) | Handle entity which will be added. | Handle entity which will be added. | async def async_added_to_hass(self) -> None:
"""Handle entity which will be added."""
await super().async_added_to_hass()
self.update_from_latest_data() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"self",
".",
"update_from_latest_data",
"(",
")"
] | [
107,
4
] | [
110,
38
] | python | en | ['en', 'en', 'en'] | True |
RecollectWasteSensor.update_from_latest_data | (self) | Update the state. | Update the state. | def update_from_latest_data(self) -> None:
"""Update the state."""
pickup_event = self.coordinator.data[0]
next_pickup_event = self.coordinator.data[1]
next_date = str(next_pickup_event.date)
self._state = pickup_event.date
self._attributes.update(
{
... | [
"def",
"update_from_latest_data",
"(",
"self",
")",
"->",
"None",
":",
"pickup_event",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"0",
"]",
"next_pickup_event",
"=",
"self",
".",
"coordinator",
".",
"data",
"[",
"1",
"]",
"next_date",
"=",
"str",
... | [
113,
4
] | [
127,
9
] | python | en | ['en', 'en', 'en'] | True |
GTIHub.__init__ | (self, host, username, password, session) | Initialize. | Initialize. | def __init__(self, host, username, password, session):
"""Initialize."""
self.host = host
self.username = username
self.password = password
self.gti = GTI(Auth(session, self.username, self.password, self.host)) | [
"def",
"__init__",
"(",
"self",
",",
"host",
",",
"username",
",",
"password",
",",
"session",
")",
":",
"self",
".",
"host",
"=",
"host",
"self",
".",
"username",
"=",
"username",
"self",
".",
"password",
"=",
"password",
"self",
".",
"gti",
"=",
"G... | [
8,
4
] | [
14,
78
] | python | en | ['en', 'en', 'it'] | False |
GTIHub.authenticate | (self) | Test if we can authenticate with the host. | Test if we can authenticate with the host. | async def authenticate(self):
"""Test if we can authenticate with the host."""
return await self.gti.init() | [
"async",
"def",
"authenticate",
"(",
"self",
")",
":",
"return",
"await",
"self",
".",
"gti",
".",
"init",
"(",
")"
] | [
16,
4
] | [
19,
36
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistantType, config: ConfigType) | Set up the Lovelace commands. | Set up the Lovelace commands. | async def async_setup(hass: HomeAssistantType, config: ConfigType):
"""Set up the Lovelace commands."""
mode = config[DOMAIN][CONF_MODE]
yaml_resources = config[DOMAIN].get(CONF_RESOURCES)
frontend.async_register_built_in_panel(hass, DOMAIN, config={"mode": mode})
async def reload_resources_servic... | [
"async",
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistantType",
",",
"config",
":",
"ConfigType",
")",
":",
"mode",
"=",
"config",
"[",
"DOMAIN",
"]",
"[",
"CONF_MODE",
"]",
"yaml_resources",
"=",
"config",
"[",
"DOMAIN",
"]",
".",
"get",
"(",
"CON... | [
72,
0
] | [
213,
15
] | python | en | ['en', 'fr', 'en'] | True |
create_yaml_resource_col | (hass, yaml_resources) | Create yaml resources collection. | Create yaml resources collection. | async def create_yaml_resource_col(hass, yaml_resources):
"""Create yaml resources collection."""
if yaml_resources is None:
default_config = dashboard.LovelaceYAML(hass, None, None)
try:
ll_conf = await default_config.async_load(False)
except HomeAssistantError:
... | [
"async",
"def",
"create_yaml_resource_col",
"(",
"hass",
",",
"yaml_resources",
")",
":",
"if",
"yaml_resources",
"is",
"None",
":",
"default_config",
"=",
"dashboard",
".",
"LovelaceYAML",
"(",
"hass",
",",
"None",
",",
"None",
")",
"try",
":",
"ll_conf",
"... | [
216,
0
] | [
231,
65
] | python | en | ['tr', 'en', 'en'] | True |
_register_panel | (hass, url_path, mode, config, update) | Register a panel. | Register a panel. | def _register_panel(hass, url_path, mode, config, update):
"""Register a panel."""
kwargs = {
"frontend_url_path": url_path,
"require_admin": config[CONF_REQUIRE_ADMIN],
"config": {"mode": mode},
"update": update,
}
if config[CONF_SHOW_IN_SIDEBAR]:
kwargs["sideba... | [
"def",
"_register_panel",
"(",
"hass",
",",
"url_path",
",",
"mode",
",",
"config",
",",
"update",
")",
":",
"kwargs",
"=",
"{",
"\"frontend_url_path\"",
":",
"url_path",
",",
"\"require_admin\"",
":",
"config",
"[",
"CONF_REQUIRE_ADMIN",
"]",
",",
"\"config\"... | [
235,
0
] | [
248,
66
] | python | en | ['en', 'da', 'en'] | True |
BaseModelSpeedup.__init__ | (self, model, config) |
Parameters
----------
model : pytorch model
The model to speed up by quantization.
config : dict
Config recording bit number and name of layers.
|
Parameters
----------
model : pytorch model
The model to speed up by quantization.
config : dict
Config recording bit number and name of layers.
| def __init__(self, model, config):
"""
Parameters
----------
model : pytorch model
The model to speed up by quantization.
config : dict
Config recording bit number and name of layers.
"""
self.model = model
self.config = config | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"config",
")",
":",
"self",
".",
"model",
"=",
"model",
"self",
".",
"config",
"=",
"config"
] | [
7,
4
] | [
17,
28
] | python | en | ['en', 'error', 'th'] | False |
BaseModelSpeedup.inference | (self, test_data) |
This function should be overrided by subclass to provide inference ability,
which should return output and inference time.
Parameters
----------
test_data : numpy data
test data given to the inference engine
Returns
-------
numpy data
... |
This function should be overrided by subclass to provide inference ability,
which should return output and inference time. | def inference(self, test_data):
"""
This function should be overrided by subclass to provide inference ability,
which should return output and inference time.
Parameters
----------
test_data : numpy data
test data given to the inference engine
Return... | [
"def",
"inference",
"(",
"self",
",",
"test_data",
")",
":",
"raise",
"NotImplementedError",
"(",
"'Backend engine must overload inference()'",
")"
] | [
19,
4
] | [
36,
77
] | python | en | ['en', 'error', 'th'] | False |
BaseModelSpeedup.compress | (self) |
This function should be overrided by subclass to build inference
engine which will be used to process input data
|
This function should be overrided by subclass to build inference
engine which will be used to process input data
| def compress(self):
"""
This function should be overrided by subclass to build inference
engine which will be used to process input data
"""
raise NotImplementedError('Backend engine must overload compress()') | [
"def",
"compress",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'Backend engine must overload compress()'",
")"
] | [
38,
4
] | [
43,
76
] | python | en | ['en', 'error', 'th'] | False |
BaseModelSpeedup.export_quantized_model | (self, path) |
This function should be overrided by subclass to build inference
engine which will be used to process input data
|
This function should be overrided by subclass to build inference
engine which will be used to process input data
| def export_quantized_model(self, path):
"""
This function should be overrided by subclass to build inference
engine which will be used to process input data
"""
raise NotImplementedError('Backend engine must overload export_quantized_model()') | [
"def",
"export_quantized_model",
"(",
"self",
",",
"path",
")",
":",
"raise",
"NotImplementedError",
"(",
"'Backend engine must overload export_quantized_model()'",
")"
] | [
45,
4
] | [
50,
90
] | python | en | ['en', 'error', 'th'] | False |
async_setup_entry | (hass, entry, async_add_entities) | Set up the binary_sensor platform. | Set up the binary_sensor platform. | async def async_setup_entry(hass, entry, async_add_entities):
"""Set up the binary_sensor platform."""
hub = hass.data[DOMAIN][entry.entry_id]
station_name = entry.data[CONF_STATION]["name"]
station = entry.data[CONF_STATION]
def get_elevator_entities_from_station_information(
station_name,... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"entry",
",",
"async_add_entities",
")",
":",
"hub",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"entry",
".",
"entry_id",
"]",
"station_name",
"=",
"entry",
".",
"data",
"[",
"CONF_STATION",
... | [
24,
0
] | [
113,
5
] | python | en | ['en', 'pt', 'en'] | True |
HvvDepartureBinarySensor.__init__ | (self, coordinator, idx, config_entry) | Initialize. | Initialize. | def __init__(self, coordinator, idx, config_entry):
"""Initialize."""
super().__init__(coordinator)
self.coordinator = coordinator
self.idx = idx
self.config_entry = config_entry | [
"def",
"__init__",
"(",
"self",
",",
"coordinator",
",",
"idx",
",",
"config_entry",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"coordinator",
")",
"self",
".",
"coordinator",
"=",
"coordinator",
"self",
".",
"idx",
"=",
"idx",
"self",
".",
"co... | [
119,
4
] | [
124,
40
] | python | en | ['en', 'en', 'it'] | False |
HvvDepartureBinarySensor.is_on | (self) | Return entity state. | Return entity state. | def is_on(self):
"""Return entity state."""
return self.coordinator.data[self.idx]["state"] | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"idx",
"]",
"[",
"\"state\"",
"]"
] | [
127,
4
] | [
129,
55
] | python | en | ['en', 'cy', 'en'] | True |
HvvDepartureBinarySensor.should_poll | (self) | No need to poll. Coordinator notifies entity of updates. | No need to poll. Coordinator notifies entity of updates. | def should_poll(self):
"""No need to poll. Coordinator notifies entity of updates."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
132,
4
] | [
134,
20
] | python | en | ['en', 'en', 'en'] | True |
HvvDepartureBinarySensor.available | (self) | Return if entity is available. | Return if entity is available. | def available(self):
"""Return if entity is available."""
return (
self.coordinator.last_update_success
and self.coordinator.data[self.idx]["available"]
) | [
"def",
"available",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"coordinator",
".",
"last_update_success",
"and",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"idx",
"]",
"[",
"\"available\"",
"]",
")"
] | [
137,
4
] | [
142,
9
] | python | en | ['en', 'en', 'en'] | True |
HvvDepartureBinarySensor.device_info | (self) | Return the device info for this sensor. | Return the device info for this sensor. | def device_info(self):
"""Return the device info for this sensor."""
return {
"identifiers": {
(
DOMAIN,
self.config_entry.entry_id,
self.config_entry.data[CONF_STATION]["id"],
self.config_entry.d... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"config_entry",
".",
"entry_id",
",",
"self",
".",
"config_entry",
".",
"data",
"[",
"CONF_STATION",
"]",
"[",
"\"id\"",
"]",
",",
... | [
145,
4
] | [
158,
9
] | python | en | ['en', 'en', 'en'] | True |
HvvDepartureBinarySensor.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.coordinator.data[self.idx]["name"] | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"idx",
"]",
"[",
"\"name\"",
"]"
] | [
161,
4
] | [
163,
54
] | python | en | ['en', 'mi', 'en'] | True |
HvvDepartureBinarySensor.unique_id | (self) | Return a unique ID to use for this sensor. | Return a unique ID to use for this sensor. | def unique_id(self):
"""Return a unique ID to use for this sensor."""
return self.idx | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"idx"
] | [
166,
4
] | [
168,
23
] | python | en | ['en', 'en', 'en'] | True |
HvvDepartureBinarySensor.device_class | (self) | Return the class of this device, from component DEVICE_CLASSES. | Return the class of this device, from component DEVICE_CLASSES. | def device_class(self):
"""Return the class of this device, from component DEVICE_CLASSES."""
return DEVICE_CLASS_PROBLEM | [
"def",
"device_class",
"(",
"self",
")",
":",
"return",
"DEVICE_CLASS_PROBLEM"
] | [
171,
4
] | [
173,
35
] | python | en | ['en', 'en', 'en'] | True |
HvvDepartureBinarySensor.device_state_attributes | (self) | Return the state attributes. | Return the state attributes. | def device_state_attributes(self):
"""Return the state attributes."""
if not (
self.coordinator.last_update_success
and self.coordinator.data[self.idx]["available"]
):
return None
return {
k: v
for k, v in self.coordinator.data[... | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"coordinator",
".",
"last_update_success",
"and",
"self",
".",
"coordinator",
".",
"data",
"[",
"self",
".",
"idx",
"]",
"[",
"\"available\"",
"]",
")",
":",
"return",
... | [
176,
4
] | [
187,
9
] | python | en | ['en', 'en', 'en'] | True |
HvvDepartureBinarySensor.async_added_to_hass | (self) | When entity is added to hass. | When entity is added to hass. | async def async_added_to_hass(self):
"""When entity is added to hass."""
self.async_on_remove(
self.coordinator.async_add_listener(self.async_write_ha_state)
) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"coordinator",
".",
"async_add_listener",
"(",
"self",
".",
"async_write_ha_state",
")",
")"
] | [
189,
4
] | [
193,
9
] | python | en | ['en', 'en', 'en'] | True |
HvvDepartureBinarySensor.async_update | (self) | Update the entity.
Only used by the generic entity update service.
| Update the entity. | async def async_update(self):
"""Update the entity.
Only used by the generic entity update service.
"""
await self.coordinator.async_request_refresh() | [
"async",
"def",
"async_update",
"(",
"self",
")",
":",
"await",
"self",
".",
"coordinator",
".",
"async_request_refresh",
"(",
")"
] | [
195,
4
] | [
200,
54
] | python | en | ['en', 'en', 'en'] | True |
async_setup_sensor | (hass, devices={}, structures={}) | Set up the platform and prerequisites. | Set up the platform and prerequisites. | async def async_setup_sensor(hass, devices={}, structures={}):
"""Set up the platform and prerequisites."""
return await async_setup_sdm_platform(hass, PLATFORM, devices, structures) | [
"async",
"def",
"async_setup_sensor",
"(",
"hass",
",",
"devices",
"=",
"{",
"}",
",",
"structures",
"=",
"{",
"}",
")",
":",
"return",
"await",
"async_setup_sdm_platform",
"(",
"hass",
",",
"PLATFORM",
",",
"devices",
",",
"structures",
")"
] | [
17,
0
] | [
19,
78
] | python | en | ['en', 'en', 'en'] | True |
test_thermostat_device | (hass) | Test a thermostat with temperature and humidity sensors. | Test a thermostat with temperature and humidity sensors. | async def test_thermostat_device(hass):
"""Test a thermostat with temperature and humidity sensors."""
devices = {
"some-device-id": Device.MakeDevice(
{
"name": "some-device-id",
"type": THERMOSTAT_TYPE,
"traits": {
"sdm.de... | [
"async",
"def",
"test_thermostat_device",
"(",
"hass",
")",
":",
"devices",
"=",
"{",
"\"some-device-id\"",
":",
"Device",
".",
"MakeDevice",
"(",
"{",
"\"name\"",
":",
"\"some-device-id\"",
",",
"\"type\"",
":",
"THERMOSTAT_TYPE",
",",
"\"traits\"",
":",
"{",
... | [
22,
0
] | [
64,
61
] | python | en | ['en', 'en', 'en'] | True |
test_no_devices | (hass) | Test no devices returned by the api. | Test no devices returned by the api. | async def test_no_devices(hass):
"""Test no devices returned by the api."""
await async_setup_sensor(hass)
temperature = hass.states.get("sensor.my_sensor_temperature")
assert temperature is None
humidity = hass.states.get("sensor.my_sensor_humidity")
assert humidity is None | [
"async",
"def",
"test_no_devices",
"(",
"hass",
")",
":",
"await",
"async_setup_sensor",
"(",
"hass",
")",
"temperature",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"sensor.my_sensor_temperature\"",
")",
"assert",
"temperature",
"is",
"None",
"humidity",
"="... | [
67,
0
] | [
75,
27
] | python | en | ['en', 'en', 'en'] | True |
test_device_no_sensor_traits | (hass) | Test a device with applicable sensor traits. | Test a device with applicable sensor traits. | async def test_device_no_sensor_traits(hass):
"""Test a device with applicable sensor traits."""
devices = {
"some-device-id": Device.MakeDevice(
{
"name": "some-device-id",
"type": THERMOSTAT_TYPE,
"traits": {},
},
auth... | [
"async",
"def",
"test_device_no_sensor_traits",
"(",
"hass",
")",
":",
"devices",
"=",
"{",
"\"some-device-id\"",
":",
"Device",
".",
"MakeDevice",
"(",
"{",
"\"name\"",
":",
"\"some-device-id\"",
",",
"\"type\"",
":",
"THERMOSTAT_TYPE",
",",
"\"traits\"",
":",
... | [
78,
0
] | [
96,
27
] | python | en | ['en', 'en', 'en'] | True |
test_device_name_from_structure | (hass) | Test a device without a custom name, inferring name from structure. | Test a device without a custom name, inferring name from structure. | async def test_device_name_from_structure(hass):
"""Test a device without a custom name, inferring name from structure."""
devices = {
"some-device-id": Device.MakeDevice(
{
"name": "some-device-id",
"type": THERMOSTAT_TYPE,
"traits": {
... | [
"async",
"def",
"test_device_name_from_structure",
"(",
"hass",
")",
":",
"devices",
"=",
"{",
"\"some-device-id\"",
":",
"Device",
".",
"MakeDevice",
"(",
"{",
"\"name\"",
":",
"\"some-device-id\"",
",",
"\"type\"",
":",
"THERMOSTAT_TYPE",
",",
"\"traits\"",
":",... | [
99,
0
] | [
122,
38
] | python | en | ['en', 'en', 'en'] | True |
test_event_updates_sensor | (hass) | Test a pubsub message received by subscriber to update temperature. | Test a pubsub message received by subscriber to update temperature. | async def test_event_updates_sensor(hass):
"""Test a pubsub message received by subscriber to update temperature."""
devices = {
"some-device-id": Device.MakeDevice(
{
"name": "some-device-id",
"type": THERMOSTAT_TYPE,
"traits": {
... | [
"async",
"def",
"test_event_updates_sensor",
"(",
"hass",
")",
":",
"devices",
"=",
"{",
"\"some-device-id\"",
":",
"Device",
".",
"MakeDevice",
"(",
"{",
"\"name\"",
":",
"\"some-device-id\"",
",",
"\"type\"",
":",
"THERMOSTAT_TYPE",
",",
"\"traits\"",
":",
"{"... | [
125,
0
] | [
171,
38
] | python | en | ['en', 'en', 'en'] | True |
test_device_with_unknown_type | (hass) | Test a device without a custom name, inferring name from structure. | Test a device without a custom name, inferring name from structure. | async def test_device_with_unknown_type(hass):
"""Test a device without a custom name, inferring name from structure."""
devices = {
"some-device-id": Device.MakeDevice(
{
"name": "some-device-id",
"type": "some-unknown-type",
"traits": {
... | [
"async",
"def",
"test_device_with_unknown_type",
"(",
"hass",
")",
":",
"devices",
"=",
"{",
"\"some-device-id\"",
":",
"Device",
".",
"MakeDevice",
"(",
"{",
"\"name\"",
":",
"\"some-device-id\"",
",",
"\"type\"",
":",
"\"some-unknown-type\"",
",",
"\"traits\"",
... | [
174,
0
] | [
209,
61
] | python | en | ['en', 'en', 'en'] | True |
async_init_integration | (
hass: HomeAssistant,
skip_setup: bool = False,
) | Set up the nexia integration in Home Assistant. | Set up the nexia integration in Home Assistant. | async def async_init_integration(
hass: HomeAssistant,
skip_setup: bool = False,
) -> MockConfigEntry:
"""Set up the nexia integration in Home Assistant."""
house_fixture = "nexia/mobile_houses_123456.json"
session_fixture = "nexia/session_123456.json"
sign_in_fixture = "nexia/sign_in.json"
... | [
"async",
"def",
"async_init_integration",
"(",
"hass",
":",
"HomeAssistant",
",",
"skip_setup",
":",
"bool",
"=",
"False",
",",
")",
"->",
"MockConfigEntry",
":",
"house_fixture",
"=",
"\"nexia/mobile_houses_123456.json\"",
"session_fixture",
"=",
"\"nexia/session_12345... | [
14,
0
] | [
45,
16
] | python | en | ['en', 'en', 'en'] | True |
velbus_entries | (hass: HomeAssistant) | Return connections for Velbus domain. | Return connections for Velbus domain. | def velbus_entries(hass: HomeAssistant):
"""Return connections for Velbus domain."""
return {
(entry.data[CONF_PORT]) for entry in hass.config_entries.async_entries(DOMAIN)
} | [
"def",
"velbus_entries",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"return",
"{",
"(",
"entry",
".",
"data",
"[",
"CONF_PORT",
"]",
")",
"for",
"entry",
"in",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
"}"
] | [
13,
0
] | [
17,
5
] | python | en | ['fr', 'en', 'en'] | True |
VelbusConfigFlow.__init__ | (self) | Initialize the velbus config flow. | Initialize the velbus config flow. | def __init__(self) -> None:
"""Initialize the velbus config flow."""
self._errors = {} | [
"def",
"__init__",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_errors",
"=",
"{",
"}"
] | [
26,
4
] | [
28,
25
] | python | en | ['en', 'en', 'en'] | True |
VelbusConfigFlow._create_device | (self, name: str, prt: str) | Create an entry async. | Create an entry async. | def _create_device(self, name: str, prt: str):
"""Create an entry async."""
return self.async_create_entry(title=name, data={CONF_PORT: prt}) | [
"def",
"_create_device",
"(",
"self",
",",
"name",
":",
"str",
",",
"prt",
":",
"str",
")",
":",
"return",
"self",
".",
"async_create_entry",
"(",
"title",
"=",
"name",
",",
"data",
"=",
"{",
"CONF_PORT",
":",
"prt",
"}",
")"
] | [
30,
4
] | [
32,
73
] | python | en | ['en', 'ga', 'en'] | True |
VelbusConfigFlow._test_connection | (self, prt) | Try to connect to the velbus with the port specified. | Try to connect to the velbus with the port specified. | def _test_connection(self, prt):
"""Try to connect to the velbus with the port specified."""
try:
controller = velbus.Controller(prt)
except Exception: # pylint: disable=broad-except
self._errors[CONF_PORT] = "cannot_connect"
return False
controller.s... | [
"def",
"_test_connection",
"(",
"self",
",",
"prt",
")",
":",
"try",
":",
"controller",
"=",
"velbus",
".",
"Controller",
"(",
"prt",
")",
"except",
"Exception",
":",
"# pylint: disable=broad-except",
"self",
".",
"_errors",
"[",
"CONF_PORT",
"]",
"=",
"\"ca... | [
34,
4
] | [
42,
19
] | python | en | ['en', 'en', 'en'] | True |
VelbusConfigFlow._prt_in_configuration_exists | (self, prt: str) | Return True if port exists in configuration. | Return True if port exists in configuration. | def _prt_in_configuration_exists(self, prt: str) -> bool:
"""Return True if port exists in configuration."""
if prt in velbus_entries(self.hass):
return True
return False | [
"def",
"_prt_in_configuration_exists",
"(",
"self",
",",
"prt",
":",
"str",
")",
"->",
"bool",
":",
"if",
"prt",
"in",
"velbus_entries",
"(",
"self",
".",
"hass",
")",
":",
"return",
"True",
"return",
"False"
] | [
44,
4
] | [
48,
20
] | python | en | ['en', 'en', 'en'] | True |
VelbusConfigFlow.async_step_user | (self, user_input=None) | Step when user initializes a integration. | Step when user initializes a integration. | async def async_step_user(self, user_input=None):
"""Step when user initializes a integration."""
self._errors = {}
if user_input is not None:
name = slugify(user_input[CONF_NAME])
prt = user_input[CONF_PORT]
if not self._prt_in_configuration_exists(prt):
... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"self",
".",
"_errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"name",
"=",
"slugify",
"(",
"user_input",
"[",
"CONF_NAME",
"]",
")",
"prt",... | [
50,
4
] | [
75,
9
] | python | en | ['en', 'en', 'en'] | True |
VelbusConfigFlow.async_step_import | (self, user_input=None) | Import a config entry. | Import a config entry. | async def async_step_import(self, user_input=None):
"""Import a config entry."""
user_input[CONF_NAME] = "Velbus Import"
prt = user_input[CONF_PORT]
if self._prt_in_configuration_exists(prt):
# if the velbus import is already in the config
# we should not proceed ... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"user_input",
"[",
"CONF_NAME",
"]",
"=",
"\"Velbus Import\"",
"prt",
"=",
"user_input",
"[",
"CONF_PORT",
"]",
"if",
"self",
".",
"_prt_in_configuration_exists",
"(",
... | [
77,
4
] | [
85,
53
] | python | en | ['en', 'en', 'en'] | True |
AbstractConfig.__init__ | (self, hass) | Initialize abstract config. | Initialize abstract config. | def __init__(self, hass):
"""Initialize abstract config."""
self.hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
")",
":",
"self",
".",
"hass",
"=",
"hass"
] | [
13,
4
] | [
15,
24
] | python | en | ['en', 'en', 'en'] | True |
AbstractConfig.supports_auth | (self) | Return if config supports auth. | Return if config supports auth. | def supports_auth(self):
"""Return if config supports auth."""
return False | [
"def",
"supports_auth",
"(",
"self",
")",
":",
"return",
"False"
] | [
18,
4
] | [
20,
20
] | python | en | ['en', 'en', 'en'] | True |
AbstractConfig.should_report_state | (self) | Return if states should be proactively reported. | Return if states should be proactively reported. | def should_report_state(self):
"""Return if states should be proactively reported."""
return False | [
"def",
"should_report_state",
"(",
"self",
")",
":",
"return",
"False"
] | [
23,
4
] | [
25,
20
] | python | en | ['en', 'en', 'en'] | True |
AbstractConfig.endpoint | (self) | Endpoint for report state. | Endpoint for report state. | def endpoint(self):
"""Endpoint for report state."""
return None | [
"def",
"endpoint",
"(",
"self",
")",
":",
"return",
"None"
] | [
28,
4
] | [
30,
19
] | python | en | ['en', 'en', 'en'] | True |
AbstractConfig.locale | (self) | Return config locale. | Return config locale. | def locale(self):
"""Return config locale.""" | [
"def",
"locale",
"(",
"self",
")",
":"
] | [
34,
4
] | [
35,
35
] | python | de | ['de', 'la', 'en'] | False |
AbstractConfig.entity_config | (self) | Return entity config. | Return entity config. | def entity_config(self):
"""Return entity config."""
return {} | [
"def",
"entity_config",
"(",
"self",
")",
":",
"return",
"{",
"}"
] | [
38,
4
] | [
40,
17
] | python | en | ['en', 'cy', 'en'] | True |
AbstractConfig.is_reporting_states | (self) | Return if proactive mode is enabled. | Return if proactive mode is enabled. | def is_reporting_states(self):
"""Return if proactive mode is enabled."""
return self._unsub_proactive_report is not None | [
"def",
"is_reporting_states",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unsub_proactive_report",
"is",
"not",
"None"
] | [
43,
4
] | [
45,
55
] | python | en | ['en', 'en', 'en'] | True |
AbstractConfig.async_enable_proactive_mode | (self) | Enable proactive mode. | Enable proactive mode. | async def async_enable_proactive_mode(self):
"""Enable proactive mode."""
if self._unsub_proactive_report is None:
self._unsub_proactive_report = self.hass.async_create_task(
async_enable_proactive_mode(self.hass, self)
)
try:
await self._unsub... | [
"async",
"def",
"async_enable_proactive_mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"_unsub_proactive_report",
"is",
"None",
":",
"self",
".",
"_unsub_proactive_report",
"=",
"self",
".",
"hass",
".",
"async_create_task",
"(",
"async_enable_proactive_mode",
"("... | [
47,
4
] | [
57,
17
] | python | en | ['fr', 'xh', 'en'] | False |
AbstractConfig.async_disable_proactive_mode | (self) | Disable proactive mode. | Disable proactive mode. | async def async_disable_proactive_mode(self):
"""Disable proactive mode."""
unsub_func = await self._unsub_proactive_report
if unsub_func:
unsub_func()
self._unsub_proactive_report = None | [
"async",
"def",
"async_disable_proactive_mode",
"(",
"self",
")",
":",
"unsub_func",
"=",
"await",
"self",
".",
"_unsub_proactive_report",
"if",
"unsub_func",
":",
"unsub_func",
"(",
")",
"self",
".",
"_unsub_proactive_report",
"=",
"None"
] | [
59,
4
] | [
64,
43
] | python | en | ['fr', 'en', 'en'] | True |
AbstractConfig.should_expose | (self, entity_id) | If an entity should be exposed. | If an entity should be exposed. | def should_expose(self, entity_id):
"""If an entity should be exposed."""
# pylint: disable=no-self-use
return False | [
"def",
"should_expose",
"(",
"self",
",",
"entity_id",
")",
":",
"# pylint: disable=no-self-use",
"return",
"False"
] | [
67,
4
] | [
70,
20
] | python | en | ['en', 'en', 'en'] | True |
AbstractConfig.async_invalidate_access_token | (self) | Invalidate access token. | Invalidate access token. | def async_invalidate_access_token(self):
"""Invalidate access token."""
raise NotImplementedError | [
"def",
"async_invalidate_access_token",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
73,
4
] | [
75,
33
] | python | en | ['en', 'fi', 'en'] | True |
AbstractConfig.async_get_access_token | (self) | Get an access token. | Get an access token. | async def async_get_access_token(self):
"""Get an access token."""
raise NotImplementedError | [
"async",
"def",
"async_get_access_token",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
77,
4
] | [
79,
33
] | python | en | ['en', 'lb', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.