summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej.certik@gmail.com>2012-08-31 15:04:29 -0700
committerOndřej Čertík <ondrej.certik@gmail.com>2012-08-31 15:04:29 -0700
commit8c75aa01e2f4ec02eb1d852a14da3e9e03107da8 (patch)
tree2ce1ffeddcaf9e189415600631e1985e525b6b87 /numpy
parentc6d8734eddc133d2fe6babc7bde53d5e981945a1 (diff)
parentecbd938adb1a370017a5ff8ca20b2c66141f48fe (diff)
downloadnumpy-8c75aa01e2f4ec02eb1d852a14da3e9e03107da8.tar.gz
Merge pull request #395 from certik/fix369
FIX: bug in np.where and recarray swapping
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/scalarapi.c2
-rw-r--r--numpy/core/tests/test_regression.py28
2 files changed, 29 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c
index d9bc492be..cdb929699 100644
--- a/numpy/core/src/multiarray/scalarapi.c
+++ b/numpy/core/src/multiarray/scalarapi.c
@@ -334,7 +334,7 @@ finish:
if (outcode == NULL) {
return (PyObject *)r;
}
- if (outcode->type_num == typecode->type_num) {
+ if (PyArray_EquivTypes(outcode, typecode)) {
if (!PyTypeNum_ISEXTENDED(typecode->type_num)
|| (outcode->elsize == typecode->elsize)) {
Py_DECREF(outcode);
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 492a4f64b..31a99909b 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -169,6 +169,34 @@ class TestRegression(TestCase):
assert_(np.all(a[ya] > 0.5))
assert_(np.all(b[yb] > 0.5))
+ def test_endian_where(self,level=rlevel):
+ """GitHuB issue #369"""
+ net = np.zeros(3, dtype='>f4')
+ net[1] = 0.00458849
+ net[2] = 0.605202
+ max_net = net.max()
+ test = np.where(net <= 0., max_net, net)
+ correct = np.array([ 0.60520202, 0.00458849, 0.60520202])
+ assert_array_almost_equal(test, correct)
+
+ def test_endian_recarray(self,level=rlevel):
+ """Ticket #2185"""
+ dt = np.dtype([
+ ('head', '>u4'),
+ ('data', '>u4', 2),
+ ])
+ buf = np.recarray(1, dtype=dt)
+ buf[0]['head'] = 1
+ buf[0]['data'][:] = [1,1]
+
+ h = buf[0]['head']
+ d = buf[0]['data'][0]
+ buf[0]['head'] = h
+ buf[0]['data'][0] = d
+ print buf[0]['head']
+ assert_(buf[0]['head'] == 1)
+
+
def test_mem_dot(self,level=rlevel):
"""Ticket #106"""
x = np.random.randn(0,1)