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
HassIOAddonPanel.post
(self, request, addon)
Handle new add-on panel requests.
Handle new add-on panel requests.
async def post(self, request, addon): """Handle new add-on panel requests.""" panels = await self.get_panels() # Panel exists for add-on slug if addon not in panels or not panels[addon][ATTR_ENABLE]: _LOGGER.error("Panel is not enable for %s", addon) return web.R...
[ "async", "def", "post", "(", "self", ",", "request", ",", "addon", ")", ":", "panels", "=", "await", "self", ".", "get_panels", "(", ")", "# Panel exists for add-on slug", "if", "addon", "not", "in", "panels", "or", "not", "panels", "[", "addon", "]", "[...
[ 48, 4 ]
[ 60, 29 ]
python
en
['it', 'en', 'en']
True
HassIOAddonPanel.delete
(self, request, addon)
Handle remove add-on panel requests.
Handle remove add-on panel requests.
async def delete(self, request, addon): """Handle remove add-on panel requests.""" self.hass.components.frontend.async_remove_panel(addon) return web.Response()
[ "async", "def", "delete", "(", "self", ",", "request", ",", "addon", ")", ":", "self", ".", "hass", ".", "components", ".", "frontend", ".", "async_remove_panel", "(", "addon", ")", "return", "web", ".", "Response", "(", ")" ]
[ 62, 4 ]
[ 65, 29 ]
python
en
['it', 'en', 'en']
True
HassIOAddonPanel.get_panels
(self)
Return panels add-on info data.
Return panels add-on info data.
async def get_panels(self): """Return panels add-on info data.""" try: data = await self.hassio.get_ingress_panels() return data[ATTR_PANELS] except HassioAPIError as err: _LOGGER.error("Can't read panel info: %s", err) return {}
[ "async", "def", "get_panels", "(", "self", ")", ":", "try", ":", "data", "=", "await", "self", ".", "hassio", ".", "get_ingress_panels", "(", ")", "return", "data", "[", "ATTR_PANELS", "]", "except", "HassioAPIError", "as", "err", ":", "_LOGGER", ".", "e...
[ 67, 4 ]
[ 74, 17 ]
python
en
['lv', 'no', 'en']
False
async_get_last_config
(hass: HomeAssistant)
Return the last known working config.
Return the last known working config.
async def async_get_last_config(hass: HomeAssistant) -> Optional[dict]: """Return the last known working config.""" store = storage.Store(hass, STORAGE_VERSION, STORAGE_KEY) return cast(Optional[dict], await store.async_load())
[ "async", "def", "async_get_last_config", "(", "hass", ":", "HomeAssistant", ")", "->", "Optional", "[", "dict", "]", ":", "store", "=", "storage", ".", "Store", "(", "hass", ",", "STORAGE_VERSION", ",", "STORAGE_KEY", ")", "return", "cast", "(", "Optional", ...
[ 103, 0 ]
[ 106, 57 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the HTTP API and debug interface.
Set up the HTTP API and debug interface.
async def async_setup(hass, config): """Set up the HTTP API and debug interface.""" conf = config.get(DOMAIN) if conf is None: conf = HTTP_SCHEMA({}) server_host = conf.get(CONF_SERVER_HOST) server_port = conf[CONF_SERVER_PORT] ssl_certificate = conf.get(CONF_SSL_CERTIFICATE) ssl_p...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "conf", "=", "config", ".", "get", "(", "DOMAIN", ")", "if", "conf", "is", "None", ":", "conf", "=", "HTTP_SCHEMA", "(", "{", "}", ")", "server_host", "=", "conf", ".", "get", "("...
[ 189, 0 ]
[ 271, 15 ]
python
en
['en', 'ceb', 'en']
True
start_http_server_and_save_config
( hass: HomeAssistant, conf: Dict, server: HomeAssistantHTTP )
Startup the http server and save the config.
Startup the http server and save the config.
async def start_http_server_and_save_config( hass: HomeAssistant, conf: Dict, server: HomeAssistantHTTP ) -> None: """Startup the http server and save the config.""" await server.start() # type: ignore # If we are set up successful, we store the HTTP settings for safe mode. store = storage.Store(h...
[ "async", "def", "start_http_server_and_save_config", "(", "hass", ":", "HomeAssistant", ",", "conf", ":", "Dict", ",", "server", ":", "HomeAssistantHTTP", ")", "->", "None", ":", "await", "server", ".", "start", "(", ")", "# type: ignore", "# If we are set up succ...
[ 443, 0 ]
[ 457, 32 ]
python
en
['en', 'en', 'en']
True
ApiConfig.__init__
( self, local_ip: str, host: str, port: Optional[int] = SERVER_PORT, use_ssl: bool = False, )
Initialize a new API config object.
Initialize a new API config object.
def __init__( self, local_ip: str, host: str, port: Optional[int] = SERVER_PORT, use_ssl: bool = False, ) -> None: """Initialize a new API config object.""" self.local_ip = local_ip self.host = host self.port = port self.use_ssl = use_s...
[ "def", "__init__", "(", "self", ",", "local_ip", ":", "str", ",", "host", ":", "str", ",", "port", ":", "Optional", "[", "int", "]", "=", "SERVER_PORT", ",", "use_ssl", ":", "bool", "=", "False", ",", ")", "->", "None", ":", "self", ".", "local_ip"...
[ 112, 4 ]
[ 134, 50 ]
python
en
['en', 'en', 'en']
True
ApiConfig.base_url
(self)
Proxy property to find caller of this deprecated property.
Proxy property to find caller of this deprecated property.
def base_url(self) -> str: """Proxy property to find caller of this deprecated property.""" found_frame = None for frame in reversed(extract_stack()[:-1]): for path in ("custom_components/", "homeassistant/components/"): try: index = frame.filename...
[ "def", "base_url", "(", "self", ")", "->", "str", ":", "found_frame", "=", "None", "for", "frame", "in", "reversed", "(", "extract_stack", "(", ")", "[", ":", "-", "1", "]", ")", ":", "for", "path", "in", "(", "\"custom_components/\"", ",", "\"homeassi...
[ 137, 4 ]
[ 186, 39 ]
python
en
['en', 'en', 'en']
True
HomeAssistantHTTP.__init__
( self, hass, ssl_certificate, ssl_peer_certificate, ssl_key, server_host, server_port, cors_origins, use_x_forwarded_for, trusted_proxies, login_threshold, is_ban_enabled, ssl_profile, )
Initialize the HTTP Home Assistant server.
Initialize the HTTP Home Assistant server.
def __init__( self, hass, ssl_certificate, ssl_peer_certificate, ssl_key, server_host, server_port, cors_origins, use_x_forwarded_for, trusted_proxies, login_threshold, is_ban_enabled, ssl_profile, ): """...
[ "def", "__init__", "(", "self", ",", "hass", ",", "ssl_certificate", ",", "ssl_peer_certificate", ",", "ssl_key", ",", "server_host", ",", "server_port", ",", "cors_origins", ",", "use_x_forwarded_for", ",", "trusted_proxies", ",", "login_threshold", ",", "is_ban_en...
[ 277, 4 ]
[ 324, 24 ]
python
en
['en', 'en', 'en']
True
HomeAssistantHTTP.register_view
(self, view)
Register a view with the WSGI server. The view argument must be a class that inherits from HomeAssistantView. It is optional to instantiate it before registering; this method will handle it either way.
Register a view with the WSGI server.
def register_view(self, view): """Register a view with the WSGI server. The view argument must be a class that inherits from HomeAssistantView. It is optional to instantiate it before registering; this method will handle it either way. """ if isinstance(view, type): ...
[ "def", "register_view", "(", "self", ",", "view", ")", ":", "if", "isinstance", "(", "view", ",", "type", ")", ":", "# Instantiate the view, if needed", "view", "=", "view", "(", ")", "if", "not", "hasattr", "(", "view", ",", "\"url\"", ")", ":", "class_...
[ 326, 4 ]
[ 345, 48 ]
python
en
['en', 'en', 'en']
True
HomeAssistantHTTP.register_redirect
(self, url, redirect_to, *, redirect_exc=HTTPMovedPermanently)
Register a redirect with the server. If given this must be either a string or callable. In case of a callable it's called with the url adapter that triggered the match and the values of the URL as keyword arguments and has to return the target for the redirect, otherwise it has to be a ...
Register a redirect with the server.
def register_redirect(self, url, redirect_to, *, redirect_exc=HTTPMovedPermanently): """Register a redirect with the server. If given this must be either a string or callable. In case of a callable it's called with the url adapter that triggered the match and the values of the URL as ke...
[ "def", "register_redirect", "(", "self", ",", "url", ",", "redirect_to", ",", "*", ",", "redirect_exc", "=", "HTTPMovedPermanently", ")", ":", "async", "def", "redirect", "(", "request", ")", ":", "\"\"\"Redirect to location.\"\"\"", "raise", "redirect_exc", "(", ...
[ 347, 4 ]
[ 361, 55 ]
python
en
['en', 'en', 'en']
True
HomeAssistantHTTP.register_static_path
(self, url_path, path, cache_headers=True)
Register a folder or file to serve as a static path.
Register a folder or file to serve as a static path.
def register_static_path(self, url_path, path, cache_headers=True): """Register a folder or file to serve as a static path.""" if os.path.isdir(path): if cache_headers: resource = CachingStaticResource else: resource = web.StaticResource ...
[ "def", "register_static_path", "(", "self", ",", "url_path", ",", "path", ",", "cache_headers", "=", "True", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "if", "cache_headers", ":", "resource", "=", "CachingStaticResource", "else...
[ 363, 4 ]
[ 385, 62 ]
python
en
['en', 'en', 'en']
True
HomeAssistantHTTP.start
(self)
Start the aiohttp server.
Start the aiohttp server.
async def start(self): """Start the aiohttp server.""" if self.ssl_certificate: try: if self.ssl_profile == SSL_INTERMEDIATE: context = ssl_util.server_context_intermediate() else: context = ssl_util.server_context_moder...
[ "async", "def", "start", "(", "self", ")", ":", "if", "self", ".", "ssl_certificate", ":", "try", ":", "if", "self", ".", "ssl_profile", "==", "SSL_INTERMEDIATE", ":", "context", "=", "ssl_util", ".", "server_context_intermediate", "(", ")", "else", ":", "...
[ 387, 4 ]
[ 435, 66 ]
python
en
['en', 'lb', 'en']
True
HomeAssistantHTTP.stop
(self)
Stop the aiohttp server.
Stop the aiohttp server.
async def stop(self): """Stop the aiohttp server.""" await self.site.stop() await self.runner.cleanup()
[ "async", "def", "stop", "(", "self", ")", ":", "await", "self", ".", "site", ".", "stop", "(", ")", "await", "self", ".", "runner", ".", "cleanup", "(", ")" ]
[ 437, 4 ]
[ 440, 35 ]
python
en
['en', 'en', 'en']
True
PickledCorpusReader.__init__
(self, root, fileids=PKL_PATTERN, **kwargs)
Initialize the corpus reader. Categorization arguments (``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to the ``CategorizedCorpusReader`` constructor. The remaining arguments are passed to the ``CorpusReader`` constructor.
Initialize the corpus reader. Categorization arguments (``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to the ``CategorizedCorpusReader`` constructor. The remaining arguments are passed to the ``CorpusReader`` constructor.
def __init__(self, root, fileids=PKL_PATTERN, **kwargs): """ Initialize the corpus reader. Categorization arguments (``cat_pattern``, ``cat_map``, and ``cat_file``) are passed to the ``CategorizedCorpusReader`` constructor. The remaining arguments are passed to the ``CorpusRead...
[ "def", "__init__", "(", "self", ",", "root", ",", "fileids", "=", "PKL_PATTERN", ",", "*", "*", "kwargs", ")", ":", "# Add the default category pattern if not passed into the class.", "if", "not", "any", "(", "key", ".", "startswith", "(", "'cat_'", ")", "for", ...
[ 18, 4 ]
[ 34, 46 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader._resolve
(self, fileids, categories)
Returns a list of fileids or categories depending on what is passed to each internal corpus reader function. This primarily bubbles up to the high level ``docs`` method, but is implemented here similar to the nltk ``CategorizedPlaintextCorpusReader``.
Returns a list of fileids or categories depending on what is passed to each internal corpus reader function. This primarily bubbles up to the high level ``docs`` method, but is implemented here similar to the nltk ``CategorizedPlaintextCorpusReader``.
def _resolve(self, fileids, categories): """ Returns a list of fileids or categories depending on what is passed to each internal corpus reader function. This primarily bubbles up to the high level ``docs`` method, but is implemented here similar to the nltk ``CategorizedPlaintex...
[ "def", "_resolve", "(", "self", ",", "fileids", ",", "categories", ")", ":", "if", "fileids", "is", "not", "None", "and", "categories", "is", "not", "None", ":", "raise", "ValueError", "(", "\"Specify fileids or categories, not both\"", ")", "if", "categories", ...
[ 36, 4 ]
[ 48, 22 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.docs
(self, fileids=None, categories=None)
Returns the document loaded from a pickled object for every file in the corpus. Similar to the BaleenCorpusReader, this uses a generator to acheive memory safe iteration.
Returns the document loaded from a pickled object for every file in the corpus. Similar to the BaleenCorpusReader, this uses a generator to acheive memory safe iteration.
def docs(self, fileids=None, categories=None): """ Returns the document loaded from a pickled object for every file in the corpus. Similar to the BaleenCorpusReader, this uses a generator to acheive memory safe iteration. """ # Resolve the fileids and the categories ...
[ "def", "docs", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "# Resolve the fileids and the categories", "fileids", "=", "self", ".", "_resolve", "(", "fileids", ",", "categories", ")", "# Create a generator, loading one documen...
[ 54, 4 ]
[ 66, 36 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.paras
(self, fileids=None, categories=None)
Returns a generator of paragraphs where each paragraph is a list of sentences, which is in turn a list of (token, tag) tuples.
Returns a generator of paragraphs where each paragraph is a list of sentences, which is in turn a list of (token, tag) tuples.
def paras(self, fileids=None, categories=None): """ Returns a generator of paragraphs where each paragraph is a list of sentences, which is in turn a list of (token, tag) tuples. """ for doc in self.docs(fileids, categories): for paragraph in doc: yiel...
[ "def", "paras", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "for", "doc", "in", "self", ".", "docs", "(", "fileids", ",", "categories", ")", ":", "for", "paragraph", "in", "doc", ":", "yield", "paragraph" ]
[ 68, 4 ]
[ 75, 31 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.sents
(self, fileids=None, categories=None)
Returns a generator of sentences where each sentence is a list of (token, tag) tuples.
Returns a generator of sentences where each sentence is a list of (token, tag) tuples.
def sents(self, fileids=None, categories=None): """ Returns a generator of sentences where each sentence is a list of (token, tag) tuples. """ for paragraph in self.paras(fileids, categories): for sentence in paragraph: yield sentence
[ "def", "sents", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "for", "paragraph", "in", "self", ".", "paras", "(", "fileids", ",", "categories", ")", ":", "for", "sentence", "in", "paragraph", ":", "yield", "senten...
[ 77, 4 ]
[ 84, 30 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.words
(self, fileids=None, categories=None)
Returns a generator of (token, tag) tuples.
Returns a generator of (token, tag) tuples.
def words(self, fileids=None, categories=None): """ Returns a generator of (token, tag) tuples. """ for sentence in self.sents(fileids, categories): for token, _ in sentence: yield token
[ "def", "words", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "for", "sentence", "in", "self", ".", "sents", "(", "fileids", ",", "categories", ")", ":", "for", "token", ",", "_", "in", "sentence", ":", "yield", ...
[ 91, 4 ]
[ 97, 27 ]
python
en
['en', 'error', 'th']
False
PickledCorpusReader.describe
(self, fileids=None, categories=None)
Performs a single pass of the corpus and returns a dictionary with a variety of metrics concerning the state of the corpus.
Performs a single pass of the corpus and returns a dictionary with a variety of metrics concerning the state of the corpus.
def describe(self, fileids=None, categories=None): """ Performs a single pass of the corpus and returns a dictionary with a variety of metrics concerning the state of the corpus. """ # Structures to perform counting. counts = nltk.FreqDist() tokens = nlt...
[ "def", "describe", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "# Structures to perform counting.", "counts", "=", "nltk", ".", "FreqDist", "(", ")", "tokens", "=", "nltk", ".", "FreqDist", "(", ")", "# Perform single ...
[ 99, 4 ]
[ 121, 9 ]
python
en
['en', 'error', 'th']
False
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the XS1 sensor platform.
Set up the XS1 sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the XS1 sensor platform.""" sensors = hass.data[COMPONENT_DOMAIN][SENSORS] actuators = hass.data[COMPONENT_DOMAIN][ACTUATORS] sensor_entities = [] for sensor in sensors: belongs_to_climate_actuator = False ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "sensors", "=", "hass", ".", "data", "[", "COMPONENT_DOMAIN", "]", "[", "SENSORS", "]", "actuators", "=", "hass", ".", "data", "[", "C...
[ 8, 0 ]
[ 27, 33 ]
python
en
['en', 'su', 'en']
True
XS1Sensor.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.device.name()
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "device", ".", "name", "(", ")" ]
[ 34, 4 ]
[ 36, 33 ]
python
en
['en', 'mi', 'en']
True
XS1Sensor.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.device.value()
[ "def", "state", "(", "self", ")", ":", "return", "self", ".", "device", ".", "value", "(", ")" ]
[ 39, 4 ]
[ 41, 34 ]
python
en
['en', 'en', 'en']
True
XS1Sensor.unit_of_measurement
(self)
Return the unit of measurement.
Return the unit of measurement.
def unit_of_measurement(self): """Return the unit of measurement.""" return self.device.unit()
[ "def", "unit_of_measurement", "(", "self", ")", ":", "return", "self", ".", "device", ".", "unit", "(", ")" ]
[ 44, 4 ]
[ 46, 33 ]
python
en
['en', 'la', 'en']
True
save_len_file
( tokenizer_name, data_dir, max_source_length=1024, max_target_length=1024, consider_target=False, **kwargs )
Save max(src_len, tgt_len) for each example to allow dynamic batching.
Save max(src_len, tgt_len) for each example to allow dynamic batching.
def save_len_file( tokenizer_name, data_dir, max_source_length=1024, max_target_length=1024, consider_target=False, **kwargs ): """Save max(src_len, tgt_len) for each example to allow dynamic batching.""" tok = AutoTokenizer.from_pretrained(tokenizer_name) train_ds = Seq2SeqDataset(tok, data_dir, max_so...
[ "def", "save_len_file", "(", "tokenizer_name", ",", "data_dir", ",", "max_source_length", "=", "1024", ",", "max_target_length", "=", "1024", ",", "consider_target", "=", "False", ",", "*", "*", "kwargs", ")", ":", "tok", "=", "AutoTokenizer", ".", "from_pretr...
[ 23, 0 ]
[ 51, 42 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the IFTTT service component.
Set up the IFTTT service component.
async def async_setup(hass, config): """Set up the IFTTT service component.""" if DOMAIN not in config: return True api_keys = config[DOMAIN][CONF_KEY] if isinstance(api_keys, str): api_keys = {"default": api_keys} def trigger_service(call): """Handle IFTTT trigger service ...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "api_keys", "=", "config", "[", "DOMAIN", "]", "[", "CONF_KEY", "]", "if", "isinstance", "(", "api_keys", ",", "str", ")"...
[ 49, 0 ]
[ 86, 15 ]
python
en
['en', 'en', 'en']
True
handle_webhook
(hass, webhook_id, request)
Handle webhook callback.
Handle webhook callback.
async def handle_webhook(hass, webhook_id, request): """Handle webhook callback.""" body = await request.text() try: data = json.loads(body) if body else {} except ValueError: _LOGGER.error( "Received invalid data from IFTTT. Data needs to be formatted as JSON: %s", ...
[ "async", "def", "handle_webhook", "(", "hass", ",", "webhook_id", ",", "request", ")", ":", "body", "=", "await", "request", ".", "text", "(", ")", "try", ":", "data", "=", "json", ".", "loads", "(", "body", ")", "if", "body", "else", "{", "}", "ex...
[ 89, 0 ]
[ 108, 45 ]
python
en
['en', 'xh', 'en']
True
async_setup_entry
(hass, entry)
Configure based on config entry.
Configure based on config entry.
async def async_setup_entry(hass, entry): """Configure based on config entry.""" hass.components.webhook.async_register( DOMAIN, "IFTTT", entry.data[CONF_WEBHOOK_ID], handle_webhook ) return True
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "components", ".", "webhook", ".", "async_register", "(", "DOMAIN", ",", "\"IFTTT\"", ",", "entry", ".", "data", "[", "CONF_WEBHOOK_ID", "]", ",", "handle_webhook", ")", ...
[ 111, 0 ]
[ 116, 15 ]
python
en
['en', 'en', 'en']
True
async_unload_entry
(hass, entry)
Unload a config entry.
Unload a config entry.
async def async_unload_entry(hass, entry): """Unload a config entry.""" hass.components.webhook.async_unregister(entry.data[CONF_WEBHOOK_ID]) return True
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ")", ":", "hass", ".", "components", ".", "webhook", ".", "async_unregister", "(", "entry", ".", "data", "[", "CONF_WEBHOOK_ID", "]", ")", "return", "True" ]
[ 119, 0 ]
[ 122, 15 ]
python
en
['en', 'es', 'en']
True
_async_reproduce_state
( hass: HomeAssistantType, state: State, *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, )
Reproduce a single state.
Reproduce a single state.
async def _async_reproduce_state( hass: HomeAssistantType, state: State, *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, ) -> None: """Reproduce a single state.""" cur_state = hass.states.get(state.entity_id) if cur_state is None: _LOGGE...
[ "async", "def", "_async_reproduce_state", "(", "hass", ":", "HomeAssistantType", ",", "state", ":", "State", ",", "*", ",", "context", ":", "Optional", "[", "Context", "]", "=", "None", ",", "reproduce_options", ":", "Optional", "[", "Dict", "[", "str", ",...
[ 37, 0 ]
[ 78, 5 ]
python
en
['en', 'en', 'en']
True
async_reproduce_states
( hass: HomeAssistantType, states: Iterable[State], *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, )
Reproduce Alarm control panel states.
Reproduce Alarm control panel states.
async def async_reproduce_states( hass: HomeAssistantType, states: Iterable[State], *, context: Optional[Context] = None, reproduce_options: Optional[Dict[str, Any]] = None, ) -> None: """Reproduce Alarm control panel states.""" await asyncio.gather( *( _async_reproduce_s...
[ "async", "def", "async_reproduce_states", "(", "hass", ":", "HomeAssistantType", ",", "states", ":", "Iterable", "[", "State", "]", ",", "*", ",", "context", ":", "Optional", "[", "Context", "]", "=", "None", ",", "reproduce_options", ":", "Optional", "[", ...
[ 81, 0 ]
[ 96, 5 ]
python
en
['it', 'en', 'en']
True
bytes_to_unicode
()
Returns list of utf-8 byte and a corresponding list of unicode strings. The reversible bpe codes work on unicode strings. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. When you're at something like a 10B token dataset you end up needing around 5K for decent co...
Returns list of utf-8 byte and a corresponding list of unicode strings. The reversible bpe codes work on unicode strings. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. When you're at something like a 10B token dataset you end up needing around 5K for decent co...
def bytes_to_unicode(): """ Returns list of utf-8 byte and a corresponding list of unicode strings. The reversible bpe codes work on unicode strings. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. When you're at something like a 10B token dataset you end up ...
[ "def", "bytes_to_unicode", "(", ")", ":", "bs", "=", "(", "list", "(", "range", "(", "ord", "(", "\"!\"", ")", ",", "ord", "(", "\"~\"", ")", "+", "1", ")", ")", "+", "list", "(", "range", "(", "ord", "(", "\"¡\")", ",", " ", "rd(", "\"", "¬\...
[ 71, 0 ]
[ 90, 28 ]
python
en
['en', 'error', 'th']
False
get_pairs
(word)
Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).
Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).
def get_pairs(word): """ Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings). """ pairs = set() prev_char = word[0] for char in word[1:]: pairs.add((prev_char, char)) prev_char = char return pairs
[ "def", "get_pairs", "(", "word", ")", ":", "pairs", "=", "set", "(", ")", "prev_char", "=", "word", "[", "0", "]", "for", "char", "in", "word", "[", "1", ":", "]", ":", "pairs", ".", "add", "(", "(", "prev_char", ",", "char", ")", ")", "prev_ch...
[ 93, 0 ]
[ 103, 16 ]
python
en
['en', 'error', 'th']
False
_is_whitespace
(char)
Checks whether `chars` is a whitespace character.
Checks whether `chars` is a whitespace character.
def _is_whitespace(char): """Checks whether `chars` is a whitespace character.""" # \t, \n, and \r are technically contorl characters but we treat them # as whitespace since they are generally considered as such. if char == " " or char == "\t" or char == "\n" or char == "\r": return True cat...
[ "def", "_is_whitespace", "(", "char", ")", ":", "# \\t, \\n, and \\r are technically contorl characters but we treat them", "# as whitespace since they are generally considered as such.", "if", "char", "==", "\" \"", "or", "char", "==", "\"\\t\"", "or", "char", "==", "\"\\n\"",...
[ 184, 0 ]
[ 193, 16 ]
python
en
['en', 'en', 'en']
True
_is_control
(char)
Checks whether `chars` is a control character.
Checks whether `chars` is a control character.
def _is_control(char): """Checks whether `chars` is a control character.""" # These are technically control characters but we count them as whitespace # characters. if char == "\t" or char == "\n" or char == "\r": return False cat = unicodedata.category(char) if cat.startswith("C"): ...
[ "def", "_is_control", "(", "char", ")", ":", "# These are technically control characters but we count them as whitespace", "# characters.", "if", "char", "==", "\"\\t\"", "or", "char", "==", "\"\\n\"", "or", "char", "==", "\"\\r\"", ":", "return", "False", "cat", "=",...
[ 196, 0 ]
[ 205, 16 ]
python
en
['en', 'en', 'en']
True
_is_punctuation
(char)
Checks whether `chars` is a punctuation character.
Checks whether `chars` is a punctuation character.
def _is_punctuation(char): """Checks whether `chars` is a punctuation character.""" cp = ord(char) # We treat all non-letter/number ASCII as punctuation. # Characters such as "^", "$", and "`" are not in the Unicode # Punctuation class but we treat them as punctuation anyways, for # consistency....
[ "def", "_is_punctuation", "(", "char", ")", ":", "cp", "=", "ord", "(", "char", ")", "# We treat all non-letter/number ASCII as punctuation.", "# Characters such as \"^\", \"$\", and \"`\" are not in the Unicode", "# Punctuation class but we treat them as punctuation anyways, for", "# ...
[ 208, 0 ]
[ 220, 16 ]
python
en
['en', 'en', 'en']
True
GPT2Tokenizer.tokenize
(self, text)
Convert an input text to tokens. Args: text (:obj:`str`): input text to be tokenized. Returns: A list of byte tokens where each token represent the byte id in GPT2 byte dictionary Example:: >>> tokenizer = GPT2Tokenizer() >>> text = "Hello worl...
Convert an input text to tokens.
def tokenize(self, text): """ Convert an input text to tokens. Args: text (:obj:`str`): input text to be tokenized. Returns: A list of byte tokens where each token represent the byte id in GPT2 byte dictionary Example:: >>> tokenizer = GPT2Tokeniz...
[ "def", "tokenize", "(", "self", ",", "text", ")", ":", "bpe", "=", "self", ".", "_encode", "(", "text", ")", "return", "[", "t", "for", "t", "in", "bpe", ".", "split", "(", "\" \"", ")", "if", "t", "]" ]
[ 354, 4 ]
[ 373, 47 ]
python
en
['en', 'error', 'th']
False
GPT2Tokenizer.convert_tokens_to_ids
(self, tokens)
Convert list of tokens to ids Args: tokens (:obj:`list<str>`): list of tokens Returns: List of ids
Convert list of tokens to ids
def convert_tokens_to_ids(self, tokens): """ Convert list of tokens to ids Args: tokens (:obj:`list<str>`): list of tokens Returns: List of ids """ return [self.vocab[t] for t in tokens]
[ "def", "convert_tokens_to_ids", "(", "self", ",", "tokens", ")", ":", "return", "[", "self", ".", "vocab", "[", "t", "]", "for", "t", "in", "tokens", "]" ]
[ 375, 4 ]
[ 386, 46 ]
python
en
['en', 'error', 'th']
False
GPT2Tokenizer.convert_ids_to_tokens
(self, ids)
Convert list of ids to tokens Args: ids (:obj:`list<int>`): list of ids Returns: List of tokens
Convert list of ids to tokens
def convert_ids_to_tokens(self, ids): """ Convert list of ids to tokens Args: ids (:obj:`list<int>`): list of ids Returns: List of tokens """ tokens = [] for i in ids: tokens.append(self.ids_to_tokens[i]) return tokens
[ "def", "convert_ids_to_tokens", "(", "self", ",", "ids", ")", ":", "tokens", "=", "[", "]", "for", "i", "in", "ids", ":", "tokens", ".", "append", "(", "self", ".", "ids_to_tokens", "[", "i", "]", ")", "return", "tokens" ]
[ 388, 4 ]
[ 402, 21 ]
python
en
['en', 'error', 'th']
False
GPT2Tokenizer.decode
(self, tokens)
Decode list of tokens to text strings Args: tokens (:obj:`list<str>`): list of tokens. Returns: Text string corresponds to the input tokens. Example:: >>> tokenizer = GPT2Tokenizer() >>> text = "Hello world!" >>> tokens = tokenizer.to...
Decode list of tokens to text strings
def decode(self, tokens): """ Decode list of tokens to text strings Args: tokens (:obj:`list<str>`): list of tokens. Returns: Text string corresponds to the input tokens. Example:: >>> tokenizer = GPT2Tokenizer() >>> text = "Hello world!...
[ "def", "decode", "(", "self", ",", "tokens", ")", ":", "return", "self", ".", "bpe", ".", "decode", "(", "[", "int", "(", "t", ")", "for", "t", "in", "tokens", "if", "t", "not", "in", "self", ".", "special_tokens", "]", ")" ]
[ 407, 4 ]
[ 426, 88 ]
python
en
['en', 'error', 'th']
False
GPT2Tokenizer.add_special_token
(self, token)
Adds a special token to the dictionary Args: token (:obj:`str`): Tthe new token/word to be added to the vocabulary. Returns: The id of new token in the vocabulary.
Adds a special token to the dictionary
def add_special_token(self, token): """ Adds a special token to the dictionary Args: token (:obj:`str`): Tthe new token/word to be added to the vocabulary. Returns: The id of new token in the vocabulary. """ self.special_tokens.append(token) ...
[ "def", "add_special_token", "(", "self", ",", "token", ")", ":", "self", ".", "special_tokens", ".", "append", "(", "token", ")", "return", "self", ".", "add_symbol", "(", "token", ")" ]
[ 428, 4 ]
[ 440, 37 ]
python
en
['en', 'error', 'th']
False
GPT2Tokenizer.add_symbol
(self, word, n=1)
Adds a word to the dictionary Args: word (:obj:`str`): Tthe new token/word to be added to the vocabulary. n (int, optional): The frequency of the word. Returns: The id of the new word.
Adds a word to the dictionary
def add_symbol(self, word, n=1): """ Adds a word to the dictionary Args: word (:obj:`str`): Tthe new token/word to be added to the vocabulary. n (int, optional): The frequency of the word. Returns: The id of the new word. """ if word in se...
[ "def", "add_symbol", "(", "self", ",", "word", ",", "n", "=", "1", ")", ":", "if", "word", "in", "self", ".", "indices", ":", "idx", "=", "self", ".", "indices", "[", "word", "]", "self", ".", "count", "[", "idx", "]", "=", "self", ".", "count"...
[ 463, 4 ]
[ 484, 22 ]
python
en
['en', 'error', 'th']
False
DebertaTokenizer._tokenize
(self, text)
Take as input a string and return a list of strings (tokens) for words/sub-words
Take as input a string and return a list of strings (tokens) for words/sub-words
def _tokenize(self, text): """Take as input a string and return a list of strings (tokens) for words/sub-words""" if self.do_lower_case: text = text.lower() return self.gpt2_tokenizer.tokenize(text)
[ "def", "_tokenize", "(", "self", ",", "text", ")", ":", "if", "self", ".", "do_lower_case", ":", "text", "=", "text", ".", "lower", "(", ")", "return", "self", ".", "gpt2_tokenizer", ".", "tokenize", "(", "text", ")" ]
[ 570, 4 ]
[ 574, 49 ]
python
en
['en', 'en', 'en']
True
DebertaTokenizer._convert_token_to_id
(self, token)
Converts a token (str) in an id using the vocab.
Converts a token (str) in an id using the vocab.
def _convert_token_to_id(self, token): """ Converts a token (str) in an id using the vocab. """ return self.vocab.get(token, self.vocab.get(self.unk_token))
[ "def", "_convert_token_to_id", "(", "self", ",", "token", ")", ":", "return", "self", ".", "vocab", ".", "get", "(", "token", ",", "self", ".", "vocab", ".", "get", "(", "self", ".", "unk_token", ")", ")" ]
[ 576, 4 ]
[ 578, 68 ]
python
en
['en', 'en', 'en']
True
DebertaTokenizer._convert_id_to_token
(self, index)
Converts an index (integer) in a token (str) using the vocab.
Converts an index (integer) in a token (str) using the vocab.
def _convert_id_to_token(self, index): """Converts an index (integer) in a token (str) using the vocab.""" return self.gpt2_tokenizer.sym(index) if index < self.vocab_size else self.unk_token
[ "def", "_convert_id_to_token", "(", "self", ",", "index", ")", ":", "return", "self", ".", "gpt2_tokenizer", ".", "sym", "(", "index", ")", "if", "index", "<", "self", ".", "vocab_size", "else", "self", ".", "unk_token" ]
[ 580, 4 ]
[ 582, 92 ]
python
en
['en', 'en', 'en']
True
DebertaTokenizer.convert_tokens_to_string
(self, tokens)
Converts a sequence of tokens (string) in a single string.
Converts a sequence of tokens (string) in a single string.
def convert_tokens_to_string(self, tokens): """ Converts a sequence of tokens (string) in a single string. """ return self.gpt2_tokenizer.decode(tokens)
[ "def", "convert_tokens_to_string", "(", "self", ",", "tokens", ")", ":", "return", "self", ".", "gpt2_tokenizer", ".", "decode", "(", "tokens", ")" ]
[ 584, 4 ]
[ 586, 49 ]
python
en
['en', 'en', 'en']
True
DebertaTokenizer.build_inputs_with_special_tokens
(self, token_ids_0, token_ids_1=None)
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. A DeBERTa sequence has the following format: - single sequence: [CLS] X [SEP] - pair of sequences: [CLS] A [SEP] B [SEP] Args: tok...
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. A DeBERTa sequence has the following format:
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None): """ Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens. A DeBERTa sequence has the following format: - single sequence: [CLS] X [...
[ "def", "build_inputs_with_special_tokens", "(", "self", ",", "token_ids_0", ",", "token_ids_1", "=", "None", ")", ":", "if", "token_ids_1", "is", "None", ":", "return", "[", "self", ".", "cls_token_id", "]", "+", "token_ids_0", "+", "[", "self", ".", "sep_to...
[ 588, 4 ]
[ 610, 58 ]
python
en
['en', 'error', 'th']
False
DebertaTokenizer.get_special_tokens_mask
(self, token_ids_0, token_ids_1=None, already_has_special_tokens=False)
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` or ``encode_plus`` methods. Args: token_ids_0 (:obj:`List[int]`): List of IDs. token_ids...
Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` or ``encode_plus`` methods.
def get_special_tokens_mask(self, token_ids_0, token_ids_1=None, already_has_special_tokens=False): """ Retrieves sequence ids from a token list that has no special tokens added. This method is called when adding special tokens using the tokenizer ``prepare_for_model`` or ``encode_plus`` methods...
[ "def", "get_special_tokens_mask", "(", "self", ",", "token_ids_0", ",", "token_ids_1", "=", "None", ",", "already_has_special_tokens", "=", "False", ")", ":", "if", "already_has_special_tokens", ":", "if", "token_ids_1", "is", "not", "None", ":", "raise", "ValueEr...
[ 612, 4 ]
[ 644, 51 ]
python
en
['en', 'error', 'th']
False
DebertaTokenizer.create_token_type_ids_from_sequences
(self, token_ids_0, token_ids_1=None)
Create a mask from the two sequences passed to be used in a sequence-pair classification task. A DeBERTa sequence pair mask has the following format: :: 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 | first sequence | second sequence | If :obj:`token_ids_1` is :o...
Create a mask from the two sequences passed to be used in a sequence-pair classification task. A DeBERTa sequence pair mask has the following format:
def create_token_type_ids_from_sequences(self, token_ids_0, token_ids_1=None): """ Create a mask from the two sequences passed to be used in a sequence-pair classification task. A DeBERTa sequence pair mask has the following format: :: 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ...
[ "def", "create_token_type_ids_from_sequences", "(", "self", ",", "token_ids_0", ",", "token_ids_1", "=", "None", ")", ":", "sep", "=", "[", "self", ".", "sep_token_id", "]", "cls", "=", "[", "self", ".", "cls_token_id", "]", "if", "token_ids_1", "is", "None"...
[ 646, 4 ]
[ 672, 80 ]
python
en
['en', 'error', 'th']
False
PolynomialTrend.__init__
(self, *args, **kwargs)
in this model x_zero will be common to all the models, however it is treated as a specific
in this model x_zero will be common to all the models, however it is treated as a specific
def __init__(self, *args, **kwargs): super(PolynomialTrend, self).__init__(*args, **kwargs) self.list_pams_common = {'x_zero': None} """ in this model x_zero will be common to all the models, however it is treated as a specific """ self.list_pams_dataset = {} ...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "PolynomialTrend", ",", "self", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "list_pams_common", "=", "{", "'x_...
[ 77, 4 ]
[ 101, 40 ]
python
en
['en', 'en', 'en']
True
PolynomialTrend.initialize_model
(self, mc, **kwargs)
The user may decide to include the 0th order anyway - be aware of correlations with dataset offset!
The user may decide to include the 0th order anyway - be aware of correlations with dataset offset!
def initialize_model(self, mc, **kwargs): if 'order' in kwargs: self.order = kwargs['order'] """ The user may decide to include the 0th order anyway - be aware of correlations with dataset offset!""" try: if kwargs['include_zero_point']: self.starting_or...
[ "def", "initialize_model", "(", "self", ",", "mc", ",", "*", "*", "kwargs", ")", ":", "if", "'order'", "in", "kwargs", ":", "self", ".", "order", "=", "kwargs", "[", "'order'", "]", "try", ":", "if", "kwargs", "[", "'include_zero_point'", "]", ":", "...
[ 104, 4 ]
[ 137, 21 ]
python
en
['en', 'en', 'en']
True
PolynomialTrend.compute
(self, variable_value, dataset, x0_input=None)
In our array, coefficient are sorted from the lowest degree to the higher Numpy Polynomials requires the inverse order (from high to small) as input
In our array, coefficient are sorted from the lowest degree to the higher Numpy Polynomials requires the inverse order (from high to small) as input
def compute(self, variable_value, dataset, x0_input=None): coeff = np.zeros(self.order+1) for i_order in range(self.starting_order, self.order+1): var = 'poly_c'+repr(i_order) coeff[i_order] = variable_value[var] """ In our array, coefficient are sorted from the lowest ...
[ "def", "compute", "(", "self", ",", "variable_value", ",", "dataset", ",", "x0_input", "=", "None", ")", ":", "coeff", "=", "np", ".", "zeros", "(", "self", ".", "order", "+", "1", ")", "for", "i_order", "in", "range", "(", "self", ".", "starting_ord...
[ 150, 4 ]
[ 163, 130 ]
python
en
['en', 'en', 'en']
True
LocalPolynomialTrend.__init__
(self, *args, **kwargs)
The x-intercept must be defined within the interval of at least one dataset, otherwise there will be a degeneracy between the offset parameter and the coefficients of the polynomial
The x-intercept must be defined within the interval of at least one dataset, otherwise there will be a degeneracy between the offset parameter and the coefficients of the polynomial
def __init__(self, *args, **kwargs): super(LocalPolynomialTrend, self).__init__(*args, **kwargs) self.list_pams_common = {} self.list_pams_dataset = {'x_zero': None} self.default_bounds = {'x_zero': [-10**6, 10**6]} self.default_spaces = {'x_zero': 'Linear'} self.defaul...
[ "def", "__init__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "LocalPolynomialTrend", ",", "self", ")", ".", "__init__", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "list_pams_common", "=", "{", ...
[ 170, 4 ]
[ 192, 40 ]
python
en
['en', 'error', 'th']
False
LocalPolynomialTrend.initialize_model
(self, mc, **kwargs)
The user may decide to include the 0th order anyway - be aware of correlations with dataset offset!
The user may decide to include the 0th order anyway - be aware of correlations with dataset offset!
def initialize_model(self, mc, **kwargs): if 'order' in kwargs: self.order = kwargs['order'] """ The user may decide to include the 0th order anyway - be aware of correlations with dataset offset!""" try: if kwargs['include_zero_point']: self.starting_or...
[ "def", "initialize_model", "(", "self", ",", "mc", ",", "*", "*", "kwargs", ")", ":", "if", "'order'", "in", "kwargs", ":", "self", ".", "order", "=", "kwargs", "[", "'order'", "]", "try", ":", "if", "kwargs", "[", "'include_zero_point'", "]", ":", "...
[ 194, 4 ]
[ 223, 54 ]
python
en
['en', 'en', 'en']
True
LocalPolynomialTrend.compute
(self, variable_value, dataset, x0_input=None)
In our array, coefficient are sorted from the lowest degree to the highest Numpy Polynomials requires the inverse order (from high to small) as input
In our array, coefficient are sorted from the lowest degree to the highest Numpy Polynomials requires the inverse order (from high to small) as input
def compute(self, variable_value, dataset, x0_input=None): coeff = np.zeros(self.order+1) for i_order in range(self.starting_order, self.order+1): var = 'poly_c'+repr(i_order) coeff[i_order] = variable_value[var] """ In our array, coefficient are sorted from the lowest ...
[ "def", "compute", "(", "self", ",", "variable_value", ",", "dataset", ",", "x0_input", "=", "None", ")", ":", "coeff", "=", "np", ".", "zeros", "(", "self", ".", "order", "+", "1", ")", "for", "i_order", "in", "range", "(", "self", ".", "starting_ord...
[ 236, 4 ]
[ 249, 130 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Set up the RFXtrx component.
Set up the RFXtrx component.
async def async_setup(hass, config): """Set up the RFXtrx component.""" if DOMAIN not in config: return True data = { CONF_HOST: config[DOMAIN].get(CONF_HOST), CONF_PORT: config[DOMAIN].get(CONF_PORT), CONF_DEVICE: config[DOMAIN].get(CONF_DEVICE), CONF_AUTOMATIC_ADD:...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "if", "DOMAIN", "not", "in", "config", ":", "return", "True", "data", "=", "{", "CONF_HOST", ":", "config", "[", "DOMAIN", "]", ".", "get", "(", "CONF_HOST", ")", ",", "CONF_PORT", ...
[ 153, 0 ]
[ 183, 15 ]
python
en
['en', 'fr', 'en']
True
async_setup_entry
(hass, entry: config_entries.ConfigEntry)
Set up the RFXtrx component.
Set up the RFXtrx component.
async def async_setup_entry(hass, entry: config_entries.ConfigEntry): """Set up the RFXtrx component.""" hass.data.setdefault(DOMAIN, {}) hass.data[DOMAIN][DATA_CLEANUP_CALLBACKS] = [] try: await async_setup_internal(hass, entry) except asyncio.TimeoutError: # Library currently doe...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "entry", ":", "config_entries", ".", "ConfigEntry", ")", ":", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_CLEANUP_CA...
[ 186, 0 ]
[ 206, 15 ]
python
en
['en', 'fr', 'en']
True
async_unload_entry
(hass, entry: config_entries.ConfigEntry)
Unload RFXtrx component.
Unload RFXtrx component.
async def async_unload_entry(hass, entry: config_entries.ConfigEntry): """Unload RFXtrx component.""" if not all( await asyncio.gather( *[ hass.config_entries.async_forward_entry_unload(entry, component) for component in DOMAINS ] ) ): ...
[ "async", "def", "async_unload_entry", "(", "hass", ",", "entry", ":", "config_entries", ".", "ConfigEntry", ")", ":", "if", "not", "all", "(", "await", "asyncio", ".", "gather", "(", "*", "[", "hass", ".", "config_entries", ".", "async_forward_entry_unload", ...
[ 209, 0 ]
[ 234, 15 ]
python
de
['de', 'fr', 'en']
False
_create_rfx
(config)
Construct a rfx object based on config.
Construct a rfx object based on config.
def _create_rfx(config): """Construct a rfx object based on config.""" if config[CONF_PORT] is not None: # If port is set then we create a TCP connection rfx = rfxtrxmod.Connect( (config[CONF_HOST], config[CONF_PORT]), None, transport_protocol=rfxtrxmod.PyNetw...
[ "def", "_create_rfx", "(", "config", ")", ":", "if", "config", "[", "CONF_PORT", "]", "is", "not", "None", ":", "# If port is set then we create a TCP connection", "rfx", "=", "rfxtrxmod", ".", "Connect", "(", "(", "config", "[", "CONF_HOST", "]", ",", "config...
[ 237, 0 ]
[ 249, 14 ]
python
en
['en', 'en', 'en']
True
_get_device_lookup
(devices)
Get a lookup structure for devices.
Get a lookup structure for devices.
def _get_device_lookup(devices): """Get a lookup structure for devices.""" lookup = {} for event_code, event_config in devices.items(): event = get_rfx_object(event_code) if event is None: continue device_id = get_device_id( event.device, data_bits=event_confi...
[ "def", "_get_device_lookup", "(", "devices", ")", ":", "lookup", "=", "{", "}", "for", "event_code", ",", "event_config", "in", "devices", ".", "items", "(", ")", ":", "event", "=", "get_rfx_object", "(", "event_code", ")", "if", "event", "is", "None", "...
[ 252, 0 ]
[ 263, 17 ]
python
en
['es', 'en', 'en']
True
async_setup_internal
(hass, entry: config_entries.ConfigEntry)
Set up the RFXtrx component.
Set up the RFXtrx component.
async def async_setup_internal(hass, entry: config_entries.ConfigEntry): """Set up the RFXtrx component.""" config = entry.data # Initialize library async with async_timeout.timeout(30): rfx_object = await hass.async_add_executor_job(_create_rfx, config) # Setup some per device config ...
[ "async", "def", "async_setup_internal", "(", "hass", ",", "entry", ":", "config_entries", ".", "ConfigEntry", ")", ":", "config", "=", "entry", ".", "data", "# Initialize library", "async", "with", "async_timeout", ".", "timeout", "(", "30", ")", ":", "rfx_obj...
[ 266, 0 ]
[ 339, 88 ]
python
en
['en', 'fr', 'en']
True
get_rfx_object
(packetid)
Return the RFXObject with the packetid.
Return the RFXObject with the packetid.
def get_rfx_object(packetid): """Return the RFXObject with the packetid.""" try: binarypacket = bytearray.fromhex(packetid) except ValueError: return None pkt = rfxtrxmod.lowlevel.parse(binarypacket) if pkt is None: return None if isinstance(pkt, rfxtrxmod.lowlevel.Senso...
[ "def", "get_rfx_object", "(", "packetid", ")", ":", "try", ":", "binarypacket", "=", "bytearray", ".", "fromhex", "(", "packetid", ")", "except", "ValueError", ":", "return", "None", "pkt", "=", "rfxtrxmod", ".", "lowlevel", ".", "parse", "(", "binarypacket"...
[ 342, 0 ]
[ 360, 14 ]
python
en
['en', 'en', 'en']
True
get_pt2262_deviceid
(device_id, nb_data_bits)
Extract and return the address bits from a Lighting4/PT2262 packet.
Extract and return the address bits from a Lighting4/PT2262 packet.
def get_pt2262_deviceid(device_id, nb_data_bits): """Extract and return the address bits from a Lighting4/PT2262 packet.""" if nb_data_bits is None: return try: data = bytearray.fromhex(device_id) except ValueError: return None mask = 0xFF & ~((1 << nb_data_bits) - 1) d...
[ "def", "get_pt2262_deviceid", "(", "device_id", ",", "nb_data_bits", ")", ":", "if", "nb_data_bits", "is", "None", ":", "return", "try", ":", "data", "=", "bytearray", ".", "fromhex", "(", "device_id", ")", "except", "ValueError", ":", "return", "None", "mas...
[ 363, 0 ]
[ 376, 33 ]
python
en
['en', 'en', 'en']
True
get_pt2262_cmd
(device_id, data_bits)
Extract and return the data bits from a Lighting4/PT2262 packet.
Extract and return the data bits from a Lighting4/PT2262 packet.
def get_pt2262_cmd(device_id, data_bits): """Extract and return the data bits from a Lighting4/PT2262 packet.""" try: data = bytearray.fromhex(device_id) except ValueError: return None mask = 0xFF & ((1 << data_bits) - 1) return hex(data[-1] & mask)
[ "def", "get_pt2262_cmd", "(", "device_id", ",", "data_bits", ")", ":", "try", ":", "data", "=", "bytearray", ".", "fromhex", "(", "device_id", ")", "except", "ValueError", ":", "return", "None", "mask", "=", "0xFF", "&", "(", "(", "1", "<<", "data_bits",...
[ 379, 0 ]
[ 388, 31 ]
python
en
['en', 'en', 'en']
True
get_device_data_bits
(device, devices)
Deduce data bits for device based on a cache of device bits.
Deduce data bits for device based on a cache of device bits.
def get_device_data_bits(device, devices): """Deduce data bits for device based on a cache of device bits.""" data_bits = None if device.packettype == DEVICE_PACKET_TYPE_LIGHTING4: for device_id, entity_config in devices.items(): bits = entity_config.get(CONF_DATA_BITS) if ge...
[ "def", "get_device_data_bits", "(", "device", ",", "devices", ")", ":", "data_bits", "=", "None", "if", "device", ".", "packettype", "==", "DEVICE_PACKET_TYPE_LIGHTING4", ":", "for", "device_id", ",", "entity_config", "in", "devices", ".", "items", "(", ")", "...
[ 391, 0 ]
[ 400, 20 ]
python
en
['en', 'en', 'en']
True
find_possible_pt2262_device
(device_ids, device_id)
Look for the device which id matches the given device_id parameter.
Look for the device which id matches the given device_id parameter.
def find_possible_pt2262_device(device_ids, device_id): """Look for the device which id matches the given device_id parameter.""" for dev_id in device_ids: if len(dev_id) == len(device_id): size = None for i, (char1, char2) in enumerate(zip(dev_id, device_id)): if...
[ "def", "find_possible_pt2262_device", "(", "device_ids", ",", "device_id", ")", ":", "for", "dev_id", "in", "device_ids", ":", "if", "len", "(", "dev_id", ")", "==", "len", "(", "device_id", ")", ":", "size", "=", "None", "for", "i", ",", "(", "char1", ...
[ 403, 0 ]
[ 427, 15 ]
python
en
['en', 'en', 'en']
True
get_device_id
(device, data_bits=None)
Calculate a device id for device.
Calculate a device id for device.
def get_device_id(device, data_bits=None): """Calculate a device id for device.""" id_string = device.id_string if data_bits and device.packettype == DEVICE_PACKET_TYPE_LIGHTING4: masked_id = get_pt2262_deviceid(id_string, data_bits) if masked_id: id_string = masked_id.decode("AS...
[ "def", "get_device_id", "(", "device", ",", "data_bits", "=", "None", ")", ":", "id_string", "=", "device", ".", "id_string", "if", "data_bits", "and", "device", ".", "packettype", "==", "DEVICE_PACKET_TYPE_LIGHTING4", ":", "masked_id", "=", "get_pt2262_deviceid",...
[ 430, 0 ]
[ 438, 71 ]
python
en
['da', 'en', 'en']
True
connect_auto_add
(hass, entry_data, callback_fun)
Connect to dispatcher for automatic add.
Connect to dispatcher for automatic add.
def connect_auto_add(hass, entry_data, callback_fun): """Connect to dispatcher for automatic add.""" if entry_data[CONF_AUTOMATIC_ADD]: hass.data[DOMAIN][DATA_CLEANUP_CALLBACKS].append( hass.helpers.dispatcher.async_dispatcher_connect(SIGNAL_EVENT, callback_fun) )
[ "def", "connect_auto_add", "(", "hass", ",", "entry_data", ",", "callback_fun", ")", ":", "if", "entry_data", "[", "CONF_AUTOMATIC_ADD", "]", ":", "hass", ".", "data", "[", "DOMAIN", "]", "[", "DATA_CLEANUP_CALLBACKS", "]", ".", "append", "(", "hass", ".", ...
[ 441, 0 ]
[ 446, 9 ]
python
en
['en', 'en', 'en']
True
RfxtrxEntity.__init__
(self, device, device_id, event=None)
Initialize the device.
Initialize the device.
def __init__(self, device, device_id, event=None): """Initialize the device.""" self._name = f"{device.type_string} {device.id_string}" self._device = device self._event = event self._device_id = device_id self._unique_id = "_".join(x for x in self._device_id)
[ "def", "__init__", "(", "self", ",", "device", ",", "device_id", ",", "event", "=", "None", ")", ":", "self", ".", "_name", "=", "f\"{device.type_string} {device.id_string}\"", "self", ".", "_device", "=", "device", "self", ".", "_event", "=", "event", "self...
[ 455, 4 ]
[ 461, 62 ]
python
en
['en', 'en', 'en']
True
RfxtrxEntity.async_added_to_hass
(self)
Restore RFXtrx device state (ON/OFF).
Restore RFXtrx device state (ON/OFF).
async def async_added_to_hass(self): """Restore RFXtrx device state (ON/OFF).""" if self._event: self._apply_event(self._event) self.async_on_remove( self.hass.helpers.dispatcher.async_dispatcher_connect( SIGNAL_EVENT, self._handle_event ) ...
[ "async", "def", "async_added_to_hass", "(", "self", ")", ":", "if", "self", ".", "_event", ":", "self", ".", "_apply_event", "(", "self", ".", "_event", ")", "self", ".", "async_on_remove", "(", "self", ".", "hass", ".", "helpers", ".", "dispatcher", "."...
[ 463, 4 ]
[ 478, 9 ]
python
en
['it', 'en', 'en']
True
RfxtrxEntity.should_poll
(self)
No polling needed for a RFXtrx switch.
No polling needed for a RFXtrx switch.
def should_poll(self): """No polling needed for a RFXtrx switch.""" return False
[ "def", "should_poll", "(", "self", ")", ":", "return", "False" ]
[ 481, 4 ]
[ 483, 20 ]
python
en
['en', 'en', 'en']
True
RfxtrxEntity.name
(self)
Return the name of the device if any.
Return the name of the device if any.
def name(self): """Return the name of the device if any.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 486, 4 ]
[ 488, 25 ]
python
en
['en', 'en', 'en']
True
RfxtrxEntity.device_state_attributes
(self)
Return the device state attributes.
Return the device state attributes.
def device_state_attributes(self): """Return the device state attributes.""" if not self._event: return None return {ATTR_EVENT: "".join(f"{x:02x}" for x in self._event.data)}
[ "def", "device_state_attributes", "(", "self", ")", ":", "if", "not", "self", ".", "_event", ":", "return", "None", "return", "{", "ATTR_EVENT", ":", "\"\"", ".", "join", "(", "f\"{x:02x}\"", "for", "x", "in", "self", ".", "_event", ".", "data", ")", "...
[ 491, 4 ]
[ 495, 74 ]
python
en
['en', 'en', 'en']
True
RfxtrxEntity.assumed_state
(self)
Return true if unable to access real state of entity.
Return true if unable to access real state of entity.
def assumed_state(self): """Return true if unable to access real state of entity.""" return True
[ "def", "assumed_state", "(", "self", ")", ":", "return", "True" ]
[ 498, 4 ]
[ 500, 19 ]
python
en
['en', 'en', 'en']
True
RfxtrxEntity.unique_id
(self)
Return unique identifier of remote device.
Return unique identifier of remote device.
def unique_id(self): """Return unique identifier of remote device.""" return self._unique_id
[ "def", "unique_id", "(", "self", ")", ":", "return", "self", ".", "_unique_id" ]
[ 503, 4 ]
[ 505, 30 ]
python
en
['fr', 'it', 'en']
False
RfxtrxEntity.device_info
(self)
Return the device info.
Return the device info.
def device_info(self): """Return the device info.""" return { "identifiers": {(DOMAIN, *self._device_id)}, "name": f"{self._device.type_string} {self._device.id_string}", "model": self._device.type_string, }
[ "def", "device_info", "(", "self", ")", ":", "return", "{", "\"identifiers\"", ":", "{", "(", "DOMAIN", ",", "*", "self", ".", "_device_id", ")", "}", ",", "\"name\"", ":", "f\"{self._device.type_string} {self._device.id_string}\"", ",", "\"model\"", ":", "self"...
[ 508, 4 ]
[ 514, 9 ]
python
en
['en', 'en', 'en']
True
RfxtrxEntity._apply_event
(self, event)
Apply a received event.
Apply a received event.
def _apply_event(self, event): """Apply a received event.""" self._event = event
[ "def", "_apply_event", "(", "self", ",", "event", ")", ":", "self", ".", "_event", "=", "event" ]
[ 516, 4 ]
[ 518, 27 ]
python
en
['en', 'en', 'en']
True
RfxtrxEntity._handle_event
(self, event, device_id)
Handle a reception of data, overridden by other classes.
Handle a reception of data, overridden by other classes.
def _handle_event(self, event, device_id): """Handle a reception of data, overridden by other classes."""
[ "def", "_handle_event", "(", "self", ",", "event", ",", "device_id", ")", ":" ]
[ 521, 4 ]
[ 522, 70 ]
python
en
['en', 'en', 'en']
True
RfxtrxCommandEntity.__init__
(self, device, device_id, signal_repetitions=1, event=None)
Initialzie a switch or light device.
Initialzie a switch or light device.
def __init__(self, device, device_id, signal_repetitions=1, event=None): """Initialzie a switch or light device.""" super().__init__(device, device_id, event=event) self.signal_repetitions = signal_repetitions self._state = None
[ "def", "__init__", "(", "self", ",", "device", ",", "device_id", ",", "signal_repetitions", "=", "1", ",", "event", "=", "None", ")", ":", "super", "(", ")", ".", "__init__", "(", "device", ",", "device_id", ",", "event", "=", "event", ")", "self", "...
[ 531, 4 ]
[ 535, 26 ]
python
en
['en', 'en', 'en']
True
setup_platform
(hass, config, add_entities, discovery_info=None)
Set up the GitLab sensor platform.
Set up the GitLab sensor platform.
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the GitLab sensor platform.""" _name = config.get(CONF_NAME) _interval = config.get(CONF_SCAN_INTERVAL, SCAN_INTERVAL) _url = config.get(CONF_URL) _gitlab_data = GitLabData( priv_token=config[CONF_TOKEN], ...
[ "def", "setup_platform", "(", "hass", ",", "config", ",", "add_entities", ",", "discovery_info", "=", "None", ")", ":", "_name", "=", "config", ".", "get", "(", "CONF_NAME", ")", "_interval", "=", "config", ".", "get", "(", "CONF_SCAN_INTERVAL", ",", "SCAN...
[ 52, 0 ]
[ 65, 59 ]
python
en
['en', 'da', 'en']
True
GitLabSensor.__init__
(self, gitlab_data, name)
Initialize the GitLab sensor.
Initialize the GitLab sensor.
def __init__(self, gitlab_data, name): """Initialize the GitLab sensor.""" self._available = False self._state = None self._started_at = None self._finished_at = None self._duration = None self._commit_id = None self._commit_date = None self._build...
[ "def", "__init__", "(", "self", ",", "gitlab_data", ",", "name", ")", ":", "self", ".", "_available", "=", "False", "self", ".", "_state", "=", "None", "self", ".", "_started_at", "=", "None", "self", ".", "_finished_at", "=", "None", "self", ".", "_du...
[ 71, 4 ]
[ 83, 25 ]
python
en
['en', 'pt', 'en']
True
GitLabSensor.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" ]
[ 86, 4 ]
[ 88, 25 ]
python
en
['en', 'mi', 'en']
True
GitLabSensor.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" ]
[ 91, 4 ]
[ 93, 26 ]
python
en
['en', 'en', 'en']
True
GitLabSensor.available
(self)
Return True if entity is available.
Return True if entity is available.
def available(self): """Return True if entity is available.""" return self._available
[ "def", "available", "(", "self", ")", ":", "return", "self", ".", "_available" ]
[ 96, 4 ]
[ 98, 30 ]
python
en
['en', 'en', 'en']
True
GitLabSensor.device_state_attributes
(self)
Return the state attributes.
Return the state attributes.
def device_state_attributes(self): """Return the state attributes.""" return { ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_BUILD_STATUS: self._state, ATTR_BUILD_STARTED: self._started_at, ATTR_BUILD_FINISHED: self._finished_at, ATTR_BUILD_DURATION: sel...
[ "def", "device_state_attributes", "(", "self", ")", ":", "return", "{", "ATTR_ATTRIBUTION", ":", "ATTRIBUTION", ",", "ATTR_BUILD_STATUS", ":", "self", ".", "_state", ",", "ATTR_BUILD_STARTED", ":", "self", ".", "_started_at", ",", "ATTR_BUILD_FINISHED", ":", "self...
[ 101, 4 ]
[ 113, 9 ]
python
en
['en', 'en', 'en']
True
GitLabSensor.icon
(self)
Return the icon to use in the frontend.
Return the icon to use in the frontend.
def icon(self): """Return the icon to use in the frontend.""" if self._state == "success": return ICON_HAPPY if self._state == "failed": return ICON_SAD return ICON_OTHER
[ "def", "icon", "(", "self", ")", ":", "if", "self", ".", "_state", "==", "\"success\"", ":", "return", "ICON_HAPPY", "if", "self", ".", "_state", "==", "\"failed\"", ":", "return", "ICON_SAD", "return", "ICON_OTHER" ]
[ 116, 4 ]
[ 122, 25 ]
python
en
['en', 'en', 'en']
True
GitLabSensor.update
(self)
Collect updated data from GitLab API.
Collect updated data from GitLab API.
def update(self): """Collect updated data from GitLab API.""" self._gitlab_data.update() self._state = self._gitlab_data.status self._started_at = self._gitlab_data.started_at self._finished_at = self._gitlab_data.finished_at self._duration = self._gitlab_data.duration ...
[ "def", "update", "(", "self", ")", ":", "self", ".", "_gitlab_data", ".", "update", "(", ")", "self", ".", "_state", "=", "self", ".", "_gitlab_data", ".", "status", "self", ".", "_started_at", "=", "self", ".", "_gitlab_data", ".", "started_at", "self",...
[ 124, 4 ]
[ 136, 53 ]
python
en
['en', 'en', 'en']
True
GitLabData.__init__
(self, gitlab_id, priv_token, interval, url)
Fetch data from GitLab API for most recent CI job.
Fetch data from GitLab API for most recent CI job.
def __init__(self, gitlab_id, priv_token, interval, url): """Fetch data from GitLab API for most recent CI job.""" self._gitlab_id = gitlab_id self._gitlab = Gitlab(url, private_token=priv_token, per_page=1) self._gitlab.auth() self.update = Throttle(interval)(self._update) ...
[ "def", "__init__", "(", "self", ",", "gitlab_id", ",", "priv_token", ",", "interval", ",", "url", ")", ":", "self", ".", "_gitlab_id", "=", "gitlab_id", "self", ".", "_gitlab", "=", "Gitlab", "(", "url", ",", "private_token", "=", "priv_token", ",", "per...
[ 142, 4 ]
[ 158, 26 ]
python
en
['en', 'en', 'en']
True
GBDTSelector.fit
(self, X, y, **kwargs)
Fit the training data to FeatureSelector Paramters --------- X : array-like numpy matrix The training input samples, which shape is [n_samples, n_features]. y : array-like numpy matrix The target values (class labels in classification, real numbers in ...
Fit the training data to FeatureSelector
def fit(self, X, y, **kwargs): """ Fit the training data to FeatureSelector Paramters --------- X : array-like numpy matrix The training input samples, which shape is [n_samples, n_features]. y : array-like numpy matrix The target values (class la...
[ "def", "fit", "(", "self", ",", "X", ",", "y", ",", "*", "*", "kwargs", ")", ":", "assert", "kwargs", "[", "'lgb_params'", "]", "assert", "kwargs", "[", "'eval_ratio'", "]", "assert", "kwargs", "[", "'early_stopping_rounds'", "]", "assert", "kwargs", "["...
[ 49, 4 ]
[ 98, 85 ]
python
en
['en', 'error', 'th']
False
GBDTSelector.get_selected_features
(self, topk)
Fit the training data to FeatureSelector Returns ------- list : Return the index of imprtant feature.
Fit the training data to FeatureSelector
def get_selected_features(self, topk): """ Fit the training data to FeatureSelector Returns ------- list : Return the index of imprtant feature. """ assert topk > 0 self.selected_features_ = self.feature_importance.argsort()[-topk:][::-1]...
[ "def", "get_selected_features", "(", "self", ",", "topk", ")", ":", "assert", "topk", ">", "0", "self", ".", "selected_features_", "=", "self", ".", "feature_importance", ".", "argsort", "(", ")", "[", "-", "topk", ":", "]", "[", ":", ":", "-", "1", ...
[ 101, 4 ]
[ 114, 38 ]
python
en
['en', 'error', 'th']
False
get_device_component_mapping
(value)
Get mapping of value to another component.
Get mapping of value to another component.
def get_device_component_mapping(value): """Get mapping of value to another component.""" if value.node.manufacturer_id.strip() and value.node.product_type.strip(): manufacturer_id = int(value.node.manufacturer_id, 16) product_type = int(value.node.product_type, 16) product_id = int(valu...
[ "def", "get_device_component_mapping", "(", "value", ")", ":", "if", "value", ".", "node", ".", "manufacturer_id", ".", "strip", "(", ")", "and", "value", ".", "node", ".", "product_type", ".", "strip", "(", ")", ":", "manufacturer_id", "=", "int", "(", ...
[ 124, 0 ]
[ 142, 15 ]
python
en
['en', 'en', 'en']
True
get_device_mapping
(value)
Get mapping of value to a workaround.
Get mapping of value to a workaround.
def get_device_mapping(value): """Get mapping of value to a workaround.""" if ( value.node.manufacturer_id.strip() and value.node.product_id.strip() and value.node.product_type.strip() ): manufacturer_id = int(value.node.manufacturer_id, 16) product_type = int(value.n...
[ "def", "get_device_mapping", "(", "value", ")", ":", "if", "(", "value", ".", "node", ".", "manufacturer_id", ".", "strip", "(", ")", "and", "value", ".", "node", ".", "product_id", ".", "strip", "(", ")", "and", "value", ".", "node", ".", "product_typ...
[ 145, 0 ]
[ 169, 15 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass, config)
Initialize the NO-IP component.
Initialize the NO-IP component.
async def async_setup(hass, config): """Initialize the NO-IP component.""" domain = config[DOMAIN].get(CONF_DOMAIN) user = config[DOMAIN].get(CONF_USERNAME) password = config[DOMAIN].get(CONF_PASSWORD) timeout = config[DOMAIN].get(CONF_TIMEOUT) auth_str = base64.b64encode(f"{user}:{password}".e...
[ "async", "def", "async_setup", "(", "hass", ",", "config", ")", ":", "domain", "=", "config", "[", "DOMAIN", "]", ".", "get", "(", "CONF_DOMAIN", ")", "user", "=", "config", "[", "DOMAIN", "]", ".", "get", "(", "CONF_USERNAME", ")", "password", "=", ...
[ 53, 0 ]
[ 75, 15 ]
python
en
['en', 'en', 'en']
True
_update_no_ip
(hass, session, domain, auth_str, timeout)
Update NO-IP.
Update NO-IP.
async def _update_no_ip(hass, session, domain, auth_str, timeout): """Update NO-IP.""" url = UPDATE_URL params = {"hostname": domain} headers = { AUTHORIZATION: f"Basic {auth_str.decode('utf-8')}", USER_AGENT: HA_USER_AGENT, } try: with async_timeout.timeout(timeout): ...
[ "async", "def", "_update_no_ip", "(", "hass", ",", "session", ",", "domain", ",", "auth_str", ",", "timeout", ")", ":", "url", "=", "UPDATE_URL", "params", "=", "{", "\"hostname\"", ":", "domain", "}", "headers", "=", "{", "AUTHORIZATION", ":", "f\"Basic {...
[ 78, 0 ]
[ 107, 16 ]
python
en
['en', 'de', 'en']
False
keygen
(kt=KeyType.RANDOM)
Generate a key (i.e. a random odd integer between 2^(P-1) and 2^P).
Generate a key (i.e. a random odd integer between 2^(P-1) and 2^P).
def keygen(kt=KeyType.RANDOM): """Generate a key (i.e. a random odd integer between 2^(P-1) and 2^P).""" lowerBound = 2**(P-2) higherBound = 2**(P-1) - 1 if kt == KeyType.SMALLEST: half = lowerBound elif kt == KeyType.LARGEST: half = higherBound elif kt == KeyType.RANDOM: ...
[ "def", "keygen", "(", "kt", "=", "KeyType", ".", "RANDOM", ")", ":", "lowerBound", "=", "2", "**", "(", "P", "-", "2", ")", "higherBound", "=", "2", "**", "(", "P", "-", "1", ")", "-", "1", "if", "kt", "==", "KeyType", ".", "SMALLEST", ":", "...
[ 13, 0 ]
[ 23, 26 ]
python
en
['en', 'ca', 'en']
True
encrypt
(sk, b, mbits=N)
Encrypt a bit into a Q-bit integer based on the provided key.
Encrypt a bit into a Q-bit integer based on the provided key.
def encrypt(sk, b, mbits=N): """Encrypt a bit into a Q-bit integer based on the provided key.""" # Random N-bit integer with the same parity as b m = (random.randint(2**(mbits-2), 2**(mbits-1) -1) << 1) + b # Random Q-bit integer q = random.randint(2**(Q-1), 2**Q) - 1 return (m + sk*q...
[ "def", "encrypt", "(", "sk", ",", "b", ",", "mbits", "=", "N", ")", ":", "# Random N-bit integer with the same parity as b", "m", "=", "(", "random", ".", "randint", "(", "2", "**", "(", "mbits", "-", "2", ")", ",", "2", "**", "(", "mbits", "-", "1",...
[ 28, 0 ]
[ 37, 21 ]
python
en
['en', 'en', 'en']
True
encryptD
(sk, b, mbits=N)
Same as encrypt except it returns Q as well to allow computation of the noise.
Same as encrypt except it returns Q as well to allow computation of the noise.
def encryptD(sk, b, mbits=N): """Same as encrypt except it returns Q as well to allow computation of the noise.""" # Random N-bit integer with the same parity as b m = (random.randint(2**(mbits-2), 2**(mbits-1) -1) << 1) + b # Random Q-bit integer q = random.randint(2**(Q-1), 2**Q) - 1 ...
[ "def", "encryptD", "(", "sk", ",", "b", ",", "mbits", "=", "N", ")", ":", "# Random N-bit integer with the same parity as b", "m", "=", "(", "random", ".", "randint", "(", "2", "**", "(", "mbits", "-", "2", ")", ",", "2", "**", "(", "mbits", "-", "1"...
[ 40, 0 ]
[ 49, 26 ]
python
en
['en', 'en', 'en']
True
decrypt
(sk, c)
Decrypt a cyphertext based on the provided key.
Decrypt a cyphertext based on the provided key.
def decrypt(sk, c): """Decrypt a cyphertext based on the provided key.""" return (c % sk) % 2
[ "def", "decrypt", "(", "sk", ",", "c", ")", ":", "return", "(", "c", "%", "sk", ")", "%", "2" ]
[ 52, 0 ]
[ 54, 23 ]
python
en
['en', 'ga', 'en']
True
noise
(sk, c)
Get the noise of a cyphertext based on the provided key.
Get the noise of a cyphertext based on the provided key.
def noise(sk, c): """Get the noise of a cyphertext based on the provided key.""" return (c % sk)
[ "def", "noise", "(", "sk", ",", "c", ")", ":", "return", "(", "c", "%", "sk", ")" ]
[ 57, 0 ]
[ 59, 19 ]
python
en
['en', 'en', 'en']
True