Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
experiment-control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
whuie2
experiment-control
Commits
c6dadf73
Commit
c6dadf73
authored
3 years ago
by
whooie
Browse files
Options
Downloads
Patches
Plain Diff
adjust terminal output from ndscan
parent
75dfc105
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/control.py
+13
-7
13 additions, 7 deletions
lib/control.py
with
13 additions
and
7 deletions
lib/control.py
+
13
−
7
View file @
c6dadf73
...
@@ -4,6 +4,7 @@ import inspect
...
@@ -4,6 +4,7 @@ import inspect
import
ctypes
import
ctypes
import
sys
import
sys
import
time
import
time
import
timeit
from
math
import
prod
,
log10
from
math
import
prod
,
log10
from
itertools
import
product
from
itertools
import
product
from
typing
import
Callable
,
Iterable
,
Sequence
,
TypeVar
from
typing
import
Callable
,
Iterable
,
Sequence
,
TypeVar
...
@@ -243,12 +244,12 @@ def _nested_loop_over(
...
@@ -243,12 +244,12 @@ def _nested_loop_over(
raise
Exception
(
"
_nested_loop_over: must have values to loop over
"
)
raise
Exception
(
"
_nested_loop_over: must have values to loop over
"
)
elif
len
(
vals
)
==
1
:
elif
len
(
vals
)
==
1
:
_fmt
=
fmt
+
f
"
{{:
{
int
(
log10
(
len
(
vals
[
0
])))
+
1
}
}}/
{
len
(
vals
[
0
])
}
"
_fmt
=
fmt
+
f
"
{{:
{
int
(
log10
(
len
(
vals
[
0
])))
+
1
}
}}/
{
len
(
vals
[
0
])
}
"
_fmt
+=
"
({:6.2f}%)
"
_fmt
+=
"
({:6.2f}%)
\r
"
for
k
,
x
in
enumerate
(
vals
[
0
]):
for
k
,
x
in
enumerate
(
vals
[
0
]):
if
printflag
:
if
printflag
:
print
(
print
(
_fmt
.
format
(
_fmt
.
format
(
*
(
Q
+
[
k
]),
*
(
[
q
+
1
for
q
in
Q
]
+
[
k
+
1
]),
100.0
*
(
100.0
*
(
sum
(
q
*
nnq
for
q
,
nnq
in
zip
(
Q
,
NN
[
1
:]))
+
k
sum
(
q
*
nnq
for
q
,
nnq
in
zip
(
Q
,
NN
[
1
:]))
+
k
)
/
NN
[
0
]
)
/
NN
[
0
]
...
@@ -261,7 +262,7 @@ def _nested_loop_over(
...
@@ -261,7 +262,7 @@ def _nested_loop_over(
if
printflag
:
if
printflag
:
print
(
print
(
_fmt
.
format
(
_fmt
.
format
(
*
([
q
+
1
for
q
in
Q
]
+
[
k
]),
*
([
q
+
1
for
q
in
Q
]
+
[
k
+
1
]),
100.0
*
(
100.0
*
(
sum
(
q
*
nnq
for
q
,
nnq
in
zip
(
Q
,
NN
[
1
:]))
+
k
+
1
sum
(
q
*
nnq
for
q
,
nnq
in
zip
(
Q
,
NN
[
1
:]))
+
k
+
1
)
/
NN
[
0
]
)
/
NN
[
0
]
...
@@ -269,7 +270,6 @@ def _nested_loop_over(
...
@@ -269,7 +270,6 @@ def _nested_loop_over(
end
=
""
,
flush
=
True
end
=
""
,
flush
=
True
)
)
elif
len
(
vals
)
==
2
and
not
reps_first
:
elif
len
(
vals
)
==
2
and
not
reps_first
:
print
(
loop_args
,
loop_kwargs
)
for
k
,
x
in
enumerate
(
vals
[
0
]):
for
k
,
x
in
enumerate
(
vals
[
0
]):
vals
[
0
].
pre_loop
(
x
,
*
loop_args
,
**
loop_kwargs
)
vals
[
0
].
pre_loop
(
x
,
*
loop_args
,
**
loop_kwargs
)
_nested_loop_over
(
_nested_loop_over
(
...
@@ -313,19 +313,25 @@ def ndscan(
...
@@ -313,19 +313,25 @@ def ndscan(
_vals
=
[
ScanVals
(
list
(
range
(
reps
)))]
+
vals
_vals
=
[
ScanVals
(
list
(
range
(
reps
)))]
+
vals
else
:
else
:
_vals
=
vals
+
[
ScanVals
(
list
(
range
(
reps
)))]
_vals
=
vals
+
[
ScanVals
(
list
(
range
(
reps
)))]
TOT
=
prod
(
len
(
X
)
for
X
in
_vals
)
t0
=
timeit
.
default_timer
()
_nested_loop_over
(
_nested_loop_over
(
_vals
,
_vals
,
loop_func
,
loop_func
,
list
(),
list
(),
[
prod
(
len
(
X
)
for
X
in
_vals
)
],
[
TOT
],
f
"
\r
"
,
"
"
,
list
()
if
loop_args
is
None
else
loop_args
,
list
()
if
loop_args
is
None
else
loop_args
,
dict
()
if
loop_kwargs
is
None
else
loop_kwargs
,
dict
()
if
loop_kwargs
is
None
else
loop_kwargs
,
reps_first
,
reps_first
,
printflag
,
printflag
,
)
)
T
=
timeit
.
default_timer
()
-
t0
if
printflag
:
if
printflag
:
print
(
""
)
print
(
f
"
\n
total time elapsed:
{
T
:
.
2
f
}
s
"
f
"
\n
average time per shot:
{
T
/
TOT
:
.
2
f
}
s
"
)
def
map_scanvars
(
def
map_scanvars
(
scan_maps
:
Sequence
[
tuple
[
Callable
[[
T
,
...],
...],
dict
[
str
,
Sequence
[
T
]]]],
scan_maps
:
Sequence
[
tuple
[
Callable
[[
T
,
...],
...],
dict
[
str
,
Sequence
[
T
]]]],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment