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

Function test_gufunc_vectorize_whitespace

dask/array/tests/test_gufunc.py:332–355  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

330
331
332def test_gufunc_vectorize_whitespace():
333 # Regression test for https://github.com/dask/dask/issues/7972.
334 # NumPy versions before https://github.com/numpy/numpy/pull/19627
335 # would not ignore whitespace characters in `signature` like they
336 # are supposed to. We remove the whitespace in Dask as a workaround.
337
338 def foo(x, y):
339 return (x + y).sum(axis=1)
340
341 a = da.ones((8, 3, 5), chunks=(2, 3, 5), dtype=int)
342 b = np.ones(5, dtype=int)
343 x = apply_gufunc(foo, "(m, n),(n)->(m)", a, b, vectorize=True)
344
345 assert_eq(x, np.full((8, 3), 10, dtype=int))
346
347 a = da.random.default_rng().random((6, 5, 5))
348
349 @da.as_gufunc(signature="(n, n)->(n, n)", output_dtypes=float, vectorize=True)
350 def gufoo(x):
351 return np.linalg.inv(x)
352
353 # Previously calling `gufoo` would raise an error due to the whitespace
354 # in its `signature`. Let's make sure it doesn't raise here.
355 gufoo(a)
356
357
358def test_gufunc():

Callers

nothing calls this directly

Calls 6

apply_gufuncFunction · 0.90
assert_eqFunction · 0.90
gufooFunction · 0.85
onesMethod · 0.45
fullMethod · 0.45
randomMethod · 0.45

Tested by

no test coverage detected