MCPcopy
hub / github.com/dask/dask / test_dispatch

Function test_dispatch

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

Source from the content-addressed store, hash-verified

150
151
152def test_dispatch():
153 foo = Dispatch()
154 foo.register(int, lambda a: a + 1)
155 foo.register(float, lambda a: a - 1)
156 foo.register(tuple, lambda a: tuple(foo(i) for i in a))
157
158 def f(a):
159 """My Docstring"""
160 return a
161
162 foo.register(object, f)
163
164 class Bar:
165 pass
166
167 b = Bar()
168 assert foo(1) == 2
169 assert foo.dispatch(int)(1) == 2
170 assert foo(1.0) == 0.0
171 assert foo(b) == b
172 assert foo((1, 2.0, b)) == (2, 1.0, b)
173
174 assert foo.__doc__ == f.__doc__
175
176
177def test_dispatch_kwargs():

Callers

nothing calls this directly

Calls 5

registerMethod · 0.95
dispatchMethod · 0.95
DispatchClass · 0.90
fooFunction · 0.70
BarClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…