[Numpy-discussion] Type checking inconsistency
Pauli Virtanen
pav at iki.fi
Sun Oct 16 12:49:16 EDT 2011
(16.10.2011 18:39), Tony Yu wrote:
> >>> import numpy as np
> >>> a = np.arange(10)
> >>> b = np.ones(10, dtype=np.uint8)
>
> # this runs without error
> >>> b[:5] = a[:5]
>
> >>> mask = a < 5
> >>> b[mask] = b[mask]
> TypeError: array cannot be safely cast to required type
Seems to be fixed in Git master
>>> import numpy as np
>>> a = np.arange(10)
>>> b = np.ones(10, dtype=np.uint8)
>>> mask = a < 5
>>> b[mask] = b[mask]
>>> b[mask] = a[mask]
>>> np.__version__
'2.0.0.dev-1dc1877'
--
Pauli Virtanen
More information about the NumPy-Discussion
mailing list