summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)