MCPcopy Create free account
hub / github.com/pydata/xarray / test_ufuncs

Method test_ufuncs

xarray/tests/test_ufuncs.py:212–231  ·  view source on GitHub ↗
(self, name, request)

Source from the content-addressed store, hash-verified

210 @pytest.mark.filterwarnings("ignore::RuntimeWarning")
211 @pytest.mark.parametrize("name", xu.__all__)
212 def test_ufuncs(self, name, request):
213 xu_func = getattr(xu, name)
214 np_func = getattr(np, name, None)
215 if np_func is None and np.lib.NumpyVersion(np.__version__) < "2.0.0":
216 pytest.skip(f"Ufunc {name} is not available in numpy {np.__version__}.")
217
218 if name == "isnat":
219 args = (self.xt,)
220 elif hasattr(np_func, "nin") and np_func.nin == 2: # type: ignore[union-attr]
221 args = (self.x, self.x) # type: ignore[assignment]
222 else:
223 args = (self.x,)
224
225 expected = np_func(*args) # type: ignore[misc]
226 actual = xu_func(*args)
227
228 if name in ["angle", "iscomplex"]:
229 np.testing.assert_equal(expected, actual.values)
230 else:
231 assert_identical(actual, expected)
232
233 def test_ufunc_pickle(self):
234 a = 1.0

Callers

nothing calls this directly

Calls 1

assert_identicalFunction · 0.70

Tested by

no test coverage detected