From 0808ae8fc5e3d539989aeceb74cbac35bb55598e Mon Sep 17 00:00:00 2001 From: jaimefrio Date: Wed, 28 Jan 2015 21:25:00 -0800 Subject: 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. --- numpy/lib/stride_tricks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'numpy/lib/stride_tricks.py') 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) -- cgit v1.2.1