[Scipy-svn] r4412 - trunk/scipy/cluster
scipy-svn at scipy.org
scipy-svn at scipy.org
Wed Jun 4 04:08:32 EDT 2008
Author: damian.eads
Date: 2008-06-04 03:08:30 -0500 (Wed, 04 Jun 2008)
New Revision: 4412
Modified:
trunk/scipy/cluster/hierarchy.py
Log:
Fixed issue with cosine.
Modified: trunk/scipy/cluster/hierarchy.py
===================================================================
--- trunk/scipy/cluster/hierarchy.py 2008-06-03 17:53:23 UTC (rev 4411)
+++ trunk/scipy/cluster/hierarchy.py 2008-06-04 08:08:30 UTC (rev 4412)
@@ -1463,18 +1463,18 @@
# Find out: Is there a dot subtraction operator so I can
# subtract matrices in a similar way to multiplying them?
# Need to get rid of as much unnecessary C code as possible.
- elif mstr in set(['cosine_old', 'cos_old']):
+ elif mstr in set(['cosine', 'cos']):
norms = np.sqrt(np.sum(X * X, axis=1))
_hierarchy_wrap.pdist_cosine_wrap(_convert_to_double(X), dm, norms)
- elif mstr in set(['cosine', 'cos']):
+ elif mstr in set(['old_cosine', 'old_cos']):
norms = np.sqrt(np.sum(X * X, axis=1))
nV = norms.reshape(m, 1)
# The numerator u * v
nm = np.dot(X, X.T)
# The denom. ||u||*||v||
de = np.dot(nV, nV.T);
- dm = 1 - (nm / de)
- dm[xrange(0,m),xrange(0,m)] = 0
+ dm = 1.0 - (nm / de)
+ dm[xrange(0,m),xrange(0,m)] = 0.0
dm = squareform(dm)
elif mstr in set(['correlation', 'co']):
X2 = X - X.mean(1)[:,np.newaxis]
More information about the Scipy-svn
mailing list