当前位置: 首页>>代码示例>>Python>>正文


Python typing.FrozenSet方法代码示例

本文整理汇总了Python中typing.FrozenSet方法的典型用法代码示例。如果您正苦于以下问题:Python typing.FrozenSet方法的具体用法?Python typing.FrozenSet怎么用?Python typing.FrozenSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在typing的用法示例。


在下文中一共展示了typing.FrozenSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def __init__(self, obj: QObject,
                 stylesheet: Optional[str], update: bool) -> None:
        super().__init__()
        self._obj = obj
        self._update = update

        # We only need to hang around if we are asked to update.
        if update:
            self.setParent(self._obj)
        if stylesheet is None:
            self._stylesheet = obj.STYLESHEET  # type: str
        else:
            self._stylesheet = stylesheet

        if update:
            self._options = jinja.template_config_variables(
                self._stylesheet)  # type: Optional[FrozenSet[str]]
        else:
            self._options = None 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:21,代码来源:stylesheet.py

示例2: server_status_required

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def server_status_required(allowed_status: FrozenSet[ManagerStatus]):

    def decorator(handler):

        @functools.wraps(handler)
        async def wrapped(request, *args, **kwargs):
            status = await request.app['config_server'].get_manager_status()
            if status not in allowed_status:
                if status == ManagerStatus.FROZEN:
                    raise ServerFrozen
                msg = f'Server is not in the required status: {allowed_status}'
                raise ServiceUnavailable(msg)
            return (await handler(request, *args, **kwargs))

        return wrapped

    return decorator 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:19,代码来源:manager.py

示例3: _make_dataset_feature_stats_proto_with_topk_for_single_feature

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def _make_dataset_feature_stats_proto_with_topk_for_single_feature(
    feature_path_to_value_count_list: Tuple[Tuple[types.SliceKey,
                                                  FeaturePathTuple],
                                            List[FeatureValueCount]],
    categorical_features: FrozenSet[types.FeaturePath], is_weighted_stats: bool,
    num_top_values: int, frequency_threshold: Union[int, float],
    num_rank_histogram_buckets: int
) -> Tuple[types.SliceKey, statistics_pb2.DatasetFeatureStatistics]:
  """Makes a DatasetFeatureStatistics proto with top-k stats for a feature."""
  (slice_key, feature_path_tuple), value_count_list = (
      feature_path_to_value_count_list)
  feature_path = types.FeaturePath(feature_path_tuple)
  result = statistics_pb2.DatasetFeatureStatistics()
  result.features.add().CopyFrom(
      make_feature_stats_proto_with_topk_stats(
          feature_path, value_count_list, feature_path in categorical_features,
          is_weighted_stats, num_top_values, frequency_threshold,
          num_rank_histogram_buckets))
  return slice_key, result 
开发者ID:tensorflow,项目名称:data-validation,代码行数:21,代码来源:top_k_uniques_stats_generator.py

示例4: get_casper_endpoints

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def get_casper_endpoints(clusters_info: Dict[str, Any]) -> FrozenSet[Tuple[str, int]]:
    """Filters out and returns casper endpoints from Envoy clusters."""
    casper_endpoints: Set[Tuple[str, int]] = set()
    for cluster_status in clusters_info["cluster_statuses"]:
        if "host_statuses" in cluster_status:
            if cluster_status["name"].startswith("spectre.") and cluster_status[
                "name"
            ].endswith(".egress_cluster"):
                for host_status in cluster_status["host_statuses"]:
                    casper_endpoints.add(
                        (
                            host_status["address"]["socket_address"]["address"],
                            host_status["address"]["socket_address"]["port_value"],
                        )
                    )
    return frozenset(casper_endpoints) 
开发者ID:Yelp,项目名称:paasta,代码行数:18,代码来源:envoy_tools.py

示例5: filter_dominated_match_sets

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def filter_dominated_match_sets(
        match_sets: List[PostingMatchSet]) -> List[PostingMatchSet]:
    """Computes a filtered list of PostingMatchSet objects with dominated match sets
    removed.

    A PostingMatchSet `a` dominates another PostingMatchSet `b` if `a` contains
    all of the matches in `b`.
    """
    match_sets.sort(key=lambda x: -len(x.matches))
    filtered_results = []
    filtered_posting_match_frozensets = [
    ]  # type: List[FrozenSet[Tuple[int,int]]]
    for match_set in match_sets:
        if any(
                all((id(a), id(b)) in existing for a, b in match_set.matches)
                for existing in filtered_posting_match_frozensets):
            continue
        filtered_posting_match_frozensets.append(
            _get_posting_match_frozenset(match_set.matches))
        filtered_results.append(match_set)
    return filtered_results


