Commit 783ee27c authored by Yb Tweezer's avatar Yb Tweezer
Browse files

add name generator to mapping function

parent 379a3c2f
......@@ -328,21 +328,30 @@ def ndscan(
def map_scanvars(
scan_maps: Sequence[tuple[Callable[[T, ...], ...], Sequence[Sequence[T]]]],
scan_maps: Sequence[tuple[Callable[[T, ...], ...], dict[str, Sequence[T]]]],
map_args: Sequence[...]=None,
map_kwargs: dict[str, ...]=None,
reps: int=None,
reps_first: bool=True,
printflag: bool=True,
) -> list[list[...]]:
) -> tuple[list[str], list[list[...]]]:
_map_args = tuple() if map_args is None else map_args
_map_kwargs = dict() if map_kwargs is None else map_kwargs
allvars = {"REP": list(range(reps))} if reps is not None and reps_first else dict()
for m in scan_maps:
if reps is not None and not reps_first:
fmt = ("_".join(v + "={:+.5f}" for v in allvars.keys())).replace("REP=", "")
if printflag:
print("[control] computing iterable scanning variables ... ",
end="", flush=True)
ret = [
[ m[0](*XYZ, *_map_args, **_map_kwargs) for XYZ in product(*m[1]) ]
names = [fmt.format(*V) for V in product(allvars.values())]
mapped = [
[m[0](*XYZ, *_map_args, **_map_kwargs) for XYZ in product(m[1].values())]
for m in scan_maps
if printflag:
print(f"done {tuple(len(X) for X in ret)}")
return ret
return names, mapped
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment