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

Function _local_functions

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

Source from the content-addressed store, hash-verified

400
401
402def _local_functions():
403 all_funcs = [
404 lambda x: x,
405 lambda x: x + 1,
406 lambda y: y,
407 lambda y: y + 1,
408 ]
409 a, b = all_funcs[:2]
410
411 def func(x):
412 return x
413
414 def f2(x): # Differs by function name
415 return x
416
417 # Suppress token differences determined by function name
418 all_funcs += [func, f2]
419
420 local_scope = 1
421
422 def func():
423 nonlocal local_scope
424 local_scope += 1
425 return a(local_scope)
426
427 all_funcs.append(func)
428
429 def func():
430 global _GLOBAL
431 _GLOBAL += 1
432 return _GLOBAL
433
434 all_funcs.append(func)
435
436 # These functions differ only by the parameter defaults, which are also lambdas
437 # Parameter defaults are lambdas
438
439 def func(x, c=a):
440 return c(x)
441
442 all_funcs.append(func)
443
444 def func(x, c=b):
445 return c(x)
446
447 all_funcs.append(func)
448
449 # These functions differ only by the constants, which are also lambdas
450 def func(x):
451 c = lambda x: x + 2
452 return c(x)
453
454 all_funcs.append(func)
455
456 def func(x):
457 c = lambda x: x + 3
458 return c(x)
459

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected