MCPcopy
hub / github.com/dask/dask / test_stringify

Function test_stringify

dask/tests/test_utils.py:742–772  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

740
741
742def test_stringify():
743 obj = "Hello"
744 assert stringify(obj) is obj
745 obj = b"Hello"
746 assert stringify(obj) is obj
747 dsk = {"x": 1}
748
749 assert stringify(dsk) == str(dsk)
750 assert stringify(dsk, exclusive=()) == dsk
751
752 dsk = {("x", 1): (inc, 1)}
753 assert stringify(dsk) == str({("x", 1): (inc, 1)})
754 assert stringify(dsk, exclusive=()) == {("x", 1): (inc, 1)}
755
756 dsk = {("x", 1): (inc, 1), ("x", 2): (inc, ("x", 1))}
757 assert stringify(dsk, exclusive=dsk) == {
758 ("x", 1): (inc, 1),
759 ("x", 2): (inc, str(("x", 1))),
760 }
761
762 dsks = [
763 {"x": 1},
764 {("x", 1): (inc, 1), ("x", 2): (inc, ("x", 1))},
765 {("x", 1): (sum, [1, 2, 3]), ("x", 2): (sum, [("x", 1), ("x", 1)])},
766 ]
767 for dsk in dsks:
768 sdsk = {stringify(k): stringify(v, exclusive=dsk) for k, v in dsk.items()}
769 keys = list(dsk)
770 skeys = [str(k) for k in keys]
771 assert all(isinstance(k, str) for k in sdsk)
772 assert get(dsk, keys) == get(sdsk, skeys)
773
774
775@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 4

stringifyFunction · 0.90
getFunction · 0.90
allFunction · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…