hierarchy.linkage raises an ugly exception for a compressed 2x2 distance matrix #3403

Closed
argriffing opened this Issue Feb 27, 2014 · 0 comments

Comments

Projects
None yet
3 participants
Contributor

argriffing commented Feb 27, 2014

>>> scipy.cluster.hierarchy.linkage([1], method='single', metric='cityblock')
Traceback (most recent call last):
/scipy/cluster/hierarchy.py", line 655, in linkage
    return Z
UnboundLocalError: local variable 'Z' referenced before assignment

A reason is that the conversion-to-double of a 1d array with 1 element is returning something other than a 1d numpy array.

>>> scipy.cluster.hierarchy._convert_to_double(np.asarray([1], order='c'))
1.0

Another reason is that the if/elif is assumed to cover all cases.

pv closed this in #3405 Jun 14, 2014

pv added this to the 0.15.0 milestone Jun 14, 2014

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