Skip to content

Latest commit

 

History

History
21 lines (18 loc) · 785 Bytes

21995.compatibility.rst

File metadata and controls

21 lines (18 loc) · 785 Bytes

Returned arrays respect uniqueness of dtype kwarg objects

When the dtype keyword argument is used with :pynp.array() or :pyasarray(), the dtype of the returned array now always exactly matches the dtype provided by the caller.

In some cases this change means that a view rather than the input array is returned. The following is an example for this on 64bit Linux where long and longlong are the same precision:

>>> arr = np.array([1, 2, 3], dtype="long")
>>> new_dtype = np.dtype("longlong")
>>> new = np.asarray(arr, dtype=new_dtype)
>>> new.dtype is dtype
True
>>> new is arr
False

Before the change, the dtype did not match because new is arr was true.