You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building a view of a masked structured array, using a dtype with offsets, a ValueError exception is fired.
Note: With an array of type np.array instead of np.ma.MaskedArray, all runs fine.
Reproducing code example:
importnumpyasnpx=np.array([('Rex', 9, 81.0), ('Fido', 3, 27.0)], dtype=[('name', 'U10'), ('age', 'i4'), ('weight', 'f4')])
age_dtype, age_offset=x.dtype.fields['age']
newdt=np.dtype({ 'names': ['age'], 'formats': [age_dtype], 'offsets': [age_offset], 'itemsize': x.dtype.itemsize })
# this works for now; it gives a view of x with column 'age' onlyx.view(newdt)
# now converting x to a masked arrayx=x.view(np.ma.MaskedArray)
# Oops!x.view(newdt)
Error message:
Traceback (most recent call last):
File "/home/etienne/sakura/.venv/lib/python3.5/site-packages/numpy/ma/core.py", line 3130, in view
if issubclass(dtype, ndarray):
TypeError: issubclass() arg 1 must be a class
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/etienne/sakura/.venv/lib/python3.5/site-packages/numpy/ma/core.py", line 3136, in view
output = ndarray.view(self, dtype)
File "/home/etienne/sakura/.venv/lib/python3.5/site-packages/numpy/ma/core.py", line 3357, in dtype
self._mask.shape = self.shape
ValueError: cannot reshape array of size 6 into shape (2,)
When building a view of a masked structured array, using a dtype with offsets, a ValueError exception is fired.
Note: With an array of type np.array instead of np.ma.MaskedArray, all runs fine.
Reproducing code example:
Error message:
Numpy/Python version information:
The text was updated successfully, but these errors were encountered: