summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorjaimefrio <jaime.frio@gmail.com>2014-10-20 22:43:35 -0700
committerjaimefrio <jaime.frio@gmail.com>2014-10-20 23:07:13 -0700
commit528bac1380c782772b9de207bb8466b03117b96d (patch)
treee5a492af281410b74f622dd202fddabaf168ded2 /numpy/core
parent140c50537087dccc764cd7540b46b039cb934530 (diff)
downloadnumpy-528bac1380c782772b9de207bb8466b03117b96d.tar.gz
DOC: Stricter checks for gufunc signatures
Documented the the new behavior in c-api.generalized-ufuncs.rst. Added PyUFunc_FromFuncAndDataAndSignature to c-api.ufunc.rst.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/umath/ufunc_object.c2
-rw-r--r--numpy/core/src/umath/umath_tests.c.src3
-rw-r--r--numpy/core/tests/test_ufunc.py9
3 files changed, 7 insertions, 7 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c
index 9ac1da7eb..91d916c0f 100644
--- a/numpy/core/src/umath/ufunc_object.c
+++ b/numpy/core/src/umath/ufunc_object.c
@@ -1943,7 +1943,7 @@ PyUFunc_GeneralizedFunction(PyUFuncObject *ufunc,
ufunc_name, i < nin ? "Input" : "Output",
i < nin ? i : i - nin, PyArray_NDIM(op[i]),
ufunc->core_signature, num_dims);
- retval = - 1;
+ retval = -1;
goto fail;
}
diff --git a/numpy/core/src/umath/umath_tests.c.src b/numpy/core/src/umath/umath_tests.c.src
index e5bf5aa07..33d9846bd 100644
--- a/numpy/core/src/umath/umath_tests.c.src
+++ b/numpy/core/src/umath/umath_tests.c.src
@@ -41,7 +41,6 @@
#define BEGIN_OUTER_LOOP_2 \
for (N_ = 0; N_ < dN; N_++, args[0] += s0, args[1] += s1) {
-
#define BEGIN_OUTER_LOOP_3 \
for (N_ = 0; N_ < dN; N_++, args[0] += s0, args[1] += s1, args[2] += s2) {
@@ -193,7 +192,7 @@ char *euclidean_pdist_signature = "(n,d)->(p)";
/*
* This implements the function
* out[j*(2*n-3-j)+k-1] = sum_d { (in1[j, d] - in1[k, d])^2 }
- * with k > j > n, i.e. computes all unique pairwise euclidean distances.
+ * with 0 < k < j < n, i.e. computes all unique pairwise euclidean distances.
*/
static void
diff --git a/numpy/core/tests/test_ufunc.py b/numpy/core/tests/test_ufunc.py
index 135059dd7..a285d5334 100644
--- a/numpy/core/tests/test_ufunc.py
+++ b/numpy/core/tests/test_ufunc.py
@@ -388,15 +388,15 @@ class TestUfunc(TestCase):
msg = "extend & broadcast loop dimensions"
b = np.arange(4).reshape((2, 2))
assert_array_equal(umt.inner1d(a, b), np.sum(a*b, axis=-1), err_msg=msg)
- # Broadcast in core dimensions
+ # Broadcast in core dimensions should fail
a = np.arange(8).reshape((4, 2))
b = np.arange(4).reshape((4, 1))
assert_raises(ValueError, umt.inner1d, a, b)
- # Extend core dimensions
+ # Extend core dimensions should fail
a = np.arange(8).reshape((4, 2))
b = np.array(7)
assert_raises(ValueError, umt.inner1d, a, b)
- # Broadcast should fail"
+ # Broadcast should fail
a = np.arange(2).reshape((2, 1, 1))
b = np.arange(3).reshape((3, 1, 1))
assert_raises(ValueError, umt.inner1d, a, b)
@@ -557,7 +557,8 @@ class TestUfunc(TestCase):
b = np.sqrt(np.sum((a[:, None] - a)**2, axis=-1))
b = b[~np.tri(a.shape[0], dtype=bool)]
assert_almost_equal(out, b)
- assert_raises(ValueError, umt.euclidean_pdist ,a)
+ # An output array is required to determine p with signature (n,d)->(p)
+ assert_raises(ValueError, umt.euclidean_pdist, a)
def test_object_logical(self):
a = np.array([3, None, True, False, "test", ""], dtype=object)