MCPcopy Create free account
hub / github.com/dask/dask / test_complex

Function test_complex

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

Source from the content-addressed store, hash-verified

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