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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
AlarmDecoderOptionsFlowHandler.async_step_zone_select | (self, user_input=None) | Zone selection form. | Zone selection form. | async def async_step_zone_select(self, user_input=None):
"""Zone selection form."""
errors = _validate_zone_input(user_input)
if user_input is not None and not errors:
self.selected_zone = str(
int(user_input[CONF_ZONE_NUMBER])
) # remove leading zeros
... | [
"async",
"def",
"async_step_zone_select",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"_validate_zone_input",
"(",
"user_input",
")",
"if",
"user_input",
"is",
"not",
"None",
"and",
"not",
"errors",
":",
"self",
".",
"selected_zone",
... | [
197,
4
] | [
211,
9
] | python | en | ['en', 'en', 'en'] | True |
AlarmDecoderOptionsFlowHandler.async_step_zone_details | (self, user_input=None) | Zone details form. | Zone details form. | async def async_step_zone_details(self, user_input=None):
"""Zone details form."""
errors = _validate_zone_input(user_input)
if user_input is not None and not errors:
zone_options = self.zone_options.copy()
zone_id = self.selected_zone
zone_options[zone_id] =... | [
"async",
"def",
"async_step_zone_details",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"errors",
"=",
"_validate_zone_input",
"(",
"user_input",
")",
"if",
"user_input",
"is",
"not",
"None",
"and",
"not",
"errors",
":",
"zone_options",
"=",
"self",
... | [
213,
4
] | [
287,
9
] | python | en | ['it', 'en', 'en'] | True |
test_kill_process | () | Test killing a process. | Test killing a process. | async def test_kill_process():
"""Test killing a process."""
sleeper = subprocess.Popen(
"sleep 1000",
shell=True, # nosec # shell by design
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
pid = sleeper.pid
assert os.kill(pid, 0) is None
process.kill_su... | [
"async",
"def",
"test_kill_process",
"(",
")",
":",
"sleeper",
"=",
"subprocess",
".",
"Popen",
"(",
"\"sleep 1000\"",
",",
"shell",
"=",
"True",
",",
"# nosec # shell by design",
"stdout",
"=",
"subprocess",
".",
"DEVNULL",
",",
"stderr",
"=",
"subprocess",
"... | [
10,
0
] | [
25,
23
] | python | en | ['en', 'mt', 'en'] | True |
_add_to_tfrecord | (filename, tfrecord_writer, offset=0) | Loads data from the cifar10 pickle files and writes files to a TFRecord.
Args:
filename: The filename of the cifar10 pickle file.
tfrecord_writer: The TFRecord writer to use for writing.
offset: An offset into the absolute number of images previously written.
Returns:
The new offset.
| Loads data from the cifar10 pickle files and writes files to a TFRecord. | def _add_to_tfrecord(filename, tfrecord_writer, offset=0):
"""Loads data from the cifar10 pickle files and writes files to a TFRecord.
Args:
filename: The filename of the cifar10 pickle file.
tfrecord_writer: The TFRecord writer to use for writing.
offset: An offset into the absolute number of images p... | [
"def",
"_add_to_tfrecord",
"(",
"filename",
",",
"tfrecord_writer",
",",
"offset",
"=",
"0",
")",
":",
"with",
"tf",
".",
"gfile",
".",
"Open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
... | [
73,
0
] | [
117,
28
] | python | en | ['en', 'en', 'en'] | True |
_get_output_filename | (dataset_dir, split_name) | Creates the output filename.
Args:
dataset_dir: The dataset directory where the dataset is stored.
split_name: The name of the train/test split.
Returns:
An absolute file path.
| Creates the output filename. | def _get_output_filename(dataset_dir, split_name):
"""Creates the output filename.
Args:
dataset_dir: The dataset directory where the dataset is stored.
split_name: The name of the train/test split.
Returns:
An absolute file path.
"""
return '%s/cifar10_%s.tfrecord' % (dataset_dir, split_name) | [
"def",
"_get_output_filename",
"(",
"dataset_dir",
",",
"split_name",
")",
":",
"return",
"'%s/cifar10_%s.tfrecord'",
"%",
"(",
"dataset_dir",
",",
"split_name",
")"
] | [
120,
0
] | [
130,
61
] | python | en | ['en', 'sm', 'en'] | True |
_download_and_uncompress_dataset | (dataset_dir) | Downloads cifar10 and uncompresses it locally.
Args:
dataset_dir: The directory where the temporary files are stored.
| Downloads cifar10 and uncompresses it locally. | def _download_and_uncompress_dataset(dataset_dir):
"""Downloads cifar10 and uncompresses it locally.
Args:
dataset_dir: The directory where the temporary files are stored.
"""
filename = _DATA_URL.split('/')[-1]
filepath = os.path.join(dataset_dir, filename)
if not os.path.exists(filepath):
def _p... | [
"def",
"_download_and_uncompress_dataset",
"(",
"dataset_dir",
")",
":",
"filename",
"=",
"_DATA_URL",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dataset_dir",
",",
"filename",
")",
"if",
"no... | [
133,
0
] | [
151,
58
] | python | en | ['en', 'en', 'en'] | True |
_clean_up_temporary_files | (dataset_dir) | Removes temporary files used to create the dataset.
Args:
dataset_dir: The directory where the temporary files are stored.
| Removes temporary files used to create the dataset. | def _clean_up_temporary_files(dataset_dir):
"""Removes temporary files used to create the dataset.
Args:
dataset_dir: The directory where the temporary files are stored.
"""
filename = _DATA_URL.split('/')[-1]
filepath = os.path.join(dataset_dir, filename)
# tf.gfile.Remove(filepath)
tmp_dir = os.pa... | [
"def",
"_clean_up_temporary_files",
"(",
"dataset_dir",
")",
":",
"filename",
"=",
"_DATA_URL",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dataset_dir",
",",
"filename",
")",
"# tf.gfile.Remove... | [
154,
0
] | [
165,
37
] | python | en | ['en', 'en', 'en'] | True |
main | () | Runs the download and conversion operation. | Runs the download and conversion operation. | def main():
"""Runs the download and conversion operation."""
args = _parse_args()
dataset_dir = args.data_dir
if not tf.gfile.Exists(dataset_dir):
tf.gfile.MakeDirs(dataset_dir)
training_filename = _get_output_filename(dataset_dir, 'train')
testing_filename = _get_output_filename(dataset_dir, 'test')... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"_parse_args",
"(",
")",
"dataset_dir",
"=",
"args",
".",
"data_dir",
"if",
"not",
"tf",
".",
"gfile",
".",
"Exists",
"(",
"dataset_dir",
")",
":",
"tf",
".",
"gfile",
".",
"MakeDirs",
"(",
"dataset_dir",
")... | [
168,
0
] | [
206,
53
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) | Set up the sensor config entry. | Set up the sensor config entry. | async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: Callable[[List[Entity], bool], None],
) -> None:
"""Set up the sensor config entry."""
controller_data = get_controller_data(hass, entry)
async_add_entities(
[
VeraBinarySensor(device, c... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistant",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
":",
"Callable",
"[",
"[",
"List",
"[",
"Entity",
"]",
",",
"bool",
"]",
",",
"None",
"]",
",",
")",
"->",
"None",
":",
... | [
18,
0
] | [
30,
5
] | python | en | ['en', 'pt', 'en'] | True |
VeraBinarySensor.__init__ | (
self, vera_device: veraApi.VeraBinarySensor, controller_data: ControllerData
) | Initialize the binary_sensor. | Initialize the binary_sensor. | def __init__(
self, vera_device: veraApi.VeraBinarySensor, controller_data: ControllerData
):
"""Initialize the binary_sensor."""
self._state = False
VeraDevice.__init__(self, vera_device, controller_data)
self.entity_id = ENTITY_ID_FORMAT.format(self.vera_id) | [
"def",
"__init__",
"(",
"self",
",",
"vera_device",
":",
"veraApi",
".",
"VeraBinarySensor",
",",
"controller_data",
":",
"ControllerData",
")",
":",
"self",
".",
"_state",
"=",
"False",
"VeraDevice",
".",
"__init__",
"(",
"self",
",",
"vera_device",
",",
"c... | [
36,
4
] | [
42,
62
] | python | en | ['en', 'haw', 'en'] | True |
VeraBinarySensor.is_on | (self) | Return true if sensor is on. | Return true if sensor is on. | def is_on(self) -> Optional[bool]:
"""Return true if sensor is on."""
return self._state | [
"def",
"is_on",
"(",
"self",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"return",
"self",
".",
"_state"
] | [
45,
4
] | [
47,
26
] | python | en | ['en', 'et', 'en'] | True |
VeraBinarySensor.update | (self) | Get the latest data and update the state. | Get the latest data and update the state. | def update(self) -> None:
"""Get the latest data and update the state."""
self._state = self.vera_device.is_tripped | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_state",
"=",
"self",
".",
"vera_device",
".",
"is_tripped"
] | [
49,
4
] | [
51,
49
] | python | en | ['en', 'en', 'en'] | True |
encode | (orig, bpe_codes, bpe_codes_reverse, vocab, separator, version, cache, glossaries_regex=None, dropout=0) | Encode word based on list of BPE merge operations, which are applied consecutively
| Encode word based on list of BPE merge operations, which are applied consecutively
| def encode(orig, bpe_codes, bpe_codes_reverse, vocab, separator, version, cache, glossaries_regex=None, dropout=0):
"""Encode word based on list of BPE merge operations, which are applied consecutively
"""
if not dropout and orig in cache:
return cache[orig]
if glossaries_regex and glossaries_... | [
"def",
"encode",
"(",
"orig",
",",
"bpe_codes",
",",
"bpe_codes_reverse",
",",
"vocab",
",",
"separator",
",",
"version",
",",
"cache",
",",
"glossaries_regex",
"=",
"None",
",",
"dropout",
"=",
"0",
")",
":",
"if",
"not",
"dropout",
"and",
"orig",
"in",... | [
117,
0
] | [
176,
15
] | python | en | ['en', 'en', 'en'] | True |
recursive_split | (segment, bpe_codes, vocab, separator, final=False) | Recursively split segment into smaller units (by reversing BPE merges)
until all units are either in-vocabulary, or cannot be split futher. | Recursively split segment into smaller units (by reversing BPE merges)
until all units are either in-vocabulary, or cannot be split futher. | def recursive_split(segment, bpe_codes, vocab, separator, final=False):
"""Recursively split segment into smaller units (by reversing BPE merges)
until all units are either in-vocabulary, or cannot be split futher."""
try:
if final:
left, right = bpe_codes[segment + '</w>']
... | [
"def",
"recursive_split",
"(",
"segment",
",",
"bpe_codes",
",",
"vocab",
",",
"separator",
",",
"final",
"=",
"False",
")",
":",
"try",
":",
"if",
"final",
":",
"left",
",",
"right",
"=",
"bpe_codes",
"[",
"segment",
"+",
"'</w>'",
"]",
"right",
"=",
... | [
178,
0
] | [
203,
22
] | python | en | ['en', 'no', 'en'] | True |
check_vocab_and_split | (orig, bpe_codes, vocab, separator) | Check for each segment in word if it is in-vocabulary,
and segment OOV segments into smaller units by reversing the BPE merge operations | Check for each segment in word if it is in-vocabulary,
and segment OOV segments into smaller units by reversing the BPE merge operations | def check_vocab_and_split(orig, bpe_codes, vocab, separator):
"""Check for each segment in word if it is in-vocabulary,
and segment OOV segments into smaller units by reversing the BPE merge operations"""
out = []
for segment in orig[:-1]:
if segment + separator in vocab:
out.appen... | [
"def",
"check_vocab_and_split",
"(",
"orig",
",",
"bpe_codes",
",",
"vocab",
",",
"separator",
")",
":",
"out",
"=",
"[",
"]",
"for",
"segment",
"in",
"orig",
"[",
":",
"-",
"1",
"]",
":",
"if",
"segment",
"+",
"separator",
"in",
"vocab",
":",
"out",... | [
205,
0
] | [
227,
14
] | python | en | ['en', 'en', 'en'] | True |
read_vocabulary | (vocab_file, threshold) | read vocabulary file produced by get_vocab.py, and filter according to frequency threshold.
| read vocabulary file produced by get_vocab.py, and filter according to frequency threshold.
| def read_vocabulary(vocab_file, threshold):
"""read vocabulary file produced by get_vocab.py, and filter according to frequency threshold.
"""
vocabulary = set()
for line in vocab_file:
word, freq = line.strip('\r\n ').split(' ')
freq = int(freq)
if threshold == None or freq >=... | [
"def",
"read_vocabulary",
"(",
"vocab_file",
",",
"threshold",
")",
":",
"vocabulary",
"=",
"set",
"(",
")",
"for",
"line",
"in",
"vocab_file",
":",
"word",
",",
"freq",
"=",
"line",
".",
"strip",
"(",
"'\\r\\n '",
")",
".",
"split",
"(",
"' '",
")",
... | [
230,
0
] | [
242,
21
] | python | en | ['en', 'en', 'en'] | True |
isolate_glossary | (word, glossary) |
Isolate a glossary present inside a word.
Returns a list of subwords. In which all 'glossary' glossaries are isolated
For example, if 'USA' is the glossary and '1934USABUSA' the word, the return value is:
['1934', 'USA', 'B', 'USA']
|
Isolate a glossary present inside a word. | def isolate_glossary(word, glossary):
"""
Isolate a glossary present inside a word.
Returns a list of subwords. In which all 'glossary' glossaries are isolated
For example, if 'USA' is the glossary and '1934USABUSA' the word, the return value is:
['1934', 'USA', 'B', 'USA']
"""
# rege... | [
"def",
"isolate_glossary",
"(",
"word",
",",
"glossary",
")",
":",
"# regex equivalent of (if word == glossary or glossary not in word)",
"if",
"re",
".",
"match",
"(",
"'^'",
"+",
"glossary",
"+",
"'$'",
",",
"word",
")",
"or",
"not",
"re",
".",
"search",
"(",
... | [
244,
0
] | [
260,
79
] | python | en | ['en', 'error', 'th'] | False |
BPE.process_line | (self, line, dropout=0) | segment line, dealing with leading and trailing whitespace | segment line, dealing with leading and trailing whitespace | def process_line(self, line, dropout=0):
"""segment line, dealing with leading and trailing whitespace"""
out = ""
leading_whitespace = len(line)-len(line.lstrip('\r\n '))
if leading_whitespace:
out += line[:leading_whitespace]
out += self.segment(line, dropout)
... | [
"def",
"process_line",
"(",
"self",
",",
"line",
",",
"dropout",
"=",
"0",
")",
":",
"out",
"=",
"\"\"",
"leading_whitespace",
"=",
"len",
"(",
"line",
")",
"-",
"len",
"(",
"line",
".",
"lstrip",
"(",
"'\\r\\n '",
")",
")",
"if",
"leading_whitespace",... | [
64,
4
] | [
79,
18
] | python | en | ['en', 'en', 'en'] | True |
BPE.segment | (self, sentence, dropout=0) | segment single sentence (whitespace-tokenized string) with BPE encoding | segment single sentence (whitespace-tokenized string) with BPE encoding | def segment(self, sentence, dropout=0):
"""segment single sentence (whitespace-tokenized string) with BPE encoding"""
segments = self.segment_tokens(sentence.strip('\r\n ').split(' '), dropout)
return ' '.join(segments) | [
"def",
"segment",
"(",
"self",
",",
"sentence",
",",
"dropout",
"=",
"0",
")",
":",
"segments",
"=",
"self",
".",
"segment_tokens",
"(",
"sentence",
".",
"strip",
"(",
"'\\r\\n '",
")",
".",
"split",
"(",
"' '",
")",
",",
"dropout",
")",
"return",
"'... | [
81,
4
] | [
84,
33
] | python | en | ['en', 'el-Latn', 'en'] | True |
BPE.segment_tokens | (self, tokens, dropout=0) | segment a sequence of tokens with BPE encoding | segment a sequence of tokens with BPE encoding | def segment_tokens(self, tokens, dropout=0):
"""segment a sequence of tokens with BPE encoding"""
output = []
for word in tokens:
# eliminate double spaces
if not word:
continue
new_word = [out for segment in self._isolate_glossaries(word)
... | [
"def",
"segment_tokens",
"(",
"self",
",",
"tokens",
",",
"dropout",
"=",
"0",
")",
":",
"output",
"=",
"[",
"]",
"for",
"word",
"in",
"tokens",
":",
"# eliminate double spaces",
"if",
"not",
"word",
":",
"continue",
"new_word",
"=",
"[",
"out",
"for",
... | [
86,
4
] | [
108,
21
] | python | en | ['en', 'en', 'en'] | True |
setup | (hass, config) | Set up the rpi_camera integration. | Set up the rpi_camera integration. | def setup(hass, config):
"""Set up the rpi_camera integration."""
config_domain = config[DOMAIN]
hass.data[DOMAIN] = {
CONF_FILE_PATH: config_domain.get(CONF_FILE_PATH),
CONF_HORIZONTAL_FLIP: config_domain.get(CONF_HORIZONTAL_FLIP),
CONF_IMAGE_WIDTH: config_domain.get(CONF_IMAGE_WIDT... | [
"def",
"setup",
"(",
"hass",
",",
"config",
")",
":",
"config_domain",
"=",
"config",
"[",
"DOMAIN",
"]",
"hass",
".",
"data",
"[",
"DOMAIN",
"]",
"=",
"{",
"CONF_FILE_PATH",
":",
"config_domain",
".",
"get",
"(",
"CONF_FILE_PATH",
")",
",",
"CONF_HORIZO... | [
65,
0
] | [
84,
15
] | python | en | ['en', 'da', 'en'] | True |
async_setup | (hass, config) | Set up the Velbus platform. | Set up the Velbus platform. | async def async_setup(hass, config):
"""Set up the Velbus platform."""
# Import from the configuration file if needed
if DOMAIN not in config:
return True
port = config[DOMAIN].get(CONF_PORT)
data = {}
if port:
data = {CONF_PORT: port, CONF_NAME: "Velbus import"}
hass.async_... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"# Import from the configuration file if needed",
"if",
"DOMAIN",
"not",
"in",
"config",
":",
"return",
"True",
"port",
"=",
"config",
"[",
"DOMAIN",
"]",
".",
"get",
"(",
"CONF_PORT",
")",
... | [
27,
0
] | [
43,
15
] | python | en | ['en', 'lv', 'en'] | True |
async_setup_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Establish connection with velbus. | Establish connection with velbus. | async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Establish connection with velbus."""
hass.data.setdefault(DOMAIN, {})
def callback():
modules = controller.get_modules()
discovery_info = {"cntrl": controller}
for category in COMPONENT_TYPES:
d... | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"hass",
".",
"data",
".",
"setdefault",
"(",
"DOMAIN",
",",
"{",
"}",
")",
"def",
"callback",
"(",
")",
":",
"modules",
"=",
"controll... | [
46,
0
] | [
108,
15
] | python | en | ['en', 'en', 'en'] | True |
async_unload_entry | (hass: HomeAssistantType, entry: ConfigEntry) | Remove the velbus connection. | Remove the velbus connection. | async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry):
"""Remove the velbus connection."""
await asyncio.wait(
[
hass.config_entries.async_forward_entry_unload(entry, component)
for component in COMPONENT_TYPES
]
)
hass.data[DOMAIN][entry.entry... | [
"async",
"def",
"async_unload_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
")",
":",
"await",
"asyncio",
".",
"wait",
"(",
"[",
"hass",
".",
"config_entries",
".",
"async_forward_entry_unload",
"(",
"entry",
",",
"component",
... | [
111,
0
] | [
123,
15
] | python | en | ['en', 'en', 'en'] | True |
VelbusEntity.__init__ | (self, module, channel) | Initialize a Velbus entity. | Initialize a Velbus entity. | def __init__(self, module, channel):
"""Initialize a Velbus entity."""
self._module = module
self._channel = channel | [
"def",
"__init__",
"(",
"self",
",",
"module",
",",
"channel",
")",
":",
"self",
".",
"_module",
"=",
"module",
"self",
".",
"_channel",
"=",
"channel"
] | [
129,
4
] | [
132,
31
] | python | en | ['es', 'en', 'it'] | False |
VelbusEntity.unique_id | (self) | Get unique ID. | Get unique ID. | def unique_id(self):
"""Get unique ID."""
serial = 0
if self._module.serial == 0:
serial = self._module.get_module_address()
else:
serial = self._module.serial
return f"{serial}-{self._channel}" | [
"def",
"unique_id",
"(",
"self",
")",
":",
"serial",
"=",
"0",
"if",
"self",
".",
"_module",
".",
"serial",
"==",
"0",
":",
"serial",
"=",
"self",
".",
"_module",
".",
"get_module_address",
"(",
")",
"else",
":",
"serial",
"=",
"self",
".",
"_module"... | [
135,
4
] | [
142,
42
] | python | en | ['fr', 'la', 'en'] | False |
VelbusEntity.name | (self) | Return the display name of this entity. | Return the display name of this entity. | def name(self):
"""Return the display name of this entity."""
return self._module.get_name(self._channel) | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_module",
".",
"get_name",
"(",
"self",
".",
"_channel",
")"
] | [
145,
4
] | [
147,
51
] | python | en | ['en', 'en', 'en'] | True |
VelbusEntity.should_poll | (self) | Disable polling. | Disable polling. | def should_poll(self):
"""Disable polling."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
150,
4
] | [
152,
20
] | python | en | ['fr', 'en', 'en'] | False |
VelbusEntity.async_added_to_hass | (self) | Add listener for state changes. | Add listener for state changes. | async def async_added_to_hass(self):
"""Add listener for state changes."""
self._module.on_status_update(self._channel, self._on_update) | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_module",
".",
"on_status_update",
"(",
"self",
".",
"_channel",
",",
"self",
".",
"_on_update",
")"
] | [
154,
4
] | [
156,
69
] | python | en | ['da', 'en', 'en'] | True |
VelbusEntity.device_info | (self) | Return the device info. | Return the device info. | def device_info(self):
"""Return the device info."""
return {
"identifiers": {
(DOMAIN, self._module.get_module_address(), self._module.serial)
},
"name": "{} ({})".format(
self._module.get_module_name(), self._module.get_module_address... | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"identifiers\"",
":",
"{",
"(",
"DOMAIN",
",",
"self",
".",
"_module",
".",
"get_module_address",
"(",
")",
",",
"self",
".",
"_module",
".",
"serial",
")",
"}",
",",
"\"name\"",
":",
"\"{} ... | [
162,
4
] | [
178,
9
] | python | en | ['en', 'en', 'en'] | True |
TasmotaEntity.__init__ | (self, tasmota_entity) | Initialize. | Initialize. | def __init__(self, tasmota_entity) -> None:
"""Initialize."""
self._state = None
self._tasmota_entity = tasmota_entity
self._unique_id = tasmota_entity.unique_id | [
"def",
"__init__",
"(",
"self",
",",
"tasmota_entity",
")",
"->",
"None",
":",
"self",
".",
"_state",
"=",
"None",
"self",
".",
"_tasmota_entity",
"=",
"tasmota_entity",
"self",
".",
"_unique_id",
"=",
"tasmota_entity",
".",
"unique_id"
] | [
24,
4
] | [
28,
50
] | python | en | ['en', 'en', 'it'] | False |
TasmotaEntity.async_added_to_hass | (self) | Subscribe to MQTT events. | Subscribe to MQTT events. | async def async_added_to_hass(self):
"""Subscribe to MQTT events."""
self._tasmota_entity.set_on_state_callback(self.state_updated)
await self._subscribe_topics() | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
":",
"self",
".",
"_tasmota_entity",
".",
"set_on_state_callback",
"(",
"self",
".",
"state_updated",
")",
"await",
"self",
".",
"_subscribe_topics",
"(",
")"
] | [
30,
4
] | [
33,
38
] | python | en | ['en', 'en', 'en'] | True |
TasmotaEntity.async_will_remove_from_hass | (self) | Unsubscribe when removed. | Unsubscribe when removed. | async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
await self._tasmota_entity.unsubscribe_topics()
await super().async_will_remove_from_hass() | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
":",
"await",
"self",
".",
"_tasmota_entity",
".",
"unsubscribe_topics",
"(",
")",
"await",
"super",
"(",
")",
".",
"async_will_remove_from_hass",
"(",
")"
] | [
35,
4
] | [
38,
51
] | python | en | ['en', 'en', 'en'] | True |
TasmotaEntity.discovery_update | (self, update, write_state=True) | Handle updated discovery message. | Handle updated discovery message. | async def discovery_update(self, update, write_state=True):
"""Handle updated discovery message."""
self._tasmota_entity.config_update(update)
await self._subscribe_topics()
if write_state:
self.async_write_ha_state() | [
"async",
"def",
"discovery_update",
"(",
"self",
",",
"update",
",",
"write_state",
"=",
"True",
")",
":",
"self",
".",
"_tasmota_entity",
".",
"config_update",
"(",
"update",
")",
"await",
"self",
".",
"_subscribe_topics",
"(",
")",
"if",
"write_state",
":"... | [
40,
4
] | [
45,
39
] | python | en | ['en', 'en', 'en'] | True |
TasmotaEntity._subscribe_topics | (self) | (Re)Subscribe to topics. | (Re)Subscribe to topics. | async def _subscribe_topics(self):
"""(Re)Subscribe to topics."""
await self._tasmota_entity.subscribe_topics() | [
"async",
"def",
"_subscribe_topics",
"(",
"self",
")",
":",
"await",
"self",
".",
"_tasmota_entity",
".",
"subscribe_topics",
"(",
")"
] | [
47,
4
] | [
49,
53
] | python | en | ['en', 'en', 'en'] | True |
TasmotaEntity.state_updated | (self, state, **kwargs) | Handle state updates. | Handle state updates. | def state_updated(self, state, **kwargs):
"""Handle state updates."""
self._state = state
self.async_write_ha_state() | [
"def",
"state_updated",
"(",
"self",
",",
"state",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_state",
"=",
"state",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
52,
4
] | [
55,
35
] | python | en | ['en', 'en', 'en'] | True |
TasmotaEntity.device_info | (self) | Return a device description for device registry. | Return a device description for device registry. | def device_info(self):
"""Return a device description for device registry."""
return {"connections": {(CONNECTION_NETWORK_MAC, self._tasmota_entity.mac)}} | [
"def",
"device_info",
"(",
"self",
")",
":",
"return",
"{",
"\"connections\"",
":",
"{",
"(",
"CONNECTION_NETWORK_MAC",
",",
"self",
".",
"_tasmota_entity",
".",
"mac",
")",
"}",
"}"
] | [
58,
4
] | [
60,
84
] | python | en | ['ro', 'fr', 'en'] | False |
TasmotaEntity.name | (self) | Return the name of the binary sensor. | Return the name of the binary sensor. | def name(self):
"""Return the name of the binary sensor."""
return self._tasmota_entity.name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_tasmota_entity",
".",
"name"
] | [
63,
4
] | [
65,
40
] | python | en | ['en', 'mi', 'en'] | True |
TasmotaEntity.should_poll | (self) | Return the polling state. | Return the polling state. | def should_poll(self):
"""Return the polling state."""
return False | [
"def",
"should_poll",
"(",
"self",
")",
":",
"return",
"False"
] | [
68,
4
] | [
70,
20
] | python | en | ['en', 'en', 'en'] | True |
TasmotaEntity.unique_id | (self) | Return a unique ID. | Return a unique ID. | def unique_id(self):
"""Return a unique ID."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unique_id"
] | [
73,
4
] | [
75,
30
] | python | ca | ['fr', 'ca', 'en'] | False |
TasmotaAvailability.__init__ | (self, **kwds) | Initialize the availability mixin. | Initialize the availability mixin. | def __init__(self, **kwds) -> None:
"""Initialize the availability mixin."""
self._available = False
super().__init__(**kwds) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
"->",
"None",
":",
"self",
".",
"_available",
"=",
"False",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"*",
"kwds",
")"
] | [
81,
4
] | [
84,
32
] | python | en | ['en', 'en', 'en'] | True |
TasmotaAvailability.async_added_to_hass | (self) | Subscribe to MQTT events. | Subscribe to MQTT events. | async def async_added_to_hass(self) -> None:
"""Subscribe to MQTT events."""
self._tasmota_entity.set_on_availability_callback(self.availability_updated)
self.async_on_remove(
async_subscribe_connection_status(self.hass, self.async_mqtt_connected)
)
await super().asyn... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_tasmota_entity",
".",
"set_on_availability_callback",
"(",
"self",
".",
"availability_updated",
")",
"self",
".",
"async_on_remove",
"(",
"async_subscribe_connection_status",
"(... | [
86,
4
] | [
92,
43
] | python | en | ['en', 'en', 'en'] | True |
TasmotaAvailability.availability_updated | (self, available: bool) | Handle updated availability. | Handle updated availability. | def availability_updated(self, available: bool) -> None:
"""Handle updated availability."""
self._tasmota_entity.poll_status()
self._available = available
self.async_write_ha_state() | [
"def",
"availability_updated",
"(",
"self",
",",
"available",
":",
"bool",
")",
"->",
"None",
":",
"self",
".",
"_tasmota_entity",
".",
"poll_status",
"(",
")",
"self",
".",
"_available",
"=",
"available",
"self",
".",
"async_write_ha_state",
"(",
")"
] | [
95,
4
] | [
99,
35
] | python | en | ['en', 'en', 'en'] | True |
TasmotaAvailability.async_mqtt_connected | (self, _) | Update state on connection/disconnection to MQTT broker. | Update state on connection/disconnection to MQTT broker. | def async_mqtt_connected(self, _):
"""Update state on connection/disconnection to MQTT broker."""
if not self.hass.is_stopping:
if not mqtt_connected(self.hass):
self._available = False
self.async_write_ha_state() | [
"def",
"async_mqtt_connected",
"(",
"self",
",",
"_",
")",
":",
"if",
"not",
"self",
".",
"hass",
".",
"is_stopping",
":",
"if",
"not",
"mqtt_connected",
"(",
"self",
".",
"hass",
")",
":",
"self",
".",
"_available",
"=",
"False",
"self",
".",
"async_w... | [
102,
4
] | [
107,
39
] | python | en | ['en', 'en', 'en'] | True |
TasmotaAvailability.available | (self) | Return if the device is available. | Return if the device is available. | def available(self) -> bool:
"""Return if the device is available."""
return self._available | [
"def",
"available",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"self",
".",
"_available"
] | [
110,
4
] | [
112,
30
] | python | en | ['en', 'en', 'en'] | True |
TasmotaDiscoveryUpdate.__init__ | (self, discovery_hash, discovery_update, **kwds) | Initialize the discovery update mixin. | Initialize the discovery update mixin. | def __init__(self, discovery_hash, discovery_update, **kwds) -> None:
"""Initialize the discovery update mixin."""
self._discovery_hash = discovery_hash
self._discovery_update = discovery_update
self._removed_from_hass = False
super().__init__(**kwds) | [
"def",
"__init__",
"(",
"self",
",",
"discovery_hash",
",",
"discovery_update",
",",
"*",
"*",
"kwds",
")",
"->",
"None",
":",
"self",
".",
"_discovery_hash",
"=",
"discovery_hash",
"self",
".",
"_discovery_update",
"=",
"discovery_update",
"self",
".",
"_remo... | [
118,
4
] | [
123,
32
] | python | en | ['en', 'en', 'en'] | True |
TasmotaDiscoveryUpdate.async_added_to_hass | (self) | Subscribe to discovery updates. | Subscribe to discovery updates. | async def async_added_to_hass(self) -> None:
"""Subscribe to discovery updates."""
self._removed_from_hass = False
await super().async_added_to_hass()
async def discovery_callback(config):
"""Handle discovery update."""
_LOGGER.debug(
"Got update ... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_removed_from_hass",
"=",
"False",
"await",
"super",
"(",
")",
".",
"async_added_to_hass",
"(",
")",
"async",
"def",
"discovery_callback",
"(",
"config",
")",
":",
"\"\... | [
125,
4
] | [
153,
9
] | python | en | ['en', 'en', 'en'] | True |
TasmotaDiscoveryUpdate.add_to_platform_abort | (self) | Abort adding an entity to a platform. | Abort adding an entity to a platform. | def add_to_platform_abort(self) -> None:
"""Abort adding an entity to a platform."""
clear_discovery_hash(self.hass, self._discovery_hash)
super().add_to_platform_abort() | [
"def",
"add_to_platform_abort",
"(",
"self",
")",
"->",
"None",
":",
"clear_discovery_hash",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_discovery_hash",
")",
"super",
"(",
")",
".",
"add_to_platform_abort",
"(",
")"
] | [
156,
4
] | [
159,
39
] | python | en | ['en', 'cy', 'en'] | True |
TasmotaDiscoveryUpdate.async_will_remove_from_hass | (self) | Stop listening to signal and cleanup discovery data.. | Stop listening to signal and cleanup discovery data.. | async def async_will_remove_from_hass(self) -> None:
"""Stop listening to signal and cleanup discovery data.."""
if not self._removed_from_hass:
clear_discovery_hash(self.hass, self._discovery_hash)
self._removed_from_hass = True
await super().async_will_remove_from_hass(... | [
"async",
"def",
"async_will_remove_from_hass",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_removed_from_hass",
":",
"clear_discovery_hash",
"(",
"self",
".",
"hass",
",",
"self",
".",
"_discovery_hash",
")",
"self",
".",
"_removed_from_hass"... | [
161,
4
] | [
166,
51
] | python | en | ['en', 'en', 'en'] | True |
FirmataFlowHandler.async_step_import | (self, import_config: dict) | Import a firmata board as a config entry.
This flow is triggered by `async_setup` for configured boards.
This will execute for any board that does not have a
config entry yet (based on entry_id). It validates a connection
and then adds the entry.
| Import a firmata board as a config entry. | async def async_step_import(self, import_config: dict):
"""Import a firmata board as a config entry.
This flow is triggered by `async_setup` for configured boards.
This will execute for any board that does not have a
config entry yet (based on entry_id). It validates a connection
... | [
"async",
"def",
"async_step_import",
"(",
"self",
",",
"import_config",
":",
"dict",
")",
":",
"name",
"=",
"f\"serial-{import_config[CONF_SERIAL_PORT]}\"",
"import_config",
"[",
"CONF_NAME",
"]",
"=",
"name",
"# Connect to the board to verify connection and then shutdown",
... | [
21,
4
] | [
56,
9
] | python | en | ['en', 'en', 'en'] | True |
pad_list_tensors | (
list_tensors,
preds_per_image,
max_detections=None,
return_tensors=None,
padding=None,
pad_value=0,
location=None,
) |
location will always be cpu for np tensors
|
location will always be cpu for np tensors
| def pad_list_tensors(
list_tensors,
preds_per_image,
max_detections=None,
return_tensors=None,
padding=None,
pad_value=0,
location=None,
):
"""
location will always be cpu for np tensors
"""
if location is None:
location = "cpu"
assert return_tensors in {"pt", "np... | [
"def",
"pad_list_tensors",
"(",
"list_tensors",
",",
"preds_per_image",
",",
"max_detections",
"=",
"None",
",",
"return_tensors",
"=",
"None",
",",
"padding",
"=",
"None",
",",
"pad_value",
"=",
"0",
",",
"location",
"=",
"None",
",",
")",
":",
"if",
"loc... | [
46,
0
] | [
112,
27
] | python | en | ['en', 'error', 'th'] | False |
find_top_rpn_proposals | (
proposals,
pred_objectness_logits,
images,
image_sizes,
nms_thresh,
pre_nms_topk,
post_nms_topk,
min_box_side_len,
training,
) | Args:
proposals (list[Tensor]): (L, N, Hi*Wi*A, 4).
pred_objectness_logits: tensors of length L.
nms_thresh (float): IoU threshold to use for NMS
pre_nms_topk (int): before nms
post_nms_topk (int): after nms
min_box_side_len (float): minimum proposal box side
trai... | Args:
proposals (list[Tensor]): (L, N, Hi*Wi*A, 4).
pred_objectness_logits: tensors of length L.
nms_thresh (float): IoU threshold to use for NMS
pre_nms_topk (int): before nms
post_nms_topk (int): after nms
min_box_side_len (float): minimum proposal box side
trai... | def find_top_rpn_proposals(
proposals,
pred_objectness_logits,
images,
image_sizes,
nms_thresh,
pre_nms_topk,
post_nms_topk,
min_box_side_len,
training,
):
"""Args:
proposals (list[Tensor]): (L, N, Hi*Wi*A, 4).
pred_objectness_logits: tensors of length L.
... | [
"def",
"find_top_rpn_proposals",
"(",
"proposals",
",",
"pred_objectness_logits",
",",
"images",
",",
"image_sizes",
",",
"nms_thresh",
",",
"pre_nms_topk",
",",
"post_nms_topk",
",",
"min_box_side_len",
",",
"training",
",",
")",
":",
"num_images",
"=",
"len",
"(... | [
255,
0
] | [
332,
18
] | python | en | ['en', 'gl', 'ur'] | False |
subsample_labels | (labels, num_samples, positive_fraction, bg_label) |
Returns:
pos_idx, neg_idx (Tensor):
1D vector of indices. The total length of both is `num_samples` or fewer.
|
Returns:
pos_idx, neg_idx (Tensor):
1D vector of indices. The total length of both is `num_samples` or fewer.
| def subsample_labels(labels, num_samples, positive_fraction, bg_label):
"""
Returns:
pos_idx, neg_idx (Tensor):
1D vector of indices. The total length of both is `num_samples` or fewer.
"""
positive = torch.nonzero((labels != -1) & (labels != bg_label)).squeeze(1)
negative = torc... | [
"def",
"subsample_labels",
"(",
"labels",
",",
"num_samples",
",",
"positive_fraction",
",",
"bg_label",
")",
":",
"positive",
"=",
"torch",
".",
"nonzero",
"(",
"(",
"labels",
"!=",
"-",
"1",
")",
"&",
"(",
"labels",
"!=",
"bg_label",
")",
")",
".",
"... | [
335,
0
] | [
357,
27
] | python | en | ['en', 'error', 'th'] | False |
Box2BoxTransform.__init__ | (self, weights: Tuple[float, float, float, float], scale_clamp: float = None) |
Args:
weights (4-element tuple): Scaling factors that are applied to the
(dx, dy, dw, dh) deltas. In Fast R-CNN, these were originally set
such that the deltas have unit variance; now they are treated as
hyperparameters of the system.
scal... |
Args:
weights (4-element tuple): Scaling factors that are applied to the
(dx, dy, dw, dh) deltas. In Fast R-CNN, these were originally set
such that the deltas have unit variance; now they are treated as
hyperparameters of the system.
scal... | def __init__(self, weights: Tuple[float, float, float, float], scale_clamp: float = None):
"""
Args:
weights (4-element tuple): Scaling factors that are applied to the
(dx, dy, dw, dh) deltas. In Fast R-CNN, these were originally set
such that the deltas have ... | [
"def",
"__init__",
"(",
"self",
",",
"weights",
":",
"Tuple",
"[",
"float",
",",
"float",
",",
"float",
",",
"float",
"]",
",",
"scale_clamp",
":",
"float",
"=",
"None",
")",
":",
"self",
".",
"weights",
"=",
"weights",
"if",
"scale_clamp",
"is",
"no... | [
428,
4
] | [
448,
52
] | python | en | ['en', 'error', 'th'] | False |
Box2BoxTransform.get_deltas | (self, src_boxes, target_boxes) |
Get box regression transformation deltas (dx, dy, dw, dh) that can be used
to transform the `src_boxes` into the `target_boxes`. That is, the relation
``target_boxes == self.apply_deltas(deltas, src_boxes)`` is true (unless
any delta is too large and is clamped).
Args:
... |
Get box regression transformation deltas (dx, dy, dw, dh) that can be used
to transform the `src_boxes` into the `target_boxes`. That is, the relation
``target_boxes == self.apply_deltas(deltas, src_boxes)`` is true (unless
any delta is too large and is clamped).
Args:
... | def get_deltas(self, src_boxes, target_boxes):
"""
Get box regression transformation deltas (dx, dy, dw, dh) that can be used
to transform the `src_boxes` into the `target_boxes`. That is, the relation
``target_boxes == self.apply_deltas(deltas, src_boxes)`` is true (unless
any d... | [
"def",
"get_deltas",
"(",
"self",
",",
"src_boxes",
",",
"target_boxes",
")",
":",
"assert",
"isinstance",
"(",
"src_boxes",
",",
"torch",
".",
"Tensor",
")",
",",
"type",
"(",
"src_boxes",
")",
"assert",
"isinstance",
"(",
"target_boxes",
",",
"torch",
".... | [
450,
4
] | [
482,
21
] | python | en | ['en', 'error', 'th'] | False |
Box2BoxTransform.apply_deltas | (self, deltas, boxes) |
Apply transformation `deltas` (dx, dy, dw, dh) to `boxes`.
Args:
deltas (Tensor): transformation deltas of shape (N, k*4), where k >= 1.
deltas[i] represents k potentially different class-specific
box transformations for the single box boxes[i].
b... |
Apply transformation `deltas` (dx, dy, dw, dh) to `boxes`.
Args:
deltas (Tensor): transformation deltas of shape (N, k*4), where k >= 1.
deltas[i] represents k potentially different class-specific
box transformations for the single box boxes[i].
b... | def apply_deltas(self, deltas, boxes):
"""
Apply transformation `deltas` (dx, dy, dw, dh) to `boxes`.
Args:
deltas (Tensor): transformation deltas of shape (N, k*4), where k >= 1.
deltas[i] represents k potentially different class-specific
box transfor... | [
"def",
"apply_deltas",
"(",
"self",
",",
"deltas",
",",
"boxes",
")",
":",
"boxes",
"=",
"boxes",
".",
"to",
"(",
"deltas",
".",
"dtype",
")",
"widths",
"=",
"boxes",
"[",
":",
",",
"2",
"]",
"-",
"boxes",
"[",
":",
",",
"0",
"]",
"heights",
"=... | [
484,
4
] | [
520,
25
] | python | en | ['en', 'error', 'th'] | False |
Matcher.__init__ | (
self,
thresholds: List[float],
labels: List[int],
allow_low_quality_matches: bool = False,
) |
Args:
thresholds (list): a list of thresholds used to stratify predictions
into levels.
labels (list): a list of values to label predictions belonging at
each level. A label can be one of {-1, 0, 1} signifying
{ignore, negative class, posi... |
Args:
thresholds (list): a list of thresholds used to stratify predictions
into levels.
labels (list): a list of values to label predictions belonging at
each level. A label can be one of {-1, 0, 1} signifying
{ignore, negative class, posi... | def __init__(
self,
thresholds: List[float],
labels: List[int],
allow_low_quality_matches: bool = False,
):
"""
Args:
thresholds (list): a list of thresholds used to stratify predictions
into levels.
labels (list): a list of val... | [
"def",
"__init__",
"(",
"self",
",",
"thresholds",
":",
"List",
"[",
"float",
"]",
",",
"labels",
":",
"List",
"[",
"int",
"]",
",",
"allow_low_quality_matches",
":",
"bool",
"=",
"False",
",",
")",
":",
"thresholds",
"=",
"thresholds",
"[",
":",
"]",
... | [
537,
4
] | [
564,
66
] | python | en | ['en', 'error', 'th'] | False |
Matcher.__call__ | (self, match_quality_matrix) |
Args:
match_quality_matrix (Tensor[float]): an MxN tensor, containing the pairwise quality between M ground-truth elements and N predicted
elements. All elements must be >= 0 (due to the us of `torch.nonzero` for selecting indices in :meth:`set_low_quality_matches_`).
Return... |
Args:
match_quality_matrix (Tensor[float]): an MxN tensor, containing the pairwise quality between M ground-truth elements and N predicted
elements. All elements must be >= 0 (due to the us of `torch.nonzero` for selecting indices in :meth:`set_low_quality_matches_`).
Return... | def __call__(self, match_quality_matrix):
"""
Args:
match_quality_matrix (Tensor[float]): an MxN tensor, containing the pairwise quality between M ground-truth elements and N predicted
elements. All elements must be >= 0 (due to the us of `torch.nonzero` for selecting indices... | [
"def",
"__call__",
"(",
"self",
",",
"match_quality_matrix",
")",
":",
"assert",
"match_quality_matrix",
".",
"dim",
"(",
")",
"==",
"2",
"if",
"match_quality_matrix",
".",
"numel",
"(",
")",
"==",
"0",
":",
"default_matches",
"=",
"match_quality_matrix",
".",... | [
566,
4
] | [
602,
36
] | python | en | ['en', 'error', 'th'] | False |
Matcher.set_low_quality_matches_ | (self, match_labels, match_quality_matrix) |
Produce additional matches for predictions that have only low-quality matches.
Specifically, for each ground-truth G find the set of predictions that have
maximum overlap with it (including ties); for each prediction in that set, if
it is unmatched, then match it to the ground-truth G.
... |
Produce additional matches for predictions that have only low-quality matches.
Specifically, for each ground-truth G find the set of predictions that have
maximum overlap with it (including ties); for each prediction in that set, if
it is unmatched, then match it to the ground-truth G.
... | def set_low_quality_matches_(self, match_labels, match_quality_matrix):
"""
Produce additional matches for predictions that have only low-quality matches.
Specifically, for each ground-truth G find the set of predictions that have
maximum overlap with it (including ties); for each predic... | [
"def",
"set_low_quality_matches_",
"(",
"self",
",",
"match_labels",
",",
"match_quality_matrix",
")",
":",
"# For each gt, find the prediction with which it has highest quality",
"highest_quality_foreach_gt",
",",
"_",
"=",
"match_quality_matrix",
".",
"max",
"(",
"dim",
"="... | [
604,
4
] | [
623,
56
] | python | en | ['en', 'error', 'th'] | False |
RPNOutputs.__init__ | (
self,
box2box_transform,
anchor_matcher,
batch_size_per_image,
positive_fraction,
images,
pred_objectness_logits,
pred_anchor_deltas,
anchors,
boundary_threshold=0,
gt_boxes=None,
smooth_l1_beta=0.0,
) |
Args:
box2box_transform (Box2BoxTransform): :class:`Box2BoxTransform` instance for anchor-proposal transformations.
anchor_matcher (Matcher): :class:`Matcher` instance for matching anchors to ground-truth boxes; used to determine training labels.
batch_size_per_image (int): ... |
Args:
box2box_transform (Box2BoxTransform): :class:`Box2BoxTransform` instance for anchor-proposal transformations.
anchor_matcher (Matcher): :class:`Matcher` instance for matching anchors to ground-truth boxes; used to determine training labels.
batch_size_per_image (int): ... | def __init__(
self,
box2box_transform,
anchor_matcher,
batch_size_per_image,
positive_fraction,
images,
pred_objectness_logits,
pred_anchor_deltas,
anchors,
boundary_threshold=0,
gt_boxes=None,
smooth_l1_beta=0.0,
):
... | [
"def",
"__init__",
"(",
"self",
",",
"box2box_transform",
",",
"anchor_matcher",
",",
"batch_size_per_image",
",",
"positive_fraction",
",",
"images",
",",
"pred_objectness_logits",
",",
"pred_anchor_deltas",
",",
"anchors",
",",
"boundary_threshold",
"=",
"0",
",",
... | [
627,
4
] | [
667,
44
] | python | en | ['en', 'error', 'th'] | False |
RPNOutputs.predict_objectness_logits | (self) |
Returns:
pred_objectness_logits (list[Tensor]) -> (N, Hi*Wi*A).
|
Returns:
pred_objectness_logits (list[Tensor]) -> (N, Hi*Wi*A).
| def predict_objectness_logits(self):
"""
Returns:
pred_objectness_logits (list[Tensor]) -> (N, Hi*Wi*A).
"""
pred_objectness_logits = [
# Reshape: (N, A, Hi, Wi) -> (N, Hi, Wi, A) -> (N, Hi*Wi*A)
score.permute(0, 2, 3, 1).reshape(self.num_images, -1)
... | [
"def",
"predict_objectness_logits",
"(",
"self",
")",
":",
"pred_objectness_logits",
"=",
"[",
"# Reshape: (N, A, Hi, Wi) -> (N, Hi, Wi, A) -> (N, Hi*Wi*A)",
"score",
".",
"permute",
"(",
"0",
",",
"2",
",",
"3",
",",
"1",
")",
".",
"reshape",
"(",
"self",
".",
... | [
689,
4
] | [
699,
37
] | python | en | ['en', 'error', 'th'] | False |
Backbone.size_divisibility | (self) |
Some backbones require the input height and width to be divisible by a specific integer. This is
typically true for encoder / decoder type networks with lateral connection (e.g., FPN) for which feature maps need to match
dimension in the "bottom up" and "top down" paths. Set to 0 if no specific... |
Some backbones require the input height and width to be divisible by a specific integer. This is
typically true for encoder / decoder type networks with lateral connection (e.g., FPN) for which feature maps need to match
dimension in the "bottom up" and "top down" paths. Set to 0 if no specific... | def size_divisibility(self):
"""
Some backbones require the input height and width to be divisible by a specific integer. This is
typically true for encoder / decoder type networks with lateral connection (e.g., FPN) for which feature maps need to match
dimension in the "bottom up" and "... | [
"def",
"size_divisibility",
"(",
"self",
")",
":",
"return",
"0"
] | [
909,
4
] | [
915,
16
] | python | en | ['en', 'error', 'th'] | False |
ResNet.__init__ | (self, stem, stages, num_classes=None, out_features=None) |
Args:
stem (nn.Module): a stem module
stages (list[list[ResNetBlock]]): several (typically 4) stages, each contains multiple :class:`ResNetBlockBase`.
num_classes (None or int): if None, will not perform classification.
out_features (list[str]): name of the layer... |
Args:
stem (nn.Module): a stem module
stages (list[list[ResNetBlock]]): several (typically 4) stages, each contains multiple :class:`ResNetBlockBase`.
num_classes (None or int): if None, will not perform classification.
out_features (list[str]): name of the layer... | def __init__(self, stem, stages, num_classes=None, out_features=None):
"""
Args:
stem (nn.Module): a stem module
stages (list[list[ResNetBlock]]): several (typically 4) stages, each contains multiple :class:`ResNetBlockBase`.
num_classes (None or int): if None, will n... | [
"def",
"__init__",
"(",
"self",
",",
"stem",
",",
"stages",
",",
"num_classes",
"=",
"None",
",",
"out_features",
"=",
"None",
")",
":",
"super",
"(",
"ResNet",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"stem",
"=",
"stem",
"self",
... | [
943,
4
] | [
990,
96
] | python | en | ['en', 'error', 'th'] | False |
ResNet.make_stage | (
block_class,
num_blocks,
first_stride=None,
*,
in_channels,
out_channels,
**kwargs,
) |
Usually, layers that produce the same feature map spatial size
are defined as one "stage".
Under such definition, stride_per_block[1:] should all be 1.
|
Usually, layers that produce the same feature map spatial size
are defined as one "stage".
Under such definition, stride_per_block[1:] should all be 1.
| def make_stage(
block_class,
num_blocks,
first_stride=None,
*,
in_channels,
out_channels,
**kwargs,
):
"""
Usually, layers that produce the same feature map spatial size
are defined as one "stage".
Under such definition, stride_... | [
"def",
"make_stage",
"(",
"block_class",
",",
"num_blocks",
",",
"first_stride",
"=",
"None",
",",
"*",
",",
"in_channels",
",",
"out_channels",
",",
"*",
"*",
"kwargs",
",",
")",
":",
"if",
"first_stride",
"is",
"not",
"None",
":",
"assert",
"\"stride\"",... | [
1018,
4
] | [
1052,
21
] | python | en | ['en', 'error', 'th'] | False |
ROIPooler.forward | (self, feature_maps, boxes) |
Args:
feature_maps: List[torch.Tensor(N,C,W,H)]
box_lists: list[torch.Tensor])
Returns:
A tensor of shape(N*B, Channels, output_size, output_size)
|
Args:
feature_maps: List[torch.Tensor(N,C,W,H)]
box_lists: list[torch.Tensor])
Returns:
A tensor of shape(N*B, Channels, output_size, output_size)
| def forward(self, feature_maps, boxes):
"""
Args:
feature_maps: List[torch.Tensor(N,C,W,H)]
box_lists: list[torch.Tensor])
Returns:
A tensor of shape(N*B, Channels, output_size, output_size)
"""
x = [v for v in feature_maps.values()]
nu... | [
"def",
"forward",
"(",
"self",
",",
"feature_maps",
",",
"boxes",
")",
":",
"x",
"=",
"[",
"v",
"for",
"v",
"in",
"feature_maps",
".",
"values",
"(",
")",
"]",
"num_level_assignments",
"=",
"len",
"(",
"self",
".",
"level_poolers",
")",
"assert",
"len"... | [
1092,
4
] | [
1133,
21
] | python | en | ['en', 'error', 'th'] | False |
AnchorGenerator.__init__ | (self, cfg, input_shape: List[ShapeSpec]) |
sizes (list[list[int]]): sizes[i] is the list of anchor sizes for feat map i
1. given in absolute lengths in units of the input image;
2. they do not dynamically scale if the input image size changes.
aspect_ratios (list[list[float]])
strides (list[int]): stride of each ... |
sizes (list[list[int]]): sizes[i] is the list of anchor sizes for feat map i
1. given in absolute lengths in units of the input image;
2. they do not dynamically scale if the input image size changes.
aspect_ratios (list[list[float]])
strides (list[int]): stride of each ... | def __init__(self, cfg, input_shape: List[ShapeSpec]):
super().__init__()
sizes = cfg.ANCHOR_GENERATOR.SIZES
aspect_ratios = cfg.ANCHOR_GENERATOR.ASPECT_RATIOS
self.strides = [x.stride for x in input_shape]
self.offset = cfg.ANCHOR_GENERATOR.OFFSET
assert 0.0 <= self.offs... | [
"def",
"__init__",
"(",
"self",
",",
"cfg",
",",
"input_shape",
":",
"List",
"[",
"ShapeSpec",
"]",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"sizes",
"=",
"cfg",
".",
"ANCHOR_GENERATOR",
".",
"SIZES",
"aspect_ratios",
"=",
"cfg",
".",
... | [
1356,
4
] | [
1374,
34
] | python | en | ['en', 'error', 'th'] | False |
AnchorGenerator.num_cell_anchors | (self) |
Returns:
list[int]: Each int is the number of anchors at every pixel location, on that feature map.
|
Returns:
list[int]: Each int is the number of anchors at every pixel location, on that feature map.
| def num_cell_anchors(self):
"""
Returns:
list[int]: Each int is the number of anchors at every pixel location, on that feature map.
"""
return [len(cell_anchors) for cell_anchors in self.cell_anchors] | [
"def",
"num_cell_anchors",
"(",
"self",
")",
":",
"return",
"[",
"len",
"(",
"cell_anchors",
")",
"for",
"cell_anchors",
"in",
"self",
".",
"cell_anchors",
"]"
] | [
1395,
4
] | [
1400,
72
] | python | en | ['en', 'error', 'th'] | False |
AnchorGenerator.generate_cell_anchors | (self, sizes=(32, 64, 128, 256, 512), aspect_ratios=(0.5, 1, 2)) |
anchors are continuous geometric rectangles
centered on one feature map point sample.
We can later build the set of anchors
for the entire feature map by tiling these tensors
|
anchors are continuous geometric rectangles
centered on one feature map point sample.
We can later build the set of anchors
for the entire feature map by tiling these tensors
| def generate_cell_anchors(self, sizes=(32, 64, 128, 256, 512), aspect_ratios=(0.5, 1, 2)):
"""
anchors are continuous geometric rectangles
centered on one feature map point sample.
We can later build the set of anchors
for the entire feature map by tiling these tensors
""... | [
"def",
"generate_cell_anchors",
"(",
"self",
",",
"sizes",
"=",
"(",
"32",
",",
"64",
",",
"128",
",",
"256",
",",
"512",
")",
",",
"aspect_ratios",
"=",
"(",
"0.5",
",",
"1",
",",
"2",
")",
")",
":",
"anchors",
"=",
"[",
"]",
"for",
"size",
"i... | [
1412,
4
] | [
1428,
50
] | python | en | ['en', 'error', 'th'] | False |
AnchorGenerator.forward | (self, features) |
Args:
features List[torch.Tensor]: list of feature maps on which to generate anchors.
Returns:
torch.Tensor: a list of #image elements.
|
Args:
features List[torch.Tensor]: list of feature maps on which to generate anchors.
Returns:
torch.Tensor: a list of #image elements.
| def forward(self, features):
"""
Args:
features List[torch.Tensor]: list of feature maps on which to generate anchors.
Returns:
torch.Tensor: a list of #image elements.
"""
num_images = features[0].size(0)
grid_sizes = [feature_map.shape[-2:] for f... | [
"def",
"forward",
"(",
"self",
",",
"features",
")",
":",
"num_images",
"=",
"features",
"[",
"0",
"]",
".",
"size",
"(",
"0",
")",
"grid_sizes",
"=",
"[",
"feature_map",
".",
"shape",
"[",
"-",
"2",
":",
"]",
"for",
"feature_map",
"in",
"features",
... | [
1430,
4
] | [
1441,
94
] | python | en | ['en', 'error', 'th'] | False |
RPNHead.forward | (self, features) |
Args:
features (list[Tensor]): list of feature maps
|
Args:
features (list[Tensor]): list of feature maps
| def forward(self, features):
"""
Args:
features (list[Tensor]): list of feature maps
"""
pred_objectness_logits = []
pred_anchor_deltas = []
for x in features:
t = F.relu(self.conv(x))
pred_objectness_logits.append(self.objectness_logit... | [
"def",
"forward",
"(",
"self",
",",
"features",
")",
":",
"pred_objectness_logits",
"=",
"[",
"]",
"pred_anchor_deltas",
"=",
"[",
"]",
"for",
"x",
"in",
"features",
":",
"t",
"=",
"F",
".",
"relu",
"(",
"self",
".",
"conv",
"(",
"x",
")",
")",
"pr... | [
1484,
4
] | [
1495,
57
] | python | en | ['en', 'error', 'th'] | False |
RPN.forward | (self, images, image_shapes, features, gt_boxes=None) |
Args:
images (torch.Tensor): input images of length `N`
features (dict[str: Tensor])
gt_instances
|
Args:
images (torch.Tensor): input images of length `N`
features (dict[str: Tensor])
gt_instances
| def forward(self, images, image_shapes, features, gt_boxes=None):
"""
Args:
images (torch.Tensor): input images of length `N`
features (dict[str: Tensor])
gt_instances
"""
# features is dict, key = block level, v = feature_map
features = [featu... | [
"def",
"forward",
"(",
"self",
",",
"images",
",",
"image_shapes",
",",
"features",
",",
"gt_boxes",
"=",
"None",
")",
":",
"# features is dict, key = block level, v = feature_map",
"features",
"=",
"[",
"features",
"[",
"f",
"]",
"for",
"f",
"in",
"self",
"."... | [
1559,
4
] | [
1589,
84
] | python | en | ['en', 'error', 'th'] | False |
FastRCNNOutputLayers.__init__ | (
self,
input_size,
num_classes,
cls_agnostic_bbox_reg,
box_dim=4,
use_attr=False,
num_attrs=-1,
) |
Args:
input_size (int): channels, or (channels, height, width)
num_classes (int)
cls_agnostic_bbox_reg (bool)
box_dim (int)
|
Args:
input_size (int): channels, or (channels, height, width)
num_classes (int)
cls_agnostic_bbox_reg (bool)
box_dim (int)
| def __init__(
self,
input_size,
num_classes,
cls_agnostic_bbox_reg,
box_dim=4,
use_attr=False,
num_attrs=-1,
):
"""
Args:
input_size (int): channels, or (channels, height, width)
num_classes (int)
cls_agnosti... | [
"def",
"__init__",
"(",
"self",
",",
"input_size",
",",
"num_classes",
",",
"cls_agnostic_bbox_reg",
",",
"box_dim",
"=",
"4",
",",
"use_attr",
"=",
"False",
",",
"num_attrs",
"=",
"-",
"1",
",",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
... | [
1599,
4
] | [
1640,
43
] | python | en | ['en', 'error', 'th'] | False |
GeneralizedRCNN.forward | (
self,
images,
image_shapes,
gt_boxes=None,
proposals=None,
scales_yx=None,
**kwargs,
) |
kwargs:
max_detections (int), return_tensors {"np", "pt", None}, padding {None,
"max_detections"}, pad_value (int), location = {"cuda", "cpu"}
|
kwargs:
max_detections (int), return_tensors {"np", "pt", None}, padding {None,
"max_detections"}, pad_value (int), location = {"cuda", "cpu"}
| def forward(
self,
images,
image_shapes,
gt_boxes=None,
proposals=None,
scales_yx=None,
**kwargs,
):
"""
kwargs:
max_detections (int), return_tensors {"np", "pt", None}, padding {None,
"max_detections"}, pad_value (int),... | [
"def",
"forward",
"(",
"self",
",",
"images",
",",
"image_shapes",
",",
"gt_boxes",
"=",
"None",
",",
"proposals",
"=",
"None",
",",
"scales_yx",
"=",
"None",
",",
"*",
"*",
"kwargs",
",",
")",
":",
"if",
"self",
".",
"training",
":",
"raise",
"NotIm... | [
1832,
4
] | [
1855,
9
] | python | en | ['en', 'error', 'th'] | False |
validate_station | (station) | Check that the station ID is well-formed. | Check that the station ID is well-formed. | def validate_station(station):
"""Check that the station ID is well-formed."""
if station is None:
return
if not re.fullmatch(r"[A-Z]{2}/s0000\d{3}", station):
raise vol.error.Invalid('Station ID must be of the form "XX/s0000###"')
return station | [
"def",
"validate_station",
"(",
"station",
")",
":",
"if",
"station",
"is",
"None",
":",
"return",
"if",
"not",
"re",
".",
"fullmatch",
"(",
"r\"[A-Z]{2}/s0000\\d{3}\"",
",",
"station",
")",
":",
"raise",
"vol",
".",
"error",
".",
"Invalid",
"(",
"'Station... | [
32,
0
] | [
38,
18
] | python | en | ['en', 'en', 'en'] | True |
setup_platform | (hass, config, add_entities, discovery_info=None) | Set up the Environment Canada sensor. | Set up the Environment Canada sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Environment Canada sensor."""
if config.get(CONF_STATION):
ec_data = ECData(
station_id=config[CONF_STATION], language=config.get(CONF_LANGUAGE)
)
else:
lat = config.get(CONF_LATITUDE, has... | [
"def",
"setup_platform",
"(",
"hass",
",",
"config",
",",
"add_entities",
",",
"discovery_info",
"=",
"None",
")",
":",
"if",
"config",
".",
"get",
"(",
"CONF_STATION",
")",
":",
"ec_data",
"=",
"ECData",
"(",
"station_id",
"=",
"config",
"[",
"CONF_STATIO... | [
51,
0
] | [
64,
87
] | python | en | ['en', 'pt', 'en'] | True |
ECSensor.__init__ | (self, sensor_type, ec_data) | Initialize the sensor. | Initialize the sensor. | def __init__(self, sensor_type, ec_data):
"""Initialize the sensor."""
self.sensor_type = sensor_type
self.ec_data = ec_data
self._unique_id = None
self._name = None
self._state = None
self._attr = None
self._unit = None | [
"def",
"__init__",
"(",
"self",
",",
"sensor_type",
",",
"ec_data",
")",
":",
"self",
".",
"sensor_type",
"=",
"sensor_type",
"self",
".",
"ec_data",
"=",
"ec_data",
"self",
".",
"_unique_id",
"=",
"None",
"self",
".",
"_name",
"=",
"None",
"self",
".",
... | [
70,
4
] | [
79,
25
] | python | en | ['en', 'en', 'en'] | True |
ECSensor.unique_id | (self) | Return the unique ID of the sensor. | Return the unique ID of the sensor. | def unique_id(self) -> str:
"""Return the unique ID of the sensor."""
return self._unique_id | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"_unique_id"
] | [
82,
4
] | [
84,
30
] | python | en | ['en', 'la', 'en'] | True |
ECSensor.name | (self) | Return the name of the sensor. | Return the name of the sensor. | def name(self):
"""Return the name of the sensor."""
return self._name | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"self",
".",
"_name"
] | [
87,
4
] | [
89,
25
] | python | en | ['en', 'mi', 'en'] | True |
ECSensor.state | (self) | Return the state of the sensor. | Return the state of the sensor. | def state(self):
"""Return the state of the sensor."""
return self._state | [
"def",
"state",
"(",
"self",
")",
":",
"return",
"self",
".",
"_state"
] | [
92,
4
] | [
94,
26
] | python | en | ['en', 'en', 'en'] | True |
ECSensor.device_state_attributes | (self) | Return the state attributes of the device. | Return the state attributes of the device. | def device_state_attributes(self):
"""Return the state attributes of the device."""
return self._attr | [
"def",
"device_state_attributes",
"(",
"self",
")",
":",
"return",
"self",
".",
"_attr"
] | [
97,
4
] | [
99,
25
] | python | en | ['en', 'en', 'en'] | True |
ECSensor.unit_of_measurement | (self) | Return the units of measurement. | Return the units of measurement. | def unit_of_measurement(self):
"""Return the units of measurement."""
return self._unit | [
"def",
"unit_of_measurement",
"(",
"self",
")",
":",
"return",
"self",
".",
"_unit"
] | [
102,
4
] | [
104,
25
] | python | en | ['en', 'bg', 'en'] | True |
ECSensor.update | (self) | Update current conditions. | Update current conditions. | def update(self):
"""Update current conditions."""
self.ec_data.update()
self.ec_data.conditions.update(self.ec_data.alerts)
conditions = self.ec_data.conditions
metadata = self.ec_data.metadata
sensor_data = conditions.get(self.sensor_type)
self._unique_id = f"... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"ec_data",
".",
"update",
"(",
")",
"self",
".",
"ec_data",
".",
"conditions",
".",
"update",
"(",
"self",
".",
"ec_data",
".",
"alerts",
")",
"conditions",
"=",
"self",
".",
"ec_data",
".",
"condi... | [
106,
4
] | [
154,
9
] | python | en | ['en', 'en', 'en'] | True |
test_next_events | (hass) | Test retrieving next sun events. | Test retrieving next sun events. | def test_next_events(hass):
"""Test retrieving next sun events."""
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
from astral import Astral
astral = Astral()
utc_today = utc_now.date()
latitude = hass.config.latitude
longitude = hass.config.longitude
mod = -1
while T... | [
"def",
"test_next_events",
"(",
"hass",
")",
":",
"utc_now",
"=",
"datetime",
"(",
"2016",
",",
"11",
",",
"1",
",",
"8",
",",
"0",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"from",
"astral",
"import",
"Astral",
"astral",
"=",
"Astr... | [
11,
0
] | [
80,
80
] | python | en | ['en', 'lb', 'en'] | True |
test_date_events | (hass) | Test retrieving next sun events. | Test retrieving next sun events. | def test_date_events(hass):
"""Test retrieving next sun events."""
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
from astral import Astral
astral = Astral()
utc_today = utc_now.date()
latitude = hass.config.latitude
longitude = hass.config.longitude
dawn = astral.dawn_u... | [
"def",
"test_date_events",
"(",
"hass",
")",
":",
"utc_now",
"=",
"datetime",
"(",
"2016",
",",
"11",
",",
"1",
",",
"8",
",",
"0",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"from",
"astral",
"import",
"Astral",
"astral",
"=",
"Astr... | [
83,
0
] | [
106,
81
] | python | en | ['en', 'lb', 'en'] | True |
test_date_events_default_date | (hass) | Test retrieving next sun events. | Test retrieving next sun events. | def test_date_events_default_date(hass):
"""Test retrieving next sun events."""
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
from astral import Astral
astral = Astral()
utc_today = utc_now.date()
latitude = hass.config.latitude
longitude = hass.config.longitude
dawn = ... | [
"def",
"test_date_events_default_date",
"(",
"hass",
")",
":",
"utc_now",
"=",
"datetime",
"(",
"2016",
",",
"11",
",",
"1",
",",
"8",
",",
"0",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"from",
"astral",
"import",
"Astral",
"astral",
... | [
109,
0
] | [
133,
85
] | python | en | ['en', 'lb', 'en'] | True |
test_date_events_accepts_datetime | (hass) | Test retrieving next sun events. | Test retrieving next sun events. | def test_date_events_accepts_datetime(hass):
"""Test retrieving next sun events."""
utc_now = datetime(2016, 11, 1, 8, 0, 0, tzinfo=dt_util.UTC)
from astral import Astral
astral = Astral()
utc_today = utc_now.date()
latitude = hass.config.latitude
longitude = hass.config.longitude
daw... | [
"def",
"test_date_events_accepts_datetime",
"(",
"hass",
")",
":",
"utc_now",
"=",
"datetime",
"(",
"2016",
",",
"11",
",",
"1",
",",
"8",
",",
"0",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"from",
"astral",
"import",
"Astral",
"astral... | [
136,
0
] | [
159,
79
] | python | en | ['en', 'lb', 'en'] | True |
test_is_up | (hass) | Test retrieving next sun events. | Test retrieving next sun events. | def test_is_up(hass):
"""Test retrieving next sun events."""
utc_now = datetime(2016, 11, 1, 12, 0, 0, tzinfo=dt_util.UTC)
with patch("homeassistant.helpers.condition.dt_util.utcnow", return_value=utc_now):
assert not sun.is_up(hass)
utc_now = datetime(2016, 11, 1, 18, 0, 0, tzinfo=dt_util.UTC)... | [
"def",
"test_is_up",
"(",
"hass",
")",
":",
"utc_now",
"=",
"datetime",
"(",
"2016",
",",
"11",
",",
"1",
",",
"12",
",",
"0",
",",
"0",
",",
"tzinfo",
"=",
"dt_util",
".",
"UTC",
")",
"with",
"patch",
"(",
"\"homeassistant.helpers.condition.dt_util.utcn... | [
162,
0
] | [
170,
30
] | python | en | ['en', 'lb', 'en'] | True |
test_norway_in_june | (hass) | Test location in Norway where the sun doesn't set in summer. | Test location in Norway where the sun doesn't set in summer. | def test_norway_in_june(hass):
"""Test location in Norway where the sun doesn't set in summer."""
hass.config.latitude = 69.6
hass.config.longitude = 18.8
june = datetime(2016, 6, 1, tzinfo=dt_util.UTC)
print(sun.get_astral_event_date(hass, SUN_EVENT_SUNRISE, datetime(2017, 7, 25)))
print(sun.... | [
"def",
"test_norway_in_june",
"(",
"hass",
")",
":",
"hass",
".",
"config",
".",
"latitude",
"=",
"69.6",
"hass",
".",
"config",
".",
"longitude",
"=",
"18.8",
"june",
"=",
"datetime",
"(",
"2016",
",",
"6",
",",
"1",
",",
"tzinfo",
"=",
"dt_util",
"... | [
173,
0
] | [
193,
74
] | python | en | ['en', 'en', 'en'] | True |
test_is_media_source_id | () | Test media source validation. | Test media source validation. | async def test_is_media_source_id():
"""Test media source validation."""
assert media_source.is_media_source_id(const.URI_SCHEME)
assert media_source.is_media_source_id(f"{const.URI_SCHEME}domain")
assert media_source.is_media_source_id(f"{const.URI_SCHEME}domain/identifier")
assert not media_source... | [
"async",
"def",
"test_is_media_source_id",
"(",
")",
":",
"assert",
"media_source",
".",
"is_media_source_id",
"(",
"const",
".",
"URI_SCHEME",
")",
"assert",
"media_source",
".",
"is_media_source_id",
"(",
"f\"{const.URI_SCHEME}domain\"",
")",
"assert",
"media_source",... | [
13,
0
] | [
18,
54
] | python | en | ['fr', 'et', 'en'] | False |
test_generate_media_source_id | () | Test identifier generation. | Test identifier generation. | async def test_generate_media_source_id():
"""Test identifier generation."""
tests = [
(None, None),
(None, ""),
("", ""),
("domain", None),
("domain", ""),
("domain", "identifier"),
]
for domain, identifier in tests:
assert media_source.is_media_... | [
"async",
"def",
"test_generate_media_source_id",
"(",
")",
":",
"tests",
"=",
"[",
"(",
"None",
",",
"None",
")",
",",
"(",
"None",
",",
"\"\"",
")",
",",
"(",
"\"\"",
",",
"\"\"",
")",
",",
"(",
"\"domain\"",
",",
"None",
")",
",",
"(",
"\"domain\... | [
21,
0
] | [
35,
9
] | python | de | ['de', 'fy', 'en'] | False |
test_async_browse_media | (hass) | Test browse media. | Test browse media. | async def test_async_browse_media(hass):
"""Test browse media."""
assert await async_setup_component(hass, const.DOMAIN, {})
await hass.async_block_till_done()
# Test non-media ignored (/media has test.mp3 and not_media.txt)
media = await media_source.async_browse_media(hass, "")
assert isinsta... | [
"async",
"def",
"test_async_browse_media",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"const",
".",
"DOMAIN",
",",
"{",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"# Test non-media ignored (/media h... | [
38,
0
] | [
57,
51
] | python | en | ['en', 'da', 'en'] | True |
test_async_resolve_media | (hass) | Test browse media. | Test browse media. | async def test_async_resolve_media(hass):
"""Test browse media."""
assert await async_setup_component(hass, const.DOMAIN, {})
await hass.async_block_till_done()
media = await media_source.async_resolve_media(
hass,
media_source.generate_media_source_id(const.DOMAIN, "local/test.mp3"),
... | [
"async",
"def",
"test_async_resolve_media",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"const",
".",
"DOMAIN",
",",
"{",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"media",
"=",
"await",
"medi... | [
60,
0
] | [
69,
59
] | python | en | ['en', 'da', 'en'] | True |
test_async_unresolve_media | (hass) | Test browse media. | Test browse media. | async def test_async_unresolve_media(hass):
"""Test browse media."""
assert await async_setup_component(hass, const.DOMAIN, {})
await hass.async_block_till_done()
# Test no media content
with pytest.raises(Unresolvable):
await media_source.async_resolve_media(hass, "") | [
"async",
"def",
"test_async_unresolve_media",
"(",
"hass",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"const",
".",
"DOMAIN",
",",
"{",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"# Test no media content",
"wi... | [
72,
0
] | [
79,
56
] | python | en | ['en', 'da', 'en'] | True |
test_websocket_browse_media | (hass, hass_ws_client) | Test browse media websocket. | Test browse media websocket. | async def test_websocket_browse_media(hass, hass_ws_client):
"""Test browse media websocket."""
assert await async_setup_component(hass, const.DOMAIN, {})
await hass.async_block_till_done()
client = await hass_ws_client(hass)
media = media_source.models.BrowseMediaSource(
domain=const.DOMA... | [
"async",
"def",
"test_websocket_browse_media",
"(",
"hass",
",",
"hass_ws_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"const",
".",
"DOMAIN",
",",
"{",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"cli... | [
82,
0
] | [
132,
44
] | python | da | ['pl', 'da', 'en'] | False |
test_websocket_resolve_media | (hass, hass_ws_client) | Test browse media websocket. | Test browse media websocket. | async def test_websocket_resolve_media(hass, hass_ws_client):
"""Test browse media websocket."""
assert await async_setup_component(hass, const.DOMAIN, {})
await hass.async_block_till_done()
client = await hass_ws_client(hass)
media = media_source.models.PlayMedia("/media/local/test.mp3", "audio/m... | [
"async",
"def",
"test_websocket_resolve_media",
"(",
"hass",
",",
"hass_ws_client",
")",
":",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"const",
".",
"DOMAIN",
",",
"{",
"}",
")",
"await",
"hass",
".",
"async_block_till_done",
"(",
")",
"cl... | [
135,
0
] | [
179,
44
] | python | da | ['pl', 'da', 'en'] | False |
get_teacher_predictions | (
model_path: str,
examples: List[str],
class_names: List[str],
hypothesis_template: str,
batch_size: int,
temperature: float,
multi_label: bool,
use_fast_tokenizer: bool,
no_cuda: bool,
fp16: bool,
) |
Gets predictions by the same method as the zero-shot pipeline but with DataParallel & more efficient batching
|
Gets predictions by the same method as the zero-shot pipeline but with DataParallel & more efficient batching
| def get_teacher_predictions(
model_path: str,
examples: List[str],
class_names: List[str],
hypothesis_template: str,
batch_size: int,
temperature: float,
multi_label: bool,
use_fast_tokenizer: bool,
no_cuda: bool,
fp16: bool,
):
"""
Gets predictions by the same method as ... | [
"def",
"get_teacher_predictions",
"(",
"model_path",
":",
"str",
",",
"examples",
":",
"List",
"[",
"str",
"]",
",",
"class_names",
":",
"List",
"[",
"str",
"]",
",",
"hypothesis_template",
":",
"str",
",",
"batch_size",
":",
"int",
",",
"temperature",
":"... | [
158,
0
] | [
212,
27
] | python | en | ['en', 'error', 'th'] | False |
get_service | (hass, config, discovery_info=None) | Get the Homematic notification service. | Get the Homematic notification service. | def get_service(hass, config, discovery_info=None):
"""Get the Homematic notification service."""
data = {
ATTR_ADDRESS: config[ATTR_ADDRESS],
ATTR_CHANNEL: config[ATTR_CHANNEL],
ATTR_PARAM: config[ATTR_PARAM],
ATTR_VALUE: config[ATTR_VALUE],
}
if ATTR_INTERFACE in config... | [
"def",
"get_service",
"(",
"hass",
",",
"config",
",",
"discovery_info",
"=",
"None",
")",
":",
"data",
"=",
"{",
"ATTR_ADDRESS",
":",
"config",
"[",
"ATTR_ADDRESS",
"]",
",",
"ATTR_CHANNEL",
":",
"config",
"[",
"ATTR_CHANNEL",
"]",
",",
"ATTR_PARAM",
":",... | [
32,
0
] | [
43,
51
] | python | en | ['en', 'en', 'en'] | True |
HomematicNotificationService.__init__ | (self, hass, data) | Initialize the service. | Initialize the service. | def __init__(self, hass, data):
"""Initialize the service."""
self.hass = hass
self.data = data | [
"def",
"__init__",
"(",
"self",
",",
"hass",
",",
"data",
")",
":",
"self",
".",
"hass",
"=",
"hass",
"self",
".",
"data",
"=",
"data"
] | [
49,
4
] | [
52,
24
] | python | en | ['en', 'en', 'en'] | True |
HomematicNotificationService.send_message | (self, message="", **kwargs) | Send a notification to the device. | Send a notification to the device. | def send_message(self, message="", **kwargs):
"""Send a notification to the device."""
data = {**self.data, **kwargs.get(ATTR_DATA, {})}
if data.get(ATTR_VALUE) is not None:
templ = template_helper.Template(self.data[ATTR_VALUE], self.hass)
data[ATTR_VALUE] = template_he... | [
"def",
"send_message",
"(",
"self",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"*",
"*",
"self",
".",
"data",
",",
"*",
"*",
"kwargs",
".",
"get",
"(",
"ATTR_DATA",
",",
"{",
"}",
")",
"}",
"if",
"data",
... | [
54,
4
] | [
62,
71
] | python | en | ['en', 'en', 'en'] | True |
async_setup_entry | (
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
) | Set up for AlarmDecoder sensor. | Set up for AlarmDecoder sensor. | async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
):
"""Set up for AlarmDecoder sensor."""
entity = AlarmDecoderSensor()
async_add_entities([entity])
return True | [
"async",
"def",
"async_setup_entry",
"(",
"hass",
":",
"HomeAssistantType",
",",
"entry",
":",
"ConfigEntry",
",",
"async_add_entities",
")",
":",
"entity",
"=",
"AlarmDecoderSensor",
"(",
")",
"async_add_entities",
"(",
"[",
"entity",
"]",
")",
"return",
"True"... | [
8,
0
] | [
15,
15
] | python | en | ['en', 'da', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.