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


Python frozendict.frozendict方法代碼示例

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


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

示例1: _default

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def _default(obj):
    if type(obj) is frozendict:
        # fishing the protected dict out of the object is a bit nasty,
        # but we don't really want the overhead of copying the dict.
        return obj._dict
    raise TypeError('Object of type %s is not JSON serializable' %
                    obj.__class__.__name__)


# ideally we'd set ensure_ascii=False, but the ensure_ascii codepath is so
# much quicker (assuming c speedups are enabled) that it's actually much
# quicker to let it do that and then substitute back (it's about 2.5x faster).
#
# (in any case, simplejson's ensure_ascii doesn't get U+2028 and U+2029 right,
# as per https://github.com/simplejson/simplejson/issues/206).
# 
開發者ID:matrix-org,項目名稱:python-canonicaljson,代碼行數:18,代碼來源:canonicaljson.py

示例2: get_args

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def get_args(pipeline_args):
        args = tools.misc.HashableNamespace()
        args.genomes = list(pipeline_args.target_genomes) + [pipeline_args.ref_genome]
        args.out_dir = os.path.join(pipeline_args.out_dir, 'assemblyHub')
        args.hub_txt = os.path.join(args.out_dir, 'hub.txt')
        args.genomes_txt = os.path.join(args.out_dir, 'genomes.txt')
        args.groups_txt = os.path.join(args.out_dir, 'groups.txt')
        genome_files = frozendict({genome: GenomeFiles.get_args(pipeline_args, genome) for genome in args.genomes})
        sizes = {}
        twobits = {}
        trackdbs = {}
        for genome, genome_file in genome_files.items():
            sizes[genome] = (genome_file.sizes, os.path.join(args.out_dir, genome, 'chrom.sizes'))
            twobits[genome] = (genome_file.two_bit, os.path.join(args.out_dir, genome, '{}.2bit'.format(genome)))
            trackdbs[genome] = os.path.join(args.out_dir, genome, 'trackDb.txt')
        args.sizes = frozendict(sizes)
        args.twobits = frozendict(twobits)
        args.trackdbs = frozendict(trackdbs)
        args.hal = os.path.join(args.out_dir, os.path.basename(pipeline_args.hal))
        return args 
開發者ID:ComparativeGenomicsToolkit,項目名稱:Comparative-Annotation-Toolkit,代碼行數:22,代碼來源:__init__.py

示例3: definitions

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def definitions(self) -> Dict[str, GraphOutput]:
        """
            Property returns definitions of the output ports by extracting them on the fly from the bound outputs.

            ..info:
                This property actually returns a FrozenDict containing port definitions to indicate that
                port definitions SHOULD not be used during the actual binding.
            

            Returns:
                Dictionary of neural types associated with bound outputs.
        """
        # Get the right output dictionary.
        d = self._manual_outputs if len(self._manual_outputs) > 0 else self._default_outputs

        # Extract port definitions (Neural Types) and return an immutable dictionary,
        # so the user won't be able to modify its content by an accident!
        return frozendict({k: v.ntype for k, v in d.items()}) 
開發者ID:NVIDIA,項目名稱:NeMo,代碼行數:20,代碼來源:graph_outputs.py

示例4: tensors

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def tensors(self) -> Dict[str, "NmTensor"]:
        """
            Property returns output tensors by extracting them on the fly from the bound outputs.

            Returns:
                Dictionary of tensors in the format (output-name: tensor).
        """
        # Get the right output dictionary.
        d = self._manual_outputs if len(self._manual_outputs) > 0 else self._default_outputs

        output_tensors = {}
        # Get tensors by acessing the producer-ports.
        # At that point all keys (k) are unigue - we made sure of that during binding/__setitem__.
        for k, v in d.items():
            producer_step = v.producer_step_module_port.step_number
            producer_port_name = v.producer_step_module_port.port_name
            # Find the right output tensor.
            tensor = self._tensors_ref[producer_step][producer_port_name]
            # Add it to the dictionary.
            output_tensors[k] = tensor
        # Return the result as an immutable dictionary,
        # so the user won't be able to modify its content by an accident!
        return frozendict(output_tensors) 
開發者ID:NVIDIA,項目名稱:NeMo,代碼行數:25,代碼來源:graph_outputs.py

示例5: _get_options

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def _get_options(self, safe=False):
        options = itertools.chain(
            (
                (
                    safe and option.safe_name or option.name or attr,
                    getattr(self, attr),
                )
                for attr, option in
                (self._safe_options if safe else self._options).items()
            ),
            (self._other_safe_options if safe else self._other_options).items(),
        )
        evaluated_options = (
            (option, value(self) if callable(value) else value)
            for option, value in options
        )
        return frozendict(
            (option, value)
            for option, value in evaluated_options
            if value is not None
        ) 
開發者ID:renskiy,項目名稱:fabricio,代碼行數:23,代碼來源:base.py

示例6: update_options

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def update_options(self):
        options = itertools.chain(
            (
                (option, value)
                for option, value in self._update_options.items()
            ),
            self._other_options.items(),
        )
        evaluated_options = (
            (option, value(self) if callable(value) else value)
            for option, value in options
        )
        return frozendict(
            (
                (option, value)
                for option, value in evaluated_options
                if value is not None
            ),
            args=self.cmd,
        ) 
