MCPcopy Index your code
hub / github.com/pydata/xarray / test_binary_op_compat_setting

Method test_binary_op_compat_setting

xarray/tests/test_dataset.py:7080–7113  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7078 assert_equal(actual, expected)
7079
7080 def test_binary_op_compat_setting(self) -> None:
7081 # Setting up a clash of non-index coordinate 'foo':
7082 a = xr.Dataset(
7083 data_vars={"var": (["x"], [0, 0, 0])},
7084 coords={
7085 "x": [1, 2, 3],
7086 "foo": (["x"], [1.0, 2.0, np.nan]),
7087 },
7088 )
7089 b = xr.Dataset(
7090 data_vars={"var": (["x"], [0, 0, 0])},
7091 coords={
7092 "x": [1, 2, 3],
7093 "foo": (["x"], [np.nan, 2.0, 3.0]),
7094 },
7095 )
7096
7097 with xr.set_options(arithmetic_compat="minimal"):
7098 assert_equal(a + b, a.drop_vars("foo"))
7099
7100 with xr.set_options(arithmetic_compat="override"):
7101 assert_equal(a + b, a)
7102 assert_equal(b + a, b)
7103
7104 with xr.set_options(arithmetic_compat="no_conflicts"):
7105 expected = a.assign_coords(foo=(["x"], [1.0, 2.0, 3.0]))
7106 assert_equal(a + b, expected)
7107 assert_equal(b + a, expected)
7108
7109 with xr.set_options(arithmetic_compat="equals"):
7110 with pytest.raises(MergeError):
7111 a + b
7112 with pytest.raises(MergeError):
7113 b + a
7114
7115 @pytest.mark.parametrize(
7116 ["keep_attrs", "expected"],

Callers

nothing calls this directly

Calls 3

drop_varsMethod · 0.95
assert_equalFunction · 0.90
assign_coordsMethod · 0.45

Tested by

no test coverage detected