(
self,
array: pd.Index,
dtype: DTypeLike | pd.api.extensions.ExtensionDtype | None = None,
)
| 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: |
nothing calls this directly
no test coverage detected