MCPcopy Create free account
hub / github.com/pydata/xarray / __init__

Method __init__

xarray/core/indexing.py:1906–1926  ·  view source on GitHub ↗
(
        self,
        array: pd.Index,
        dtype: DTypeLike | pd.api.extensions.ExtensionDtype | None = None,
    )

Source from the content-addressed store, hash-verified

1904 _dtype: np.dtype | pd.api.extensions.ExtensionDtype
1905
1906 def __init__(
1907 self,
1908 array: pd.Index,
1909 dtype: DTypeLike | pd.api.extensions.ExtensionDtype | None = None,
1910 ):
1911 from xarray.core.indexes import safe_cast_to_index
1912
1913 self.array = safe_cast_to_index(array)
1914
1915 if dtype is None:
1916 if is_allowed_extension_array(array):
1917 cast(pd.api.extensions.ExtensionDtype, array.dtype)
1918 self._dtype = array.dtype
1919 else:
1920 self._dtype = get_valid_numpy_dtype(array)
1921 elif is_allowed_extension_array_dtype(dtype):
1922 self._dtype = cast(pd.api.extensions.ExtensionDtype, dtype)
1923 elif HAS_STRING_DTYPE and isinstance(dtype, pd.StringDtype):
1924 self._dtype = np.dtypes.StringDType(na_object=dtype.na_value)
1925 else:
1926 self._dtype = np.dtype(cast(DTypeLike, dtype))
1927
1928 @property
1929 def _in_memory(self) -> bool:

Callers

nothing calls this directly

Calls 5

safe_cast_to_indexFunction · 0.90
get_valid_numpy_dtypeFunction · 0.90
dtypeMethod · 0.45

Tested by

no test coverage detected