(self, unit, error, dtype)
| 2974 | ), |
| 2975 | ) |
| 2976 | def test_combine_first(self, unit, error, dtype): |
| 2977 | array = np.zeros(shape=(2, 2), dtype=dtype) * unit_registry.m |
| 2978 | other_array = np.ones_like(array) * unit |
| 2979 | |
| 2980 | data_array = xr.DataArray( |
| 2981 | data=array, coords={"x": ["a", "b"], "y": [-1, 0]}, dims=["x", "y"] |
| 2982 | ) |
| 2983 | other = xr.DataArray( |
| 2984 | data=other_array, coords={"x": ["b", "c"], "y": [0, 1]}, dims=["x", "y"] |
| 2985 | ) |
| 2986 | |
| 2987 | if error is not None: |
| 2988 | with pytest.raises(error): |
| 2989 | data_array.combine_first(other) |
| 2990 | |
| 2991 | return |
| 2992 | |
| 2993 | units = extract_units(data_array) |
| 2994 | expected = attach_units( |
| 2995 | strip_units(data_array).combine_first( |
| 2996 | strip_units(convert_units(other, units)) |
| 2997 | ), |
| 2998 | units, |
| 2999 | ) |
| 3000 | actual = data_array.combine_first(other) |
| 3001 | |
| 3002 | assert_units_equal(expected, actual) |
| 3003 | assert_identical(expected, actual) |
| 3004 | |
| 3005 | @pytest.mark.parametrize( |
| 3006 | "unit", |
nothing calls this directly
no test coverage detected