astropy / specreduce

Tools for the reduction of spectroscopic observations from Optical and NIR instruments
https://specreduce.readthedocs.io
62 stars 38 forks source link

Refactor reference file loading #233

Open hpparvi opened 1 week ago

hpparvi commented 1 week ago

This PR addresses Issue #169 (also discussed in PR #165) by using the astropy.config.ConfigNamespace.set_temp context manager to temporarily set the default data download URL and then using either astropy.utils.data.get_pkg_data_fileobj or astropy.utils.data.get_pkg_data_filename to get a readable file or a path to the downloaded and cached file.

However, I'm not convinced this approach leads to more elegant code than the original one. We eliminate the two wrapper functions, but the file-handling code is somewhat messy because of all the nesting. Please take a look and let me know what you think.

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 80.00000% with 10 lines in your changes missing coverage. Please review.

Project coverage is 83.61%. Comparing base (ef38dc0) to head (e775f39).

Files with missing lines Patch % Lines
specreduce/calibration_data.py 80.00% 10 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #233 +/- ## ========================================== + Coverage 83.36% 83.61% +0.25% ========================================== Files 13 13 Lines 1136 1129 -7 ========================================== - Hits 947 944 -3 + Misses 189 185 -4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features: