Skip to content

Commit

Permalink
Use existing 'readall' method instead of new '_read_all_hdus'
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella committed Feb 13, 2018
1 parent 8ea8030 commit e93dda4
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions astropy/io/fits/hdu/hdulist.py
Expand Up @@ -238,14 +238,14 @@ def __init__(self, hdus=[], file=None):

def __len__(self):
if not self._in_read_next_hdu:
self._read_all_hdus()
self.readall()

return super().__len__()

def __repr__(self):
# In order to correctly repr an HDUList we need to load all the
# HDUs as well
self._read_all_hdus()
self.readall()

return super().__repr__()

Expand Down Expand Up @@ -510,13 +510,9 @@ def fileinfo(self, index):

return output

def _read_all_hdus(self):
while self._read_next_hdu():
pass

def pop(self, index=-1):
# Make sure that HDUs are loaded before attempting to pop
self._read_all_hdus()
self.readall()
return super(HDUList, self).pop(index)

def insert(self, index, hdu):
Expand Down Expand Up @@ -718,10 +714,8 @@ def readall(self):
"""
Read data of all HDUs into memory.
"""

for hdu in self:
if hdu.data is not None:
continue
while self._read_next_hdu():
pass

@ignore_sigint
def flush(self, output_verify='fix', verbose=False):
Expand Down

0 comments on commit e93dda4

Please sign in to comment.