Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
35229d94
Commit
35229d94
authored
Sep 14, 2022
by
DepFA
Committed by
AUTOMATIC1111
Sep 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add square bracket range+count syntax
parent
3daf9cac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
xy_grid.py
scripts/xy_grid.py
+17
-0
No files found.
scripts/xy_grid.py
View file @
35229d94
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment