Python typing.ValuesView() Examples

The following are 14 code examples of typing.ValuesView(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module typing , or try the search function .
Example #1
Source File: structures.py    From rasa_core with Apache License 2.0 6 votes vote down vote up
def _find_unused_checkpoints(
        story_steps: ValuesView[StoryStep],
        story_end_checkpoints: Dict[Text, Text]
    ) -> Set[Text]:
        """Finds all unused checkpoints."""

        collected_start = {STORY_END, STORY_START}
        collected_end = {STORY_END, STORY_START}

        for step in story_steps:
            for start in step.start_checkpoints:
                collected_start.add(start.name)
            for end in step.end_checkpoints:
                start_name = story_end_checkpoints.get(end.name, end.name)
                collected_end.add(start_name)

        return collected_end.symmetric_difference(collected_start) 
Example #2
Source File: structures.py    From rasa-for-botfront with Apache License 2.0 6 votes vote down vote up
def _find_unused_checkpoints(
        story_steps: ValuesView[StoryStep], story_end_checkpoints: Dict[Text, Text]
    ) -> Set[Text]:
        """Finds all unused checkpoints."""

        collected_start = {STORY_END, STORY_START}
        collected_end = {STORY_END, STORY_START}

        for step in story_steps:
            for start in step.start_checkpoints:
                collected_start.add(start.name)
            for end in step.end_checkpoints:
                start_name = story_end_checkpoints.get(end.name, end.name)
                collected_end.add(start_name)

        return collected_end.symmetric_difference(collected_start) 
Example #3
Source File: filters.py    From mutatest with MIT License 5 votes vote down vote up
def valid_codes(self) -> ValuesView[str]:
        """All valid 2 letter codes.

        Returns:
            View of the values of ``valid_categories``.
        """
        return self._valid_categories.values() 
Example #4
Source File: event.py    From brownie with MIT License 5 votes vote down vote up
def values(self) -> ValuesView:
        """EventDict.values() -> a list object providing a view on EventDict's values"""
        return self._dict.values() 
Example #5
Source File: utils.py    From nevergrad with MIT License 5 votes vote down vote up
def values(self) -> tp.ValuesView[Y]:
        return self.bytesdict.values() 
Example #6
Source File: TomlFile.py    From ProjectAlice with GNU General Public License v3.0 5 votes vote down vote up
def values(self) -> ValuesView:
		return self._data.values() 
Example #7
Source File: TomlFile.py    From ProjectAlice with GNU General Public License v3.0 5 votes vote down vote up
def values(self) -> ValuesView:
		return self.data.values() 
Example #8
Source File: ir.py    From ambassador with Apache License 2.0 5 votes vote down vote up
def get_tls_contexts(self) -> ValuesView[IRTLSContext]:
        return self.tls_contexts.values() 
Example #9
Source File: base.py    From Neuraxle with Apache License 2.0 5 votes vote down vote up
def values(self) -> ValuesView:
        """
        Get step values.

        :return: all of the steps
        """
        return self.steps.values() 
Example #10
Source File: hashing_tfidf_vectorizer.py    From DeepPavlov with Apache License 2.0 5 votes vote down vote up
def get_counts(self, docs: List[str], doc_ids: List[Any]) \
            -> Generator[Tuple[KeysView, ValuesView, List[int]], Any, None]:
        """Get term counts for a list of documents.

        Args:
            docs: a list of input documents
            doc_ids: a list of document ids corresponding to input documents

        Yields:
            a tuple of term hashes, count values and column ids

        Returns:
            None

        """
        logger.info("Tokenizing batch...")
        batch_ngrams = list(self.tokenizer(docs))
        logger.info("Counting hash...")
        doc_id = iter(doc_ids)
        for ngrams in batch_ngrams:
            counts = Counter([hash_(gram, self.hash_size) for gram in ngrams])
            hashes = counts.keys()
            values = counts.values()
            _id = self.doc_index[next(doc_id)]
            if values:
                col_id = [_id] * len(values)
            else:
                col_id = []
            yield hashes, values, col_id 
Example #11
Source File: _mean_decrease_impurity.py    From optuna with MIT License 5 votes vote down vote up
def _encode_categorical(
    params_data: numpy.ndarray, distributions: ValuesView[BaseDistribution],
) -> Tuple[numpy.ndarray, numpy.ndarray]:
    # Transform the `params_data` matrix by expanding categorical integer-valued columns to one-hot
    # encoding matrices. Note that the resulting matrix can be sparse and potentially very big.

    numerical_cols = []
    categorical_cols = []
    categories = []

    for col, distribution in enumerate(distributions):
        if isinstance(distribution, CategoricalDistribution):
            categorical_cols.append(col)
            categories.append(list(range(len(distribution.choices))))
        else:
            numerical_cols.append(col)
    assert col == params_data.shape[1] - 1

    col_transformer = ColumnTransformer(
        [("_categorical", OneHotEncoder(categories=categories, sparse=False), categorical_cols)],
        remainder="passthrough",
    )
    # All categorical one-hot columns are placed before the numerical columns in
    # `ColumnTransformer.fit_transform`.
    params_data = col_transformer.fit_transform(params_data)

    # `cols_to_raw_cols["column index in transformed matrix"]
    #     == "column index in original matrix"`
    cols_to_raw_cols = numpy.empty((params_data.shape[1],), dtype=numpy.int32)

    i = 0
    for categorical_col, cats in zip(categorical_cols, categories):
        for _ in range(len(cats)):
            cols_to_raw_cols[i] = categorical_col
            i += 1
    for numerical_col in numerical_cols:
        cols_to_raw_cols[i] = numerical_col
        i += 1
    assert i == cols_to_raw_cols.size

    return params_data, cols_to_raw_cols 
Example #12
Source File: parameter_scope.py    From qupulse with MIT License 5 votes vote down vote up
def values(self) -> ValuesView[Number]:
        return self.as_dict().values() 
Example #13
Source File: common.py    From VxWireguard-Generator with MIT License 5 votes vote down vote up
def values(self) -> ValuesView[VT]:
        return super().values() 
Example #14
Source File: sectioning.py    From py-pdf-parser with MIT License 5 votes vote down vote up
def sections(self) -> ValuesView[Section]:
        """
        Returns the list of all created Sections.
        """
        return self.sections_dict.values()