Python collections.ValuesView() Examples
The following are 19
code examples of collections.ValuesView().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
collections
, or try the search function
.
Example #1
Source File: nanguardmode.py From D-VAE with MIT License | 6 votes |
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
Example #2
Source File: nanguardmode.py From treeano with Apache License 2.0 | 6 votes |
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
Example #3
Source File: __init__.py From TextDetector with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: nanguardmode.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #5
Source File: nanguardmode.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #6
Source File: nanguardmode.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #7
Source File: nanguardmode.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #8
Source File: nanguardmode.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #9
Source File: nanguardmode.py From attention-lvcsr with MIT License | 6 votes |
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
Example #10
Source File: test_dictviews.py From ironpython2 with Apache License 2.0 | 6 votes |
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)
Example #11
Source File: ordereddict.py From pyRevit with GNU General Public License v3.0 | 5 votes |
def viewvalues(self): "Return object with view of mapping values." return ValuesView(self)
Example #12
Source File: config.py From gin-config with Apache License 2.0 | 5 votes |
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
Example #13
Source File: 6_16_dictsorted.py From Python-Journey-from-Novice-to-Expert with MIT License | 5 votes |
def values(self): return ValuesView(self)
Example #14
Source File: dbm.py From TextDetector with GNU General Public License v3.0 | 5 votes |
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
Example #15
Source File: 6_16_dictsorted.py From Python_Master-the-Art-of-Design-Patterns with MIT License | 5 votes |
def values(self): return ValuesView(self)
Example #16
Source File: request_environment.py From python-compat-runtime with Apache License 2.0 | 5 votes |
def viewvalues(self): return collections.ValuesView(self)
Example #17
Source File: test_rabbitmq_connections.py From async-worker with MIT License | 5 votes |
def test_values(self): self.maxDiff = None conn = AMQPConnection( hostname="localhost", username="guest", password="pwd" ) self.assertEqual(str(ValuesView(conn)), str(conn.values()))
Example #18
Source File: connections.py From async-worker with MIT License | 5 votes |
def values(self): return ValuesView(self)
Example #19
Source File: _mutablemapping.py From compas with MIT License | 5 votes |
def values(self): """D.values() => an object providing a view on D's values""" return stdlib_collections.ValuesView(self)