-
Notifications
You must be signed in to change notification settings - Fork 268
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
Add a trait for astropy quantities #2524
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2524 +/- ##
==========================================
+ Coverage 92.53% 92.62% +0.08%
==========================================
Files 235 233 -2
Lines 20063 20139 +76
==========================================
+ Hits 18565 18653 +88
+ Misses 1498 1486 -12 ☔ View full report in Codecov by Sentry. |
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.
Nice! One suggestion would be to add the ability to set a physical type or default unit, and have it fail if the user tries to set the value to a quantity that is not convertable.
I.e. if my trait is called energy_min
and the user tries to set it to "12 m" it should fail.
That would mean either
- adding a new field to the contructor for "physical_type"
- just assuming if there is a default value, that any value should be convertable to the unit of that default and if no raise an error
The case where there is no unit check should still be handled, since there are use cases where you don't know the unit in advance.
Also missing are tests for setting quantities from the command line and in config files. For the CLI, you have to implement |
I implemented |
Would be nice to make sure, can be as simple as:
and maybe add a test that the error message is nice on invalid input |
Analysis Details4 IssuesCoverage and DuplicationsProject ID: cta-observatory_ctapipe_AY52EYhuvuGcMFidNyUs |
@kosack I think this is ready, you requested changes so merger is currently blocked. Could you please check that your requested changes were implemented? |
Having a configurable trait containing an
astropy.units.Quantity
is useful for the irf tool and will probably be useful for other high-level tools, too.