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

Function test_normalize_numpy_ufunc_unserializable

dask/tests/test_tokenize.py:281–301  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

279
280@pytest.mark.skipif("not np")
281def test_normalize_numpy_ufunc_unserializable():
282 # Make a ufunc that isn't in the numpy namespace and can't be serialized
283 inc = np.frompyfunc(lambda x: x + 1, 1, 1)
284 with dask.config.set({"tokenize.ensure-deterministic": False}):
285 # Not idempotent
286 assert tokenize(inc) != tokenize(inc)
287 # You can call normalize_token directly
288 assert normalize_token(inc) != normalize_token(inc)
289
290 with dask.config.set({"tokenize.ensure-deterministic": True}):
291 with pytest.raises(
292 TokenizationError, match=r"Cannot tokenize.*dask\.array\.ufunc.*instead"
293 ):
294 tokenize(inc)
295
296 # Test env override
297 assert tokenize(inc, ensure_deterministic=False) != tokenize(
298 inc, ensure_deterministic=False
299 )
300 with pytest.raises(TokenizationError, match="Cannot tokenize"):
301 tokenize(inc, ensure_deterministic=True)
302
303
304def test_normalize_object_unserializable():

Callers

nothing calls this directly

Calls 2

tokenizeFunction · 0.90
setMethod · 0.80

Tested by

no test coverage detected