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

Function test_frompyfunc_wrapper

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

Source from the content-addressed store, hash-verified

388
389
390def test_frompyfunc_wrapper():
391 f = da_frompyfunc(add, 2, 1)
392 np_f = np.frompyfunc(add, 2, 1)
393 x = np.array([1, 2, 3])
394
395 # Callable
396 np.testing.assert_equal(f(x, 1), np_f(x, 1))
397
398 # picklable
399 f2 = pickle.loads(pickle.dumps(f))
400 np.testing.assert_equal(f2(x, 1), np_f(x, 1))
401
402 # Attributes
403 assert f.ntypes == np_f.ntypes
404 with pytest.raises(AttributeError):
405 f.not_an_attribute
406
407 # Tab completion
408 assert "ntypes" in dir(f)
409
410 # Methods
411 np.testing.assert_equal(f.outer(x, x), np_f.outer(x, x))
412
413 # funcname
414 assert f.__name__ == "frompyfunc-add"
415
416 # repr
417 assert repr(f) == "da.frompyfunc<add, 2, 1>"
418
419 # tokenize
420 assert tokenize(da_frompyfunc(add, 2, 1)) == tokenize(da_frompyfunc(add, 2, 1))
421
422
423def 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