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

Method test_merge_fill_value

xarray/tests/test_merge.py:716–737  ·  view source on GitHub ↗
(self, fill_value)

Source from the content-addressed store, hash-verified

714
715 @pytest.mark.parametrize("fill_value", [dtypes.NA, 2, 2.0, {"a": 2, "b": 1}])
716 def test_merge_fill_value(self, fill_value):
717 ds1 = xr.Dataset({"a": ("x", [1, 2]), "x": [0, 1]})
718 ds2 = xr.Dataset({"b": ("x", [3, 4]), "x": [1, 2]})
719 if fill_value == dtypes.NA:
720 # if we supply the default, we expect the missing value for a
721 # float array
722 fill_value_a = fill_value_b = np.nan
723 elif isinstance(fill_value, dict):
724 fill_value_a = fill_value["a"]
725 fill_value_b = fill_value["b"]
726 else:
727 fill_value_a = fill_value_b = fill_value
728
729 expected = xr.Dataset(
730 {"a": ("x", [1, 2, fill_value_a]), "b": ("x", [fill_value_b, 3, 4])},
731 {"x": [0, 1, 2]},
732 )
733 assert expected.identical(ds1.merge(ds2, join="outer", fill_value=fill_value))
734 assert expected.identical(ds2.merge(ds1, join="outer", fill_value=fill_value))
735 assert expected.identical(
736 xr.merge([ds1, ds2], join="outer", fill_value=fill_value)
737 )
738
739 def test_merge_no_conflicts(self):
740 ds1 = xr.Dataset({"a": ("x", [1, 2]), "x": [0, 1]})

Callers

nothing calls this directly

Calls 2

identicalMethod · 0.95
mergeMethod · 0.95

Tested by

no test coverage detected