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
get_m4s
(segment: io.BytesIO, sequence: int)
Get m4s section from fragmented mp4.
Get m4s section from fragmented mp4.
def get_m4s(segment: io.BytesIO, sequence: int) -> bytes: """Get m4s section from fragmented mp4.""" moof_location = next(find_box(segment, b"moof")) mfra_location = next(find_box(segment, b"mfra")) segment.seek(moof_location) return segment.read(mfra_location - moof_location)
[ "def", "get_m4s", "(", "segment", ":", "io", ".", "BytesIO", ",", "sequence", ":", "int", ")", "->", "bytes", ":", "moof_location", "=", "next", "(", "find_box", "(", "segment", ",", "b\"moof\"", ")", ")", "mfra_location", "=", "next", "(", "find_box", ...
[ 32, 0 ]
[ 37, 54 ]
python
en
['en', 'en', 'en']
True
get_codec_string
(segment: io.BytesIO)
Get RFC 6381 codec string.
Get RFC 6381 codec string.
def get_codec_string(segment: io.BytesIO) -> str: """Get RFC 6381 codec string.""" codecs = [] # Find moov moov_location = next(find_box(segment, b"moov")) # Find tracks for trak_location in find_box(segment, b"trak", moov_location): # Drill down to media info mdia_location = n...
[ "def", "get_codec_string", "(", "segment", ":", "io", ".", "BytesIO", ")", "->", "str", ":", "codecs", "=", "[", "]", "# Find moov", "moov_location", "=", "next", "(", "find_box", "(", "segment", ",", "b\"moov\"", ")", ")", "# Find tracks", "for", "trak_lo...
[ 40, 0 ]
[ 149, 27 ]
python
cy
['fr', 'cy', 'en']
False
async_setup_entry
(hass, config, async_add_entities)
Set up the blink binary sensors.
Set up the blink binary sensors.
async def async_setup_entry(hass, config, async_add_entities): """Set up the blink binary sensors.""" data = hass.data[DOMAIN][config.entry_id] entities = [] for camera in data.cameras: for sensor_type in BINARY_SENSORS: entities.append(BlinkBinarySensor(data, camera, sensor_type)) ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config", ",", "async_add_entities", ")", ":", "data", "=", "hass", ".", "data", "[", "DOMAIN", "]", "[", "config", ".", "entry_id", "]", "entities", "=", "[", "]", "for", "camera", "in", "data", "...
[ 16, 0 ]
[ 24, 32 ]
python
en
['en', 'no', 'en']
True
BlinkBinarySensor.__init__
(self, data, camera, sensor_type)
Initialize the sensor.
Initialize the sensor.
def __init__(self, data, camera, sensor_type): """Initialize the sensor.""" self.data = data self._type = sensor_type name, device_class = BINARY_SENSORS[sensor_type] self._name = f"{DOMAIN} {camera} {name}" self._device_class = device_class self._camera = data.ca...
[ "def", "__init__", "(", "self", ",", "data", ",", "camera", ",", "sensor_type", ")", ":", "self", ".", "data", "=", "data", "self", ".", "_type", "=", "sensor_type", "name", ",", "device_class", "=", "BINARY_SENSORS", "[", "sensor_type", "]", "self", "."...
[ 30, 4 ]
[ 39, 63 ]
python
en
['en', 'en', 'en']
True
BlinkBinarySensor.name
(self)
Return the name of the blink sensor.
Return the name of the blink sensor.
def name(self): """Return the name of the blink sensor.""" return self._name
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_name" ]
[ 42, 4 ]
[ 44, 25 ]
python
en
['en', 'no', 'en']
True
BlinkBinarySensor.device_class
(self)
Return the class of this device.
Return the class of this device.
def device_class(self): """Return the class of this device.""" return self._device_class
[ "def", "device_class", "(", "self", ")", ":", "return", "self", ".", "_device_class" ]
[ 47, 4 ]
[ 49, 33 ]
python
en
['en', 'en', 'en']
True
BlinkBinarySensor.is_on
(self)
Return the status of the sensor.
Return the status of the sensor.
def is_on(self): """Return the status of the sensor.""" return self._state
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "_state" ]
[ 52, 4 ]
[ 54, 26 ]
python
en
['en', 'id', 'en']
True
BlinkBinarySensor.update
(self)
Update sensor state.
Update sensor state.
def update(self): """Update sensor state.""" self.data.refresh() state = self._camera.attributes[self._type] if self._type == TYPE_BATTERY: state = state != "ok" self._state = state
[ "def", "update", "(", "self", ")", ":", "self", ".", "data", ".", "refresh", "(", ")", "state", "=", "self", ".", "_camera", ".", "attributes", "[", "self", ".", "_type", "]", "if", "self", ".", "_type", "==", "TYPE_BATTERY", ":", "state", "=", "st...
[ 56, 4 ]
[ 62, 27 ]
python
en
['en', 'co', 'en']
True
TFTrainer.get_train_tfdataset
(self)
Returns the training :class:`~tf.data.Dataset`. Subclass and override this method if you want to inject some custom behavior.
Returns the training :class:`~tf.data.Dataset`.
def get_train_tfdataset(self) -> tf.data.Dataset: """ Returns the training :class:`~tf.data.Dataset`. Subclass and override this method if you want to inject some custom behavior. """ if self.train_dataset is None: raise ValueError("Trainer: training requires a train...
[ "def", "get_train_tfdataset", "(", "self", ")", "->", "tf", ".", "data", ".", "Dataset", ":", "if", "self", ".", "train_dataset", "is", "None", ":", "raise", "ValueError", "(", "\"Trainer: training requires a train_dataset.\"", ")", "self", ".", "total_train_batch...
[ 130, 4 ]
[ 152, 69 ]
python
en
['en', 'error', 'th']
False
TFTrainer.get_eval_tfdataset
(self, eval_dataset: Optional[tf.data.Dataset] = None)
Returns the evaluation :class:`~tf.data.Dataset`. Args: eval_dataset (:class:`~tf.data.Dataset`, `optional`): If provided, will override `self.eval_dataset`. The dataset should yield tuples of ``(features, labels)`` where ``features`` is a dict of input feat...
Returns the evaluation :class:`~tf.data.Dataset`.
def get_eval_tfdataset(self, eval_dataset: Optional[tf.data.Dataset] = None) -> tf.data.Dataset: """ Returns the evaluation :class:`~tf.data.Dataset`. Args: eval_dataset (:class:`~tf.data.Dataset`, `optional`): If provided, will override `self.eval_dataset`. The data...
[ "def", "get_eval_tfdataset", "(", "self", ",", "eval_dataset", ":", "Optional", "[", "tf", ".", "data", ".", "Dataset", "]", "=", "None", ")", "->", "tf", ".", "data", ".", "Dataset", ":", "if", "eval_dataset", "is", "None", "and", "self", ".", "eval_d...
[ 154, 4 ]
[ 185, 90 ]
python
en
['en', 'error', 'th']
False
TFTrainer.get_test_tfdataset
(self, test_dataset: tf.data.Dataset)
Returns a test :class:`~tf.data.Dataset`. Args: test_dataset (:class:`~tf.data.Dataset`): The dataset to use. The dataset should yield tuples of ``(features, labels)`` where ``features`` is a dict of input features and ``labels`` is the labels. If ``labels``...
Returns a test :class:`~tf.data.Dataset`.
def get_test_tfdataset(self, test_dataset: tf.data.Dataset) -> tf.data.Dataset: """ Returns a test :class:`~tf.data.Dataset`. Args: test_dataset (:class:`~tf.data.Dataset`): The dataset to use. The dataset should yield tuples of ``(features, labels)`` where ``feature...
[ "def", "get_test_tfdataset", "(", "self", ",", "test_dataset", ":", "tf", ".", "data", ".", "Dataset", ")", "->", "tf", ".", "data", ".", "Dataset", ":", "num_examples", "=", "test_dataset", ".", "cardinality", "(", ")", ".", "numpy", "(", ")", "if", "...
[ 187, 4 ]
[ 210, 90 ]
python
en
['en', 'error', 'th']
False
TFTrainer.create_optimizer_and_scheduler
(self, num_training_steps: int)
Setup the optimizer and the learning rate scheduler. We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the TFTrainer's init through :obj:`optimizers`, or subclass and override this method.
Setup the optimizer and the learning rate scheduler.
def create_optimizer_and_scheduler(self, num_training_steps: int): """ Setup the optimizer and the learning rate scheduler. We provide a reasonable default that works well. If you want to use something else, you can pass a tuple in the TFTrainer's init through :obj:`optimizers`, or subc...
[ "def", "create_optimizer_and_scheduler", "(", "self", ",", "num_training_steps", ":", "int", ")", ":", "if", "not", "self", ".", "optimizer", "and", "not", "self", ".", "lr_scheduler", ":", "warmup_steps", "=", "(", "self", ".", "args", ".", "warmup_steps", ...
[ 212, 4 ]
[ 235, 13 ]
python
en
['en', 'error', 'th']
False
TFTrainer.setup_wandb
(self)
Setup the optional Weights & Biases (`wandb`) integration. One can subclass and override this method to customize the setup if needed. Find more information `here <https://docs.wandb.com/huggingface>`__. You can also override the following environment variables: Environment: ...
Setup the optional Weights & Biases (`wandb`) integration.
def setup_wandb(self): """ Setup the optional Weights & Biases (`wandb`) integration. One can subclass and override this method to customize the setup if needed. Find more information `here <https://docs.wandb.com/huggingface>`__. You can also override the following environment variable...
[ "def", "setup_wandb", "(", "self", ")", ":", "logger", ".", "info", "(", "'Automatic Weights & Biases logging enabled, to disable set os.environ[\"WANDB_DISABLED\"] = \"true\"'", ")", "combined_dict", "=", "{", "*", "*", "self", ".", "model", ".", "config", ".", "to_dic...
[ 237, 4 ]
[ 254, 116 ]
python
en
['en', 'error', 'th']
False
TFTrainer.setup_comet
(self)
Setup the optional Comet.ml integration. Environment: COMET_MODE: (Optional): str - "OFFLINE", "ONLINE", or "DISABLED" COMET_PROJECT_NAME: (Optional): str - Comet.ml project name for experiments COMET_OFFLINE_DIRECTORY: ...
Setup the optional Comet.ml integration.
def setup_comet(self): """ Setup the optional Comet.ml integration. Environment: COMET_MODE: (Optional): str - "OFFLINE", "ONLINE", or "DISABLED" COMET_PROJECT_NAME: (Optional): str - Comet.ml project name for experiments COMET...
[ "def", "setup_comet", "(", "self", ")", ":", "comet_mode", "=", "os", ".", "getenv", "(", "\"COMET_MODE\"", ",", "\"ONLINE\"", ")", ".", "upper", "(", ")", "args", "=", "{", "\"project_name\"", ":", "os", ".", "getenv", "(", "\"COMET_PROJECT_NAME\"", ",", ...
[ 256, 4 ]
[ 284, 101 ]
python
en
['en', 'error', 'th']
False
TFTrainer.prediction_loop
( self, dataset: tf.data.Dataset, steps: int, num_examples: int, description: str, prediction_loss_only: Optional[bool] = None, )
Prediction/evaluation loop, shared by :func:`~transformers.TFTrainer.evaluate` and :func:`~transformers.TFTrainer.predict`. Works both with or without labels.
Prediction/evaluation loop, shared by :func:`~transformers.TFTrainer.evaluate` and :func:`~transformers.TFTrainer.predict`.
def prediction_loop( self, dataset: tf.data.Dataset, steps: int, num_examples: int, description: str, prediction_loss_only: Optional[bool] = None, ) -> PredictionOutput: """ Prediction/evaluation loop, shared by :func:`~transformers.TFTrainer.evaluate`...
[ "def", "prediction_loop", "(", "self", ",", "dataset", ":", "tf", ".", "data", ".", "Dataset", ",", "steps", ":", "int", ",", "num_examples", ":", "int", ",", "description", ":", "str", ",", "prediction_loss_only", ":", "Optional", "[", "bool", "]", "=",...
[ 286, 4 ]
[ 371, 88 ]
python
en
['en', 'error', 'th']
False
TFTrainer.log
(self, logs: Dict[str, float])
Log :obj:`logs` on the various objects watching training. Subclass and override this method to inject custom behavior. Args: logs (:obj:`Dict[str, float]`): The values to log.
Log :obj:`logs` on the various objects watching training.
def log(self, logs: Dict[str, float]) -> None: """ Log :obj:`logs` on the various objects watching training. Subclass and override this method to inject custom behavior. Args: logs (:obj:`Dict[str, float]`): The values to log. """ logs["epoch...
[ "def", "log", "(", "self", ",", "logs", ":", "Dict", "[", "str", ",", "float", "]", ")", "->", "None", ":", "logs", "[", "\"epoch\"", "]", "=", "self", ".", "epoch_logging", "if", "self", ".", "tb_writer", ":", "with", "self", ".", "tb_writer", "."...
[ 373, 4 ]
[ 403, 27 ]
python
en
['en', 'error', 'th']
False
TFTrainer.evaluate
(self, eval_dataset: Optional[tf.data.Dataset] = None)
Run evaluation and returns metrics. The calling script will be responsible for providing a method to compute metrics, as they are task-dependent (pass it to the init :obj:`compute_metrics` argument). Args: eval_dataset (:class:`~tf.data.Dataset`, `optional`): ...
Run evaluation and returns metrics.
def evaluate(self, eval_dataset: Optional[tf.data.Dataset] = None) -> Dict[str, float]: """ Run evaluation and returns metrics. The calling script will be responsible for providing a method to compute metrics, as they are task-dependent (pass it to the init :obj:`compute_metrics` argume...
[ "def", "evaluate", "(", "self", ",", "eval_dataset", ":", "Optional", "[", "tf", ".", "data", ".", "Dataset", "]", "=", "None", ")", "->", "Dict", "[", "str", ",", "float", "]", ":", "eval_ds", ",", "steps", ",", "num_examples", "=", "self", ".", "...
[ 405, 4 ]
[ 431, 29 ]
python
en
['en', 'error', 'th']
False
TFTrainer.prediction_step
( self, features: tf.Tensor, labels: tf.Tensor, nb_instances_in_global_batch: tf.Tensor )
Compute the prediction on features and update the loss with labels. Subclass and override to inject some custom behavior.
Compute the prediction on features and update the loss with labels.
def prediction_step( self, features: tf.Tensor, labels: tf.Tensor, nb_instances_in_global_batch: tf.Tensor ) -> tf.Tensor: """ Compute the prediction on features and update the loss with labels. Subclass and override to inject some custom behavior. """ per_example_lo...
[ "def", "prediction_step", "(", "self", ",", "features", ":", "tf", ".", "Tensor", ",", "labels", ":", "tf", ".", "Tensor", ",", "nb_instances_in_global_batch", ":", "tf", ".", "Tensor", ")", "->", "tf", ".", "Tensor", ":", "per_example_loss", ",", "logits"...
[ 433, 4 ]
[ 446, 21 ]
python
en
['en', 'error', 'th']
False
TFTrainer.train
(self)
Train method to train the model.
Train method to train the model.
def train(self) -> None: """ Train method to train the model. """ train_ds = self.get_train_tfdataset() if self.args.debug: tf.summary.trace_on(graph=True, profiler=True) self.gradient_accumulator.reset() num_update_steps_per_epoch = self.num_train_...
[ "def", "train", "(", "self", ")", "->", "None", ":", "train_ds", "=", "self", ".", "get_train_tfdataset", "(", ")", "if", "self", ".", "args", ".", "debug", ":", "tf", ".", "summary", ".", "trace_on", "(", "graph", "=", "True", ",", "profiler", "=", ...
[ 458, 4 ]
[ 613, 34 ]
python
en
['en', 'error', 'th']
False
TFTrainer.training_step
(self, features, labels, nb_instances_in_global_batch)
Perform a training step on features and labels. Subclass and override to inject some custom behavior.
Perform a training step on features and labels.
def training_step(self, features, labels, nb_instances_in_global_batch): """ Perform a training step on features and labels. Subclass and override to inject some custom behavior. """ per_example_loss, _ = self.run_model(features, labels, True) scaled_loss = per_example_l...
[ "def", "training_step", "(", "self", ",", "features", ",", "labels", ",", "nb_instances_in_global_batch", ")", ":", "per_example_loss", ",", "_", "=", "self", ".", "run_model", "(", "features", ",", "labels", ",", "True", ")", "scaled_loss", "=", "per_example_...
[ 615, 4 ]
[ 634, 28 ]
python
en
['en', 'error', 'th']
False
TFTrainer.run_model
(self, features, labels, training)
Computes the loss of the given features and labels pair. Subclass and override this method if you want to inject some custom behavior. Args: features (:obj:`tf.Tensor`): A batch of input features. labels (:obj:`tf.Tensor`): A batch of labels. training (:obj...
Computes the loss of the given features and labels pair.
def run_model(self, features, labels, training): """ Computes the loss of the given features and labels pair. Subclass and override this method if you want to inject some custom behavior. Args: features (:obj:`tf.Tensor`): A batch of input features. labels (:obj...
[ "def", "run_model", "(", "self", ",", "features", ",", "labels", ",", "training", ")", ":", "if", "self", ".", "args", ".", "past_index", ">=", "0", "and", "getattr", "(", "self", ",", "\"_past\"", ",", "None", ")", "is", "not", "None", ":", "feature...
[ 722, 4 ]
[ 750, 27 ]
python
en
['en', 'error', 'th']
False
TFTrainer.predict
(self, test_dataset: tf.data.Dataset)
Run prediction and returns predictions and potential metrics. Depending on the dataset and your use case, your test dataset may contain labels. In that case, this method will also return metrics, like in :obj:`evaluate()`. Args: test_dataset (:class:`~tf.data.Dataset`): ...
Run prediction and returns predictions and potential metrics.
def predict(self, test_dataset: tf.data.Dataset) -> PredictionOutput: """ Run prediction and returns predictions and potential metrics. Depending on the dataset and your use case, your test dataset may contain labels. In that case, this method will also return metrics, like in :obj:`eva...
[ "def", "predict", "(", "self", ",", "test_dataset", ":", "tf", ".", "data", ".", "Dataset", ")", "->", "PredictionOutput", ":", "test_ds", ",", "steps", ",", "num_examples", "=", "self", ".", "get_test_tfdataset", "(", "test_dataset", ")", "return", "self", ...
[ 752, 4 ]
[ 776, 91 ]
python
en
['en', 'error', 'th']
False
TFTrainer.save_model
(self, output_dir: Optional[str] = None)
Will save the model, so you can reload it using :obj:`from_pretrained()`.
Will save the model, so you can reload it using :obj:`from_pretrained()`.
def save_model(self, output_dir: Optional[str] = None): """ Will save the model, so you can reload it using :obj:`from_pretrained()`. """ output_dir = output_dir if output_dir is not None else self.args.output_dir logger.info("Saving model in {}".format(output_dir)) if ...
[ "def", "save_model", "(", "self", ",", "output_dir", ":", "Optional", "[", "str", "]", "=", "None", ")", ":", "output_dir", "=", "output_dir", "if", "output_dir", "is", "not", "None", "else", "self", ".", "args", ".", "output_dir", "logger", ".", "info",...
[ 778, 4 ]
[ 789, 46 ]
python
en
['en', 'error', 'th']
False
Preprocessor.__init__
(self, corpus, target=None, **kwargs)
The corpus is the `HTMLCorpusReader` to preprocess and pickle. The target is the directory on disk to output the pickled corpus to.
The corpus is the `HTMLCorpusReader` to preprocess and pickle. The target is the directory on disk to output the pickled corpus to.
def __init__(self, corpus, target=None, **kwargs): """ The corpus is the `HTMLCorpusReader` to preprocess and pickle. The target is the directory on disk to output the pickled corpus to. """ self.corpus = corpus self.target = target
[ "def", "__init__", "(", "self", ",", "corpus", ",", "target", "=", "None", ",", "*", "*", "kwargs", ")", ":", "self", ".", "corpus", "=", "corpus", "self", ".", "target", "=", "target" ]
[ 18, 4 ]
[ 24, 28 ]
python
en
['en', 'error', 'th']
False
Preprocessor.fileids
(self, fileids=None, categories=None)
Helper function access the fileids of the corpus
Helper function access the fileids of the corpus
def fileids(self, fileids=None, categories=None): """ Helper function access the fileids of the corpus """ fileids = self.corpus.resolve(fileids, categories) if fileids: return fileids return self.corpus.fileids()
[ "def", "fileids", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "fileids", "=", "self", ".", "corpus", ".", "resolve", "(", "fileids", ",", "categories", ")", "if", "fileids", ":", "return", "fileids", "return", "s...
[ 26, 4 ]
[ 33, 36 ]
python
en
['en', 'error', 'th']
False
Preprocessor.abspath
(self, fileid)
Returns the absolute path to the target fileid from the corpus fileid.
Returns the absolute path to the target fileid from the corpus fileid.
def abspath(self, fileid): """ Returns the absolute path to the target fileid from the corpus fileid. """ # Find the directory, relative from the corpus root. parent = os.path.relpath( os.path.dirname(self.corpus.abspath(fileid)), self.corpus.root ) #...
[ "def", "abspath", "(", "self", ",", "fileid", ")", ":", "# Find the directory, relative from the corpus root.", "parent", "=", "os", ".", "path", ".", "relpath", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "corpus", ".", "abspath", "(", "fileid...
[ 35, 4 ]
[ 52, 76 ]
python
en
['en', 'error', 'th']
False
Preprocessor.tokenize
(self, fileid)
Segments, tokenizes, and tags a document in the corpus. Returns a generator of paragraphs, which are lists of sentences, which in turn are lists of part of speech tagged words.
Segments, tokenizes, and tags a document in the corpus. Returns a generator of paragraphs, which are lists of sentences, which in turn are lists of part of speech tagged words.
def tokenize(self, fileid): """ Segments, tokenizes, and tags a document in the corpus. Returns a generator of paragraphs, which are lists of sentences, which in turn are lists of part of speech tagged words. """ for paragraph in self.corpus.paras(fileids=fileid): ...
[ "def", "tokenize", "(", "self", ",", "fileid", ")", ":", "for", "paragraph", "in", "self", ".", "corpus", ".", "paras", "(", "fileids", "=", "fileid", ")", ":", "yield", "[", "pos_tag", "(", "wordpunct_tokenize", "(", "sent", ")", ")", "for", "sent", ...
[ 54, 4 ]
[ 64, 13 ]
python
en
['en', 'error', 'th']
False
Preprocessor.process
(self, fileid)
For a single file does the following preprocessing work: 1. Checks the location on disk to make sure no errors occur. 2. Gets all paragraphs for the given text. 3. Segements the paragraphs with the sent_tokenizer 4. Tokenizes the sentences with the wordpunct_toke...
For a single file does the following preprocessing work: 1. Checks the location on disk to make sure no errors occur. 2. Gets all paragraphs for the given text. 3. Segements the paragraphs with the sent_tokenizer 4. Tokenizes the sentences with the wordpunct_toke...
def process(self, fileid): """ For a single file does the following preprocessing work: 1. Checks the location on disk to make sure no errors occur. 2. Gets all paragraphs for the given text. 3. Segements the paragraphs with the sent_tokenizer 4. Tokenizes...
[ "def", "process", "(", "self", ",", "fileid", ")", ":", "# Compute the outpath to write the file to.", "target", "=", "self", ".", "abspath", "(", "fileid", ")", "parent", "=", "os", ".", "path", ".", "dirname", "(", "target", ")", "# Make sure the directory exi...
[ 66, 4 ]
[ 102, 21 ]
python
en
['en', 'error', 'th']
False
Preprocessor.transform
(self, fileids=None, categories=None)
Transform the wrapped corpus, writing out the segmented, tokenized, and part of speech tagged corpus as a pickle to the target directory. This method will also directly copy files that are in the corpus.root directory that are not matched by the corpus.fileids().
Transform the wrapped corpus, writing out the segmented, tokenized, and part of speech tagged corpus as a pickle to the target directory. This method will also directly copy files that are in the corpus.root directory that are not matched by the corpus.fileids().
def transform(self, fileids=None, categories=None): """ Transform the wrapped corpus, writing out the segmented, tokenized, and part of speech tagged corpus as a pickle to the target directory. This method will also directly copy files that are in the corpus.root directory that a...
[ "def", "transform", "(", "self", ",", "fileids", "=", "None", ",", "categories", "=", "None", ")", ":", "# Make the target directory if it doesn't already exist", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "target", ")", ":", "os", ".",...
[ 104, 4 ]
[ 120, 9 ]
python
en
['en', 'error', 'th']
False
test_config_flow_registers_webhook
(hass, aiohttp_client)
Test setting up Twilio and sending webhook.
Test setting up Twilio and sending webhook.
async def test_config_flow_registers_webhook(hass, aiohttp_client): """Test setting up Twilio and sending webhook.""" with patch("homeassistant.util.get_local_ip", return_value="example.com"): result = await hass.config_entries.flow.async_init( "twilio", context={"source": "user"} ) ...
[ "async", "def", "test_config_flow_registers_webhook", "(", "hass", ",", "aiohttp_client", ")", ":", "with", "patch", "(", "\"homeassistant.util.get_local_ip\"", ",", "return_value", "=", "\"example.com\"", ")", ":", "result", "=", "await", "hass", ".", "config_entries...
[ 8, 0 ]
[ 34, 53 ]
python
en
['en', 'zu', 'en']
True
get_service
(hass, config, discovery_info=None)
Get the ClickSend notification service.
Get the ClickSend notification service.
def get_service(hass, config, discovery_info=None): """Get the ClickSend notification service.""" if not _authenticate(config): _LOGGER.error("You are not authorized to access ClickSend") return None return ClicksendNotificationService(config)
[ "def", "get_service", "(", "hass", ",", "config", ",", "discovery_info", "=", "None", ")", ":", "if", "not", "_authenticate", "(", "config", ")", ":", "_LOGGER", ".", "error", "(", "\"You are not authorized to access ClickSend\"", ")", "return", "None", "return"...
[ 44, 0 ]
[ 49, 47 ]
python
en
['en', 'en', 'en']
True
_authenticate
(config)
Authenticate with ClickSend.
Authenticate with ClickSend.
def _authenticate(config): """Authenticate with ClickSend.""" api_url = f"{BASE_API_URL}/account" resp = requests.get( api_url, headers=HEADERS, auth=(config[CONF_USERNAME], config[CONF_API_KEY]), timeout=TIMEOUT, ) if resp.status_code != HTTP_OK: return False...
[ "def", "_authenticate", "(", "config", ")", ":", "api_url", "=", "f\"{BASE_API_URL}/account\"", "resp", "=", "requests", ".", "get", "(", "api_url", ",", "headers", "=", "HEADERS", ",", "auth", "=", "(", "config", "[", "CONF_USERNAME", "]", ",", "config", ...
[ 94, 0 ]
[ 105, 15 ]
python
en
['en', 'en', 'en']
True
ClicksendNotificationService.__init__
(self, config)
Initialize the service.
Initialize the service.
def __init__(self, config): """Initialize the service.""" self.username = config[CONF_USERNAME] self.api_key = config[CONF_API_KEY] self.recipients = config[CONF_RECIPIENT] self.sender = config[CONF_SENDER]
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "self", ".", "username", "=", "config", "[", "CONF_USERNAME", "]", "self", ".", "api_key", "=", "config", "[", "CONF_API_KEY", "]", "self", ".", "recipients", "=", "config", "[", "CONF_RECIPIENT", ...
[ 55, 4 ]
[ 60, 41 ]
python
en
['en', 'en', 'en']
True
ClicksendNotificationService.send_message
(self, message="", **kwargs)
Send a message to a user.
Send a message to a user.
def send_message(self, message="", **kwargs): """Send a message to a user.""" data = {"messages": []} for recipient in self.recipients: data["messages"].append( { "source": "hass.notify", "from": self.sender, ...
[ "def", "send_message", "(", "self", ",", "message", "=", "\"\"", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "\"messages\"", ":", "[", "]", "}", "for", "recipient", "in", "self", ".", "recipients", ":", "data", "[", "\"messages\"", "]", ".",...
[ 62, 4 ]
[ 91, 9 ]
python
en
['en', 'en', 'en']
True
async_setup_entry
(hass, config_entry, async_add_entities)
Set up a Axis binary sensor.
Set up a Axis binary sensor.
async def async_setup_entry(hass, config_entry, async_add_entities): """Set up a Axis binary sensor.""" device = hass.data[AXIS_DOMAIN][config_entry.unique_id] @callback def async_add_sensor(event_id): """Add binary sensor from Axis device.""" event = device.api.event[event_id] ...
[ "async", "def", "async_setup_entry", "(", "hass", ",", "config_entry", ",", "async_add_entities", ")", ":", "device", "=", "hass", ".", "data", "[", "AXIS_DOMAIN", "]", "[", "config_entry", ".", "unique_id", "]", "@", "callback", "def", "async_add_sensor", "("...
[ 39, 0 ]
[ 55, 5 ]
python
en
['en', 'haw', 'en']
True
AxisBinarySensor.__init__
(self, event, device)
Initialize the Axis binary sensor.
Initialize the Axis binary sensor.
def __init__(self, event, device): """Initialize the Axis binary sensor.""" super().__init__(event, device) self.cancel_scheduled_update = None
[ "def", "__init__", "(", "self", ",", "event", ",", "device", ")", ":", "super", "(", ")", ".", "__init__", "(", "event", ",", "device", ")", "self", ".", "cancel_scheduled_update", "=", "None" ]
[ 61, 4 ]
[ 64, 43 ]
python
en
['en', 'en', 'en']
True
AxisBinarySensor.update_callback
(self, no_delay=False)
Update the sensor's state, if needed. Parameter no_delay is True when device_event_reachable is sent.
Update the sensor's state, if needed.
def update_callback(self, no_delay=False): """Update the sensor's state, if needed. Parameter no_delay is True when device_event_reachable is sent. """ @callback def scheduled_update(now): """Timer callback for sensor update.""" self.cancel_scheduled_upd...
[ "def", "update_callback", "(", "self", ",", "no_delay", "=", "False", ")", ":", "@", "callback", "def", "scheduled_update", "(", "now", ")", ":", "\"\"\"Timer callback for sensor update.\"\"\"", "self", ".", "cancel_scheduled_update", "=", "None", "self", ".", "as...
[ 67, 4 ]
[ 91, 9 ]
python
en
['en', 'en', 'en']
True
AxisBinarySensor.is_on
(self)
Return true if event is active.
Return true if event is active.
def is_on(self): """Return true if event is active.""" return self.event.is_tripped
[ "def", "is_on", "(", "self", ")", ":", "return", "self", ".", "event", ".", "is_tripped" ]
[ 94, 4 ]
[ 96, 36 ]
python
en
['en', 'nl', 'en']
True
AxisBinarySensor.name
(self)
Return the name of the event.
Return the name of the event.
def name(self): """Return the name of the event.""" if ( self.event.CLASS == CLASS_INPUT and self.event.id and self.device.api.vapix.ports[self.event.id].name ): return ( f"{self.device.name} {self.device.api.vapix.ports[self.event....
[ "def", "name", "(", "self", ")", ":", "if", "(", "self", ".", "event", ".", "CLASS", "==", "CLASS_INPUT", "and", "self", ".", "event", ".", "id", "and", "self", ".", "device", ".", "api", ".", "vapix", ".", "ports", "[", "self", ".", "event", "."...
[ 99, 4 ]
[ 125, 27 ]
python
en
['en', 'en', 'en']
True
AxisBinarySensor.device_class
(self)
Return the class of the sensor.
Return the class of the sensor.
def device_class(self): """Return the class of the sensor.""" return DEVICE_CLASS.get(self.event.CLASS)
[ "def", "device_class", "(", "self", ")", ":", "return", "DEVICE_CLASS", ".", "get", "(", "self", ".", "event", ".", "CLASS", ")" ]
[ 128, 4 ]
[ 130, 49 ]
python
en
['en', 'pt', 'en']
True
TFAlbertEmbeddings.call
( self, input_ids: tf.Tensor = None, position_ids: tf.Tensor = None, token_type_ids: tf.Tensor = None, inputs_embeds: tf.Tensor = None, training: bool = False, )
Applies embedding based on inputs tensor. Returns: final_embeddings (:obj:`tf.Tensor`): output embedding tensor.
Applies embedding based on inputs tensor.
def call( self, input_ids: tf.Tensor = None, position_ids: tf.Tensor = None, token_type_ids: tf.Tensor = None, inputs_embeds: tf.Tensor = None, training: bool = False, ) -> tf.Tensor: """ Applies embedding based on inputs tensor. Returns: ...
[ "def", "call", "(", "self", ",", "input_ids", ":", "tf", ".", "Tensor", "=", "None", ",", "position_ids", ":", "tf", ".", "Tensor", "=", "None", ",", "token_type_ids", ":", "tf", ".", "Tensor", "=", "None", ",", "inputs_embeds", ":", "tf", ".", "Tens...
[ 153, 4 ]
[ 187, 31 ]
python
en
['en', 'error', 'th']
False
_inplace_fused_prox_jv_slow
(y_hat, dout)
not efficient in python for long seqs, but template for a cython impl
not efficient in python for long seqs, but template for a cython impl
def _inplace_fused_prox_jv_slow(y_hat, dout): """not efficient in python for long seqs, but template for a cython impl""" n_features = len(dout) for i in range(n_features + 1): if i in (0, n_features) or y_hat[i] != y_hat[i - 1]: if i > 0: dout[last_ix:i] = acc / n ...
[ "def", "_inplace_fused_prox_jv_slow", "(", "y_hat", ",", "dout", ")", ":", "n_features", "=", "len", "(", "dout", ")", "for", "i", "in", "range", "(", "n_features", "+", "1", ")", ":", "if", "i", "in", "(", "0", ",", "n_features", ")", "or", "y_hat",...
[ 21, 0 ]
[ 38, 15 ]
python
en
['en', 'en', 'en']
True
RetiariiAdvisor.handle_initialize
(self, data)
callback for initializing the advisor Parameters ---------- data: dict search space
callback for initializing the advisor Parameters ---------- data: dict search space
def handle_initialize(self, data): """callback for initializing the advisor Parameters ---------- data: dict search space """ self.handle_update_search_space(data) send(CommandType.Initialized, '')
[ "def", "handle_initialize", "(", "self", ",", "data", ")", ":", "self", ".", "handle_update_search_space", "(", "data", ")", "send", "(", "CommandType", ".", "Initialized", ",", "''", ")" ]
[ 60, 4 ]
[ 68, 41 ]
python
en
['en', 'zu', 'en']
True
RetiariiAdvisor.send_trial
(self, parameters)
Send parameters to NNI. Parameters ---------- parameters : Any Any payload. Returns ------- int Parameter ID that is assigned to this parameter, which will be used for identification in future.
Send parameters to NNI.
def send_trial(self, parameters): """ Send parameters to NNI. Parameters ---------- parameters : Any Any payload. Returns ------- int Parameter ID that is assigned to this parameter, which will be used for identificati...
[ "def", "send_trial", "(", "self", ",", "parameters", ")", ":", "self", ".", "parameters_count", "+=", "1", "new_trial", "=", "{", "'parameter_id'", ":", "self", ".", "parameters_count", ",", "'parameters'", ":", "parameters", ",", "'parameter_source'", ":", "'...
[ 70, 4 ]
[ 95, 36 ]
python
en
['en', 'error', 'th']
False
test_intent_set_humidity
(hass)
Test the set humidity intent.
Test the set humidity intent.
async def test_intent_set_humidity(hass): """Test the set humidity intent.""" hass.states.async_set( "humidifier.bedroom_humidifier", STATE_ON, {ATTR_HUMIDITY: 40} ) humidity_calls = async_mock_service(hass, DOMAIN, SERVICE_SET_HUMIDITY) turn_on_calls = async_mock_service(hass, DOMAIN, SERVI...
[ "async", "def", "test_intent_set_humidity", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"humidifier.bedroom_humidifier\"", ",", "STATE_ON", ",", "{", "ATTR_HUMIDITY", ":", "40", "}", ")", "humidity_calls", "=", "async_mock_service", "(",...
[ 22, 0 ]
[ 46, 45 ]
python
en
['en', 'en', 'en']
True
test_intent_set_humidity_and_turn_on
(hass)
Test the set humidity intent for turned off humidifier.
Test the set humidity intent for turned off humidifier.
async def test_intent_set_humidity_and_turn_on(hass): """Test the set humidity intent for turned off humidifier.""" hass.states.async_set( "humidifier.bedroom_humidifier", STATE_OFF, {ATTR_HUMIDITY: 40} ) humidity_calls = async_mock_service(hass, DOMAIN, SERVICE_SET_HUMIDITY) turn_on_calls =...
[ "async", "def", "test_intent_set_humidity_and_turn_on", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"humidifier.bedroom_humidifier\"", ",", "STATE_OFF", ",", "{", "ATTR_HUMIDITY", ":", "40", "}", ")", "humidity_calls", "=", "async_mock_ser...
[ 49, 0 ]
[ 80, 45 ]
python
en
['en', 'en', 'en']
True
test_intent_set_mode
(hass)
Test the set mode intent.
Test the set mode intent.
async def test_intent_set_mode(hass): """Test the set mode intent.""" hass.states.async_set( "humidifier.bedroom_humidifier", STATE_ON, { ATTR_HUMIDITY: 40, ATTR_SUPPORTED_FEATURES: 1, ATTR_AVAILABLE_MODES: ["home", "away"], ATTR_MODE: "hom...
[ "async", "def", "test_intent_set_mode", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"humidifier.bedroom_humidifier\"", ",", "STATE_ON", ",", "{", "ATTR_HUMIDITY", ":", "40", ",", "ATTR_SUPPORTED_FEATURES", ":", "1", ",", "ATTR_AVAILABLE_...
[ 83, 0 ]
[ 117, 45 ]
python
en
['en', 'en', 'en']
True
test_intent_set_mode_and_turn_on
(hass)
Test the set mode intent.
Test the set mode intent.
async def test_intent_set_mode_and_turn_on(hass): """Test the set mode intent.""" hass.states.async_set( "humidifier.bedroom_humidifier", STATE_OFF, { ATTR_HUMIDITY: 40, ATTR_SUPPORTED_FEATURES: 1, ATTR_AVAILABLE_MODES: ["home", "away"], AT...
[ "async", "def", "test_intent_set_mode_and_turn_on", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"humidifier.bedroom_humidifier\"", ",", "STATE_OFF", ",", "{", "ATTR_HUMIDITY", ":", "40", ",", "ATTR_SUPPORTED_FEATURES", ":", "1", ",", "AT...
[ 120, 0 ]
[ 158, 45 ]
python
en
['en', 'en', 'en']
True
test_intent_set_mode_tests_feature
(hass)
Test the set mode intent where modes are not supported.
Test the set mode intent where modes are not supported.
async def test_intent_set_mode_tests_feature(hass): """Test the set mode intent where modes are not supported.""" hass.states.async_set( "humidifier.bedroom_humidifier", STATE_ON, {ATTR_HUMIDITY: 40} ) mode_calls = async_mock_service(hass, DOMAIN, SERVICE_SET_MODE) await intent.async_setup_i...
[ "async", "def", "test_intent_set_mode_tests_feature", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"humidifier.bedroom_humidifier\"", ",", "STATE_ON", ",", "{", "ATTR_HUMIDITY", ":", "40", "}", ")", "mode_calls", "=", "async_mock_service", ...
[ 161, 0 ]
[ 179, 31 ]
python
en
['en', 'en', 'en']
True
test_intent_set_unknown_mode
(hass)
Test the set mode intent for unsupported mode.
Test the set mode intent for unsupported mode.
async def test_intent_set_unknown_mode(hass): """Test the set mode intent for unsupported mode.""" hass.states.async_set( "humidifier.bedroom_humidifier", STATE_ON, { ATTR_HUMIDITY: 40, ATTR_SUPPORTED_FEATURES: 1, ATTR_AVAILABLE_MODES: ["home", "away"]...
[ "async", "def", "test_intent_set_unknown_mode", "(", "hass", ")", ":", "hass", ".", "states", ".", "async_set", "(", "\"humidifier.bedroom_humidifier\"", ",", "STATE_ON", ",", "{", "ATTR_HUMIDITY", ":", "40", ",", "ATTR_SUPPORTED_FEATURES", ":", "1", ",", "ATTR_AV...
[ 182, 0 ]
[ 207, 31 ]
python
en
['en', 'en', 'en']
True
display_temp
( hass: HomeAssistant, temperature: Optional[float], unit: str, precision: float )
Convert temperature into preferred units/precision for display.
Convert temperature into preferred units/precision for display.
def display_temp( hass: HomeAssistant, temperature: Optional[float], unit: str, precision: float ) -> Optional[float]: """Convert temperature into preferred units/precision for display.""" temperature_unit = unit ha_unit = hass.config.units.temperature_unit if temperature is None: return te...
[ "def", "display_temp", "(", "hass", ":", "HomeAssistant", ",", "temperature", ":", "Optional", "[", "float", "]", ",", "unit", ":", "str", ",", "precision", ":", "float", ")", "->", "Optional", "[", "float", "]", ":", "temperature_unit", "=", "unit", "ha...
[ 9, 0 ]
[ 36, 22 ]
python
en
['en', 'it', 'en']
True
run_information
(hass, point_in_time: Optional[datetime] = None)
Return information about current run. There is also the run that covers point_in_time.
Return information about current run.
def run_information(hass, point_in_time: Optional[datetime] = None): """Return information about current run. There is also the run that covers point_in_time. """ run_info = run_information_from_instance(hass, point_in_time) if run_info: return run_info with session_scope(hass=hass) as...
[ "def", "run_information", "(", "hass", ",", "point_in_time", ":", "Optional", "[", "datetime", "]", "=", "None", ")", ":", "run_info", "=", "run_information_from_instance", "(", "hass", ",", "point_in_time", ")", "if", "run_info", ":", "return", "run_info", "w...
[ 116, 0 ]
[ 126, 67 ]
python
en
['en', 'en', 'en']
True
run_information_from_instance
(hass, point_in_time: Optional[datetime] = None)
Return information about current run from the existing instance. Does not query the database for older runs.
Return information about current run from the existing instance.
def run_information_from_instance(hass, point_in_time: Optional[datetime] = None): """Return information about current run from the existing instance. Does not query the database for older runs. """ ins = hass.data[DATA_INSTANCE] if point_in_time is None or point_in_time > ins.recording_start: ...
[ "def", "run_information_from_instance", "(", "hass", ",", "point_in_time", ":", "Optional", "[", "datetime", "]", "=", "None", ")", ":", "ins", "=", "hass", ".", "data", "[", "DATA_INSTANCE", "]", "if", "point_in_time", "is", "None", "or", "point_in_time", "...
[ 129, 0 ]
[ 137, 27 ]
python
en
['en', 'en', 'en']
True
run_information_with_session
(session, point_in_time: Optional[datetime] = None)
Return information about current run from the database.
Return information about current run from the database.
def run_information_with_session(session, point_in_time: Optional[datetime] = None): """Return information about current run from the database.""" recorder_runs = RecorderRuns query = session.query(recorder_runs) if point_in_time: query = query.filter( (recorder_runs.start < point_i...
[ "def", "run_information_with_session", "(", "session", ",", "point_in_time", ":", "Optional", "[", "datetime", "]", "=", "None", ")", ":", "recorder_runs", "=", "RecorderRuns", "query", "=", "session", ".", "query", "(", "recorder_runs", ")", "if", "point_in_tim...
[ 140, 0 ]
[ 153, 14 ]
python
en
['en', 'en', 'en']
True
async_setup
(hass: HomeAssistant, config: ConfigType)
Set up the recorder.
Set up the recorder.
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the recorder.""" conf = config[DOMAIN] entity_filter = convert_include_exclude_filter(conf) auto_purge = conf[CONF_AUTO_PURGE] keep_days = conf[CONF_PURGE_KEEP_DAYS] commit_interval = conf[CONF_COMMIT_INTERVAL] ...
[ "async", "def", "async_setup", "(", "hass", ":", "HomeAssistant", ",", "config", ":", "ConfigType", ")", "->", "bool", ":", "conf", "=", "config", "[", "DOMAIN", "]", "entity_filter", "=", "convert_include_exclude_filter", "(", "conf", ")", "auto_purge", "=", ...
[ 156, 0 ]
[ 195, 40 ]
python
en
['en', 'en', 'en']
True
Recorder.__init__
( self, hass: HomeAssistant, auto_purge: bool, keep_days: int, commit_interval: int, uri: str, db_max_retries: int, db_retry_wait: int, entity_filter: Callable[[str], bool], exclude_t: List[str], db_integrity_check: bool, )
Initialize the recorder.
Initialize the recorder.
def __init__( self, hass: HomeAssistant, auto_purge: bool, keep_days: int, commit_interval: int, uri: str, db_max_retries: int, db_retry_wait: int, entity_filter: Callable[[str], bool], exclude_t: List[str], db_integrity_check: bool...
[ "def", "__init__", "(", "self", ",", "hass", ":", "HomeAssistant", ",", "auto_purge", ":", "bool", ",", "keep_days", ":", "int", ",", "commit_interval", ":", "int", ",", "uri", ":", "str", ",", "db_max_retries", ":", "int", ",", "db_retry_wait", ":", "in...
[ 208, 4 ]
[ 249, 46 ]
python
en
['en', 'en', 'en']
True
Recorder.async_initialize
(self)
Initialize the recorder.
Initialize the recorder.
def async_initialize(self): """Initialize the recorder.""" self.hass.bus.async_listen(MATCH_ALL, self.event_listener)
[ "def", "async_initialize", "(", "self", ")", ":", "self", ".", "hass", ".", "bus", ".", "async_listen", "(", "MATCH_ALL", ",", "self", ".", "event_listener", ")" ]
[ 252, 4 ]
[ 254, 66 ]
python
en
['en', 'en', 'en']
True
Recorder.do_adhoc_purge
(self, **kwargs)
Trigger an adhoc purge retaining keep_days worth of data.
Trigger an adhoc purge retaining keep_days worth of data.
def do_adhoc_purge(self, **kwargs): """Trigger an adhoc purge retaining keep_days worth of data.""" keep_days = kwargs.get(ATTR_KEEP_DAYS, self.keep_days) repack = kwargs.get(ATTR_REPACK) self.queue.put(PurgeTask(keep_days, repack))
[ "def", "do_adhoc_purge", "(", "self", ",", "*", "*", "kwargs", ")", ":", "keep_days", "=", "kwargs", ".", "get", "(", "ATTR_KEEP_DAYS", ",", "self", ".", "keep_days", ")", "repack", "=", "kwargs", ".", "get", "(", "ATTR_REPACK", ")", "self", ".", "queu...
[ 256, 4 ]
[ 261, 52 ]
python
en
['en', 'sn', 'en']
True
Recorder.run
(self)
Start processing events to save.
Start processing events to save.
def run(self): """Start processing events to save.""" tries = 1 connected = False while not connected and tries <= self.db_max_retries: if tries != 1: time.sleep(self.db_retry_wait) try: self._setup_connection() mig...
[ "def", "run", "(", "self", ")", ":", "tries", "=", "1", "connected", "=", "False", "while", "not", "connected", "and", "tries", "<=", "self", ".", "db_max_retries", ":", "if", "tries", "!=", "1", ":", "time", ".", "sleep", "(", "self", ".", "db_retry...
[ 263, 4 ]
[ 431, 53 ]
python
en
['en', 'en', 'en']
True
Recorder.event_listener
(self, event)
Listen for new events and put them in the process queue.
Listen for new events and put them in the process queue.
def event_listener(self, event): """Listen for new events and put them in the process queue.""" self.queue.put(event)
[ "def", "event_listener", "(", "self", ",", "event", ")", ":", "self", ".", "queue", ".", "put", "(", "event", ")" ]
[ 529, 4 ]
[ 531, 29 ]
python
en
['en', 'en', 'en']
True
Recorder.block_till_done
(self)
Block till all events processed. This is only called in tests. This only blocks until the queue is empty which does not mean the recorder is done. Call tests.common's wait_recording_done after calling this to ensure the data is in the database.
Block till all events processed.
def block_till_done(self): """Block till all events processed. This is only called in tests. This only blocks until the queue is empty which does not mean the recorder is done. Call tests.common's wait_recording_done after calling this to ensure the data is in ...
[ "def", "block_till_done", "(", "self", ")", ":", "self", ".", "_queue_watch", ".", "clear", "(", ")", "self", ".", "queue", ".", "put", "(", "WaitTask", "(", ")", ")", "self", ".", "_queue_watch", ".", "wait", "(", ")" ]
[ 533, 4 ]
[ 547, 32 ]
python
en
['sv', 'en', 'en']
True
Recorder._setup_connection
(self)
Ensure database is ready to fly.
Ensure database is ready to fly.
def _setup_connection(self): """Ensure database is ready to fly.""" kwargs = {} def setup_recorder_connection(dbapi_connection, connection_record): """Dbapi specific connection settings.""" if self._completed_database_setup: return # We do no...
[ "def", "_setup_connection", "(", "self", ")", ":", "kwargs", "=", "{", "}", "def", "setup_recorder_connection", "(", "dbapi_connection", ",", "connection_record", ")", ":", "\"\"\"Dbapi specific connection settings.\"\"\"", "if", "self", ".", "_completed_database_setup", ...
[ 549, 4 ]
[ 607, 73 ]
python
en
['en', 'en', 'en']
True
Recorder._close_connection
(self)
Close the connection.
Close the connection.
def _close_connection(self): """Close the connection.""" self.engine.dispose() self.engine = None self.get_session = None
[ "def", "_close_connection", "(", "self", ")", ":", "self", ".", "engine", ".", "dispose", "(", ")", "self", ".", "engine", "=", "None", "self", ".", "get_session", "=", "None" ]
[ 609, 4 ]
[ 613, 31 ]
python
en
['en', 'en', 'en']
True
Recorder._setup_run
(self)
Log the start of the current run.
Log the start of the current run.
def _setup_run(self): """Log the start of the current run.""" with session_scope(session=self.get_session()) as session: for run in session.query(RecorderRuns).filter_by(end=None): run.closed_incorrect = True run.end = self.recording_start _LOG...
[ "def", "_setup_run", "(", "self", ")", ":", "with", "session_scope", "(", "session", "=", "self", ".", "get_session", "(", ")", ")", "as", "session", ":", "for", "run", "in", "session", ".", "query", "(", "RecorderRuns", ")", ".", "filter_by", "(", "en...
[ 615, 4 ]
[ 631, 42 ]
python
en
['en', 'en', 'en']
True
Recorder._close_run
(self)
Save end time for current run.
Save end time for current run.
def _close_run(self): """Save end time for current run.""" if self.event_session is not None: self.run_info.end = dt_util.utcnow() self.event_session.add(self.run_info) self._commit_event_session_or_retry() self.event_session.close() self.run_info...
[ "def", "_close_run", "(", "self", ")", ":", "if", "self", ".", "event_session", "is", "not", "None", ":", "self", ".", "run_info", ".", "end", "=", "dt_util", ".", "utcnow", "(", ")", "self", ".", "event_session", ".", "add", "(", "self", ".", "run_i...
[ 633, 4 ]
[ 641, 28 ]
python
en
['en', 'en', 'en']
True
mockup_raise
(*args, **kwargs)
Mockup to replace regular functions for error injection.
Mockup to replace regular functions for error injection.
def mockup_raise(*args, **kwargs): """Mockup to replace regular functions for error injection.""" raise NumatoGpioError("Error mockup")
[ "def", "mockup_raise", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "raise", "NumatoGpioError", "(", "\"Error mockup\"", ")" ]
[ 41, 0 ]
[ 43, 41 ]
python
en
['da', 'en', 'en']
True
mockup_return
(*args, **kwargs)
Mockup to replace regular functions for error injection.
Mockup to replace regular functions for error injection.
def mockup_return(*args, **kwargs): """Mockup to replace regular functions for error injection.""" return False
[ "def", "mockup_return", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "False" ]
[ 46, 0 ]
[ 48, 16 ]
python
en
['da', 'en', 'en']
True
test_cover_async_setup_entry
(hass, aioclient_mock)
Test climate setup without sensors.
Test climate setup without sensors.
async def test_cover_async_setup_entry(hass, aioclient_mock): """Test climate setup without sensors.""" aioclient_mock.get( TEST_SYSTEM_URL, text=TEST_SYSTEM_DATA, ) aioclient_mock.get( TEST_SET_URL, text=TEST_SET_RESPONSE, ) await add_mock_config(hass) reg...
[ "async", "def", "test_cover_async_setup_entry", "(", "hass", ",", "aioclient_mock", ")", ":", "aioclient_mock", ".", "get", "(", "TEST_SYSTEM_URL", ",", "text", "=", "TEST_SYSTEM_DATA", ",", ")", "aioclient_mock", ".", "get", "(", "TEST_SET_URL", ",", "text", "=...
[ 27, 0 ]
[ 112, 68 ]
python
en
['en', 'en', 'en']
True
assert_tensors_close
(a, b, atol=1e-12, prefix="")
If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error.
If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error.
def assert_tensors_close(a, b, atol=1e-12, prefix=""): """If tensors have different shapes, different values or a and b are not both tensors, raise a nice Assertion error.""" if a is None and b is None: return True try: if torch.allclose(a, b, atol=atol): return True rais...
[ "def", "assert_tensors_close", "(", "a", ",", "b", ",", "atol", "=", "1e-12", ",", "prefix", "=", "\"\"", ")", ":", "if", "a", "is", "None", "and", "b", "is", "None", ":", "return", "True", "try", ":", "if", "torch", ".", "allclose", "(", "a", ",...
[ 267, 0 ]
[ 283, 33 ]
python
en
['en', 'en', 'en']
True
test_cors_middleware_loaded_by_default
(hass)
Test accessing to server from banned IP when feature is off.
Test accessing to server from banned IP when feature is off.
async def test_cors_middleware_loaded_by_default(hass): """Test accessing to server from banned IP when feature is off.""" with patch("homeassistant.components.http.setup_cors") as mock_setup: await async_setup_component(hass, "http", {"http": {}}) assert len(mock_setup.mock_calls) == 1
[ "async", "def", "test_cors_middleware_loaded_by_default", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.http.setup_cors\"", ")", "as", "mock_setup", ":", "await", "async_setup_component", "(", "hass", ",", "\"http\"", ",", "{", "\"http\"", "...
[ 25, 0 ]
[ 30, 42 ]
python
en
['en', 'en', 'en']
True
test_cors_middleware_loaded_from_config
(hass)
Test accessing to server from banned IP when feature is off.
Test accessing to server from banned IP when feature is off.
async def test_cors_middleware_loaded_from_config(hass): """Test accessing to server from banned IP when feature is off.""" with patch("homeassistant.components.http.setup_cors") as mock_setup: await async_setup_component( hass, "http", {"http": {"cors_allowed_origins...
[ "async", "def", "test_cors_middleware_loaded_from_config", "(", "hass", ")", ":", "with", "patch", "(", "\"homeassistant.components.http.setup_cors\"", ")", "as", "mock_setup", ":", "await", "async_setup_component", "(", "hass", ",", "\"http\"", ",", "{", "\"http\"", ...
[ 33, 0 ]
[ 42, 42 ]
python
en
['en', 'en', 'en']
True
mock_handler
(request)
Return if request was authenticated.
Return if request was authenticated.
async def mock_handler(request): """Return if request was authenticated.""" return web.Response(status=200)
[ "async", "def", "mock_handler", "(", "request", ")", ":", "return", "web", ".", "Response", "(", "status", "=", "200", ")" ]
[ 45, 0 ]
[ 47, 35 ]
python
en
['en', 'en', 'en']
True
client
(loop, aiohttp_client)
Fixture to set up a web.Application.
Fixture to set up a web.Application.
def client(loop, aiohttp_client): """Fixture to set up a web.Application.""" app = web.Application() app.router.add_get("/", mock_handler) setup_cors(app, [TRUSTED_ORIGIN]) return loop.run_until_complete(aiohttp_client(app))
[ "def", "client", "(", "loop", ",", "aiohttp_client", ")", ":", "app", "=", "web", ".", "Application", "(", ")", "app", ".", "router", ".", "add_get", "(", "\"/\"", ",", "mock_handler", ")", "setup_cors", "(", "app", ",", "[", "TRUSTED_ORIGIN", "]", ")"...
[ 51, 0 ]
[ 56, 55 ]
python
en
['en', 'en', 'en']
True
test_cors_requests
(client)
Test cross origin requests.
Test cross origin requests.
async def test_cors_requests(client): """Test cross origin requests.""" req = await client.get("/", headers={ORIGIN: TRUSTED_ORIGIN}) assert req.status == 200 assert req.headers[ACCESS_CONTROL_ALLOW_ORIGIN] == TRUSTED_ORIGIN # With password in URL req = await client.get( "/", params={"a...
[ "async", "def", "test_cors_requests", "(", "client", ")", ":", "req", "=", "await", "client", ".", "get", "(", "\"/\"", ",", "headers", "=", "{", "ORIGIN", ":", "TRUSTED_ORIGIN", "}", ")", "assert", "req", ".", "status", "==", "200", "assert", "req", "...
[ 59, 0 ]
[ 84, 69 ]
python
en
['en', 'nl', 'en']
True
test_cors_preflight_allowed
(client)
Test cross origin resource sharing preflight (OPTIONS) request.
Test cross origin resource sharing preflight (OPTIONS) request.
async def test_cors_preflight_allowed(client): """Test cross origin resource sharing preflight (OPTIONS) request.""" req = await client.options( "/", headers={ ORIGIN: TRUSTED_ORIGIN, ACCESS_CONTROL_REQUEST_METHOD: "GET", ACCESS_CONTROL_REQUEST_HEADERS: "x-req...
[ "async", "def", "test_cors_preflight_allowed", "(", "client", ")", ":", "req", "=", "await", "client", ".", "options", "(", "\"/\"", ",", "headers", "=", "{", "ORIGIN", ":", "TRUSTED_ORIGIN", ",", "ACCESS_CONTROL_REQUEST_METHOD", ":", "\"GET\"", ",", "ACCESS_CON...
[ 87, 0 ]
[ 100, 74 ]
python
en
['en', 'lb', 'en']
True
test_cors_middleware_with_cors_allowed_view
(hass)
Test that we can configure cors and have a cors_allowed view.
Test that we can configure cors and have a cors_allowed view.
async def test_cors_middleware_with_cors_allowed_view(hass): """Test that we can configure cors and have a cors_allowed view.""" class MyView(HomeAssistantView): """Test view that allows CORS.""" requires_auth = False cors_allowed = True def __init__(self, url, name): ...
[ "async", "def", "test_cors_middleware_with_cors_allowed_view", "(", "hass", ")", ":", "class", "MyView", "(", "HomeAssistantView", ")", ":", "\"\"\"Test view that allows CORS.\"\"\"", "requires_auth", "=", "False", "cors_allowed", "=", "True", "def", "__init__", "(", "s...
[ 103, 0 ]
[ 130, 33 ]
python
en
['en', 'en', 'en']
True
test_cors_works_with_frontend
(hass, hass_client)
Test CORS works with the frontend.
Test CORS works with the frontend.
async def test_cors_works_with_frontend(hass, hass_client): """Test CORS works with the frontend.""" assert await async_setup_component( hass, "frontend", {"http": {"cors_allowed_origins": ["http://home-assistant.io"]}}, ) client = await hass_client() resp = await client.get(...
[ "async", "def", "test_cors_works_with_frontend", "(", "hass", ",", "hass_client", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"frontend\"", ",", "{", "\"http\"", ":", "{", "\"cors_allowed_origins\"", ":", "[", "\"http://home-assistant.io\...
[ 133, 0 ]
[ 142, 29 ]
python
en
['en', 'en', 'en']
True
test_cors_on_static_files
(hass, hass_client)
Test that we enable CORS for static files.
Test that we enable CORS for static files.
async def test_cors_on_static_files(hass, hass_client): """Test that we enable CORS for static files.""" assert await async_setup_component( hass, "frontend", {"http": {"cors_allowed_origins": ["http://www.example.com"]}} ) hass.http.register_static_path("/something", str(Path(__file__).parent))...
[ "async", "def", "test_cors_on_static_files", "(", "hass", ",", "hass_client", ")", ":", "assert", "await", "async_setup_component", "(", "hass", ",", "\"frontend\"", ",", "{", "\"http\"", ":", "{", "\"cors_allowed_origins\"", ":", "[", "\"http://www.example.com\"", ...
[ 145, 0 ]
[ 161, 80 ]
python
en
['en', 'en', 'en']
True
async_get_next_ping_id
(hass)
Find the next id to use in the outbound ping. Must be called in async
Find the next id to use in the outbound ping.
def async_get_next_ping_id(hass): """Find the next id to use in the outbound ping. Must be called in async """ current_id = hass.data.setdefault(DOMAIN, {}).get(PING_ID, DEFAULT_START_ID) if current_id == MAX_PING_ID: next_id = DEFAULT_START_ID else: next_id = current_id + 1 ...
[ "def", "async_get_next_ping_id", "(", "hass", ")", ":", "current_id", "=", "hass", ".", "data", ".", "setdefault", "(", "DOMAIN", ",", "{", "}", ")", ".", "get", "(", "PING_ID", ",", "DEFAULT_START_ID", ")", "if", "current_id", "==", "MAX_PING_ID", ":", ...
[ 13, 0 ]
[ 27, 18 ]
python
en
['en', 'en', 'en']
True
accuracy
(output, target, topk=(1,))
Computes the precision@k for the specified values of k
Computes the precision
def accuracy(output, target, topk=(1,)): """ Computes the precision@k for the specified values of k """ maxk = max(topk) batch_size = target.size(0) _, pred = output.topk(maxk, 1, True, True) pred = pred.t() # one-hot case if target.ndimension() > 1: target = target.max(1)[1] c...
[ "def", "accuracy", "(", "output", ",", "target", ",", "topk", "=", "(", "1", ",", ")", ")", ":", "maxk", "=", "max", "(", "topk", ")", "batch_size", "=", "target", ".", "size", "(", "0", ")", "_", ",", "pred", "=", "output", ".", "topk", "(", ...
[ 3, 0 ]
[ 20, 14 ]
python
en
['en', 'en', 'en']
True
test_setup
(hass, requests_mock)
Test for successfully setting up the platform.
Test for successfully setting up the platform.
async def test_setup(hass, requests_mock): """Test for successfully setting up the platform.""" config = { "sensor": { "platform": "openhardwaremonitor", "host": "localhost", "port": 8085, } } requests_mock.get( "http://localhost:8085/data.jso...
[ "async", "def", "test_setup", "(", "hass", ",", "requests_mock", ")", ":", "config", "=", "{", "\"sensor\"", ":", "{", "\"platform\"", ":", "\"openhardwaremonitor\"", ",", "\"host\"", ":", "\"localhost\"", ",", "\"port\"", ":", "8085", ",", "}", "}", "reques...
[ 6, 0 ]
[ 35, 32 ]
python
en
['en', 'en', 'en']
True
BertGenerationPreTrainedModel._init_weights
(self, module)
Initialize the weights
Initialize the weights
def _init_weights(self, module): """ Initialize the weights """ if isinstance(module, nn.Linear): # Slightly different from the TF version which uses truncated_normal for initialization # cf https://github.com/pytorch/pytorch/pull/5617 module.weight.data.normal_(mean=...
[ "def", "_init_weights", "(", "self", ",", "module", ")", ":", "if", "isinstance", "(", "module", ",", "nn", ".", "Linear", ")", ":", "# Slightly different from the TF version which uses truncated_normal for initialization", "# cf https://github.com/pytorch/pytorch/pull/5617", ...
[ 178, 4 ]
[ 192, 41 ]
python
en
['en', 'en', 'en']
True
setup_config
(hass)
Fixture that sets up the auth provider homeassistant module.
Fixture that sets up the auth provider homeassistant module.
def setup_config(hass): """Fixture that sets up the auth provider homeassistant module.""" hass.loop.run_until_complete( register_auth_provider(hass, {"type": "homeassistant"}) ) hass.loop.run_until_complete(auth_ha.async_setup(hass))
[ "def", "setup_config", "(", "hass", ")", ":", "hass", ".", "loop", ".", "run_until_complete", "(", "register_auth_provider", "(", "hass", ",", "{", "\"type\"", ":", "\"homeassistant\"", "}", ")", ")", "hass", ".", "loop", ".", "run_until_complete", "(", "aut...
[ 10, 0 ]
[ 15, 59 ]
python
en
['en', 'en', 'en']
True
auth_provider
(hass)
Hass auth provider.
Hass auth provider.
async def auth_provider(hass): """Hass auth provider.""" provider = hass.auth.auth_providers[0] await provider.async_initialize() return provider
[ "async", "def", "auth_provider", "(", "hass", ")", ":", "provider", "=", "hass", ".", "auth", ".", "auth_providers", "[", "0", "]", "await", "provider", ".", "async_initialize", "(", ")", "return", "provider" ]
[ 19, 0 ]
[ 23, 19 ]
python
en
['fr', 'en', 'en']
True
owner_access_token
(hass, hass_owner_user)
Access token for owner user.
Access token for owner user.
async def owner_access_token(hass, hass_owner_user): """Access token for owner user.""" refresh_token = await hass.auth.async_create_refresh_token( hass_owner_user, CLIENT_ID ) return hass.auth.async_create_access_token(refresh_token)
[ "async", "def", "owner_access_token", "(", "hass", ",", "hass_owner_user", ")", ":", "refresh_token", "=", "await", "hass", ".", "auth", ".", "async_create_refresh_token", "(", "hass_owner_user", ",", "CLIENT_ID", ")", "return", "hass", ".", "auth", ".", "async_...
[ 27, 0 ]
[ 32, 61 ]
python
en
['en', 'no', 'en']
True
test_user_credential
(hass, auth_provider)
Add a test user.
Add a test user.
async def test_user_credential(hass, auth_provider): """Add a test user.""" await hass.async_add_executor_job( auth_provider.data.add_auth, "test-user", "test-pass" ) return await auth_provider.async_get_or_create_credentials( {"username": "test-user"} )
[ "async", "def", "test_user_credential", "(", "hass", ",", "auth_provider", ")", ":", "await", "hass", ".", "async_add_executor_job", "(", "auth_provider", ".", "data", ".", "add_auth", ",", "\"test-user\"", ",", "\"test-pass\"", ")", "return", "await", "auth_provi...
[ 36, 0 ]
[ 44, 5 ]
python
en
['en', 'cy', 'en']
True
test_create_auth_system_generated_user
(hass, hass_ws_client)
Test we can't add auth to system generated users.
Test we can't add auth to system generated users.
async def test_create_auth_system_generated_user(hass, hass_ws_client): """Test we can't add auth to system generated users.""" system_user = MockUser(system_generated=True).add_to_hass(hass) client = await hass_ws_client(hass) await client.send_json( { "id": 5, "type": ...
[ "async", "def", "test_create_auth_system_generated_user", "(", "hass", ",", "hass_ws_client", ")", ":", "system_user", "=", "MockUser", "(", "system_generated", "=", "True", ")", ".", "add_to_hass", "(", "hass", ")", "client", "=", "await", "hass_ws_client", "(", ...
[ 47, 0 ]
[ 65, 56 ]
python
en
['en', 'en', 'en']
True
test_create_auth_user_already_credentials
()
Test we can't create auth for user with pre-existing credentials.
Test we can't create auth for user with pre-existing credentials.
async def test_create_auth_user_already_credentials(): """Test we can't create auth for user with pre-existing credentials."""
[ "async", "def", "test_create_auth_user_already_credentials", "(", ")", ":" ]
[ 68, 0 ]
[ 69, 75 ]
python
en
['en', 'en', 'en']
True
test_create_auth_unknown_user
(hass_ws_client, hass)
Test create pointing at unknown user.
Test create pointing at unknown user.
async def test_create_auth_unknown_user(hass_ws_client, hass): """Test create pointing at unknown user.""" client = await hass_ws_client(hass) await client.send_json( { "id": 5, "type": "config/auth_provider/homeassistant/create", "user_id": "test-id", ...
[ "async", "def", "test_create_auth_unknown_user", "(", "hass_ws_client", ",", "hass", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "5", ",", "\"type\"", ":", "\"config/auth_p...
[ 73, 0 ]
[ 90, 49 ]
python
en
['en', 'en', 'en']
True
test_create_auth_requires_admin
( hass, hass_ws_client, hass_read_only_access_token )
Test create requires admin to call API.
Test create requires admin to call API.
async def test_create_auth_requires_admin( hass, hass_ws_client, hass_read_only_access_token ): """Test create requires admin to call API.""" client = await hass_ws_client(hass, hass_read_only_access_token) await client.send_json( { "id": 5, "type": "config/auth_provider...
[ "async", "def", "test_create_auth_requires_admin", "(", "hass", ",", "hass_ws_client", ",", "hass_read_only_access_token", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ",", "hass_read_only_access_token", ")", "await", "client", ".", "send_json", "(...
[ 93, 0 ]
[ 111, 52 ]
python
en
['en', 'en', 'en']
True
test_create_auth
(hass, hass_ws_client, hass_storage)
Test create auth command works.
Test create auth command works.
async def test_create_auth(hass, hass_ws_client, hass_storage): """Test create auth command works.""" client = await hass_ws_client(hass) user = MockUser().add_to_hass(hass) assert len(user.credentials) == 0 await client.send_json( { "id": 5, "type": "config/auth_pr...
[ "async", "def", "test_create_auth", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "user", "=", "MockUser", "(", ")", ".", "add_to_hass", "(", "hass", ")", "assert", "len", "("...
[ 114, 0 ]
[ 140, 43 ]
python
en
['en', 'en', 'en']
True
test_create_auth_duplicate_username
(hass, hass_ws_client, hass_storage)
Test we can't create auth with a duplicate username.
Test we can't create auth with a duplicate username.
async def test_create_auth_duplicate_username(hass, hass_ws_client, hass_storage): """Test we can't create auth with a duplicate username.""" client = await hass_ws_client(hass) user = MockUser().add_to_hass(hass) hass_storage[prov_ha.STORAGE_KEY] = { "version": 1, "data": {"users": [{"...
[ "async", "def", "test_create_auth_duplicate_username", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "user", "=", "MockUser", "(", ")", ".", "add_to_hass", "(", "hass", ")", "hass...
[ 143, 0 ]
[ 165, 55 ]
python
en
['en', 'en', 'en']
True
test_delete_removes_just_auth
(hass_ws_client, hass, hass_storage)
Test deleting an auth without being connected to a user.
Test deleting an auth without being connected to a user.
async def test_delete_removes_just_auth(hass_ws_client, hass, hass_storage): """Test deleting an auth without being connected to a user.""" client = await hass_ws_client(hass) hass_storage[prov_ha.STORAGE_KEY] = { "version": 1, "data": {"users": [{"username": "test-user"}]}, } awai...
[ "async", "def", "test_delete_removes_just_auth", "(", "hass_ws_client", ",", "hass", ",", "hass_storage", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "hass_storage", "[", "prov_ha", ".", "STORAGE_KEY", "]", "=", "{", "\"version\"", ":",...
[ 168, 0 ]
[ 187, 71 ]
python
en
['en', 'en', 'en']
True
test_delete_removes_credential
(hass, hass_ws_client, hass_storage)
Test deleting auth that is connected to a user.
Test deleting auth that is connected to a user.
async def test_delete_removes_credential(hass, hass_ws_client, hass_storage): """Test deleting auth that is connected to a user.""" client = await hass_ws_client(hass) user = MockUser().add_to_hass(hass) hass_storage[prov_ha.STORAGE_KEY] = { "version": 1, "data": {"users": [{"username":...
[ "async", "def", "test_delete_removes_credential", "(", "hass", ",", "hass_ws_client", ",", "hass_storage", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "user", "=", "MockUser", "(", ")", ".", "add_to_hass", "(", "hass", ")", "hass_stor...
[ 190, 0 ]
[ 216, 71 ]
python
en
['en', 'en', 'en']
True
test_delete_requires_admin
(hass, hass_ws_client, hass_read_only_access_token)
Test delete requires admin.
Test delete requires admin.
async def test_delete_requires_admin(hass, hass_ws_client, hass_read_only_access_token): """Test delete requires admin.""" client = await hass_ws_client(hass, hass_read_only_access_token) await client.send_json( { "id": 5, "type": "config/auth_provider/homeassistant/delete",...
[ "async", "def", "test_delete_requires_admin", "(", "hass", ",", "hass_ws_client", ",", "hass_read_only_access_token", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ",", "hass_read_only_access_token", ")", "await", "client", ".", "send_json", "(", ...
[ 219, 0 ]
[ 233, 52 ]
python
en
['wa', 'la', 'en']
False
test_delete_unknown_auth
(hass, hass_ws_client)
Test trying to delete an unknown auth username.
Test trying to delete an unknown auth username.
async def test_delete_unknown_auth(hass, hass_ws_client): """Test trying to delete an unknown auth username.""" client = await hass_ws_client(hass) await client.send_json( { "id": 5, "type": "config/auth_provider/homeassistant/delete", "username": "test-user", ...
[ "async", "def", "test_delete_unknown_auth", "(", "hass", ",", "hass_ws_client", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "5", ",", "\"type\"", ":", "\"config/auth_provid...
[ 236, 0 ]
[ 250, 54 ]
python
en
['en', 'en', 'en']
True
test_change_password
( hass, hass_ws_client, hass_admin_user, auth_provider, test_user_credential )
Test that change password succeeds with valid password.
Test that change password succeeds with valid password.
async def test_change_password( hass, hass_ws_client, hass_admin_user, auth_provider, test_user_credential ): """Test that change password succeeds with valid password.""" await hass.auth.async_link_user(hass_admin_user, test_user_credential) client = await hass_ws_client(hass) await client.send_js...
[ "async", "def", "test_change_password", "(", "hass", ",", "hass_ws_client", ",", "hass_admin_user", ",", "auth_provider", ",", "test_user_credential", ")", ":", "await", "hass", ".", "auth", ".", "async_link_user", "(", "hass_admin_user", ",", "test_user_credential", ...
[ 253, 0 ]
[ 271, 69 ]
python
en
['en', 'nl', 'en']
True
test_change_password_wrong_pw
( hass, hass_ws_client, hass_admin_user, auth_provider, test_user_credential )
Test that change password fails with invalid password.
Test that change password fails with invalid password.
async def test_change_password_wrong_pw( hass, hass_ws_client, hass_admin_user, auth_provider, test_user_credential ): """Test that change password fails with invalid password.""" await hass.auth.async_link_user(hass_admin_user, test_user_credential) client = await hass_ws_client(hass) await client...
[ "async", "def", "test_change_password_wrong_pw", "(", "hass", ",", "hass_ws_client", ",", "hass_admin_user", ",", "auth_provider", ",", "test_user_credential", ")", ":", "await", "hass", ".", "auth", ".", "async_link_user", "(", "hass_admin_user", ",", "test_user_cred...
[ 274, 0 ]
[ 294, 73 ]
python
en
['en', 'en', 'en']
True
test_change_password_no_creds
(hass, hass_ws_client)
Test that change password fails with no credentials.
Test that change password fails with no credentials.
async def test_change_password_no_creds(hass, hass_ws_client): """Test that change password fails with no credentials.""" client = await hass_ws_client(hass) await client.send_json( { "id": 6, "type": "config/auth_provider/homeassistant/change_password", "current...
[ "async", "def", "test_change_password_no_creds", "(", "hass", ",", "hass_ws_client", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"id\"", ":", "6", ",", "\"type\"", ":", "\"config/auth_p...
[ 297, 0 ]
[ 312, 61 ]
python
en
['en', 'en', 'en']
True
test_admin_change_password_not_owner
( hass, hass_ws_client, auth_provider, test_user_credential )
Test that change password fails when not owner.
Test that change password fails when not owner.
async def test_admin_change_password_not_owner( hass, hass_ws_client, auth_provider, test_user_credential ): """Test that change password fails when not owner.""" client = await hass_ws_client(hass) await client.send_json( { "id": 6, "type": "config/auth_provider/homeass...
[ "async", "def", "test_admin_change_password_not_owner", "(", "hass", ",", "hass_ws_client", ",", "auth_provider", ",", "test_user_credential", ")", ":", "client", "=", "await", "hass_ws_client", "(", "hass", ")", "await", "client", ".", "send_json", "(", "{", "\"i...
[ 315, 0 ]
[ 335, 70 ]
python
en
['en', 'en', 'en']
True