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


Python defaultdict.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from collections import defaultdict [as 别名]
# 或者: from collections.defaultdict import __init__ [as 别名]
def __init__(self, function, *lists, **config):
        """
        :param function: The function that should be applied to
            elements of ``lists``.  It should take as many arguments
            as there are ``lists``.
        :param lists: The underlying lists.
        :param cache_size: Determines the size of the cache used
            by this lazy map.  (default=5)
        """
        if not lists:
            raise TypeError('LazyMap requires at least two args')

        self._lists = lists
        self._func = function
        self._cache_size = config.get('cache_size', 5)
        self._cache = ({} if self._cache_size > 0 else None)

        # If you just take bool() of sum() here _all_lazy will be true just
        # in case n >= 1 list is an AbstractLazySequence.  Presumably this
        # isn't what's intended.
        self._all_lazy = sum(isinstance(lst, AbstractLazySequence)
                             for lst in lists) == len(lists) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:24,代码来源:util.py

示例2: __init__

# 需要导入模块: from collections import defaultdict [as 别名]
# 或者: from collections.defaultdict import __init__ [as 别名]
def __init__(self, samples=None):
        """
        Construct a new frequency distribution.  If ``samples`` is
        given, then the frequency distribution will be initialized
        with the count of each object in ``samples``; otherwise, it
        will be initialized to be empty.

        In particular, ``FreqDist()`` returns an empty frequency
        distribution; and ``FreqDist(samples)`` first creates an empty
        frequency distribution, and then calls ``update`` with the
        list ``samples``.

        :param samples: The samples to initialize the frequency
            distribution with.
        :type samples: Sequence
        """
        Counter.__init__(self, samples) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:19,代码来源:probability.py

示例3: __init__

# 需要导入模块: from collections import defaultdict [as 别名]
# 或者: from collections.defaultdict import __init__ [as 别名]
def __init__(self, parent, trace, node_label, firsthit, leaf, depth, seqID):
        """
        initialize a node in the graph
        here a node keeps record of trace i.e. from where the node is reached (the edge label)
        so nodes with same other attributes may have different trace
        """
        self.parent = parent
        self.trace = trace
        self.node_label = node_label
        self.firsthit = firsthit
        self.leaf = leaf
        self.depth = depth
        self.children = []
        self.seqID = seqID
        #Node.node_id += 1
        #self.node_id = node_id 
开发者ID:c-amr,项目名称:camr,代码行数:18,代码来源:AMRGraph.py

示例4: __init__

# 需要导入模块: from collections import defaultdict [as 别名]
# 或者: from collections.defaultdict import __init__ [as 别名]
def __init__(
        self, name, definition, container_definition=None, tags=None,
    ):
        from .solid import ISolidDefinition, CompositeSolidDefinition

        self.name = check.str_param(name, 'name')
        self.definition = check.inst_param(definition, 'definition', ISolidDefinition)
        self.container_definition = check.opt_inst_param(
            container_definition, 'container_definition', CompositeSolidDefinition
        )
        self._additional_tags = validate_tags(tags)

        input_handles = {}
        for name, input_def in self.definition.input_dict.items():
            input_handles[name] = SolidInputHandle(self, input_def)

        self._input_handles = input_handles

        output_handles = {}
        for name, output_def in self.definition.output_dict.items():
            output_handles[name] = SolidOutputHandle(self, output_def)

        self._output_handles = output_handles 
开发者ID:dagster-io,项目名称:dagster,代码行数:25,代码来源:dependency.py

示例5: __init__

# 需要导入模块: from collections import defaultdict [as 别名]
# 或者: from collections.defaultdict import __init__ [as 别名]
def __init__(self, function, *lists, **config):
        """
        :param function: The function that should be applied to
            elements of ``lists``.  It should take as many arguments
            as there are ``lists``.
        :param lists: The underlying lists.
        :param cache_size: Determines the size of the cache used
            by this lazy map.  (default=5)
        """
        if not lists:
            raise TypeError('LazyMap requires at least two args')

        self._lists = lists
        self._func = function
        self._cache_size = config.get('cache_size', 5)
        if self._cache_size > 0:
            self._cache = {}
        else:
            self._cache = None

        # If you just take bool() of sum() here _all_lazy will be true just
        # in case n >= 1 list is an AbstractLazySequence.  Presumably this
        # isn't what's intended.
        self._all_lazy = sum(isinstance(lst, AbstractLazySequence)
                             for lst in lists) == len(lists) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:27,代码来源:util.py

示例6: __init__

# 需要导入模块: from collections import defaultdict [as 别名]
# 或者: from collections.defaultdict import __init__ [as 别名]
def __init__(self, samples=None):
        """
        Construct a new frequency distribution.  If ``samples`` is
        given, then the frequency distribution will be initialized
        with the count of each object in ``samples``; otherwise, it
        will be initialized to be empty.

        In particular, ``FreqDist()`` returns an empty frequency
        distribution; and ``FreqDist(samples)`` first creates an empty
        frequency distribution, and then calls ``update`` with the
        list ``samples``.

        :param samples: The samples to initialize the frequency
            distribution with.
        :type samples: Sequence
        """
        dict.__init__(self)
        self._N = 0
        self._reset_caches()
        if samples:
            self.update(samples) 
开发者ID:blackye,项目名称:luscan-devel,代码行数:23,代码来源:probability.py


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