Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ess-python-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
ESS Beam Physics
ess-python-tools
Commits
c6055b20
Commit
c6055b20
authored
3 years ago
by
Yngve Levinsen
Browse files
Options
Downloads
Patches
Plain Diff
TraceWin.project new data type int:list
parent
428b252c
No related branches found
Branches containing commit
Tags
2.12.0
Tags containing commit
No related merge requests found
Pipeline
#91296
passed
3 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ess/TraceWin.py
+28
-2
28 additions, 2 deletions
ess/TraceWin.py
ess/data/tw_project_file_reverse_engineered.json
+11
-2
11 additions, 2 deletions
ess/data/tw_project_file_reverse_engineered.json
with
39 additions
and
4 deletions
ess/TraceWin.py
+
28
−
2
View file @
c6055b20
...
...
@@ -1598,6 +1598,16 @@ class project:
if
vals
.
count
(
True
)
!=
1
:
raise
ValueError
(
f
"
Did not find
{
key
}
to be set correctly
"
)
self
.
_dict
[
key
]
=
o
[
-
1
][
vals
.
index
(
True
)]
elif
o
[
1
]
==
"
int:list
"
:
current
=
""
.
join
(
hexlist
[
o
[
0
]
:
o
[
0
]
+
o
[
2
]])
value
=
struct
.
unpack
(
"
i
"
,
b
""
.
fromhex
(
current
))[
0
]
found
=
False
for
k
,
v
in
o
[
3
].
items
():
if
v
==
value
:
self
.
_dict
[
key
]
=
k
found
=
True
if
not
found
:
raise
ValueError
(
"
Unknown setting {value} for {key}
"
)
elif
o
[
1
]
==
"
str
"
:
string
=
self
.
_find_string
(
hexlist
,
o
[
0
],
o
[
2
])
self
.
_dict
[
key
]
=
bytes
.
fromhex
(
string
).
decode
(
"
utf-8
"
)
...
...
@@ -1642,6 +1652,14 @@ class project:
"""
Get the type of parameter
as specified in the reference file
d : double value
i : integer value,
int:list : integer representing a list selection
bool:list : booleans representing a list selection
For int:list and bool:list, recommend to use get_options()
to figure out how to set as a user.
"""
return
self
.
_refdict
[
parameter
][
1
]
...
...
@@ -1650,7 +1668,10 @@ class project:
Get the possible options for parameter
as specified in the reference file
"""
return
self
.
_refdict
[
parameter
][
-
1
]
if
isinstance
(
self
.
_refdict
[
parameter
][
-
1
],
dict
):
return
list
(
self
.
_refdict
[
parameter
][
-
1
].
keys
())
else
:
return
self
.
_refdict
[
parameter
][
-
1
]
def
set
(
self
,
parameter
,
value
):
"""
...
...
@@ -1663,7 +1684,7 @@ class project:
elif
isinstance
(
current
,
(
float
,
int
)):
if
not
isinstance
(
value
,
(
float
,
int
)):
raise
ValueError
(
f
"
{
parameter
}
should be a number
"
)
elif
self
.
get_type
(
parameter
)
==
"
bool:list
"
:
elif
self
.
get_type
(
parameter
)
in
[
"
bool:list
"
,
"
int:list
"
]
:
opts
=
self
.
get_options
(
parameter
)
if
value
not
in
opts
:
raise
ValueError
(
f
"
{
parameter
}
should be one of
{
opts
}
"
)
...
...
@@ -1750,6 +1771,11 @@ class project:
else
:
t
=
False
hexlist
[
i
]
=
struct
.
pack
(
"
?
"
,
t
).
hex
()
elif
o
[
1
]
==
"
int:list
"
:
v
=
o
[
-
1
][
v
]
v
=
wrap
(
struct
.
pack
(
"
i
"
,
v
).
hex
(),
2
)
for
i
in
range
(
len
(
v
)):
hexlist
[
o
[
0
]
+
i
]
=
v
[
i
]
elif
o
[
1
]
==
"
str
"
:
v
=
self
.
_unset_string_rules
(
key
,
v
)
h
=
wrap
(
v
.
encode
(
encoding
=
"
utf_8
"
).
hex
(),
2
)
...
...
This diff is collapsed.
Click to expand it.
ess/data/tw_project_file_reverse_engineered.json
+
11
−
2
View file @
c6055b20
...
...
@@ -168,8 +168,17 @@
],
"mp:input_distr"
:
[
8732
,
"i"
,
4
"int:list"
,
4
,
{
"4Dellipse"
:
1
,
"2phaseplane"
:
2
,
"kv"
:
3
,
"4DtransvHyp"
:
4
,
"realspace"
:
5
,
"parmila"
:
7
,
"inputfile"
:
9
}
],
"mp:input_distr_mask_transv"
:
[
8728
,
...
...
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