當前位置: 首頁>>代碼示例>>Python>>正文


Python typing.ValuesView方法代碼示例

本文整理匯總了Python中typing.ValuesView方法的典型用法代碼示例。如果您正苦於以下問題:Python typing.ValuesView方法的具體用法?Python typing.ValuesView怎麽用?Python typing.ValuesView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在typing的用法示例。


在下文中一共展示了typing.ValuesView方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _find_unused_checkpoints

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
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) 
開發者ID:RasaHQ,項目名稱:rasa_core,代碼行數:19,代碼來源:structures.py

示例2: _find_unused_checkpoints

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
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) 
開發者ID:botfront,項目名稱:rasa-for-botfront,代碼行數:18,代碼來源:structures.py

示例3: valid_codes

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def valid_codes(self) -> ValuesView[str]:
        """All valid 2 letter codes.

        Returns:
            View of the values of ``valid_categories``.
        """
        return self._valid_categories.values() 
開發者ID:EvanKepner,項目名稱:mutatest,代碼行數:9,代碼來源:filters.py

示例4: values

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> ValuesView:
        """EventDict.values() -> a list object providing a view on EventDict's values"""
        return self._dict.values() 
開發者ID:eth-brownie,項目名稱:brownie,代碼行數:5,代碼來源:event.py

示例5: values

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> tp.ValuesView[Y]:
        return self.bytesdict.values() 
開發者ID:facebookresearch,項目名稱:nevergrad,代碼行數:4,代碼來源:utils.py

示例6: values

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> ValuesView:
		return self._data.values() 
開發者ID:project-alice-assistant,項目名稱:ProjectAlice,代碼行數:4,代碼來源:TomlFile.py

示例7: get_tls_contexts

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def get_tls_contexts(self) -> ValuesView[IRTLSContext]:
        return self.tls_contexts.values() 
開發者ID:datawire,項目名稱:ambassador,代碼行數:4,代碼來源:ir.py

示例8: values

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> ValuesView:
        """
        Get step values.

        :return: all of the steps
        """
        return self.steps.values() 
開發者ID:Neuraxio,項目名稱:Neuraxle,代碼行數:9,代碼來源:base.py

示例9: get_counts

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
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 
開發者ID:deepmipt,項目名稱:DeepPavlov,代碼行數:31,代碼來源:hashing_tfidf_vectorizer.py

示例10: _encode_categorical

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
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 
開發者ID:optuna,項目名稱:optuna,代碼行數:43,代碼來源:_mean_decrease_impurity.py

示例11: values

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> ValuesView[Number]:
        return self.as_dict().values() 
開發者ID:qutech,項目名稱:qupulse,代碼行數:4,代碼來源:parameter_scope.py

示例12: values

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> ValuesView[VT]:
        return super().values() 
開發者ID:m13253,項目名稱:VxWireguard-Generator,代碼行數:4,代碼來源:common.py

示例13: sections

# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def sections(self) -> ValuesView[Section]:
        """
        Returns the list of all created Sections.
        """
        return self.sections_dict.values() 
開發者ID:jstockwin,項目名稱:py-pdf-parser,代碼行數:7,代碼來源:sectioning.py


注:本文中的typing.ValuesView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。