DOC: add caveats to jnp.ndarray.astype

This commit is contained in:
Jake VanderPlas 2022-03-23 09:38:15 -07:00
parent e0d3946e34
commit 852a747189

View File

@ -4341,6 +4341,13 @@ def nanmedian(a, axis: Optional[Union[int, Tuple[int, ...]]] = None, out=None,
def _astype(arr, dtype):
"""Copy the array and cast to a specified dtype.
This is implemeted via :func:`jax.lax.convert_element_type`, which may
have slightly different behavior than :meth:`numpy.ndarray.astype` in
some cases. In particular, the details of float-to-int and int-to-float
casts are implementation dependent.
"""
if dtype is None:
dtype = dtypes.canonicalize_dtype(float_)
lax_internal._check_user_dtype_supported(dtype, "astype")