Skip to content
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

Merged
merged 2 commits into from
Sep 26, 2024
Merged

Conversation

jokasimr
Copy link
Contributor

Fixes scipp/essreflectometry#81

  • Is NexusStructureError the right kind of error to raise if the transform is missing the vector attribute?

try:
dg = maybe_transformation(self, value=dg, sel=sel)
except (sc.DimensionError, NexusStructureError) as e:
self._warn_fallback(e)
Copy link
Member

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?

Copy link
Contributor Author

@jokasimr jokasimr Sep 26, 2024

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?

Comment on lines 90 to 91
if self.attrs.get('vector') is None:
raise NexusStructureError('A transformation needs a vector attribute')
Copy link
Member

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.

Copy link
Contributor Author

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 Show resolved Hide resolved
Comment on lines 90 to 91
if self.attrs.get('vector') is None:
raise TransformationError('A transformation needs a vector attribute.')
Copy link
Member

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?

@jokasimr jokasimr merged commit cd17d10 into main Sep 26, 2024
4 checks passed
@jokasimr jokasimr deleted the nxtransformation-warn branch September 26, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix nightly builds
2 participants