xarray/core/variable.py
def _as_array_or_item(data):
    """Return the given values as a numpy array, or as an individual item if
    it's a 0d datetime64 or timedelta64 array.

    Importantly, this function does not copy data if it is already an ndarray -
    otherwise, it will not be possible to update Variable values in place.

    This function mostly exists because 0-dimensional ndarrays with
    dtype=datetime64 are broken :(
    https://github.com/numpy/numpy/issues/4337
    https://github.com/numpy/numpy/issues/7619

    TODO: remove this (replace with np.asarray) once these issues are fixed
    """
    if isinstance(data, cupy_array_type):
        data = data.get()
    else:
        data = np.asarray(data)
    if data.ndim == 0:
        if data.dtype.kind == "M":
            data = np.datetime64(data, "ns")
        elif data.dtype.kind == "m":
            data = np.timedelta64(data, "ns")
    return data
Return the given values as a numpy array, or as an individual item if
    it's a 0d datetime64 or timedelta64 array.

    Importantly, this function does not copy data if it is already an ndarray -
    otherwise, it will not be possible to update Variable values in place.

    This function mostly exists because 0-dimensional ndarrays with
    dtype=datetime64 are broken :(
    https://github.com/numpy/numpy/issues/4337
    https://github.com/numpy/numpy/issues/7619

    TODO: remove this (replace with np.asarray) once these issues are fixed
    
Return the given values as a numpy array, or as an individual item if
it's a 0d datetime64 or timedelta64 array.

Importantly, this function does not copy data if it is already an ndarray
otherwise, it will not be possible to update Variable values in place.



remove this (replace with np.asarray) once these issues are fixed
Return the given values as a numpy array or as an individual item if it ' s a 0d datetime64 or timedelta64 array . Importantly this function does not copy data if it is already an ndarray otherwise it will not be possible to update Variable values in place . remove this ( replace with np . asarray ) once these issues are fixed
def _as_array_or_item(data):
    if isinstance(data, cupy_array_type):
        data = data.get()
    else:
        data = np.asarray(data)
    if data.ndim == 0:
        if data.dtype.kind == "M":
            data = np.datetime64(data, "ns")
        elif data.dtype.kind == "m":
            data = np.timedelta64(data, "ns")
    return data
def _as_array_or_item ( data ) : if isinstance ( data , cupy_array_type ) : data = data . get ( ) else : data = np . asarray ( data ) if data . ndim == 0 : if data . dtype . kind == "M" : data = np . datetime64 ( data , "ns" ) elif data . dtype . kind == "m" : data = np . timedelta64 ( data , "ns" ) return data
Return the given values as a numpy array, or as an individual item if
it's a 0d datetime64 or timedelta64 array.
Return the given values as a numpy array or as an individual item if it ' s a 0d datetime64 or timedelta64 array .
"""Return the given values as a numpy array, or as an individual item if
    it's a 0d datetime64 or timedelta64 array.

    Importantly, this function does not copy data if it is already an ndarray -
    otherwise, it will not be possible to update Variable values in place.

    This function mostly exists because 0-dimensional ndarrays with
    dtype=datetime64 are broken :(
    https://github.com/numpy/numpy/issues/4337
    https://github.com/numpy/numpy/issues/7619

    TODO: remove this (replace with np.asarray) once these issues are fixed
    """
data