開發者ID:renskiy,項目名稱:fabricio,代碼行數:22,代碼來源:service.py

示例7: test_frozen_dict

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def test_frozen_dict(self):
        self.assertEqual(
            encode_canonical_json(frozendict({"a": 1})),
            b'{"a":1}',
        )
        self.assertEqual(
            encode_pretty_printed_json(frozendict({"a": 1})),
            b'{\n    "a": 1\n}') 
開發者ID:matrix-org,項目名稱:python-canonicaljson,代碼行數:10,代碼來源:test_canonicaljson.py

示例8: get_databases

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def get_databases(pipeline_args):
        """wrapper for get_database() that provides all of the databases"""
        dbs = {genome: PipelineTask.get_database(pipeline_args, genome) for genome in pipeline_args.hal_genomes}
        return frozendict(dbs) 
開發者ID:ComparativeGenomicsToolkit,項目名稱:Comparative-Annotation-Toolkit,代碼行數:6,代碼來源:__init__.py

示例9: convert

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def convert(genes):
    # Genes supplied as dictionary.
    if isinstance(genes, Mapping):
        return frozendict(genes)
    # Genes supplied as iterable of (gene, weight) tuples.
    elif isinstance(genes, Iterable) and all(isinstance(n, tuple) for n in genes):
        return frozendict(genes)
    # Genes supplied as iterable of genes.
    elif isinstance(genes, Iterable) and all(isinstance(n, str) for n in genes):
        return frozendict(zip(genes, repeat(1.0))) 
開發者ID:aertslab,項目名稱:pySCENIC,代碼行數:12,代碼來源:genesig.py

示例10: union

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def union(self, other: Type['GeneSignature']) -> Type['GeneSignature']:
        """
        Creates a new :class:`GeneSignature` instance which is the union of this signature and the other supplied
        signature.

        The weight associated with the genes in the intersection is the maximum of the weights in the composing signatures.

        :param other: The other :class:`GeneSignature`.
        :return: the new :class:`GeneSignature` instance.
        """
        return self.copy(name="({} | {})".format(self.name, other.name) if self.name != other.name else self.name,
                             gene2weight=frozendict(merge_with(max, self.gene2weight, other.gene2weight))) 
開發者ID:aertslab,項目名稱:pySCENIC,代碼行數:14,代碼來源:genesig.py

示例11: difference

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def difference(self, other: Type['GeneSignature']) -> Type['GeneSignature']:
        """
        Creates a new :class:`GeneSignature` instance which is the difference of this signature and the supplied other
        signature.

        The weight associated with the genes in the difference are taken from this gene signature.

        :param other: The other :class:`GeneSignature`.
        :return: the new :class:`GeneSignature` instance.
        """
        return self.copy(name="({} - {})".format(self.name, other.name) if self.name != other.name else self.name,
                         gene2weight=frozendict(dissoc(dict(self.gene2weight), *other.genes))) 
開發者ID:aertslab,項目名稱:pySCENIC,代碼行數:14,代碼來源:genesig.py

示例12: intersection

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def intersection(self, other: Type['GeneSignature']) -> Type['GeneSignature']:
        """
        Creates a new :class:`GeneSignature` instance which is the intersection of this signature and the supplied other
        signature.

        The weight associated with the genes in the intersection is the maximum of the weights in the composing signatures.

        :param other: The other :class:`GeneSignature`.
        :return: the new :class:`GeneSignature` instance.
        """
        genes = set(self.gene2weight.keys()).intersection(set(other.gene2weight.keys()))
        return self.copy(name="({} & {})".format(self.name, other.name) if self.name != other.name else self.name,
                         gene2weight=frozendict(keyfilter(lambda k: k in genes,
                                                          merge_with(max, self.gene2weight, other.gene2weight)))) 
開發者ID:aertslab,項目名稱:pySCENIC,代碼行數:16,代碼來源:genesig.py

示例13: test_frozendict_init_write_once

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def test_frozendict_init_write_once():
    odict = OrderedDict()
    odict['test'] = 'best value ever'

    obj.popsicle = odict

    assert isinstance(obj.popsicle, frozendict)

    assert obj.popsicle is not None
    assert 'test' in obj.popsicle
    assert obj.popsicle['test'] == 'best value ever' 
開發者ID:cyanogen,項目名稱:uchroma,代碼行數:13,代碼來源:test_traits.py

示例14: validate

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def validate(self, obj, value):
        return frozendict(super().validate(obj, value)) 
開發者ID:cyanogen,項目名稱:uchroma,代碼行數:4,代碼來源:traits.py

示例15: __init__

# 需要導入模塊: import frozendict [as 別名]
# 或者: from frozendict import frozendict [as 別名]
def __init__(self, driver):
        self._driver = driver
        self._available_fx = frozendict(self._load_fx()) 
開發者ID:cyanogen,項目名稱:uchroma,代碼行數:5,代碼來源:fx.py


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