本文整理匯總了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)
示例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)
示例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()
示例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()
示例5: values
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> tp.ValuesView[Y]:
return self.bytesdict.values()
示例6: values
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> ValuesView:
return self._data.values()
示例7: get_tls_contexts
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def get_tls_contexts(self) -> ValuesView[IRTLSContext]:
return self.tls_contexts.values()
示例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()
示例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
示例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
示例11: values
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> ValuesView[Number]:
return self.as_dict().values()
示例12: values
# 需要導入模塊: import typing [as 別名]
# 或者: from typing import ValuesView [as 別名]
def values(self) -> ValuesView[VT]:
return super().values()
示例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()