-
Notifications
You must be signed in to change notification settings - Fork 12
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
Check camera json encoding #237
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #237 +/- ##
=======================================
Coverage 54.44% 54.44%
=======================================
Files 23 23
Lines 2911 2911
=======================================
Hits 1585 1585
Misses 1326 1326 ☔ 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.
Looks good assuming the test passes.
max_data_value=max_val, | ||
) | ||
|
||
c2 = Camera.parse_raw(c.json()) |
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.
Seems like a reasonable test.
@@ -240,7 +240,8 @@ class Config: | |||
json_encoders = { | |||
Quantity: lambda v: f"{v.value} {v.unit}", | |||
QuantityType: lambda v: f"{v.value} {v.unit}", | |||
UnitType: lambda v: f"{v}", | |||
Unit: lambda v: f"{v}", |
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 assume this sets it up some you store both the units and irreducible units in JSON. Do you know why this is more 'round-trippable'? Is it because UnitType isn't an actual astropy object but Unit and IrreducibleUnit are?
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 it is because the encoding is done based on the type of the setting, eg. Unit
or IrreducibleUnit
. I could have used just IrreducibleUnit
here but in principle units could be more complicated, e.g. aand image data unit of electron / sec
or something.
This fixes an oversight from #231 in which I forgot to add a json encoder for units.