summaryrefslogtreecommitdiff
path: root/numpy/lib/stride_tricks.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/stride_tricks.py')
-rw-r--r--numpy/lib/stride_tricks.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py
index 545623c38..6c240db7f 100644
--- a/numpy/lib/stride_tricks.py
+++ b/numpy/lib/stride_tricks.py
@@ -100,10 +100,9 @@ def as_strided(x, shape=None, strides=None, subok=False, writeable=True):
interface['strides'] = tuple(strides)
array = np.asarray(DummyArray(interface, base=x))
-
- 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
+ # The route via `__interface__` does not preserve structured
+ # dtypes. Since dtype should remain unchanged, we set it explicitly.
+ array.dtype = x.dtype
view = _maybe_view_as_subclass(x, array)