當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。