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


Python collections.ValuesView方法代码示例

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


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

示例1: test_abc_registry

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def test_abc_registry(self):
        d = dict(a=1)

        self.assertIsInstance(d.viewkeys(), collections.KeysView)
        self.assertIsInstance(d.viewkeys(), collections.MappingView)
        self.assertIsInstance(d.viewkeys(), collections.Set)
        self.assertIsInstance(d.viewkeys(), collections.Sized)
        self.assertIsInstance(d.viewkeys(), collections.Iterable)
        self.assertIsInstance(d.viewkeys(), collections.Container)

        self.assertIsInstance(d.viewvalues(), collections.ValuesView)
        self.assertIsInstance(d.viewvalues(), collections.MappingView)
        self.assertIsInstance(d.viewvalues(), collections.Sized)

        self.assertIsInstance(d.viewitems(), collections.ItemsView)
        self.assertIsInstance(d.viewitems(), collections.MappingView)
        self.assertIsInstance(d.viewitems(), collections.Set)
        self.assertIsInstance(d.viewitems(), collections.Sized)
        self.assertIsInstance(d.viewitems(), collections.Iterable)
        self.assertIsInstance(d.viewitems(), collections.Container) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_dictviews.py

示例2: flatten

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def flatten(l):
    """
    Turns a nested graph of lists/tuples/other objects into a list of objects.

    Parameters
    ----------
    l : list/tuple/other objects
        Might be nested.

    Returns
    -------
    object
        A flattened list of objects.

    """
    if isinstance(l, (list, tuple, collections.ValuesView)):
        rval = []
        for elem in l:
            if isinstance(elem, (list, tuple)):
                rval.extend(flatten(elem))
            else:
                rval.append(elem)
    else:
        return [l]
    return rval 
开发者ID:muhanzhang,项目名称:D-VAE,代码行数:27,代码来源:nanguardmode.py

示例3: flatten

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def flatten(l):
    """
    Turns a nested graph of lists/tuples/other objects into a list of objects.

    Parameters
    ----------
    l : List/tuple/other objects, might be nested.

    Returns
    -------
    A flattened list of objects
    """
    if isinstance(l, (list, tuple, collections.ValuesView)):
        rval = []
        for elem in l:
            if isinstance(elem, (list, tuple)):
                rval.extend(flatten(elem))
            else:
                rval.append(elem)
    else:
        return [l]
    return rval 
开发者ID:SBU-BMI,项目名称:u24_lymphocyte,代码行数:24,代码来源:nanguardmode.py

示例4: flatten

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def flatten(l):
    """
    Turns a nested graph of lists/tuples/other objects
    into a list of objects.

    Parameters
    ----------
    l : WRITEME

    Returns
    -------
    WRITEME
    """
    if isinstance(l, (list, tuple, collections.ValuesView)):
        rval = []
        for elem in l:
            if isinstance(elem, (list, tuple)):
                rval.extend(flatten(elem))
            else:
                rval.append(elem)
    else:
        return [l]
    return rval 
开发者ID:zchengquan,项目名称:TextDetector,代码行数:25,代码来源:__init__.py

示例5: values

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def values(self):
        return ValuesView(self) 
开发者ID:PacktPublishing,项目名称:Python-Journey-from-Novice-to-Expert,代码行数:4,代码来源:6_16_dictsorted.py

示例6: _iterate_flattened_values

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def _iterate_flattened_values(value):
  """Provides an iterator over all values in a nested structure."""
  if isinstance(value, six.string_types):
    yield value
    return

  if isinstance(value, collections.Mapping):
    value = collections.ValuesView(value)

  if isinstance(value, collections.Iterable):
    for nested_value in value:
      for nested_nested_value in _iterate_flattened_values(nested_value):
        yield nested_nested_value

  yield value 
开发者ID:google,项目名称:gin-config,代码行数:17,代码来源:config.py

示例7: viewvalues

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def viewvalues(self):
        "Return object with view of mapping values."
        return ValuesView(self) 
开发者ID:eirannejad,项目名称:pyRevit,代码行数:5,代码来源:ordereddict.py

示例8: _get_negative_phase

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def _get_negative_phase(self, model, X, Y=None):
        """
        .. todo::

            WRITEME
        """
        layer_to_chains = model.make_layer_to_state(self.num_chains)

        def recurse_check(l):
            if isinstance(l, (list, tuple, collections.ValuesView)):
                for elem in l:
                    recurse_check(elem)
            else:
                assert l.get_value().shape[0] == self.num_chains

        recurse_check(layer_to_chains.values())

        model.layer_to_chains = layer_to_chains

        # Note that we replace layer_to_chains with a dict mapping to the new
        # state of the chains
        updates, layer_to_chains = model.get_sampling_updates(
            layer_to_chains, self.theano_rng, num_steps=self.num_gibbs_steps,
            return_layer_to_updated=True)

        if self.toronto_neg:
            neg_phase_grads = self._get_toronto_neg(model, layer_to_chains)
        else:
            neg_phase_grads = self._get_standard_neg(model, layer_to_chains)

        return neg_phase_grads, updates 
开发者ID:zchengquan,项目名称:TextDetector,代码行数:33,代码来源:dbm.py

示例9: viewvalues

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def viewvalues(self):
    return collections.ValuesView(self) 
开发者ID:GoogleCloudPlatform,项目名称:python-compat-runtime,代码行数:4,代码来源:request_environment.py

示例10: test_values

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def test_values(self):
        self.maxDiff = None
        conn = AMQPConnection(
            hostname="localhost", username="guest", password="pwd"
        )
        self.assertEqual(str(ValuesView(conn)), str(conn.values())) 
开发者ID:b2wdigital,项目名称:async-worker,代码行数:8,代码来源:test_rabbitmq_connections.py

示例11: values

# 需要导入模块: import collections [as 别名]
# 或者: from collections import ValuesView [as 别名]
def values(self):
        """D.values() => an object providing a view on D's values"""
        return stdlib_collections.ValuesView(self) 
开发者ID:compas-dev,项目名称:compas,代码行数:5,代码来源:_mutablemapping.py


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