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

Function iskey

dask/core.py:154–169  ·  view source on GitHub ↗

Return True if the given object is a potential dask key; False otherwise. The definition of a key in a Dask graph is any str, int, float, or tuple thereof. See Also -------- ishashable validate_key dask.typing.Key

(key: object)

Source from the content-addressed store, hash-verified

152
153
154def iskey(key: object) -> bool:
155 """Return True if the given object is a potential dask key; False otherwise.
156
157 The definition of a key in a Dask graph is any str, int, float, or tuple
158 thereof.
159
160 See Also
161 --------
162 ishashable
163 validate_key
164 dask.typing.Key
165 """
166 typ = type(key)
167 if typ is tuple:
168 return all(iskey(i) for i in cast(tuple, key))
169 return typ in {int, float, str}
170
171
172def validate_key(key: object) -> None:

Callers 3

test_iskeyFunction · 0.90
test_iskey_numpy_typesFunction · 0.90
validate_keyFunction · 0.85

Calls 1

allFunction · 0.85

Tested by 2

test_iskeyFunction · 0.72
test_iskey_numpy_typesFunction · 0.72