diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-05-11 10:08:10 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-11 10:08:10 -0700 |
commit | 3337865dd9f1c6141199577a8a7a432551a04f9e (patch) | |
tree | ff5f09943484eb6e538964139260d51632592590 /numpy/lib/recfunctions.py | |
parent | 4a2b6a7d8e389abe06d5d7f2fbfa6ebd03b9092a (diff) | |
parent | e6a7e05753f8a5f56de9653bfecd85a22f53d7c6 (diff) | |
download | numpy-3337865dd9f1c6141199577a8a7a432551a04f9e.tar.gz |
Merge pull request #13332 from eric-wieser/fix-subarray-unstructured
BUG: Always return views from structured_to_unstructured when possible
Diffstat (limited to 'numpy/lib/recfunctions.py')
-rw-r--r-- | numpy/lib/recfunctions.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py index ccbcfad91..08a9cf09c 100644 --- a/numpy/lib/recfunctions.py +++ b/numpy/lib/recfunctions.py @@ -976,7 +976,7 @@ def structured_to_unstructured(arr, dtype=None, copy=False, casting='unsafe'): # next cast to a packed format with all fields converted to new dtype packed_fields = np.dtype({'names': names, - 'formats': [(out_dtype, c) for c in counts]}) + 'formats': [(out_dtype, dt.shape) for dt in dts]}) arr = arr.astype(packed_fields, copy=copy, casting=casting) # finally is it safe to view the packed fields as the unstructured type @@ -1069,7 +1069,7 @@ def unstructured_to_structured(arr, dtype=None, names=None, align=False, # first view as a packed structured array of one dtype packed_fields = np.dtype({'names': names, - 'formats': [(arr.dtype, c) for c in counts]}) + 'formats': [(arr.dtype, dt.shape) for dt in dts]}) arr = np.ascontiguousarray(arr).view(packed_fields) # next cast to an unpacked but flattened format with varied dtypes |