(self, func, unit, convert_data, dtype)
| 1793 | ids=repr, |
| 1794 | ) |
| 1795 | def test_comparisons(self, func, unit, convert_data, dtype): |
| 1796 | array = np.linspace(0, 1, 9).astype(dtype) |
| 1797 | quantity1 = array * unit_registry.m |
| 1798 | variable = xr.Variable("x", quantity1) |
| 1799 | |
| 1800 | if convert_data and is_compatible(unit_registry.m, unit): |
| 1801 | quantity2 = convert_units(array * unit_registry.m, {None: unit}) |
| 1802 | else: |
| 1803 | quantity2 = array * unit |
| 1804 | other = xr.Variable("x", quantity2) |
| 1805 | |
| 1806 | expected = func( |
| 1807 | strip_units(variable), |
| 1808 | strip_units( |
| 1809 | convert_units(other, extract_units(variable)) |
| 1810 | if is_compatible(unit_registry.m, unit) |
| 1811 | else other |
| 1812 | ), |
| 1813 | ) |
| 1814 | if func.name == "identical": |
| 1815 | expected &= extract_units(variable) == extract_units(other) |
| 1816 | else: |
| 1817 | expected &= all( |
| 1818 | compatible_mappings( |
| 1819 | extract_units(variable), extract_units(other) |
| 1820 | ).values() |
| 1821 | ) |
| 1822 | |
| 1823 | actual = func(variable, other) |
| 1824 | |
| 1825 | assert expected == actual |
| 1826 | |
| 1827 | @pytest.mark.parametrize( |
| 1828 | "unit", |
nothing calls this directly
no test coverage detected