Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
bliss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
492
Issues
492
List
Boards
Labels
Service Desk
Milestones
Jira
Jira
Merge Requests
134
Merge Requests
134
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bliss
bliss
Commits
d8933038
Commit
d8933038
authored
Feb 04, 2020
by
Valentin Valls
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework the computed items with ComputeError
parent
a7df7a9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
13 deletions
+29
-13
bliss/flint/model/plot_model.py
bliss/flint/model/plot_model.py
+21
-1
bliss/flint/model/plot_state_model.py
bliss/flint/model/plot_state_model.py
+8
-12
No files found.
bliss/flint/model/plot_model.py
View file @
d8933038
...
...
@@ -382,6 +382,16 @@ _NotComputed = object()
"""Allow to flag an attribute as not computed"""
class
ComputeError
(
Exception
):
"""Raised when the `compute` method of AbstractComputableItem can't compute
any output"""
def
__init__
(
self
,
msg
:
str
,
result
=
None
):
super
(
ComputeError
,
self
).
__init__
(
self
,
msg
)
self
.
msg
=
msg
self
.
result
=
result
class
AbstractComputableItem
(
Item
):
"""This item use the scan data to process result before displaying it."""
...
...
@@ -428,7 +438,17 @@ class AbstractComputableItem(Item):
if
scan
.
hasCachedResult
(
self
):
result
=
scan
.
getCachedResult
(
self
)
else
:
result
=
self
.
compute
(
scan
)
try
:
result
=
self
.
compute
(
scan
)
except
ComputeError
as
e
:
scan
.
setCacheValidation
(
self
,
self
.
version
(),
e
.
msg
)
result
=
e
.
result
except
Exception
as
e
:
scan
.
setCacheValidation
(
self
,
self
.
version
(),
"Error while computing:"
+
str
(
e
)
)
result
=
None
scan
.
setCachedResult
(
self
,
result
)
if
not
self
.
isResultValid
(
result
):
return
None
...
...
bliss/flint/model/plot_state_model.py
View file @
d8933038
...
...
@@ -20,12 +20,15 @@ from typing import Optional
from
typing
import
NamedTuple
import
numpy
import
logging
from
.
import
scan_model
from
.
import
plot_model
from
.
import
plot_item_model
from
..utils
import
mathutils
_logger
=
logging
.
getLogger
(
__name__
)
class
CurveStatisticMixIn
:
"""This item use the scan data to process result before displaying it."""
...
...
@@ -60,25 +63,18 @@ class DerivativeItem(plot_model.AbstractComputableItem, plot_item_model.CurveMix
)
->
Optional
[
Tuple
[
numpy
.
ndarray
,
numpy
.
ndarray
]]:
sourceItem
=
self
.
source
()
x
=
sourceItem
.
xData
(
scan
)
y
=
sourceItem
.
yData
(
scan
)
if
x
is
None
or
y
is
None
:
return
None
x
=
x
.
array
()
y
=
y
.
array
()
x
=
sourceItem
.
xArray
(
scan
)
y
=
sourceItem
.
yArray
(
scan
)
if
x
is
None
or
y
is
None
:
return
None
try
:
result
=
mathutils
.
derivate
(
x
,
y
)
except
Exception
as
e
:
# FIXME: Maybe it is better to return a special type and then return
# Managed outside to store it into the validation cache
scan
.
setCacheValidation
(
self
,
self
.
version
(),
"Error while creating derivative.
\n
"
+
str
(
e
)
_logger
.
debug
(
"Error while computing derivative"
,
exc_info
=
True
)
raise
plot_model
.
ComputeError
(
"Error while creating derivative.
\n
"
+
str
(
e
),
result
=
None
)
return
None
return
result
...
...
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