(self, comparison, unit, error, dtype)
| 2486 | ), |
| 2487 | ) |
| 2488 | def test_comparison_operations(self, comparison, unit, error, dtype): |
| 2489 | array = ( |
| 2490 | np.array([10.1, 5.2, 6.5, 8.0, 21.3, 7.1, 1.3]).astype(dtype) |
| 2491 | * unit_registry.m |
| 2492 | ) |
| 2493 | data_array = xr.DataArray(data=array) |
| 2494 | |
| 2495 | value = 8 |
| 2496 | to_compare_with = value * unit |
| 2497 | |
| 2498 | # incompatible units are all not equal |
| 2499 | if error is not None and comparison is not operator.eq: |
| 2500 | with pytest.raises(error): |
| 2501 | comparison(array, to_compare_with) |
| 2502 | |
| 2503 | with pytest.raises(error): |
| 2504 | comparison(data_array, to_compare_with) |
| 2505 | |
| 2506 | return |
| 2507 | |
| 2508 | actual = comparison(data_array, to_compare_with) |
| 2509 | |
| 2510 | expected_units = {None: unit_registry.m if array.check(unit) else None} |
| 2511 | expected = array.check(unit) & comparison( |
| 2512 | strip_units(data_array), |
| 2513 | strip_units(convert_units(to_compare_with, expected_units)), |
| 2514 | ) |
| 2515 | |
| 2516 | assert_units_equal(expected, actual) |
| 2517 | assert_identical(expected, actual) |
| 2518 | |
| 2519 | @pytest.mark.parametrize( |
| 2520 | "units,error", |
nothing calls this directly
no test coverage detected