diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/xy_grid.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/xy_grid.py b/scripts/xy_grid.py index 74918789..b6119208 100644 --- a/scripts/xy_grid.py +++ b/scripts/xy_grid.py @@ -109,6 +109,9 @@ def draw_xy_grid(p, xs, ys, x_label, y_label, cell): re_range = re.compile(r"\s*([+-]?\s*\d+)\s*-\s*([+-]?\s*\d+)(?:\s*\(([+-]\d+)\s*\))?\s*")
re_range_float = re.compile(r"\s*([+-]?\s*\d+(?:.\d*)?)\s*-\s*([+-]?\s*\d+(?:.\d*)?)(?:\s*\(([+-]\d+(?:.\d*)?)\s*\))?\s*")
+re_range_count = re.compile(r"\s*([+-]?\s*\d+)\s*-\s*([+-]?\s*\d+)(?:\s*\[(\d+)\s*\])?\s*")
+re_range_count_float = re.compile(r"\s*([+-]?\s*\d+(?:.\d*)?)\s*-\s*([+-]?\s*\d+(?:.\d*)?)(?:\s*\[(\d+(?:.\d*)?)\s*\])?\s*")
+
class Script(scripts.Script):
def title(self):
return "X/Y plot"
@@ -138,6 +141,7 @@ class Script(scripts.Script): for val in valslist:
m = re_range.fullmatch(val)
+ mc = re_range_count.fullmatch(val)
if m is not None:
start = int(m.group(1))
@@ -145,6 +149,12 @@ class Script(scripts.Script): step = int(m.group(3)) if m.group(3) is not None else 1
valslist_ext += list(range(start, end, step))
+ elif mc is not None:
+ start = int(mc.group(1))
+ end = int(mc.group(2))
+ num = int(mc.group(3)) if mc.group(3) is not None else 1
+
+ valslist_ext += [int(x) for x in np.linspace(start = start, stop = end, num = num).tolist()]
else:
valslist_ext.append(val)
@@ -154,12 +164,19 @@ class Script(scripts.Script): for val in valslist:
m = re_range_float.fullmatch(val)
+ mc = re_range_count_float.fullmatch(val)
if m is not None:
start = float(m.group(1))
end = float(m.group(2))
step = float(m.group(3)) if m.group(3) is not None else 1
valslist_ext += np.arange(start, end + step, step).tolist()
+ elif mc is not None:
+ start = float(mc.group(1))
+ end = float(mc.group(2))
+ num = int(mc.group(3)) if mc.group(3) is not None else 1
+
+ valslist_ext += np.linspace(start = start, stop = end, num = num).tolist()
else:
valslist_ext.append(val)
|