(self, unit, dtype)
| 4367 | ), |
| 4368 | ) |
| 4369 | def test_isin(self, unit, dtype): |
| 4370 | array1 = ( |
| 4371 | create_nan_array([1.4, np.nan, 2.3, np.nan, np.nan, 9.1], dtype) |
| 4372 | * unit_registry.m |
| 4373 | ) |
| 4374 | array2 = ( |
| 4375 | create_nan_array([4.3, 9.8, 7.5, np.nan, 8.2, np.nan], dtype) |
| 4376 | * unit_registry.m |
| 4377 | ) |
| 4378 | ds = xr.Dataset({"a": ("x", array1), "b": ("x", array2)}) |
| 4379 | |
| 4380 | raw_values = create_nan_array([1.4, np.nan, 2.3], dtype) |
| 4381 | values = raw_values * unit |
| 4382 | |
| 4383 | converted_values = ( |
| 4384 | convert_units(values, {None: unit_registry.m}) |
| 4385 | if is_compatible(unit, unit_registry.m) |
| 4386 | else values |
| 4387 | ) |
| 4388 | |
| 4389 | expected = strip_units(ds).isin(strip_units(converted_values)) |
| 4390 | # TODO: use `unit_registry.is_compatible_with(unit, unit_registry.m)` instead. |
| 4391 | # Needs `pint>=0.12.1`, though, so we probably should wait until that is released. |
| 4392 | if not is_compatible(unit, unit_registry.m): |
| 4393 | expected.a[:] = False |
| 4394 | expected.b[:] = False |
| 4395 | |
| 4396 | actual = ds.isin(values) |
| 4397 | |
| 4398 | assert_units_equal(expected, actual) |
| 4399 | assert_equal(expected, actual) |
| 4400 | |
| 4401 | @pytest.mark.parametrize( |
| 4402 | "variant", ("masking", "replacing_scalar", "replacing_array", "dropping") |
nothing calls this directly
no test coverage detected