MCPcopy Index your code
hub / github.com/clips/pattern / update

Method update

pattern/metrics.py:28–39  ·  view source on GitHub ↗

Updates counter with the tallies from the given iterable, dictionary or Counter.

(self, iterable=None, **kwargs)

Source from the content-addressed store, hash-verified

26 return 0
27
28 def update(self, iterable=None, **kwargs):
29 """ Updates counter with the tallies from the given iterable, dictionary or Counter.
30 """
31 if kwargs:
32 self.update(kwargs)
33 if hasattr(iterable, "items"):
34 for k, v in iterable.items():
35 self[k] = self.get(k, 0) + v
36 elif hasattr(iterable, "__getitem__") \
37 or hasattr(iterable, "__iter__"):
38 for k in iterable:
39 self[k] = self.get(k, 0) + 1
40
41 def most_common(self, n=None):
42 """ Returns a list of the n most common (element, count)-tuples.

Callers 11

__init__Method · 0.95
filterFunction · 0.45
adjustFunction · 0.45
compositeFunction · 0.45
polarFunction · 0.45
test_updateMethod · 0.45
test_layoutMethod · 0.45
test_repulsionMethod · 0.45
test_attractionMethod · 0.45

Calls 2

itemsMethod · 0.45
getMethod · 0.45

Tested by 5

test_updateMethod · 0.36
test_layoutMethod · 0.36
test_repulsionMethod · 0.36
test_attractionMethod · 0.36