Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pes_to_spec
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
Machine Learning projects.
pes_to_spec
Commits
cc84e420
Commit
cc84e420
authored
1 year ago
by
Danilo Ferreira de Lima
Browse files
Options
Downloads
Patches
Plain Diff
Fixes several points found by Cammille.
parent
22f1d63b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!26
Added example for SCS.
Pipeline
#132017
passed
1 year ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pes_to_spec/config.py
+11
-7
11 additions, 7 deletions
pes_to_spec/config.py
with
11 additions
and
7 deletions
pes_to_spec/config.py
+
11
−
7
View file @
cc84e420
...
...
@@ -23,13 +23,15 @@ class VSConfig(object):
"
SA3_XTD10_PES/DCTRL/V30330S_XENON
"
,
]
def
__init__
(
self
,
other
=
None
):
def
__init__
(
self
,
other
:
object
=
None
):
self
.
voltage
:
Dict
[
str
,
float
]
=
dict
()
self
.
voltage_tol
:
Dict
[
str
,
float
]
=
dict
()
self
.
pressure
:
float
=
np
.
nan
self
.
pressure_tol
:
float
=
np
.
nan
self
.
gas
:
Set
[
str
]
=
set
()
if
other
is
not
None
:
if
not
isinstance
(
other
,
VSConfig
):
raise
ValueError
(
"
The argument given in the constructor must be another class of type VSConfig.
"
)
self
.
voltage
=
deepcopy
(
other
.
voltage
)
self
.
voltage_tol
=
deepcopy
(
other
.
voltage_tol
)
self
.
pressure
=
deepcopy
(
other
.
pressure
)
...
...
@@ -92,16 +94,18 @@ class VSConfig(object):
errors
+=
[
f
"
Multiple gas active during the data:
{
self
.
gas
}
.
"
]
return
errors
def
__sub__
(
self
,
other
:
'
VSConfig
'
)
->
'
VSConfig
'
:
def
__sub__
(
self
,
other
:
object
)
->
'
VSConfig
'
:
"""
Take difference between two configuratons.
"""
if
not
isinstance
(
other
,
VSConfig
):
raise
ValueError
(
"
I can only subtract with another VSConfig object.
"
)
diff
=
VSConfig
(
self
)
diff
.
voltage
=
{
k
:
self
.
voltage
[
k
]
-
other
.
voltage
[
k
]
for
k
in
self
.
voltage
}
diff
.
voltage
=
{
k
:
v
-
other
.
voltage
[
k
]
for
k
,
v
in
self
.
voltage
.
items
()
}
diff
.
pressure
=
self
.
pressure
-
other
.
pressure
diff
.
voltage_tol
=
{
k
:
np
.
sqrt
(
self
.
voltage_tol
[
k
]
**
2
+
other
.
voltage_tol
[
k
]
**
2
)
for
k
in
self
.
voltage_tol
}
diff
.
voltage_tol
=
{
k
:
np
.
sqrt
(
v
**
2
+
other
.
voltage_tol
[
k
]
**
2
)
for
k
in
self
.
voltage_tol
.
items
()
}
diff
.
pressure_tol
=
np
.
sqrt
(
self
.
pressure_tol
**
2
+
other
.
pressure_tol
**
2
)
diff
.
gas
=
set
(
self
.
gas
).
difference
(
set
(
other
.
gas
))
return
diff
...
...
@@ -113,7 +117,7 @@ class VSConfig(object):
if
not
isinstance
(
other
,
VSConfig
):
raise
ValueError
(
"
I can only check equality with another VSConfig object.
"
)
diff
=
self
-
other
for
k
,
v
in
diff
.
voltage
.
item
s
():
for
v
in
diff
.
voltage
.
value
s
():
if
np
.
fabs
(
v
)
>
0.1
:
return
False
if
np
.
fabs
(
diff
.
pressure
)
>
diff
.
pressure_tol
:
...
...
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