-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: warn if missing vector in transformation #242
Conversation
src/scippnexus/base.py
Outdated
try: | ||
dg = maybe_transformation(self, value=dg, sel=sel) | ||
except (sc.DimensionError, NexusStructureError) as e: | ||
self._warn_fallback(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is actually the wrong warning, since it will say "failed to load as NXlog", but that part worked. The subsequent parsing of the log as a transform failed. Maybe moving the try/catch into maybe_transformation
is better after all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the test into maybe_transformation
instead, and made it emit the warning if the transform loading errored out for any reason. Is that desirable?
src/scippnexus/nxtransformations.py
Outdated
if self.attrs.get('vector') is None: | ||
raise NexusStructureError('A transformation needs a vector attribute') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think using this error is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using TransformationError
?
src/scippnexus/nxtransformations.py
Outdated
if self.attrs.get('vector') is None: | ||
raise TransformationError('A transformation needs a vector attribute.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better put this into self.vector
?
71dc6c8
to
0b7667d
Compare
Fixes scipp/essreflectometry#81
NexusStructureError
the right kind of error to raise if the transform is missing thevector
attribute?