MCPcopy
hub / github.com/pydata/xarray / test_create_variables

Method test_create_variables

xarray/tests/test_indexes.py:202–216  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

200 PandasIndex.concat(indexes, "x")
201
202 def test_create_variables(self) -> None:
203 # pandas has only Float64Index but variable dtype should be preserved
204 data = np.array([1.1, 2.2, 3.3], dtype=np.float32)
205 pd_idx = pd.Index(data, name="foo")
206 index = PandasIndex(pd_idx, "x", coord_dtype=data.dtype)
207 index_vars = {
208 "foo": IndexVariable(
209 "x", data, attrs={"unit": "m"}, encoding={"fill_value": 0.0}
210 )
211 }
212
213 actual = index.create_variables(index_vars)
214 assert_identical(actual["foo"], index_vars["foo"])
215 assert actual["foo"].dtype == index_vars["foo"].dtype
216 assert actual["foo"].dtype == index.coord_dtype
217
218 def test_to_pandas_index(self) -> None:
219 pd_idx = pd.Index([1, 2, 3], name="foo")

Callers

nothing calls this directly

Calls 4

create_variablesMethod · 0.95
PandasIndexClass · 0.90
IndexVariableClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected