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

Function sequence

pattern/vector/__init__.py:1599–1608  ·  view source on GitHub ↗

Yields an infinite sequence, for example: sequence() => 0, 1, 2, 3, ... sequence(1.0, lambda i: i/2) => 1, 0.5, 0.25, 0.125, ...

(i=0, f=lambda i: i+1)

Source from the content-addressed store, hash-verified

1597 return "Cluster(%s)" % list.__repr__(self)[1:-1]
1598
1599def sequence(i=0, f=lambda i: i+1):
1600 """ Yields an infinite sequence, for example:
1601 sequence() => 0, 1, 2, 3, ...
1602 sequence(1.0, lambda i: i/2) => 1, 0.5, 0.25, 0.125, ...
1603 """
1604 # Used to generate unique vector id's in hierarchical().
1605 # We cannot use Vector.id, since the given vectors might be plain dicts.
1606 # We cannot use id(vector), since id() is only unique for the lifespan of the object.
1607 while True:
1608 yield i; i=f(i)
1609
1610def hierarchical(vectors, k=1, iterations=1000, distance=COSINE, **kwargs):
1611 """ Returns a Cluster containing k items (vectors or clusters with nested items).

Callers 1

hierarchicalFunction · 0.85

Calls 1

fFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…