Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

BUG: cluster: fix a bug in type checking in vq (#1596)

  • Loading branch information...
commit a35418a8ad54581b1a725f52beffe9ccae0fcf95 1 parent 24a3532
@pv pv authored
Showing with 8 additions and 2 deletions.
  1. +1 −1  scipy/cluster/src/vq_module.c
  2. +7 −1 scipy/cluster/tests/test_vq.py
View
2  scipy/cluster/src/vq_module.c
@@ -68,7 +68,7 @@ PyObject* compute_vq(PyObject* self, PyObject* args)
typenum1 = PyArray_TYPE(obs);
typenum2 = PyArray_TYPE(code);
- if (typenum1 != typenum1) {
+ if (typenum1 != typenum2) {
PyErr_Format(PyExc_ValueError,
"observation and code should have same type");
return NULL;
View
8 scipy/cluster/tests/test_vq.py
@@ -8,7 +8,7 @@
import numpy as np
from numpy.testing import assert_array_equal, assert_array_almost_equal, \
- TestCase, run_module_suite
+ TestCase, run_module_suite, assert_raises
from scipy.cluster.vq import kmeans, kmeans2, py_vq, py_vq2, vq, ClusterError
try:
@@ -83,6 +83,12 @@ def test_vq_1d(self):
else:
print "== not testing C imp of vq (rank 1) =="
+ def test__vq_sametype(self):
+ if TESTC:
+ a = np.array([1, 2])
+ b = a.astype(float)
+ assert_raises(ValueError, _vq.vq, a, b)
+
class TestKMean(TestCase):
def test_large_features(self):
# Generate a data set with large values, and run kmeans on it to
Please sign in to comment.
Something went wrong with that request. Please try again.