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

Function test_dispatch

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

Source from the content-addressed store, hash-verified

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