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

Method test_reindex_fill_value

xarray/tests/test_dataset.py:2459–2479  ·  view source on GitHub ↗
(self, fill_value)

Source from the content-addressed store, hash-verified

2457
2458 @pytest.mark.parametrize("fill_value", [dtypes.NA, 2, 2.0, {"x": 2, "z": 1}])
2459 def test_reindex_fill_value(self, fill_value) -> None:
2460 ds = Dataset({"x": ("y", [10, 20]), "z": ("y", [-20, -10]), "y": [0, 1]})
2461 y = [0, 1, 2]
2462 actual = ds.reindex(y=y, fill_value=fill_value)
2463 if fill_value == dtypes.NA:
2464 # if we supply the default, we expect the missing value for a
2465 # float array
2466 fill_value_x = fill_value_z = np.nan
2467 elif isinstance(fill_value, dict):
2468 fill_value_x = fill_value["x"]
2469 fill_value_z = fill_value["z"]
2470 else:
2471 fill_value_x = fill_value_z = fill_value
2472 expected = Dataset(
2473 {
2474 "x": ("y", [10, 20, fill_value_x]),
2475 "z": ("y", [-20, -10, fill_value_z]),
2476 "y": y,
2477 }
2478 )
2479 assert_identical(expected, actual)
2480
2481 @pytest.mark.parametrize("fill_value", [dtypes.NA, 2, 2.0, {"x": 2, "z": 1}])
2482 def test_reindex_like_fill_value(self, fill_value) -> None:

Callers

nothing calls this directly

Calls 3

reindexMethod · 0.95
DatasetClass · 0.90
assert_identicalFunction · 0.90

Tested by

no test coverage detected