MCPcopy Index your code
hub / github.com/dask/dask / test_complex

Function test_complex

dask/array/tests/test_ufunc.py:270–295  ·  view source on GitHub ↗
(ufunc)

Source from the content-addressed store, hash-verified

268
269@pytest.mark.parametrize("ufunc", ["isreal", "iscomplex", "real", "imag"])
270def test_complex(ufunc):
271 dafunc = getattr(da, ufunc)
272 # Note that these functions are not NumPy ufuncs
273 npfunc = getattr(np, ufunc)
274
275 real = np.random.randint(1, 100, size=(20, 20))
276 imag = np.random.randint(1, 100, size=(20, 20)) * 1j
277 comp = real + imag
278
279 dareal = da.from_array(real, 3)
280 daimag = da.from_array(imag, 3)
281 dacomp = da.from_array(comp, 3)
282
283 assert_eq(dacomp.real, comp.real)
284 assert_eq(dacomp.imag, comp.imag)
285 assert_eq(dacomp.conj(), comp.conj())
286
287 for darr, arr in [(dacomp, comp), (dareal, real), (daimag, imag)]:
288 # applying Dask ufunc doesn't trigger computation
289 assert isinstance(dafunc(darr), da.Array)
290 assert_eq(dafunc(darr), npfunc(arr))
291 assert_eq(npfunc(darr), npfunc(arr))
292
293 # applying Dask ufunc to normal ndarray triggers computation
294 assert isinstance(dafunc(arr), np.ndarray)
295 assert_eq(dafunc(arr), npfunc(arr))
296
297
298@pytest.mark.parametrize("ufunc", ["frexp", "modf"])

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
randintMethod · 0.45
conjMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…