summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-03-13 09:20:32 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-03-13 09:20:32 -0600
commitdfe6c7ed74c087c0deabfd4f7a50224498840838 (patch)
treefef4b0bf4d2610eca2ffe5cff50c233b09441a1f
parent12472aab0426b98edbe4dc52f4f48c92d11c99bd (diff)
parent0c82f6995a8d89b7ca8de046d6ae697b07f8a963 (diff)
downloadnumpy-dfe6c7ed74c087c0deabfd4f7a50224498840838.tar.gz
Merge pull request #4473 from Sankarshan-Mudkavi/fix-gh-2208
BUG: Fixes gh-2208, alignment in subarrays
-rw-r--r--numpy/core/src/multiarray/descriptor.c1
-rw-r--r--numpy/core/tests/test_dtype.py6
2 files changed, 7 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c
index 8f6582edf..b7a8f11ef 100644
--- a/numpy/core/src/multiarray/descriptor.c
+++ b/numpy/core/src/multiarray/descriptor.c
@@ -351,6 +351,7 @@ _convert_from_tuple(PyObject *obj)
goto fail;
}
newdescr->flags = type->flags;
+ newdescr->alignment = type->alignment;
newdescr->subarray->base = type;
type = NULL;
Py_XDECREF(newdescr->fields);
diff --git a/numpy/core/tests/test_dtype.py b/numpy/core/tests/test_dtype.py
index b20dad33b..2e98b2cf8 100644
--- a/numpy/core/tests/test_dtype.py
+++ b/numpy/core/tests/test_dtype.py
@@ -331,6 +331,12 @@ class TestSubarray(TestCase):
assert_raises(ValueError, np.dtype, [('a', 'f4', -1)])
assert_raises(ValueError, np.dtype, [('a', 'f4', (-1, -1))])
+ def test_alignment(self):
+ #Check that subarrays are aligned
+ t1 = np.dtype('1i4', align=True)
+ t2 = np.dtype('2i4', align=True)
+ assert_equal(t1.alignment, t2.alignment)
+
class TestMonsterType(TestCase):
"""Test deeply nested subtypes."""