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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
XiaomiAqaraFlowHandler.async_step_user | (self, user_input=None) | Handle a flow initialized by the user. | Handle a flow initialized by the user. | async def async_step_user(self, user_input=None):
"""Handle a flow initialized by the user."""
errors = {}
if user_input is None:
return self.async_show_form_step_user(errors)
self.interface = user_input[CONF_INTERFACE]
# allow optional manual setting of host and ma... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"None",
":",
"return",
"self",
".",
"async_show_form_step_user",
"(",
"errors",
")",
"self",
".",
"interface",
"=",... | [
69,
4
] | [
128,
53
] | python | en | ['en', 'en', 'en'] | True |
XiaomiAqaraFlowHandler.async_step_select | (self, user_input=None) | Handle multiple aqara gateways found. | Handle multiple aqara gateways found. | async def async_step_select(self, user_input=None):
"""Handle multiple aqara gateways found."""
errors = {}
if user_input is not None:
ip_adress = user_input["select_ip"]
self.selected_gateway = self.gateways[ip_adress]
self.sid = self.selected_gateway.sid
... | [
"async",
"def",
"async_step_select",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"ip_adress",
"=",
"user_input",
"[",
"\"select_ip\"",
"]",
"self",
".",
"selected_gateway",
"... | [
130,
4
] | [
149,
9
] | python | en | ['en', 'cy', 'en'] | True |
XiaomiAqaraFlowHandler.async_step_zeroconf | (self, discovery_info) | Handle zeroconf discovery. | Handle zeroconf discovery. | async def async_step_zeroconf(self, discovery_info):
"""Handle zeroconf discovery."""
name = discovery_info.get("name")
self.host = discovery_info.get("host")
mac_address = discovery_info.get("properties", {}).get("mac")
if not name or not self.host or not mac_address:
... | [
"async",
"def",
"async_step_zeroconf",
"(",
"self",
",",
"discovery_info",
")",
":",
"name",
"=",
"discovery_info",
".",
"get",
"(",
"\"name\"",
")",
"self",
".",
"host",
"=",
"discovery_info",
".",
"get",
"(",
"\"host\"",
")",
"mac_address",
"=",
"discovery... | [
151,
4
] | [
186,
43
] | python | de | ['de', 'sr', 'en'] | False |
XiaomiAqaraFlowHandler.async_step_settings | (self, user_input=None) | Specify settings and connect aqara gateway. | Specify settings and connect aqara gateway. | async def async_step_settings(self, user_input=None):
"""Specify settings and connect aqara gateway."""
errors = {}
if user_input is not None:
# get all required data
name = user_input[CONF_NAME]
key = user_input.get(CONF_KEY)
ip_adress = self.sele... | [
"async",
"def",
"async_step_settings",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"{",
"}",
"if",
"user_input",
"is",
"not",
"None",
":",
"# get all required data",
"name",
"=",
"user_input",
"[",
"CONF_NAME",
"]",
"key",
"=",
"u... | [
188,
4
] | [
232,
9
] | python | en | ['en', 'en', 'en'] | True |
mock_updater | () | Mock updater. | Mock updater. | def mock_updater():
"""Mock updater."""
with patch("homeassistant.components.updater.get_newest_version"):
yield | [
"def",
"mock_updater",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.updater.get_newest_version\"",
")",
":",
"yield"
] | [
16,
0
] | [
19,
13
] | python | en | ['en', 'nl', 'en'] | False |
recorder_url_mock | () | Mock recorder url. | Mock recorder url. | def recorder_url_mock():
"""Mock recorder url."""
with patch("homeassistant.components.recorder.DEFAULT_URL", "sqlite://"):
yield | [
"def",
"recorder_url_mock",
"(",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.recorder.DEFAULT_URL\"",
",",
"\"sqlite://\"",
")",
":",
"yield"
] | [
23,
0
] | [
26,
13
] | python | en | ['fr', 'sv', 'en'] | False |
test_setup | (hass, mock_zeroconf) | Test setup. | Test setup. | async def test_setup(hass, mock_zeroconf):
"""Test setup."""
assert await async_setup_component(hass, "default_config", {"foo": "bar"}) | [
"async",
"def",
"test_setup",
"(",
"hass",
",",
"mock_zeroconf",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"\"default_config\"",
",",
"{",
"\"foo\"",
":",
"\"bar\"",
"}",
")"
] | [
29,
0
] | [
31,
78
] | python | en | ['en', 'haw', 'en'] | False |
async_get_engine | (hass, config, discovery_info=None) | Set up Cloud speech component. | Set up Cloud speech component. | async def async_get_engine(hass, config, discovery_info=None):
"""Set up Cloud speech component."""
cloud: Cloud = hass.data[DOMAIN]
return CloudProvider(cloud) | [
"async",
"def",
"async_get_engine",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"cloud",
":",
"Cloud",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"return",
"CloudProvider",
"(",
"cloud",
")"
] | [
43,
0
] | [
47,
31
] | python | en | ['en', 'lb', 'en'] | True |
CloudProvider.__init__ | (self, cloud: Cloud) | Home Assistant NabuCasa Speech to text. | Home Assistant NabuCasa Speech to text. | def __init__(self, cloud: Cloud) -> None:
"""Home Assistant NabuCasa Speech to text."""
self.cloud = cloud | [
"def",
"__init__",
"(",
"self",
",",
"cloud",
":",
"Cloud",
")",
"->",
"None",
":",
"self",
".",
"cloud",
"=",
"cloud"
] | [
53,
4
] | [
55,
26
] | python | en | ['en', 'en', 'pt'] | True |
CloudProvider.supported_languages | (self) | Return a list of supported languages. | Return a list of supported languages. | def supported_languages(self) -> List[str]:
"""Return a list of supported languages."""
return SUPPORT_LANGUAGES | [
"def",
"supported_languages",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"SUPPORT_LANGUAGES"
] | [
58,
4
] | [
60,
32
] | python | en | ['en', 'en', 'en'] | True |
CloudProvider.supported_formats | (self) | Return a list of supported formats. | Return a list of supported formats. | def supported_formats(self) -> List[AudioFormats]:
"""Return a list of supported formats."""
return [AudioFormats.WAV, AudioFormats.OGG] | [
"def",
"supported_formats",
"(",
"self",
")",
"->",
"List",
"[",
"AudioFormats",
"]",
":",
"return",
"[",
"AudioFormats",
".",
"WAV",
",",
"AudioFormats",
".",
"OGG",
"]"
] | [
63,
4
] | [
65,
51
] | python | en | ['en', 'en', 'en'] | True |
CloudProvider.supported_codecs | (self) | Return a list of supported codecs. | Return a list of supported codecs. | def supported_codecs(self) -> List[AudioCodecs]:
"""Return a list of supported codecs."""
return [AudioCodecs.PCM, AudioCodecs.OPUS] | [
"def",
"supported_codecs",
"(",
"self",
")",
"->",
"List",
"[",
"AudioCodecs",
"]",
":",
"return",
"[",
"AudioCodecs",
".",
"PCM",
",",
"AudioCodecs",
".",
"OPUS",
"]"
] | [
68,
4
] | [
70,
50
] | python | en | ['en', 'en', 'en'] | True |
CloudProvider.supported_bit_rates | (self) | Return a list of supported bitrates. | Return a list of supported bitrates. | def supported_bit_rates(self) -> List[AudioBitRates]:
"""Return a list of supported bitrates."""
return [AudioBitRates.BITRATE_16] | [
"def",
"supported_bit_rates",
"(",
"self",
")",
"->",
"List",
"[",
"AudioBitRates",
"]",
":",
"return",
"[",
"AudioBitRates",
".",
"BITRATE_16",
"]"
] | [
73,
4
] | [
75,
41
] | python | en | ['en', 'en', 'en'] | True |
CloudProvider.supported_sample_rates | (self) | Return a list of supported samplerates. | Return a list of supported samplerates. | def supported_sample_rates(self) -> List[AudioSampleRates]:
"""Return a list of supported samplerates."""
return [AudioSampleRates.SAMPLERATE_16000] | [
"def",
"supported_sample_rates",
"(",
"self",
")",
"->",
"List",
"[",
"AudioSampleRates",
"]",
":",
"return",
"[",
"AudioSampleRates",
".",
"SAMPLERATE_16000",
"]"
] | [
78,
4
] | [
80,
50
] | python | en | ['en', 'en', 'en'] | True |
CloudProvider.supported_channels | (self) | Return a list of supported channels. | Return a list of supported channels. | def supported_channels(self) -> List[AudioChannels]:
"""Return a list of supported channels."""
return [AudioChannels.CHANNEL_MONO] | [
"def",
"supported_channels",
"(",
"self",
")",
"->",
"List",
"[",
"AudioChannels",
"]",
":",
"return",
"[",
"AudioChannels",
".",
"CHANNEL_MONO",
"]"
] | [
83,
4
] | [
85,
43
] | python | en | ['en', 'en', 'en'] | True |
CloudProvider.async_process_audio_stream | (
self, metadata: SpeechMetadata, stream: StreamReader
) | Process an audio stream to STT service. | Process an audio stream to STT service. | async def async_process_audio_stream(
self, metadata: SpeechMetadata, stream: StreamReader
) -> SpeechResult:
"""Process an audio stream to STT service."""
content = f"audio/{metadata.format!s}; codecs=audio/{metadata.codec!s}; samplerate=16000"
# Process STT
try:
... | [
"async",
"def",
"async_process_audio_stream",
"(",
"self",
",",
"metadata",
":",
"SpeechMetadata",
",",
"stream",
":",
"StreamReader",
")",
"->",
"SpeechResult",
":",
"content",
"=",
"f\"audio/{metadata.format!s}; codecs=audio/{metadata.codec!s}; samplerate=16000\"",
"# Proce... | [
87,
4
] | [
105,
9
] | python | en | ['en', 'lb', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Xiaomi TV platform. | Set up the Xiaomi TV platform. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Xiaomi TV platform."""
# If a hostname is set. Discovery is skipped.
host = config.get(CONF_HOST)
name = config.get(CONF_NAME)
if host is not None:
# Check if there's a valid TV at the IP address.
if... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"# If a hostname is set. Discovery is skipped.",
"host",
"=",
"config",
".",
"get",
"(",
"CONF_HOST",
")",
"name",
"=",
"config",
".",
"get",
... | [
30,
0
] | [
46,
83
] | python | en | ['en', 'lv', 'en'] | True |
XiaomiTV.__init__ | (self, ip, name) | Receive IP address and name to construct class. | Receive IP address and name to construct class. | def __init__(self, ip, name):
"""Receive IP address and name to construct class."""
# Initialize the Xiaomi TV.
self._tv = pymitv.TV(ip)
# Default name value, only to be overridden by user.
self._name = name
self._state = STATE_OFF | [
"def",
"__init__",
"(",
"self",
",",
"ip",
",",
"name",
")",
":",
"# Initialize the Xiaomi TV.",
"self",
".",
"_tv",
"=",
"pymitv",
".",
"TV",
"(",
"ip",
")",
"# Default name value, only to be overridden by user.",
"self",
".",
"_name",
"=",
"name",
"self",
".... | [
52,
4
] | [
59,
31
] | python | en | ['en', 'en', 'en'] | True |
XiaomiTV.name | (self) | Return the display name of this TV. | Return the display name of this TV. | def name(self):
"""Return the display name of this TV."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
62,
4
] | [
64,
25
] | python | en | ['en', 'en', 'en'] | True |
XiaomiTV.state | (self) | Return _state variable, containing the appropriate constant. | Return _state variable, containing the appropriate constant. | def state(self):
"""Return _state variable, containing the appropriate constant."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
67,
4
] | [
69,
26
] | python | en | ['en', 'en', 'en'] | True |
XiaomiTV.assumed_state | (self) | Indicate that state is assumed. | Indicate that state is assumed. | def assumed_state(self):
"""Indicate that state is assumed."""
return True | [
"def",
"assumed_state",
"(",
"self",
")",
":",
"return",
"True"
] | [
72,
4
] | [
74,
19
] | python | en | ['en', 'en', 'en'] | True |
XiaomiTV.supported_features | (self) | Flag media player features that are supported. | Flag media player features that are supported. | def supported_features(self):
"""Flag media player features that are supported."""
return SUPPORT_XIAOMI_TV | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"SUPPORT_XIAOMI_TV"
] | [
77,
4
] | [
79,
32
] | python | en | ['en', 'en', 'en'] | True |
XiaomiTV.turn_off | (self) |
Instruct the TV to turn sleep.
This is done instead of turning off,
because the TV won't accept any input when turned off. Thus, the user
would be unable to turn the TV back on, unless it's done manually.
|
Instruct the TV to turn sleep. | def turn_off(self):
"""
Instruct the TV to turn sleep.
This is done instead of turning off,
because the TV won't accept any input when turned off. Thus, the user
would be unable to turn the TV back on, unless it's done manually.
"""
if self._state != STATE_OFF:
... | [
"def",
"turn_off",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"!=",
"STATE_OFF",
":",
"self",
".",
"_tv",
".",
"sleep",
"(",
")",
"self",
".",
"_state",
"=",
"STATE_OFF"
] | [
81,
4
] | [
92,
35
] | python | en | ['en', 'error', 'th'] | False |
XiaomiTV.turn_on | (self) | Wake the TV back up from sleep. | Wake the TV back up from sleep. | def turn_on(self):
"""Wake the TV back up from sleep."""
if self._state != STATE_ON:
self._tv.wake()
self._state = STATE_ON | [
"def",
"turn_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"!=",
"STATE_ON",
":",
"self",
".",
"_tv",
".",
"wake",
"(",
")",
"self",
".",
"_state",
"=",
"STATE_ON"
] | [
94,
4
] | [
99,
34
] | python | en | ['en', 'en', 'en'] | True |
XiaomiTV.volume_up | (self) | Increase volume by one. | Increase volume by one. | def volume_up(self):
"""Increase volume by one."""
self._tv.volume_up() | [
"def",
"volume_up",
"(",
"self",
")",
":",
"self",
".",
"_tv",
".",
"volume_up",
"(",
")"
] | [
101,
4
] | [
103,
28
] | python | en | ['en', 'en', 'en'] | True |
XiaomiTV.volume_down | (self) | Decrease volume by one. | Decrease volume by one. | def volume_down(self):
"""Decrease volume by one."""
self._tv.volume_down() | [
"def",
"volume_down",
"(",
"self",
")",
":",
"self",
".",
"_tv",
".",
"volume_down",
"(",
")"
] | [
105,
4
] | [
107,
30
] | python | en | ['en', 'de', 'en'] | True |
VmSchedulingPipeline._aria2p_download | (self, is_force: bool = False) | Read from the text file which contains urls and use aria2p to download.
Args:
is_force (bool): Is force or not.
| Read from the text file which contains urls and use aria2p to download. | def _aria2p_download(self, is_force: bool = False) -> List[list]:
"""Read from the text file which contains urls and use aria2p to download.
Args:
is_force (bool): Is force or not.
"""
logger.info_green("Downloading vmtable and cpu readings.")
# Download parts of cpu... | [
"def",
"_aria2p_download",
"(",
"self",
",",
"is_force",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"list",
"]",
":",
"logger",
".",
"info_green",
"(",
"\"Downloading vmtable and cpu readings.\"",
")",
"# Download parts of cpu reading files.",
"num_files",
"... | [
86,
4
] | [
119,
44
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingPipeline._check_all_download_completed | (self) | Check all download tasks are completed and remove the ".aria2" files. | Check all download tasks are completed and remove the ".aria2" files. | def _check_all_download_completed(self):
"""Check all download tasks are completed and remove the ".aria2" files."""
while 1:
downloads = self.aria2.get_downloads()
if len(downloads) == 0:
logger.info_green("Doesn't exist any pending file.")
break... | [
"def",
"_check_all_download_completed",
"(",
"self",
")",
":",
"while",
"1",
":",
"downloads",
"=",
"self",
".",
"aria2",
".",
"get_downloads",
"(",
")",
"if",
"len",
"(",
"downloads",
")",
"==",
"0",
":",
"logger",
".",
"info_green",
"(",
"\"Doesn't exist... | [
121,
4
] | [
139,
26
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingPipeline.clean | (self) | Unzip the csv file and process it for building binary file. | Unzip the csv file and process it for building binary file. | def clean(self):
"""Unzip the csv file and process it for building binary file."""
super().clean()
self._new_folder_list.append(self._raw_folder)
os.makedirs(self._raw_folder, exist_ok=True)
logger.info_green("Cleaning VM data.")
# Unzip vmtable.
self._unzip_file... | [
"def",
"clean",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"clean",
"(",
")",
"self",
".",
"_new_folder_list",
".",
"append",
"(",
"self",
".",
"_raw_folder",
")",
"os",
".",
"makedirs",
"(",
"self",
".",
"_raw_folder",
",",
"exist_ok",
"=",
"Tru... | [
158,
4
] | [
173,
26
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingPipeline._process_vm_table | (self, raw_vm_table_file: str) | Process vmtable file. | Process vmtable file. | def _process_vm_table(self, raw_vm_table_file: str):
"""Process vmtable file."""
headers = [
'vmid', 'subscriptionid', 'deploymentid', 'vmcreated', 'vmdeleted', 'maxcpu', 'avgcpu', 'p95maxcpu',
'vmcategory', 'vmcorecountbucket', 'vmmemorybucket'
]
required_heade... | [
"def",
"_process_vm_table",
"(",
"self",
",",
"raw_vm_table_file",
":",
"str",
")",
":",
"headers",
"=",
"[",
"'vmid'",
",",
"'subscriptionid'",
",",
"'deploymentid'",
",",
"'vmcreated'",
",",
"'vmdeleted'",
",",
"'maxcpu'",
",",
"'avgcpu'",
",",
"'p95maxcpu'",
... | [
182,
4
] | [
234,
32
] | python | en | ['en', 'en', 'en'] | True |
VmSchedulingPipeline._convert_cpu_readings_id | (self, old_data_path: str, new_data_path: str, vm_id_map: dict) | Convert vmid in each cpu readings file. | Convert vmid in each cpu readings file. | def _convert_cpu_readings_id(self, old_data_path: str, new_data_path: str, vm_id_map: dict):
"""Convert vmid in each cpu readings file."""
with open(old_data_path, 'r') as f_in:
csv_reader = reader(f_in)
with open(new_data_path, 'w') as f_out:
csv_writer = writer(... | [
"def",
"_convert_cpu_readings_id",
"(",
"self",
",",
"old_data_path",
":",
"str",
",",
"new_data_path",
":",
"str",
",",
"vm_id_map",
":",
"dict",
")",
":",
"with",
"open",
"(",
"old_data_path",
",",
"'r'",
")",
"as",
"f_in",
":",
"csv_reader",
"=",
"reade... | [
236,
4
] | [
247,
52
] | python | en | ['en', 'af', 'en'] | True |
lock | (hass, zigpy_device_mock, zha_device_joined_restored) | Lock cluster fixture. | Lock cluster fixture. | async def lock(hass, zigpy_device_mock, zha_device_joined_restored):
"""Lock cluster fixture."""
zigpy_device = zigpy_device_mock(
{
1: {
"in_clusters": [closures.DoorLock.cluster_id, general.Basic.cluster_id],
"out_clusters": [],
"device_type... | [
"async",
"def",
"lock",
"(",
"hass",
",",
"zigpy_device_mock",
",",
"zha_device_joined_restored",
")",
":",
"zigpy_device",
"=",
"zigpy_device_mock",
"(",
"{",
"1",
":",
"{",
"\"in_clusters\"",
":",
"[",
"closures",
".",
"DoorLock",
".",
"cluster_id",
",",
"ge... | [
21,
0
] | [
35,
58
] | python | en | ['en', 'nl', 'en'] | True |
test_lock | (hass, lock) | Test zha lock platform. | Test zha lock platform. | async def test_lock(hass, lock):
"""Test zha lock platform."""
zha_device, cluster = lock
entity_id = await find_entity_id(DOMAIN, zha_device, hass)
assert entity_id is not None
assert hass.states.get(entity_id).state == STATE_UNLOCKED
await async_enable_traffic(hass, [zha_device], enabled=Fal... | [
"async",
"def",
"test_lock",
"(",
"hass",
",",
"lock",
")",
":",
"zha_device",
",",
"cluster",
"=",
"lock",
"entity_id",
"=",
"await",
"find_entity_id",
"(",
"DOMAIN",
",",
"zha_device",
",",
"hass",
")",
"assert",
"entity_id",
"is",
"not",
"None",
"assert... | [
38,
0
] | [
68,
48
] | python | cs | ['cs', 'de', 'pl'] | False |
async_lock | (hass, cluster, entity_id) | Test lock functionality from hass. | Test lock functionality from hass. | async def async_lock(hass, cluster, entity_id):
"""Test lock functionality from hass."""
with patch(
"zigpy.zcl.Cluster.request", return_value=mock_coro([zcl_f.Status.SUCCESS])
):
# lock via UI
await hass.services.async_call(
DOMAIN, "lock", {"entity_id": entity_id}, bloc... | [
"async",
"def",
"async_lock",
"(",
"hass",
",",
"cluster",
",",
"entity_id",
")",
":",
"with",
"patch",
"(",
"\"zigpy.zcl.Cluster.request\"",
",",
"return_value",
"=",
"mock_coro",
"(",
"[",
"zcl_f",
".",
"Status",
".",
"SUCCESS",
"]",
")",
")",
":",
"# lo... | [
71,
0
] | [
82,
59
] | python | en | ['en', 'en', 'en'] | True |
async_unlock | (hass, cluster, entity_id) | Test lock functionality from hass. | Test lock functionality from hass. | async def async_unlock(hass, cluster, entity_id):
"""Test lock functionality from hass."""
with patch(
"zigpy.zcl.Cluster.request", return_value=mock_coro([zcl_f.Status.SUCCESS])
):
# lock via UI
await hass.services.async_call(
DOMAIN, "unlock", {"entity_id": entity_id}, ... | [
"async",
"def",
"async_unlock",
"(",
"hass",
",",
"cluster",
",",
"entity_id",
")",
":",
"with",
"patch",
"(",
"\"zigpy.zcl.Cluster.request\"",
",",
"return_value",
"=",
"mock_coro",
"(",
"[",
"zcl_f",
".",
"Status",
".",
"SUCCESS",
"]",
")",
")",
":",
"# ... | [
85,
0
] | [
96,
61
] | python | en | ['en', 'en', 'en'] | True |
get_cert | (host, port) | Get the certificate for the host and port combination. | Get the certificate for the host and port combination. | def get_cert(host, port):
"""Get the certificate for the host and port combination."""
ctx = ssl.create_default_context()
address = (host, port)
with socket.create_connection(address, timeout=TIMEOUT) as sock:
with ctx.wrap_socket(sock, server_hostname=address[0]) as ssock:
# pylint ... | [
"def",
"get_cert",
"(",
"host",
",",
"port",
")",
":",
"ctx",
"=",
"ssl",
".",
"create_default_context",
"(",
")",
"address",
"=",
"(",
"host",
",",
"port",
")",
"with",
"socket",
".",
"create_connection",
"(",
"address",
",",
"timeout",
"=",
"TIMEOUT",
... | [
15,
0
] | [
23,
23
] | python | en | ['en', 'en', 'en'] | True |
get_cert_expiry_timestamp | (hass, hostname, port) | Return the certificate's expiration timestamp. | Return the certificate's expiration timestamp. | async def get_cert_expiry_timestamp(hass, hostname, port):
"""Return the certificate's expiration timestamp."""
try:
cert = await hass.async_add_executor_job(get_cert, hostname, port)
except socket.gaierror as err:
raise ResolveFailed(f"Cannot resolve hostname: {hostname}") from err
exce... | [
"async",
"def",
"get_cert_expiry_timestamp",
"(",
"hass",
",",
"hostname",
",",
"port",
")",
":",
"try",
":",
"cert",
"=",
"await",
"hass",
".",
"async_add_executor_job",
"(",
"get_cert",
",",
"hostname",
",",
"port",
")",
"except",
"socket",
".",
"gaierror"... | [
26,
0
] | [
46,
44
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass: HomeAssistant) | Set up local media source. | Set up local media source. | def async_setup(hass: HomeAssistant):
"""Set up local media source."""
source = LocalSource(hass)
hass.data[DOMAIN][DOMAIN] = source
hass.http.register_view(LocalMediaView(hass, source)) | [
"def",
"async_setup",
"(",
"hass",
":",
"HomeAssistant",
")",
":",
"source",
"=",
"LocalSource",
"(",
"hass",
")",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DOMAIN",
"]",
"=",
"source",
"hass",
".",
"http",
".",
"register_view",
"(",
"LocalMediaView... | [
19,
0
] | [
23,
57
] | python | en | ['en', 'en', 'en'] | True |
LocalSource.__init__ | (self, hass: HomeAssistant) | Initialize local source. | Initialize local source. | def __init__(self, hass: HomeAssistant):
"""Initialize local source."""
super().__init__(DOMAIN)
self.hass = hass | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"DOMAIN",
")",
"self",
".",
"hass",
"=",
"hass"
] | [
31,
4
] | [
34,
24
] | python | en | ['en', 'en', 'en'] | True |
LocalSource.async_full_path | (self, source_dir_id, location) | Return full path. | Return full path. | def async_full_path(self, source_dir_id, location) -> Path:
"""Return full path."""
return Path(self.hass.config.media_dirs[source_dir_id], location) | [
"def",
"async_full_path",
"(",
"self",
",",
"source_dir_id",
",",
"location",
")",
"->",
"Path",
":",
"return",
"Path",
"(",
"self",
".",
"hass",
".",
"config",
".",
"media_dirs",
"[",
"source_dir_id",
"]",
",",
"location",
")"
] | [
37,
4
] | [
39,
73
] | python | en | ['en', 'ig', 'en'] | True |
LocalSource.async_parse_identifier | (self, item: MediaSourceItem) | Parse identifier. | Parse identifier. | def async_parse_identifier(self, item: MediaSourceItem) -> Tuple[str, str]:
"""Parse identifier."""
if not item.identifier:
# Empty source_dir_id and location
return "", ""
source_dir_id, location = item.identifier.split("/", 1)
if source_dir_id not in self.hass.... | [
"def",
"async_parse_identifier",
"(",
"self",
",",
"item",
":",
"MediaSourceItem",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"if",
"not",
"item",
".",
"identifier",
":",
"# Empty source_dir_id and location",
"return",
"\"\"",
",",
"\"\"",
"source_d... | [
42,
4
] | [
55,
38
] | python | de | ['en', 'de', 'hi'] | False |
LocalSource.async_resolve_media | (self, item: MediaSourceItem) | Resolve media to a url. | Resolve media to a url. | async def async_resolve_media(self, item: MediaSourceItem) -> str:
"""Resolve media to a url."""
source_dir_id, location = self.async_parse_identifier(item)
if source_dir_id == "" or source_dir_id not in self.hass.config.media_dirs:
raise Unresolvable("Unknown source directory.")
... | [
"async",
"def",
"async_resolve_media",
"(",
"self",
",",
"item",
":",
"MediaSourceItem",
")",
"->",
"str",
":",
"source_dir_id",
",",
"location",
"=",
"self",
".",
"async_parse_identifier",
"(",
"item",
")",
"if",
"source_dir_id",
"==",
"\"\"",
"or",
"source_d... | [
57,
4
] | [
66,
64
] | python | en | ['en', 'en', 'en'] | True |
LocalSource.async_browse_media | (
self, item: MediaSourceItem, media_types: Tuple[str] = MEDIA_MIME_TYPES
) | Return media. | Return media. | async def async_browse_media(
self, item: MediaSourceItem, media_types: Tuple[str] = MEDIA_MIME_TYPES
) -> BrowseMediaSource:
"""Return media."""
try:
source_dir_id, location = self.async_parse_identifier(item)
except Unresolvable as err:
raise BrowseError(str... | [
"async",
"def",
"async_browse_media",
"(",
"self",
",",
"item",
":",
"MediaSourceItem",
",",
"media_types",
":",
"Tuple",
"[",
"str",
"]",
"=",
"MEDIA_MIME_TYPES",
")",
"->",
"BrowseMediaSource",
":",
"try",
":",
"source_dir_id",
",",
"location",
"=",
"self",
... | [
68,
4
] | [
79,
9
] | python | en | ['en', 'no', 'en'] | False |
LocalSource._browse_media | (self, source_dir_id: str, location: Path) | Browse media. | Browse media. | def _browse_media(self, source_dir_id: str, location: Path):
"""Browse media."""
# If only one media dir is configured, use that as the local media root
if source_dir_id == "" and len(self.hass.config.media_dirs) == 1:
source_dir_id = list(self.hass.config.media_dirs)[0]
# ... | [
"def",
"_browse_media",
"(",
"self",
",",
"source_dir_id",
":",
"str",
",",
"location",
":",
"Path",
")",
":",
"# If only one media dir is configured, use that as the local media root",
"if",
"source_dir_id",
"==",
"\"\"",
"and",
"len",
"(",
"self",
".",
"hass",
"."... | [
81,
4
] | [
121,
66
] | python | en | ['en', 'en', 'en'] | False |
LocalMediaView.__init__ | (self, hass: HomeAssistant, source: LocalSource) | Initialize the media view. | Initialize the media view. | def __init__(self, hass: HomeAssistant, source: LocalSource):
"""Initialize the media view."""
self.hass = hass
self.source = source | [
"def",
"__init__",
"(",
"self",
",",
"hass",
":",
"HomeAssistant",
",",
"source",
":",
"LocalSource",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"source",
"=",
"source"
] | [
182,
4
] | [
185,
28
] | python | en | ['en', 'en', 'en'] | True |
LocalMediaView.get | (
self, request: web.Request, source_dir_id: str, location: str
) | Start a GET request. | Start a GET request. | async def get(
self, request: web.Request, source_dir_id: str, location: str
) -> web.FileResponse:
"""Start a GET request."""
if location != sanitize_path(location):
raise web.HTTPNotFound()
if source_dir_id not in self.hass.config.media_dirs:
raise web.HTTP... | [
"async",
"def",
"get",
"(",
"self",
",",
"request",
":",
"web",
".",
"Request",
",",
"source_dir_id",
":",
"str",
",",
"location",
":",
"str",
")",
"->",
"web",
".",
"FileResponse",
":",
"if",
"location",
"!=",
"sanitize_path",
"(",
"location",
")",
":... | [
187,
4
] | [
208,
43
] | python | en | ['en', 'lb', 'en'] | True |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up AdvantageAir toggle platform. | Set up AdvantageAir toggle platform. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up AdvantageAir toggle platform."""
instance = hass.data[ADVANTAGE_AIR_DOMAIN][config_entry.entry_id]
entities = []
for ac_key, ac_device in instance["coordinator"].data["aircons"].items():
if ac_device["info"]["freshA... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"instance",
"=",
"hass",
".",
"data",
"[",
"ADVANTAGE_AIR_DOMAIN",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"entities",
"=",
"[",
"]",
"for",
"... | [
12,
0
] | [
21,
32
] | python | en | ['en', 'lv', 'en'] | True |
AdvantageAirFreshAir.name | (self) | Return the name. | Return the name. | def name(self):
"""Return the name."""
return f'{self._ac["name"]} Fresh Air' | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"f'{self._ac[\"name\"]} Fresh Air'"
] | [
28,
4
] | [
30,
46
] | python | en | ['en', 'ig', 'en'] | True |
AdvantageAirFreshAir.unique_id | (self) | Return a unique id. | Return a unique id. | def unique_id(self):
"""Return a unique id."""
return f'{self.coordinator.data["system"]["rid"]}-{self.ac_key}-freshair' | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"f'{self.coordinator.data[\"system\"][\"rid\"]}-{self.ac_key}-freshair'"
] | [
33,
4
] | [
35,
81
] | python | ca | ['fr', 'ca', 'en'] | False |
AdvantageAirFreshAir.is_on | (self) | Return the fresh air status. | Return the fresh air status. | def is_on(self):
"""Return the fresh air status."""
return self._ac["freshAirStatus"] == ADVANTAGE_AIR_STATE_ON | [
"def",
"is_on",
"(",
"self",
")",
":",
"return",
"self",
".",
"_ac",
"[",
"\"freshAirStatus\"",
"]",
"==",
"ADVANTAGE_AIR_STATE_ON"
] | [
38,
4
] | [
40,
67
] | python | en | ['en', 'hi-Latn', 'en'] | True |
AdvantageAirFreshAir.icon | (self) | Return a representative icon of the fresh air switch. | Return a representative icon of the fresh air switch. | def icon(self):
"""Return a representative icon of the fresh air switch."""
return "mdi:air-filter" | [
"def",
"icon",
"(",
"self",
")",
":",
"return",
"\"mdi:air-filter\""
] | [
43,
4
] | [
45,
31
] | python | en | ['en', 'en', 'en'] | True |
AdvantageAirFreshAir.async_turn_on | (self, **kwargs) | Turn fresh air on. | Turn fresh air on. | async def async_turn_on(self, **kwargs):
"""Turn fresh air on."""
await self.async_change(
{self.ac_key: {"info": {"freshAirStatus": ADVANTAGE_AIR_STATE_ON}}}
) | [
"async",
"def",
"async_turn_on",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"async_change",
"(",
"{",
"self",
".",
"ac_key",
":",
"{",
"\"info\"",
":",
"{",
"\"freshAirStatus\"",
":",
"ADVANTAGE_AIR_STATE_ON",
"}",
"}",
"}",
")... | [
47,
4
] | [
51,
9
] | python | en | ['ga', 'gd', 'en'] | False |
AdvantageAirFreshAir.async_turn_off | (self, **kwargs) | Turn fresh air off. | Turn fresh air off. | async def async_turn_off(self, **kwargs):
"""Turn fresh air off."""
await self.async_change(
{self.ac_key: {"info": {"freshAirStatus": ADVANTAGE_AIR_STATE_OFF}}}
) | [
"async",
"def",
"async_turn_off",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"await",
"self",
".",
"async_change",
"(",
"{",
"self",
".",
"ac_key",
":",
"{",
"\"info\"",
":",
"{",
"\"freshAirStatus\"",
":",
"ADVANTAGE_AIR_STATE_OFF",
"}",
"}",
"}",
... | [
53,
4
] | [
57,
9
] | python | en | ['en', 'gd', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Fibaro covers. | Set up the Fibaro covers. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Fibaro covers."""
if discovery_info is None:
return
add_entities(
[FibaroCover(device) for device in hass.data[FIBARO_DEVICES]["cover"]], True
) | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"discovery_info",
"is",
"None",
":",
"return",
"add_entities",
"(",
"[",
"FibaroCover",
"(",
"device",
")",
"for",
"device",
"in",
... | [
11,
0
] | [
18,
5
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.__init__ | (self, fibaro_device) | Initialize the Vera device. | Initialize the Vera device. | def __init__(self, fibaro_device):
"""Initialize the Vera device."""
super().__init__(fibaro_device)
self.entity_id = f"{DOMAIN}.{self.ha_id}" | [
"def",
"__init__",
"(",
"self",
",",
"fibaro_device",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"fibaro_device",
")",
"self",
".",
"entity_id",
"=",
"f\"{DOMAIN}.{self.ha_id}\""
] | [
24,
4
] | [
27,
49
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.bound | (position) | Normalize the position. | Normalize the position. | def bound(position):
"""Normalize the position."""
if position is None:
return None
position = int(position)
if position <= 5:
return 0
if position >= 95:
return 100
return position | [
"def",
"bound",
"(",
"position",
")",
":",
"if",
"position",
"is",
"None",
":",
"return",
"None",
"position",
"=",
"int",
"(",
"position",
")",
"if",
"position",
"<=",
"5",
":",
"return",
"0",
"if",
"position",
">=",
"95",
":",
"return",
"100",
"retu... | [
30,
4
] | [
39,
23
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.current_cover_position | (self) | Return current position of cover. 0 is closed, 100 is open. | Return current position of cover. 0 is closed, 100 is open. | def current_cover_position(self):
"""Return current position of cover. 0 is closed, 100 is open."""
return self.bound(self.level) | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"bound",
"(",
"self",
".",
"level",
")"
] | [
42,
4
] | [
44,
37
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.current_cover_tilt_position | (self) | Return the current tilt position for venetian blinds. | Return the current tilt position for venetian blinds. | def current_cover_tilt_position(self):
"""Return the current tilt position for venetian blinds."""
return self.bound(self.level2) | [
"def",
"current_cover_tilt_position",
"(",
"self",
")",
":",
"return",
"self",
".",
"bound",
"(",
"self",
".",
"level2",
")"
] | [
47,
4
] | [
49,
38
] | python | en | ['en', 'no', 'en'] | True |
FibaroCover.set_cover_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
self.set_level(kwargs.get(ATTR_POSITION)) | [
"def",
"set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"set_level",
"(",
"kwargs",
".",
"get",
"(",
"ATTR_POSITION",
")",
")"
] | [
51,
4
] | [
53,
49
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.set_cover_tilt_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | def set_cover_tilt_position(self, **kwargs):
"""Move the cover to a specific position."""
self.set_level2(kwargs.get(ATTR_TILT_POSITION)) | [
"def",
"set_cover_tilt_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"set_level2",
"(",
"kwargs",
".",
"get",
"(",
"ATTR_TILT_POSITION",
")",
")"
] | [
55,
4
] | [
57,
55
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.is_closed | (self) | Return if the cover is closed. | Return if the cover is closed. | def is_closed(self):
"""Return if the cover is closed."""
if self.current_cover_position is None:
return None
return self.current_cover_position == 0 | [
"def",
"is_closed",
"(",
"self",
")",
":",
"if",
"self",
".",
"current_cover_position",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"current_cover_position",
"==",
"0"
] | [
60,
4
] | [
64,
47
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.open_cover | (self, **kwargs) | Open the cover. | Open the cover. | def open_cover(self, **kwargs):
"""Open the cover."""
self.action("open") | [
"def",
"open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"action",
"(",
"\"open\"",
")"
] | [
66,
4
] | [
68,
27
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.close_cover | (self, **kwargs) | Close the cover. | Close the cover. | def close_cover(self, **kwargs):
"""Close the cover."""
self.action("close") | [
"def",
"close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"action",
"(",
"\"close\"",
")"
] | [
70,
4
] | [
72,
28
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.open_cover_tilt | (self, **kwargs) | Open the cover tilt. | Open the cover tilt. | def open_cover_tilt(self, **kwargs):
"""Open the cover tilt."""
self.set_level2(100) | [
"def",
"open_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"set_level2",
"(",
"100",
")"
] | [
74,
4
] | [
76,
28
] | python | en | ['en', 'no', 'en'] | True |
FibaroCover.close_cover_tilt | (self, **kwargs) | Close the cover. | Close the cover. | def close_cover_tilt(self, **kwargs):
"""Close the cover."""
self.set_level2(0) | [
"def",
"close_cover_tilt",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"set_level2",
"(",
"0",
")"
] | [
78,
4
] | [
80,
26
] | python | en | ['en', 'en', 'en'] | True |
FibaroCover.stop_cover | (self, **kwargs) | Stop the cover. | Stop the cover. | def stop_cover(self, **kwargs):
"""Stop the cover."""
self.action("stop") | [
"def",
"stop_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"action",
"(",
"\"stop\"",
")"
] | [
82,
4
] | [
84,
27
] | python | en | ['en', 'en', 'en'] | True |
reshape_break_channel_dependency | (op_node) |
The reshape operations such as (reshape, view, flatten) may break
the channel dependency. We need to check the input parameters of
these reshape operations to check if this reshape node will break
the channel dependency. However, it's complicated to analyze the the input
parameters for each reshape... |
The reshape operations such as (reshape, view, flatten) may break
the channel dependency. We need to check the input parameters of
these reshape operations to check if this reshape node will break
the channel dependency. However, it's complicated to analyze the the input
parameters for each reshape... | def reshape_break_channel_dependency(op_node):
"""
The reshape operations such as (reshape, view, flatten) may break
the channel dependency. We need to check the input parameters of
these reshape operations to check if this reshape node will break
the channel dependency. However, it's complicated to... | [
"def",
"reshape_break_channel_dependency",
"(",
"op_node",
")",
":",
"in_shape",
"=",
"op_node",
".",
"auxiliary",
"[",
"'in_shape'",
"]",
"out_shape",
"=",
"op_node",
".",
"auxiliary",
"[",
"'out_shape'",
"]",
"in_channel",
"=",
"in_shape",
"[",
"1",
"]",
"ou... | [
192,
0
] | [
218,
36
] | python | en | ['en', 'error', 'th'] | False |
Dependency.__init__ | (self, model=None, dummy_input=None, traced_model=None) |
Build the graph for the model.
|
Build the graph for the model.
| def __init__(self, model=None, dummy_input=None, traced_model=None):
"""
Build the graph for the model.
"""
from nni.common.graph_utils import TorchModuleGraph
# check if the input is legal
if traced_model is None:
# user should provide model & dummy_input to... | [
"def",
"__init__",
"(",
"self",
",",
"model",
"=",
"None",
",",
"dummy_input",
"=",
"None",
",",
"traced_model",
"=",
"None",
")",
":",
"from",
"nni",
".",
"common",
".",
"graph_utils",
"import",
"TorchModuleGraph",
"# check if the input is legal",
"if",
"trac... | [
18,
4
] | [
31,
31
] | python | en | ['en', 'error', 'th'] | False |
ChannelDependency.__init__ | (self, model=None, dummy_input=None, traced_model=None) |
This model analyze the channel dependencies between the conv
layers in a model.
Parameters
----------
model : torch.nn.Module
The model to be analyzed.
data : torch.Tensor
The example input data to trace the network architecture.
traced_m... |
This model analyze the channel dependencies between the conv
layers in a model. | def __init__(self, model=None, dummy_input=None, traced_model=None):
"""
This model analyze the channel dependencies between the conv
layers in a model.
Parameters
----------
model : torch.nn.Module
The model to be analyzed.
data : torch.Tensor
... | [
"def",
"__init__",
"(",
"self",
",",
"model",
"=",
"None",
",",
"dummy_input",
"=",
"None",
",",
"traced_model",
"=",
"None",
")",
":",
"super",
"(",
"ChannelDependency",
",",
"self",
")",
".",
"__init__",
"(",
"model",
",",
"dummy_input",
",",
"traced_m... | [
41,
4
] | [
57,
45
] | python | en | ['en', 'error', 'th'] | False |
ChannelDependency._get_parent_layers | (self, node) |
Find the nearest father conv layers for the target node.
Parameters
---------
node : torch._C.Node
target node.
Returns
-------
parent_layers: list
nearest father conv/linear layers for the target worknode.
|
Find the nearest father conv layers for the target node. | def _get_parent_layers(self, node):
"""
Find the nearest father conv layers for the target node.
Parameters
---------
node : torch._C.Node
target node.
Returns
-------
parent_layers: list
nearest father conv/linear layers for the ... | [
"def",
"_get_parent_layers",
"(",
"self",
",",
"node",
")",
":",
"parent_layers",
"=",
"[",
"]",
"queue",
"=",
"[",
"]",
"queue",
".",
"append",
"(",
"node",
")",
"while",
"queue",
":",
"curnode",
"=",
"queue",
".",
"pop",
"(",
"0",
")",
"if",
"cur... | [
59,
4
] | [
86,
28
] | python | en | ['en', 'error', 'th'] | False |
ChannelDependency.build_dependency | (self) |
Build the channel dependency for the conv layers
in the model.
|
Build the channel dependency for the conv layers
in the model.
| def build_dependency(self):
"""
Build the channel dependency for the conv layers
in the model.
"""
# unpack the tuple/list manually before analyze the
# channel dependency
self.graph.unpack_manually()
for node in self.graph.nodes_py.nodes_op:
p... | [
"def",
"build_dependency",
"(",
"self",
")",
":",
"# unpack the tuple/list manually before analyze the",
"# channel dependency",
"self",
".",
"graph",
".",
"unpack_manually",
"(",
")",
"for",
"node",
"in",
"self",
".",
"graph",
".",
"nodes_py",
".",
"nodes_op",
":",... | [
88,
4
] | [
124,
55
] | python | en | ['en', 'error', 'th'] | False |
ChannelDependency.export | (self, filepath) |
export the channel dependencies as a csv file.
The layers at the same line have output channel
dependencies with each other. For example,
layer1.1.conv2, conv1, and layer1.0.conv2 have
output channel dependencies with each other, which
means the output channel(filters) n... |
export the channel dependencies as a csv file.
The layers at the same line have output channel
dependencies with each other. For example,
layer1.1.conv2, conv1, and layer1.0.conv2 have
output channel dependencies with each other, which
means the output channel(filters) n... | def export(self, filepath):
"""
export the channel dependencies as a csv file.
The layers at the same line have output channel
dependencies with each other. For example,
layer1.1.conv2, conv1, and layer1.0.conv2 have
output channel dependencies with each other, which
... | [
"def",
"export",
"(",
"self",
",",
"filepath",
")",
":",
"header",
"=",
"[",
"'Dependency Set'",
",",
"'Layers'",
"]",
"setid",
"=",
"0",
"visited",
"=",
"set",
"(",
")",
"with",
"open",
"(",
"filepath",
",",
"'w'",
")",
"as",
"csvf",
":",
"csv_w",
... | [
126,
4
] | [
161,
35
] | python | en | ['en', 'error', 'th'] | False |
ChannelDependency.dependency_sets | (self) |
Get the list of the dependency set.
Returns
-------
dependency_sets : list
list of the dependency sets. For example,
[set(['conv1', 'conv2']), set(['conv3', 'conv4'])]
|
Get the list of the dependency set. | def dependency_sets(self):
"""
Get the list of the dependency set.
Returns
-------
dependency_sets : list
list of the dependency sets. For example,
[set(['conv1', 'conv2']), set(['conv3', 'conv4'])]
"""
d_sets = []
visited = set()... | [
"def",
"dependency_sets",
"(",
"self",
")",
":",
"d_sets",
"=",
"[",
"]",
"visited",
"=",
"set",
"(",
")",
"for",
"node",
"in",
"self",
".",
"graph",
".",
"nodes_py",
".",
"nodes_op",
":",
"if",
"node",
".",
"op_type",
"!=",
"'Conv2d'",
"or",
"node",... | [
164,
4
] | [
189,
21
] | python | en | ['en', 'error', 'th'] | False |
InputChannelDependency.__init__ | (self, model, dummy_input=None, traced_model=None) |
This model analyze the input channel dependencies between the conv
layers in a model.
Parameters
----------
model : torch.nn.Module
The model to be analyzed.
data : torch.Tensor
The example input data to trace the network architecture.
tr... |
This model analyze the input channel dependencies between the conv
layers in a model. | def __init__(self, model, dummy_input=None, traced_model=None):
"""
This model analyze the input channel dependencies between the conv
layers in a model.
Parameters
----------
model : torch.nn.Module
The model to be analyzed.
data : torch.Tensor
... | [
"def",
"__init__",
"(",
"self",
",",
"model",
",",
"dummy_input",
"=",
"None",
",",
"traced_model",
"=",
"None",
")",
":",
"super",
"(",
"InputChannelDependency",
",",
"self",
")",
".",
"__init__",
"(",
"model",
",",
"dummy_input",
",",
"traced_model",
")"... | [
235,
4
] | [
251,
45
] | python | en | ['en', 'error', 'th'] | False |
InputChannelDependency.build_dependency | (self) |
Build the input channel dependencies.
The `InputChannelDependency` indicates the layers that have
dependencies when pruning the input channel of the conv layers.
In contrast, `ChannelDependency` indicates the dependent layers
when pruning the output channles of conv layers (for ... |
Build the input channel dependencies.
The `InputChannelDependency` indicates the layers that have
dependencies when pruning the input channel of the conv layers.
In contrast, `ChannelDependency` indicates the dependent layers
when pruning the output channles of conv layers (for ... | def build_dependency(self):
"""
Build the input channel dependencies.
The `InputChannelDependency` indicates the layers that have
dependencies when pruning the input channel of the conv layers.
In contrast, `ChannelDependency` indicates the dependent layers
when pruning t... | [
"def",
"build_dependency",
"(",
"self",
")",
":",
"# unpack the tuple or list manually",
"self",
".",
"graph",
".",
"unpack_manually",
"(",
")",
"for",
"tensor",
"in",
"self",
".",
"graph",
".",
"input_to_node",
":",
"# start from this tensor, find all the conv layers t... | [
274,
4
] | [
294,
55
] | python | en | ['en', 'error', 'th'] | False |
CatPaddingDependency.build_dependency | (self) |
Build the cat padding dependencies.
If the output features of several layers are stitched together
by cat operation, then these layers have cat padding dependencies.
This is because when inferring the cat mask, we need all the input
masks for the cat operation. At this time we n... |
Build the cat padding dependencies.
If the output features of several layers are stitched together
by cat operation, then these layers have cat padding dependencies.
This is because when inferring the cat mask, we need all the input
masks for the cat operation. At this time we n... | def build_dependency(self):
"""
Build the cat padding dependencies.
If the output features of several layers are stitched together
by cat operation, then these layers have cat padding dependencies.
This is because when inferring the cat mask, we need all the input
masks f... | [
"def",
"build_dependency",
"(",
"self",
")",
":",
"for",
"node",
"in",
"self",
".",
"graph",
".",
"nodes_py",
".",
"nodes_op",
":",
"parent_layers",
"=",
"[",
"]",
"if",
"node",
".",
"op_type",
"==",
"CAT_TYPE",
":",
"parent_layers",
"=",
"self",
".",
... | [
302,
4
] | [
322,
59
] | python | en | ['en', 'error', 'th'] | False |
CatPaddingDependency.export | (self, filepath) |
Export the dependencies into a file.
In the output file, each line contains a set of layers
whose output features are stitched together by the cat
operation.
output example:
Dependency Set, Layers
set1, Conv1, Conv2
set2, Conv3, Conv4
|
Export the dependencies into a file.
In the output file, each line contains a set of layers
whose output features are stitched together by the cat
operation. | def export(self, filepath):
"""
Export the dependencies into a file.
In the output file, each line contains a set of layers
whose output features are stitched together by the cat
operation.
output example:
Dependency Set, Layers
set1, Conv1, Conv2
... | [
"def",
"export",
"(",
"self",
",",
"filepath",
")",
":",
"header",
"=",
"[",
"'Dependency Set'",
",",
"'Layers'",
"]",
"setid",
"=",
"0",
"with",
"open",
"(",
"filepath",
",",
"'w'",
")",
"as",
"csvf",
":",
"csv_w",
"=",
"csv",
".",
"writer",
"(",
... | [
334,
4
] | [
355,
35
] | python | en | ['en', 'error', 'th'] | False |
GroupDependency.__init__ | (self, model=None, dummy_input=None, traced_model=None) |
This model analyze the group dependencis between the conv
layers in a model.
Parameters
----------
model : torch.nn.Module
The model to be analyzed.
data : torch.Tensor
The example input data to trace the network architecture.
traced_mode... |
This model analyze the group dependencis between the conv
layers in a model. | def __init__(self, model=None, dummy_input=None, traced_model=None):
"""
This model analyze the group dependencis between the conv
layers in a model.
Parameters
----------
model : torch.nn.Module
The model to be analyzed.
data : torch.Tensor
... | [
"def",
"__init__",
"(",
"self",
",",
"model",
"=",
"None",
",",
"dummy_input",
"=",
"None",
",",
"traced_model",
"=",
"None",
")",
":",
"super",
"(",
"GroupDependency",
",",
"self",
")",
".",
"__init__",
"(",
"model",
",",
"dummy_input",
",",
"traced_mod... | [
359,
4
] | [
374,
79
] | python | en | ['en', 'error', 'th'] | False |
GroupDependency._get_parent_convs | (self, node) |
Find the nearest father conv layers for the target node.
Parameters
---------
node : torch._C.Node
target node.
Returns
-------
parent_layers : list
nearest father conv layers for the target node. Due to the group
dependency ... |
Find the nearest father conv layers for the target node. | def _get_parent_convs(self, node):
"""
Find the nearest father conv layers for the target node.
Parameters
---------
node : torch._C.Node
target node.
Returns
-------
parent_layers : list
nearest father conv layers for the target ... | [
"def",
"_get_parent_convs",
"(",
"self",
",",
"node",
")",
":",
"parent_layers",
"=",
"[",
"]",
"# the input node is a Conv node",
"predeessors",
"=",
"self",
".",
"graph",
".",
"find_predecessors",
"(",
"node",
".",
"unique_name",
")",
"predeessors",
"=",
"[",
... | [
376,
4
] | [
407,
28
] | python | en | ['en', 'error', 'th'] | False |
GroupDependency._get_conv_groups | (self, node_group) |
Get the number of groups for a convolutional layer.
Parameters
----------
node_group : NodePyGroup
target node.
Returns
-------
group : int
the number of the groups of the target conv layer.
|
Get the number of groups for a convolutional layer. | def _get_conv_groups(self, node_group):
"""
Get the number of groups for a convolutional layer.
Parameters
----------
node_group : NodePyGroup
target node.
Returns
-------
group : int
the number of the groups of the target conv la... | [
"def",
"_get_conv_groups",
"(",
"self",
",",
"node_group",
")",
":",
"cpp_conv",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"kind",
"(",
")",
"==",
"CONV_TYPE",
",",
"node_group",
".",
"node_cpps",
")",
")",
"assert",
"len",
"(",
... | [
409,
4
] | [
430,
20
] | python | en | ['en', 'error', 'th'] | False |
GroupDependency.build_dependency | (self) |
Build the channel dependency for the conv layers
in the model. This function return the group number
of each conv layers. Note that, here, the group count
of conv layers may be larger than their originl groups.
This is because that the input channel will also be grouped
... |
Build the channel dependency for the conv layers
in the model. This function return the group number
of each conv layers. Note that, here, the group count
of conv layers may be larger than their originl groups.
This is because that the input channel will also be grouped
... | def build_dependency(self):
"""
Build the channel dependency for the conv layers
in the model. This function return the group number
of each conv layers. Note that, here, the group count
of conv layers may be larger than their originl groups.
This is because that the inpu... | [
"def",
"build_dependency",
"(",
"self",
")",
":",
"for",
"node",
"in",
"self",
".",
"graph",
".",
"nodes_py",
".",
"nodes_op",
":",
"if",
"node",
".",
"op_type",
"==",
"'Conv2d'",
"or",
"node",
".",
"op_type",
"==",
"'ConvTranspose2d'",
":",
"group",
"="... | [
432,
4
] | [
474,
30
] | python | en | ['en', 'error', 'th'] | False |
GroupDependency.export | (self, filepath) |
export the group dependency to a csv file.
Each line describes a convolution layer, the
first part of each line is the Pytorch module
name of the conv layer. The second part of each
line is the group count of the filters in this layer.
Note that, the group count may be l... |
export the group dependency to a csv file.
Each line describes a convolution layer, the
first part of each line is the Pytorch module
name of the conv layer. The second part of each
line is the group count of the filters in this layer.
Note that, the group count may be l... | def export(self, filepath):
"""
export the group dependency to a csv file.
Each line describes a convolution layer, the
first part of each line is the Pytorch module
name of the conv layer. The second part of each
line is the group count of the filters in this layer.
... | [
"def",
"export",
"(",
"self",
",",
"filepath",
")",
":",
"header",
"=",
"[",
"'Conv Layer Name'",
",",
"'Group'",
"]",
"with",
"open",
"(",
"filepath",
",",
"'w'",
")",
"as",
"csvf",
":",
"csv_w",
"=",
"csv",
".",
"writer",
"(",
"csvf",
",",
"delimit... | [
476,
4
] | [
498,
45
] | python | en | ['en', 'error', 'th'] | False |
async_setup_platform | (hass, config, async_add_entities, discovery_info=None) | Set up the scenes for KNX platform. | Set up the scenes for KNX platform. | async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
"""Set up the scenes for KNX platform."""
entities = []
for device in hass.data[DOMAIN].xknx.devices:
if isinstance(device, XknxScene):
entities.append(KNXScene(device))
async_add_entities(entities... | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
",",
"config",
",",
"async_add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"entities",
"=",
"[",
"]",
"for",
"device",
"in",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
".",
"xknx",
".",
"dev... | [
11,
0
] | [
17,
32
] | python | en | ['en', 'da', 'en'] | True |
KNXScene.__init__ | (self, device: XknxScene) | Init KNX scene. | Init KNX scene. | def __init__(self, device: XknxScene):
"""Init KNX scene."""
super().__init__(device) | [
"def",
"__init__",
"(",
"self",
",",
"device",
":",
"XknxScene",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"device",
")"
] | [
23,
4
] | [
25,
32
] | python | en | ['en', 'sl', 'en'] | True |
KNXScene.async_activate | (self, **kwargs: Any) | Activate the scene. | Activate the scene. | async def async_activate(self, **kwargs: Any) -> None:
"""Activate the scene."""
await self._device.run() | [
"async",
"def",
"async_activate",
"(",
"self",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"await",
"self",
".",
"_device",
".",
"run",
"(",
")"
] | [
27,
4
] | [
29,
32
] | python | en | ['en', 'it', 'en'] | True |
test_scene | (
hass: HomeAssistant, vera_component_factory: ComponentFactory
) | Test function. | Test function. | async def test_scene(
hass: HomeAssistant, vera_component_factory: ComponentFactory
) -> None:
"""Test function."""
vera_scene = MagicMock(spec=pv.VeraScene) # type: pv.VeraScene
vera_scene.scene_id = 1
vera_scene.vera_scene_id = vera_scene.scene_id
vera_scene.name = "dev1"
entity_id = "sce... | [
"async",
"def",
"test_scene",
"(",
"hass",
":",
"HomeAssistant",
",",
"vera_component_factory",
":",
"ComponentFactory",
")",
"->",
"None",
":",
"vera_scene",
"=",
"MagicMock",
"(",
"spec",
"=",
"pv",
".",
"VeraScene",
")",
"# type: pv.VeraScene",
"vera_scene",
... | [
10,
0
] | [
30,
38
] | python | en | ['en', 'en', 'en'] | False |
async_setup_entry | (hass, config_entry, async_add_entities) | Set up cover for device. | Set up cover for device. | async def async_setup_entry(hass, config_entry, async_add_entities):
"""Set up cover for device."""
wrapper = hass.data[DOMAIN][DATA_CONFIG_ENTRY][config_entry.entry_id][COAP]
blocks = [block for block in wrapper.device.blocks if block.type == "roller"]
if not blocks:
return
async_add_enti... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
",",
"config_entry",
",",
"async_add_entities",
")",
":",
"wrapper",
"=",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"[",
"DATA_CONFIG_ENTRY",
"]",
"[",
"config_entry",
".",
"entry_id",
"]",
"[",
"COAP",
"]",
... | [
18,
0
] | [
26,
71
] | python | en | ['da', 'en', 'en'] | True |
ShellyCover.__init__ | (self, wrapper: ShellyDeviceWrapper, block: Block) | Initialize light. | Initialize light. | def __init__(self, wrapper: ShellyDeviceWrapper, block: Block) -> None:
"""Initialize light."""
super().__init__(wrapper, block)
self.control_result = None
self._supported_features = SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP
if self.wrapper.device.settings["rollers"][0]["positi... | [
"def",
"__init__",
"(",
"self",
",",
"wrapper",
":",
"ShellyDeviceWrapper",
",",
"block",
":",
"Block",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"wrapper",
",",
"block",
")",
"self",
".",
"control_result",
"=",
"None",
"self",
"... | [
32,
4
] | [
38,
60
] | python | en | ['en', 'en', 'en'] | False |
ShellyCover.is_closed | (self) | If cover is closed. | If cover is closed. | def is_closed(self):
"""If cover is closed."""
if self.control_result:
return self.control_result["current_pos"] == 0
return self.block.rollerPos == 0 | [
"def",
"is_closed",
"(",
"self",
")",
":",
"if",
"self",
".",
"control_result",
":",
"return",
"self",
".",
"control_result",
"[",
"\"current_pos\"",
"]",
"==",
"0",
"return",
"self",
".",
"block",
".",
"rollerPos",
"==",
"0"
] | [
41,
4
] | [
46,
40
] | python | en | ['en', 'en', 'en'] | True |
ShellyCover.current_cover_position | (self) | Position of the cover. | Position of the cover. | def current_cover_position(self):
"""Position of the cover."""
if self.control_result:
return self.control_result["current_pos"]
return self.block.rollerPos | [
"def",
"current_cover_position",
"(",
"self",
")",
":",
"if",
"self",
".",
"control_result",
":",
"return",
"self",
".",
"control_result",
"[",
"\"current_pos\"",
"]",
"return",
"self",
".",
"block",
".",
"rollerPos"
] | [
49,
4
] | [
54,
35
] | python | en | ['en', 'en', 'en'] | True |
ShellyCover.is_closing | (self) | Return if the cover is closing. | Return if the cover is closing. | def is_closing(self):
"""Return if the cover is closing."""
if self.control_result:
return self.control_result["state"] == "close"
return self.block.roller == "close" | [
"def",
"is_closing",
"(",
"self",
")",
":",
"if",
"self",
".",
"control_result",
":",
"return",
"self",
".",
"control_result",
"[",
"\"state\"",
"]",
"==",
"\"close\"",
"return",
"self",
".",
"block",
".",
"roller",
"==",
"\"close\""
] | [
57,
4
] | [
62,
43
] | python | en | ['en', 'en', 'en'] | True |
ShellyCover.is_opening | (self) | Return if the cover is opening. | Return if the cover is opening. | def is_opening(self):
"""Return if the cover is opening."""
if self.control_result:
return self.control_result["state"] == "open"
return self.block.roller == "open" | [
"def",
"is_opening",
"(",
"self",
")",
":",
"if",
"self",
".",
"control_result",
":",
"return",
"self",
".",
"control_result",
"[",
"\"state\"",
"]",
"==",
"\"open\"",
"return",
"self",
".",
"block",
".",
"roller",
"==",
"\"open\""
] | [
65,
4
] | [
70,
42
] | python | en | ['en', 'en', 'en'] | True |
ShellyCover.supported_features | (self) | Flag supported features. | Flag supported features. | def supported_features(self):
"""Flag supported features."""
return self._supported_features | [
"def",
"supported_features",
"(",
"self",
")",
":",
"return",
"self",
".",
"_supported_features"
] | [
73,
4
] | [
75,
39
] | python | en | ['da', 'en', 'en'] | True |
ShellyCover.async_close_cover | (self, **kwargs) | Close cover. | Close cover. | async def async_close_cover(self, **kwargs):
"""Close cover."""
self.control_result = await self.block.set_state(go="close")
self.async_write_ha_state() | [
"async",
"def",
"async_close_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"control_result",
"=",
"await",
"self",
".",
"block",
".",
"set_state",
"(",
"go",
"=",
"\"close\"",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
77,
4
] | [
80,
35
] | python | en | ['en', 'la', 'en'] | False |
ShellyCover.async_open_cover | (self, **kwargs) | Open cover. | Open cover. | async def async_open_cover(self, **kwargs):
"""Open cover."""
self.control_result = await self.block.set_state(go="open")
self.async_write_ha_state() | [
"async",
"def",
"async_open_cover",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"control_result",
"=",
"await",
"self",
".",
"block",
".",
"set_state",
"(",
"go",
"=",
"\"open\"",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
82,
4
] | [
85,
35
] | python | en | ['es', 'en', 'en'] | False |
ShellyCover.async_set_cover_position | (self, **kwargs) | Move the cover to a specific position. | Move the cover to a specific position. | async def async_set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
self.control_result = await self.block.set_state(
go="to_pos", roller_pos=kwargs[ATTR_POSITION]
)
self.async_write_ha_state() | [
"async",
"def",
"async_set_cover_position",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"control_result",
"=",
"await",
"self",
".",
"block",
".",
"set_state",
"(",
"go",
"=",
"\"to_pos\"",
",",
"roller_pos",
"=",
"kwargs",
"[",
"ATTR_POSI... | [
87,
4
] | [
92,
35
] | python | en | ['en', 'en', 'en'] | True |
ShellyCover.async_stop_cover | (self, **_kwargs) | Stop the cover. | Stop the cover. | async def async_stop_cover(self, **_kwargs):
"""Stop the cover."""
self.control_result = await self.block.set_state(go="stop")
self.async_write_ha_state() | [
"async",
"def",
"async_stop_cover",
"(",
"self",
",",
"*",
"*",
"_kwargs",
")",
":",
"self",
".",
"control_result",
"=",
"await",
"self",
".",
"block",
".",
"set_state",
"(",
"go",
"=",
"\"stop\"",
")",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
94,
4
] | [
97,
35
] | python | en | ['en', 'en', 'en'] | True |
ShellyCover._update_callback | (self) | When device updates, clear control result that overrides state. | When device updates, clear control result that overrides state. | def _update_callback(self):
"""When device updates, clear control result that overrides state."""
self.control_result = None
super()._update_callback() | [
"def",
"_update_callback",
"(",
"self",
")",
":",
"self",
".",
"control_result",
"=",
"None",
"super",
"(",
")",
".",
"_update_callback",
"(",
")"
] | [
100,
4
] | [
103,
34
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the sensors.
Login to the bank and get a list of existing accounts. Create a
sensor for each account.
| Set up the sensors. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the sensors.
Login to the bank and get a list of existing accounts. Create a
sensor for each account.
"""
credentials = BankCredentials(
config[CONF_BIN], config[CONF_USERNAME], config[CONF_PIN], config[CONF_URL]... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"credentials",
"=",
"BankCredentials",
"(",
"config",
"[",
"CONF_BIN",
"]",
",",
"config",
"[",
"CONF_USERNAME",
"]",
",",
"config",
"[",
... | [
52,
0
] | [
101,
32
] | python | en | ['en', 'bg', 'en'] | True |
FinTsClient.__init__ | (self, credentials: BankCredentials, name: str) | Initialize a FinTsClient. | Initialize a FinTsClient. | def __init__(self, credentials: BankCredentials, name: str):
"""Initialize a FinTsClient."""
self._credentials = credentials
self.name = name | [
"def",
"__init__",
"(",
"self",
",",
"credentials",
":",
"BankCredentials",
",",
"name",
":",
"str",
")",
":",
"self",
".",
"_credentials",
"=",
"credentials",
"self",
".",
"name",
"=",
"name"
] | [
110,
4
] | [
113,
24
] | python | en | ['en', 'fr', 'it'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.