[Scipy-svn] r4149 - in trunk/scipy/cluster: . tests
scipy-svn at scipy.org
scipy-svn at scipy.org
Thu Apr 17 22:25:28 EDT 2008
Author: damian.eads
Date: 2008-04-17 21:25:25 -0500 (Thu, 17 Apr 2008)
New Revision: 4149
Modified:
trunk/scipy/cluster/hierarchy.py
trunk/scipy/cluster/tests/test_hierarchy.py
Log:
Added test to make sure pdist checks properly for observation matrices of unsupported type.
Modified: trunk/scipy/cluster/hierarchy.py
===================================================================
--- trunk/scipy/cluster/hierarchy.py 2008-04-18 02:13:12 UTC (rev 4148)
+++ trunk/scipy/cluster/hierarchy.py 2008-04-18 02:25:25 UTC (rev 4149)
@@ -1301,7 +1301,7 @@
if type(X) is not _array_type:
raise TypeError('The parameter passed must be an array.')
- if X.dtype == 'float32':
+ if X.dtype == 'float32' or X.dtype == 'float96':
raise TypeError('Floating point arrays must be 64-bit.')
# The C code doesn't do striding.
Modified: trunk/scipy/cluster/tests/test_hierarchy.py
===================================================================
--- trunk/scipy/cluster/tests/test_hierarchy.py 2008-04-18 02:13:12 UTC (rev 4148)
+++ trunk/scipy/cluster/tests/test_hierarchy.py 2008-04-18 02:25:25 UTC (rev 4149)
@@ -1,8 +1,8 @@
#! /usr/bin/env python
-
+#
# Author: Damian Eads
# Date: April 17, 2008
-
+#
# Copyright (C) 2008 Damian Eads
#
# Redistribution and use in source and binary forms, with or without
@@ -87,6 +87,49 @@
class TestPdist(TestCase):
+ def test_pdist_raises_type_error_float32(self):
+ "Testing whether passing a float32 observation array generates an exception."
+ X = numpy.zeros((10, 10), dtype='float32')
+ try:
+ pdist(X, 'euclidean')
+ except TypeError:
+ pass
+ except:
+ fail("float32 matrices should generate an error in pdist.")
+
+ def test_pdist_raises_type_error_float96(self):
+ "Testing whether passing a float96 observation array generates an exception."
+ X = numpy.zeros((10, 10), dtype='float96')
+ try:
+ pdist(X, 'euclidean')
+ except TypeError:
+ pass
+ except:
+ fail("float96 matrices should generate an error in pdist.")
+
+ def test_pdist_var_raises_type_error_float32(self):
+ "Testing whether passing a float32 variance matrix generates an exception."
+ X = numpy.zeros((10, 10))
+ V = numpy.zeros((10, 10), dtype='float32')
+ try:
+ pdist(X, 'seuclidean', V)
+ except TypeError:
+ pass
+ except:
+ fail("float32 matrices should generate an error in pdist.")
+
+ def test_pdist_var_raises_type_error_float96(self):
+ "Testing whether passing a float96 variance matrix generates an exception."
+ X = numpy.zeros((10, 10))
+ V = numpy.zeros((10, 10), dtype='float96')
+
+ try:
+ pdist(X, 'seuclidean', V)
+ except TypeError:
+ pass
+ except:
+ fail("float96 matrices should generate an error in pdist.")
+
################### pdist: euclidean
def test_pdist_euclidean_random(self):
"Tests pdist(X, 'euclidean') on random data."
More information about the Scipy-svn
mailing list