# [[neg_a, neg_b], [pos_a, pos_b]] 
开发者ID:jbms,项目名称:beancount-import,代码行数:26,代码来源:matching.py

示例6: _get_valid_posting_matches

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def _get_valid_posting_matches(
        transaction_constraint: IsTransactionMergeablePredicate,
        posting: Posting, negate: bool, posting_db: PostingDatabase,
        excluded_transaction_ids: FrozenSet[int]
) -> Iterable[Tuple[Transaction, MatchablePosting]]:
    """Returns the matching transaction, posting pairs.

    Transactions already present in `excluded_transaction_ids` are excluded, as
    are transactions that do not satisfy `transaction_constraint`.
    """
    matches = posting_db.get_posting_matches(
        transaction_constraint.transaction, posting, negate=negate)
    for matching_transaction, mp in matches:
        if id(matching_transaction) in excluded_transaction_ids:
            continue
        if not transaction_constraint(matching_transaction): continue
        yield matching_transaction, mp 
开发者ID:jbms,项目名称:beancount-import,代码行数:19,代码来源:matching.py

示例7: get_unknown_to_opposite_unknown_extensions

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def get_unknown_to_opposite_unknown_extensions(
        transaction_constraint: IsTransactionMergeablePredicate,
        posting_db: PostingDatabase,
        excluded_transaction_ids: FrozenSet[int],
        mp: MatchablePosting) -> Iterable[SingleStepMergedTransaction]:
    """Finds extensions that remove both `mp` and an unknown posting of opposite
    weight in the matching transaction.
    """
    for matching_transaction, other_mp in _get_valid_posting_matches(
            transaction_constraint,
            mp.posting,
            negate=True,
            posting_db=posting_db,
            excluded_transaction_ids=excluded_transaction_ids):
        if not is_removal_candidate(other_mp): continue
        yield SingleStepMergedTransaction(
            combine_transactions_using_match_set(
                (transaction_constraint.transaction, matching_transaction),
                match_set=PostingMatchSet(matches=[], removals=(mp, other_mp)),
                is_cleared=posting_db.is_cleared), matching_transaction) 
开发者ID:jbms,项目名称:beancount-import,代码行数:22,代码来源:matching.py

示例8: get_entries_with_link

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def get_entries_with_link(
            self,
            all_entries: Entries,
            valid_links: Union[Set[str], FrozenSet[str]],
            results: SourceResults,
    ) -> Dict[str, List[Transaction]]:
        link_prefix = self.link_prefix
        seen_entries = dict()  # type: Dict[str, Entries]
        for entry in all_entries:
            if not isinstance(entry, Transaction): continue
            for link in entry.links:
                if not link.startswith(link_prefix): continue
                txn_id = link[len(link_prefix):]
                seen_entries.setdefault(txn_id, []).append(entry)
        for txn_id, entries in seen_entries.items():
            expected_count = 1 if txn_id in valid_links else 0
            if len(entries) == expected_count: continue
            results.add_invalid_reference(
                InvalidSourceReference(
                    num_extras=len(entries) - expected_count,
                    transaction_posting_pairs=[(t, None) for t in entries]))
        return seen_entries 
开发者ID:jbms,项目名称:beancount-import,代码行数:24,代码来源:link_based_source.py

示例9: kinds

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def kinds(self) -> FrozenSet[KubernetesGVK]:
        kinds = [
            'AuthService',
            'ConsulResolver',
            'Host',
            'KubernetesEndpointResolver',
            'KubernetesServiceResolver',
            'LogService',
            'Mapping',
            'Module',
            'RateLimitService',
            'TCPMapping',
            'TLSContext',
            'TracingService',
        ]

        return frozenset([
            KubernetesGVK.for_ambassador(kind, version=version) for (kind, version) in itertools.product(kinds, ['v1', 'v2'])
        ]) 
