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

Function test_frompyfunc_wrapper

dask/array/tests/test_ufunc.py:377–407  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

375
376
377def test_frompyfunc_wrapper():
378 f = da_frompyfunc(add, 2, 1)
379 np_f = np.frompyfunc(add, 2, 1)
380 x = np.array([1, 2, 3])
381
382 # Callable
383 np.testing.assert_equal(f(x, 1), np_f(x, 1))
384
385 # picklable
386 f2 = pickle.loads(pickle.dumps(f))
387 np.testing.assert_equal(f2(x, 1), np_f(x, 1))
388
389 # Attributes
390 assert f.ntypes == np_f.ntypes
391 with pytest.raises(AttributeError):
392 f.not_an_attribute
393
394 # Tab completion
395 assert "ntypes" in dir(f)
396
397 # Methods
398 np.testing.assert_equal(f.outer(x, x), np_f.outer(x, x))
399
400 # funcname
401 assert f.__name__ == "frompyfunc-add"
402
403 # repr
404 assert repr(f) == "da.frompyfunc<add, 2, 1>"
405
406 # tokenize
407 assert tokenize(da_frompyfunc(add, 2, 1)) == tokenize(da_frompyfunc(add, 2, 1))
408
409
410def test_array_ufunc():

Callers

nothing calls this directly

Calls 5

da_frompyfuncClass · 0.90
fFunction · 0.70
f2Function · 0.50
tokenizeFunction · 0.50
outerMethod · 0.45

Tested by

no test coverage detected