ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() #10

Closed
exhuma opened this Issue Mar 8, 2013 · 0 comments

Comments

Projects
None yet
1 participant
Owner

exhuma commented Mar 8, 2013

From an interactive shell:

>>> from numpy import random as rnd
>>> data=rnd.rand(1000,2)
>>> dist = [(rnd.rand(),rnd.rand()) for i in xrange(1000)]
>>> from cluster import KMeansClustering
>>> cl=KMeansClustering(data,lambda p0,p1:(p0[0] - p1[0])**2 + (p0[1] - p1[1])**2)
>>> cl.getclusters(10)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cluster.py", line 752, in getclusters
    res = self.assign_item(item, cluster)
  File "cluster.py", line 771, in assign_item
    if closest_cluster != origin:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

exhuma was assigned Mar 11, 2013

@exhuma exhuma added a commit that referenced this issue Mar 11, 2013

@exhuma exhuma Fix for issue #10
KMeansClustering now accepts an optional equality function. This is useful
when using numpy arrays as inputs.
9b8358d

exhuma closed this Mar 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment