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

Close FITS files after loading #330

Merged
merged 2 commits into from
Jan 9, 2023
Merged

Conversation

svank
Copy link
Contributor

@svank svank commented Dec 28, 2022

I noticed a comment pointing out that when FITS file names are passed for the input data, the file is opened but never closed. Changing that looked like a quick fix, and should be safe---after the file is opened, parse_input_data calls itself a few times before eventually extracting the .data and .header attributes of the selected HDU and returning those, so the HDUL object never leaves parse_input_data. (Not sure if the garbage collector would have eventually closed everything anyway.)

While checking that this was covered by existing tests, I saw that the parse_input_data tests were checking the data array that gets returned but not the corresponding WCS, so I augmented those tests to check both.

(The CI failure appears to be pre-existing)

@codecov
Copy link

codecov bot commented Dec 28, 2022

Codecov Report

Merging #330 (6fbceb0) into main (aa23eb1) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #330      +/-   ##
==========================================
+ Coverage   91.75%   91.77%   +0.01%     
==========================================
  Files          24       24              
  Lines         716      717       +1     
==========================================
+ Hits          657      658       +1     
  Misses         59       59              
Impacted Files Coverage Δ
reproject/utils.py 87.83% <100.00%> (+0.08%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@astrofrog astrofrog merged commit 775171d into astropy:main Jan 9, 2023
@astrofrog astrofrog changed the title Close fits files after loading Close FITS files after loading Jan 30, 2023
@svank svank deleted the close-fits-files branch June 23, 2023 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants