diff options
author | jaimefrio <jaime.frio@gmail.com> | 2015-01-28 21:25:00 -0800 |
---|---|---|
committer | Jaime Fernandez <jaime.frio@gmail.com> | 2015-03-08 23:12:42 -0700 |
commit | 0808ae8fc5e3d539989aeceb74cbac35bb55598e (patch) | |
tree | c204ab9879d0c41177a341ff19aff904fdbc8626 /numpy/lib/stride_tricks.py | |
parent | 06af9918f6bf03b8d818ec834f9fb48db57d1489 (diff) | |
download | numpy-0808ae8fc5e3d539989aeceb74cbac35bb55598e.tar.gz |
ENH: PyArray_FromInterface checks descr if typestr is np.void
When the 'typestr' member of the __array_interface__ dictionary defines
a np.void dtype, check the 'descr' member, and if it is a valid dtype
description and it is not the default one, use it to construct the
dtype for the array to return.
This fixes #5081, as as_strided no longer has to worry about changing
the dtype of the return.
Diffstat (limited to 'numpy/lib/stride_tricks.py')
-rw-r--r-- | numpy/lib/stride_tricks.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py index 0f46ed335..e9ba97413 100644 --- a/numpy/lib/stride_tricks.py +++ b/numpy/lib/stride_tricks.py @@ -46,9 +46,11 @@ def as_strided(x, shape=None, strides=None, subok=False): if strides is not None: interface['strides'] = tuple(strides) array = np.asarray(DummyArray(interface, base=x)) - # Make sure dtype is correct in case of custom dtype - if array.dtype.kind == 'V': + + if array.dtype.fields is None and x.dtype.fields is not None: + # This should only happen if x.dtype is [('', 'Vx')] array.dtype = x.dtype + return _maybe_view_as_subclass(x, array) |