Skip to content

Commit

Permalink
Merge pull request astropy#10416 from pllim/shhh-win-depre-warn
Browse files Browse the repository at this point in the history
Silence deprecation warning we cannot control
  • Loading branch information
saimn authored and astrofrog committed Sep 16, 2020
1 parent 7b194f9 commit 987c95c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
10 changes: 6 additions & 4 deletions astropy/io/fits/hdu/hdulist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Licensed under a 3-clause BSD style license - see PYFITS.rst


import gzip
import itertools
import os
Expand Down Expand Up @@ -354,7 +353,7 @@ def __setitem__(self, key, hdu):
self._try_while_unread_hdus(super().__setitem__, _key, hdu)
except IndexError:
raise IndexError('Extension {} is out of bound or not found.'
.format(key))
.format(key))

self._resize = True
self._truncate = False
Expand Down Expand Up @@ -803,7 +802,7 @@ def flush(self, output_verify='fix', verbose=False):

if self._file.mode not in ('append', 'update', 'ostream'):
warnings.warn("Flush for '{}' mode is not supported."
.format(self._file.mode), AstropyUserWarning)
.format(self._file.mode), AstropyUserWarning)
return

save_backup = self._open_kwargs.get('save_backup', False)
Expand Down Expand Up @@ -1354,7 +1353,10 @@ def _flush_resize(self):
# flushing (on Windows--again, this is no problem on Linux).
for idx, mmap, arr in mmaps:
if mmap is not None:
arr.data = self[idx].data.data
# https://github.com/numpy/numpy/issues/8628
with warnings.catch_warnings():
warnings.simplefilter('ignore', category=DeprecationWarning)
arr.data = self[idx].data.data
del mmaps # Just to be sure

else:
Expand Down
5 changes: 0 additions & 5 deletions astropy/io/fits/tests/test_hdulist.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,11 +619,6 @@ def test_update_with_truncated_header(self):
with fits.open(self.temp('temp.fits')) as hdul:
assert (hdul[0].data == data).all()

# This test used to fail on Windows - if it fails again in future, see
# https://github.com/astropy/astropy/issues/5797
# The warning appears on Windows but cannot be explicitly caught.
@pytest.mark.filterwarnings("ignore:Assigning the 'data' attribute is an "
"inherently unsafe operation")
def test_update_resized_header(self):
"""
Test saving updates to a file where the header is one block smaller
Expand Down
5 changes: 0 additions & 5 deletions astropy/io/fits/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,6 @@ def test_primary_with_extname(self):
with fits.open(self.temp('test.fits')) as hdul:
assert hdul[0].name == 'XPRIMARY2'

# This test used to fail on Windows - if it fails again in future, see
# https://github.com/astropy/astropy/issues/5797
# The warning appears on Windows but cannot be explicitly caught.
@pytest.mark.filterwarnings("ignore:Assigning the 'data' attribute is an "
"inherently unsafe operation")
def test_io_manipulation(self):
# Get a keyword value. An extension can be referred by name or by
# number. Both extension and keyword names are case insensitive.
Expand Down

0 comments on commit 987c95c

Please sign in to comment.