From 5645c2bdaed88ba402d7905766582944bb035b97 Mon Sep 17 00:00:00 2001 From: Mackerel Date: Fri, 7 Apr 2023 16:26:43 -0400 Subject: [PATCH] extract elements from lists returned by cont(v) --- sample.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sample.py b/sample.py index 0013dc3..6eaa6a6 100644 --- a/sample.py +++ b/sample.py @@ -350,7 +350,14 @@ class KSamplerXYZ: def parse(self, input: str, cont: Union[Callable[[str],Any],None]): vs = [ x.strip() for x in input.split(',') ] if cont is not None: - vs = [cont(v) for v in vs ] + new_vs = [] + for v in vs: + new_v = cont(v) + if isinstance(new_v, list): + new_vs += new_v + else: + new_vs.append(new_v) + vs = new_vs return vs def parse_int(self, input: str): @@ -365,8 +372,8 @@ class KSamplerXYZ: start, end, step = m.group(1), m.group(2), m.group(3) if step is None: step = 1 - - return list(range(int(start), int(end), int(step))) + + return list(range(int(start), int(end) + 1, int(step))) def parse_float(self, input: str): m = re_float.fullmatch(input)