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

Support Astropy Quantity as radius arg for Registry SkyCoord Spatial constraint #594

Merged
merged 2 commits into from
Sep 13, 2024

Conversation

duytnguyendtn
Copy link
Contributor

@duytnguyendtn duytnguyendtn commented Sep 11, 2024

Hi PyVO maintainers!

This PR adds a small quality of life improvement to the Spatial registry constraint, to allow an astropy quantity to be provided for the radius argument. Was implementing this downstream in Jdaviz, but figured it would be broadly useful here as well?

I've added a simple test to verify the unit conversion back to degrees, as well as testing for invalid units.

I'll add a changelog entry once a PR number is assigned.

Thanks!
Duy

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.47%. Comparing base (1c8741c) to head (13e4abe).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #594      +/-   ##
==========================================
+ Coverage   81.46%   81.47%   +0.01%     
==========================================
  Files          68       68              
  Lines        7034     7039       +5     
==========================================
+ Hits         5730     5735       +5     
  Misses       1304     1304              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the error message as e.g. degree works there just as well as radians.

@@ -719,9 +719,16 @@ def tomoc(s):

elif len(geom_spec) == 2:
if isinstance(geom_spec[0], SkyCoord):
# If radius given is astropy quantity, then convert to degrees
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this case to the docstring, and possibly an example to the narrative docs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried my best to write useful examples!

Docstring example implemented in: be70c43

Narrative example implemented in: d91c80a

How do those look?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re narrative docs: There is value to list the expected outputs, so I'll add those to your example, as well as will remove the IGNORE_OUTPUT, as we use that only for cases where results are expected to chang often or are unpredictable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(ahh, never mind, I see that we already have that in the previous example)

pyvo/registry/rtcons.py Outdated Show resolved Hide resolved
@bsipocz bsipocz added this to the v1.6 milestone Sep 11, 2024
@bsipocz
Copy link
Member

bsipocz commented Sep 11, 2024

I'll look into the (unrelated) CI failure separately. In the meantime, would you mind squashing the commits a bit to remove the incremental convergence done in the last ~4?

(you can also run test locally either using the same tox commands the CI does, or by running pytest pyvo -R and flake8 pyvo, those would smoke out most of these.

@duytnguyendtn
Copy link
Contributor Author

Ahh does PyVO not usually squash PR commits at merge time? I'm admittedly reckless when it comes to my commits due to the assumption they'll get squashed anyways when it gets accepted. I'll clean up the commit history now!

@bsipocz
Copy link
Member

bsipocz commented Sep 11, 2024

Ahh does PyVO not usually squash PR commits at merge time

No, we assume nice logical chunks for commits 😅. It takes some time to get used to, but comes second nature soon enough. (and given that we have large PRs, I find it useful to have them merged in in a manageable sequence into main, it will make it easier to dig back history/bugs as opposed to have one gigantic commit on merge and then a likely messy commit history separately in a PR).

So TL;DR: no need to squash down to 1 commit, but limit the one-liner CI wrangler ones once a PR is ready for review/merge.

@duytnguyendtn duytnguyendtn changed the title Support Astropy Quantity as SkyCoord radius arg Registry Spatial constraint Support Astropy Quantity as radius arg for Registry SkyCoord Spatial constraint Sep 11, 2024
@bsipocz bsipocz merged commit 0aa02a6 into astropy:main Sep 13, 2024
13 checks passed
@bsipocz
Copy link
Member

bsipocz commented Sep 13, 2024

Thank you @duytnguyendtn!

@bsipocz
Copy link
Member

bsipocz commented Oct 11, 2024

Having a look at this, we can interpret this PR as a bugfix, as quantities should have been supported already. So I'll remilestone, which will also help the jdaviz folks.

@bsipocz bsipocz modified the milestones: v1.6, v1.5.3 Oct 11, 2024
bsipocz added a commit that referenced this pull request Oct 14, 2024
Support Astropy Quantity as radius arg for Registry SkyCoord Spatial constraint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants