Do better with waveranges#936
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #936 +/- ##
==========================================
- Coverage 75.17% 75.16% -0.02%
==========================================
Files 70 70
Lines 9024 9030 +6
==========================================
+ Hits 6784 6787 +3
- Misses 2240 2243 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
teutoburg
left a comment
There was a problem hiding this comment.
Yeah floats can be nasty. I've added countless round over the years, but it seems there's always more.
|
Oh, I should make sure the test don't fail though |
Yeah, for some reason I didn't see the failures on the app? I do now, whatever. Once everything passes, go ahead and merge. |
|
The tests were useful but annoying. See, indeed does not include the end point But divide everything by 10000, and this happens: where the last two numbers are actually Hmm is that correct behavior from numpy actually? To have Anyway it works now. But I saw the same code is used later in the same function, so I updated that too, but that is apparently untested. |
|
We do have a function |
Weirdness indeed, but at least it is somewhat documented: https://numpy.org/doc/stable/reference/generated/numpy.arange.html
with some bizar examples. Thanks for the includes Maybe we should internally do everything in Or use I'm not sure what the best way to proceed is. Probably to improve the code now, but I don't want to; the patch works... |
Here I meant to only allow integer ångström wavelengths. So we don't need to do any float conversion, just do everything in ints internally. |
That would be my gut instinct option...
Synphot "does everything in AA internally" anyway, and since we depend on it in many places, I think it wouldn't be the worst idea to also do that. Input/output to the user can still be in µm, if everything is in Astropy units that's easy enough... |
| # Cannot test for equality, because this does not hold in astropy.units: | ||
| # 1.98 * u.um == 19800.0 * u.AA | ||
| # assert new_spec.waverange[0] == 1.98 * u.um | ||
| assert abs(new_spec.waverange[0] == 1.98 * u.um) < 1e-10 * u.AA |
There was a problem hiding this comment.
I don't quite understand this line. You're checking for the absolute values of the equality check? Wouldn't that always be a bool?
There was a problem hiding this comment.
Now that this takes 4 lines and occurs twice, maybe consider wrapping it in a utils function?
There were loads of irrelevant warnings being spit out, prevent those by dealing better with floats.