(self, unit, error)
| 1728 | ), |
| 1729 | ) |
| 1730 | def test_missing_value_fillna(self, unit, error): |
| 1731 | value = 10 |
| 1732 | array = ( |
| 1733 | np.array( |
| 1734 | [ |
| 1735 | [1.4, 2.3, np.nan, 7.2], |
| 1736 | [np.nan, 9.7, np.nan, np.nan], |
| 1737 | [2.1, np.nan, np.nan, 4.6], |
| 1738 | [9.9, np.nan, 7.2, 9.1], |
| 1739 | ] |
| 1740 | ) |
| 1741 | * unit_registry.m |
| 1742 | ) |
| 1743 | variable = xr.Variable(("x", "y"), array) |
| 1744 | |
| 1745 | fill_value = value * unit |
| 1746 | |
| 1747 | if error is not None: |
| 1748 | with pytest.raises(error): |
| 1749 | variable.fillna(value=fill_value) |
| 1750 | |
| 1751 | return |
| 1752 | |
| 1753 | expected = attach_units( |
| 1754 | strip_units(variable).fillna( |
| 1755 | value=fill_value.to(unit_registry.m).magnitude |
| 1756 | ), |
| 1757 | extract_units(variable), |
| 1758 | ) |
| 1759 | actual = variable.fillna(value=fill_value) |
| 1760 | |
| 1761 | assert_units_equal(expected, actual) |
| 1762 | assert_identical(expected, actual) |
| 1763 | |
| 1764 | @pytest.mark.parametrize( |
| 1765 | "unit", |
nothing calls this directly
no test coverage detected