diff options
author | Antoine Pitrou <antoine@python.org> | 2017-05-23 16:46:06 +0200 |
---|---|---|
committer | Antoine Pitrou <antoine@python.org> | 2017-05-24 15:44:28 +0200 |
commit | 3c0b4db0b51ec4f4b67f63d647d8f8a668b7e754 (patch) | |
tree | 830ec571d6c0fbe8b1d9c3cdba72133e5d498514 /numpy/lib/tests/test_stride_tricks.py | |
parent | d0c15fab8e3c0324914baede7496810485eb4e56 (diff) | |
download | numpy-3c0b4db0b51ec4f4b67f63d647d8f8a668b7e754.tar.gz |
BUG: have as_strided() keep custom dtypes
Fixes issue #9161
Diffstat (limited to 'numpy/lib/tests/test_stride_tricks.py')
-rw-r--r-- | numpy/lib/tests/test_stride_tricks.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_stride_tricks.py b/numpy/lib/tests/test_stride_tricks.py index 7dc3c4d24..0599324d7 100644 --- a/numpy/lib/tests/test_stride_tricks.py +++ b/numpy/lib/tests/test_stride_tricks.py @@ -1,6 +1,7 @@ from __future__ import division, absolute_import, print_function import numpy as np +from numpy.core.test_rational import rational from numpy.testing import ( run_module_suite, assert_equal, assert_array_equal, assert_raises, assert_ @@ -317,6 +318,13 @@ def test_as_strided(): a_view = as_strided(a, shape=(3, 4), strides=(0, a.itemsize)) assert_equal(a.dtype, a_view.dtype) + # Custom dtypes should not be lost (gh-9161) + r = [rational(i) for i in range(4)] + a = np.array(r, dtype=rational) + a_view = as_strided(a, shape=(3, 4), strides=(0, a.itemsize)) + assert_equal(a.dtype, a_view.dtype) + assert_array_equal([r] * 3, a_view) + def as_strided_writeable(): arr = np.ones(10) view = as_strided(arr, writeable=False) |