开发者ID:datawire,项目名称:ambassador,代码行数:21,代码来源:ambassador.py

示例10: _filter_write

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def _filter_write(
    input_tsv_path: str, phones: FrozenSet[str], output_tsv_path: str
) -> None:
    """Creates TSV filtered by whitelist."""
    with open(input_tsv_path, "r") as source, open(
        output_tsv_path, "w"
    ) as sink:
        for line in source:
            line = line.rstrip()
            (word, pron, *_) = line.split("\t", 2)
            these_phones = frozenset(pron.split())
            bad_phones = these_phones - phones
            if bad_phones:
                for phone in bad_phones:
                    logging.warning("Bad phone:\t%s\t(%s)", phone, word)
            else:
                print(line, file=sink) 
开发者ID:kylebgorman,项目名称:wikipron,代码行数:19,代码来源:whitelist.py

示例11: search_by_attribute_set

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def search_by_attribute_set(
        url: str,
        profile: FrozenSet[str],
        limit: Optional[int] = 100,
        namespace_filter: Optional[str]=None) -> Dict:
    """
    Given a list of phenotypes, returns a ranked list of individuals
    individuals can be filtered by namespace, eg MONDO, MGI, HGNC
    :returns Dict with the structure: {
        'unresolved' : [...]
        'query_IRIs' : [...]
        'results': {...}
    }
    :raises JSONDecodeError: If the response body does not contain valid json.
    """
    owlsim_url = url + 'searchByAttributeSet'

    params = {
        'a': profile,
        'limit': limit,
        'target': namespace_filter
    }
    return requests.post(owlsim_url, data=params, timeout=TIMEOUT).json() 
开发者ID:biolink,项目名称:ontobio,代码行数:25,代码来源:owlsim2.py

示例12: compare_attribute_sets

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def compare_attribute_sets(
        url: str,
        profile_a: FrozenSet[str],
        profile_b: FrozenSet[str]) -> Dict:
    """
    Given two phenotype profiles, returns their similarity
    :returns Dict with the structure: {
        'unresolved' : [...]
        'query_IRIs' : [...]
        'target_IRIs': [...]
        'results': {...}
    }
    """
    owlsim_url = url + 'compareAttributeSets'

    params = {
        'a': profile_a,
        'b': profile_b,
    }

    return requests.post(owlsim_url, data=params, timeout=TIMEOUT).json() 
开发者ID:biolink,项目名称:ontobio,代码行数:23,代码来源:owlsim2.py

示例13: get_attribute_information_profile

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def get_attribute_information_profile(
        url: str,
        profile: Optional[FrozenSet[str]]=None,
        categories: Optional[FrozenSet[str]]=None) -> Dict:
    """
    Get the information content for a list of phenotypes
    and the annotation sufficiency simple and
    and categorical scores if categories are provied

    Ref: https://zenodo.org/record/834091#.W8ZnCxhlCV4
    Note that the simple score varies slightly from the pub in that
    it uses max_max_ic instead of mean_max_ic

    If no arguments are passed this function returns the
    system (loaded cohort) stats
    :raises JSONDecodeError: If the response body does not contain valid json.
    """
    owlsim_url = url + 'getAttributeInformationProfile'

    params = {
        'a': profile,
        'r': categories
    }
    return requests.post(owlsim_url, data=params, timeout=TIMEOUT).json() 
开发者ID:biolink,项目名称:ontobio,代码行数:26,代码来源:owlsim2.py

示例14: variables

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def variables(self) -> FrozenSet[str]:
        """The names of the variables the constraint depends upon.

        Used by matchers to decide when a constraint can be evaluated (which is when all
        the dependency variables have been assigned a value). If the set is empty, the constraint will
        only be evaluated once the whole match is complete.
        """
        return frozenset() 
开发者ID:HPAC,项目名称:matchpy,代码行数:10,代码来源:constraints.py

示例15: available_teams

# 需要导入模块: import typing [as 别名]
# 或者: from typing import FrozenSet [as 别名]
def available_teams(self) -> FrozenSet[str]:
        return frozenset([p.team for p in self._players]) 
开发者ID:DimaKudosh,项目名称:pydfs-lineup-optimizer,代码行数:4,代码来源:lineup_optimizer.py


注:本文中的typing.FrozenSet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。