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

Function test_complex

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

Source from the content-addressed store, hash-verified

254
255@pytest.mark.parametrize("ufunc", ["isreal", "iscomplex", "real", "imag"])
256def test_complex(ufunc):
257 dafunc = getattr(da, ufunc)
258 # Note that these functions are not NumPy ufuncs
259 npfunc = getattr(np, ufunc)
260
261 real = np.random.randint(1, 100, size=(20, 20))
262 imag = np.random.randint(1, 100, size=(20, 20)) * 1j
263 comp = real + imag
264
265 dareal = da.from_array(real, 3)
266 daimag = da.from_array(imag, 3)
267 dacomp = da.from_array(comp, 3)
268
269 assert_eq(dacomp.real, comp.real)
270 assert_eq(dacomp.imag, comp.imag)
271 assert_eq(dacomp.conj(), comp.conj())
272
273 for darr, arr in [(dacomp, comp), (dareal, real), (daimag, imag)]:
274 # applying Dask ufunc doesn't trigger computation
275 assert isinstance(dafunc(darr), da.Array)
276 assert_eq(dafunc(darr), npfunc(arr))
277 assert_eq(npfunc(darr), npfunc(arr))
278
279 # applying Dask ufunc to normal ndarray triggers computation
280 assert isinstance(dafunc(arr), np.ndarray)
281 assert_eq(dafunc(arr), npfunc(arr))
282
283
284@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