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

Function _expander

dask/array/slicing.py:680–704  ·  view source on GitHub ↗
(where)

Source from the content-addressed store, hash-verified

678
679@memoize
680def _expander(where):
681 if not where:
682
683 def expand(seq, val):
684 return seq
685
686 return expand
687 else:
688 decl = """def expand(seq, val):
689 return ({left}) + tuple({right})
690 """
691 left = []
692 j = 0
693 for i in range(max(where) + 1):
694 if i in where:
695 left.append("val, ")
696 else:
697 left.append(f"seq[{j}], ")
698 j += 1
699 right = f"seq[{j}:]"
700 left = "".join(left)
701 decl = decl.format(**locals())
702 ns = {}
703 exec(compile(decl, "<dynamic>", "exec"), ns, ns)
704 return ns["expand"]
705
706
707def expander(where):

Callers 1

expanderFunction · 0.85

Calls 2

maxFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected