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

radec_to_desiname should include bounds checks #206

Closed
weaverba137 opened this issue May 7, 2024 · 3 comments · Fixed by #207
Closed

radec_to_desiname should include bounds checks #206

weaverba137 opened this issue May 7, 2024 · 3 comments · Fixed by #207
Assignees

Comments

@weaverba137
Copy link
Member

As mentioned in desihub/desispec#2238, NaN can result in obviously bad values of DESINAME:

>>> import numpy as np
>>> from desiutil.names import radec_to_desiname
>>> radec_to_desiname(np.nan, np.nan)
array(['DESI J-922337203685477.5808-922337203685477.5808'], dtype='<U48')

Other bounds should also be checked:

  • NaN
  • Inf
  • RA not in [0, 360).
  • Dec not in [-90, 90].

The proposal is that any value that exceeds these bounds should trigger an exception. We can issue exception messages that are easy to understand, e.g., "Dec values outside of the range [-90, 90] detected." but it should still raise the exception rather than "soldiering on".

@sbailey, @akremin, @schlafly any opinions on the exception, or other bounds that should be checked?

@weaverba137 weaverba137 self-assigned this May 7, 2024
@weaverba137 weaverba137 added this to Jura May 7, 2024
@weaverba137 weaverba137 moved this to Todo in Jura May 7, 2024
@akremin
Copy link
Member

akremin commented May 7, 2024

I think a ValueError for the 4 checks you mentioned would make a lot of sense.

@sbailey
Copy link
Contributor

sbailey commented May 7, 2024

Sounds good, and +1 for including an informative exception message. I'd suggest also including the invalid value itself in the message and not just that an invalid value was detected and what the good range is.

@weaverba137
Copy link
Member Author

@sbailey I thought about that, but it could be inconvenient if the inputs are large arrays. Inf or NaN is easy, I'm thinking more about out-of-bounds RA, Dec.

@weaverba137 weaverba137 moved this from Todo to In Progress in Jura May 7, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Jura May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants