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

Check camera json encoding #237

Merged
merged 2 commits into from
Jan 1, 2024

Conversation

mwcraig
Copy link
Contributor

@mwcraig mwcraig commented Dec 31, 2023

This fixes an oversight from #231 in which I forgot to add a json encoder for units.

@mwcraig mwcraig added the refactor Summer 2023 project to rewrite stellarphot label Dec 31, 2023
@mwcraig mwcraig requested a review from JuanCab December 31, 2023 16:37
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cd69d8c) 54.44% compared to head (1826b76) 54.44%.
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@JuanCab JuanCab left a 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())
Copy link
Contributor

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}",
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@mwcraig mwcraig merged commit a35aa74 into feder-observatory:main Jan 1, 2024
8 checks passed
@mwcraig mwcraig deleted the check-camera-encoding branch February 8, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Summer 2023 project to rewrite stellarphot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants