|
5 | 5 | coverage. Complete coverage of all numpy functions is done |
6 | 6 | with less detailed tests in test_function_helpers. |
7 | 7 | """ |
| 8 | +import erfa.ufunc as erfa_ufunc |
8 | 9 | import numpy as np |
9 | 10 | import pytest |
10 | 11 | from numpy.testing import assert_array_equal |
@@ -151,6 +152,27 @@ def test_3op_ufunc(self): |
151 | 152 | assert_array_equal(ma_mb.unmasked, expected_data) |
152 | 153 | assert_array_equal(ma_mb.mask, expected_mask) |
153 | 154 |
|
| 155 | + def test_multi_op_ufunc(self): |
| 156 | + mask = [True, False, False] |
| 157 | + iy = Masked([2000, 2001, 2002], mask=mask) |
| 158 | + im = Masked([1, 2, 3], mask=mask) |
| 159 | + idy = Masked([10, 20, 25], mask=mask) |
| 160 | + ihr = Masked([11, 12, 13], mask=[False, False, True]) |
| 161 | + imn = np.array([50, 51, 52]) |
| 162 | + isc = np.array([12.5, 13.6, 14.7]) |
| 163 | + result = erfa_ufunc.dtf2d("utc", iy, im, idy, ihr, imn, isc) |
| 164 | + # Also test scalar |
| 165 | + result0 = erfa_ufunc.dtf2d("utc", iy[0], im[0], idy[0], ihr[0], imn[0], isc[0]) |
| 166 | + expected = erfa_ufunc.dtf2d( |
| 167 | + "utc", iy.unmasked, im.unmasked, idy.unmasked, ihr.unmasked, imn, isc |
| 168 | + ) |
| 169 | + expected_mask = np.array([True, False, True]) |
| 170 | + for res, res0, exp in zip(result, result0, expected): |
| 171 | + assert_array_equal(res.unmasked, exp) |
| 172 | + assert_array_equal(res.mask, expected_mask) |
| 173 | + assert res0.unmasked == exp[0] |
| 174 | + assert res0.mask == expected_mask[0] |
| 175 | + |
154 | 176 | @pytest.mark.parametrize("axis", (0, 1, None)) |
155 | 177 | def test_add_reduce(self, axis): |
156 | 178 | ma_reduce = np.add.reduce(self.ma, axis=axis) |
|
0 commit comments