Skip to content

Commit

Permalink
Compatibility with Python 3.9, unit test for Pypeline.list_attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstolker committed Sep 28, 2021
1 parent 9c7b228 commit 250c253
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation
============

PynPoint is compatible with Python 3.7/3.8. Earlier versions (up to v0.7.0) are also compatible with Python 2.7.
PynPoint is compatible with Python 3.7/3.8/3.9. Earlier versions (up to v0.7.0) are also compatible with Python 2.7.

.. _virtual_environment:

Expand Down
19 changes: 8 additions & 11 deletions pynpoint/core/pypeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,30 +772,27 @@ def list_attributes(self,
Dictionary with all attributes, both static and non-static.
"""

data_text = f'Attribute overview of {data_tag}'
print_text = f'Attribute overview of {data_tag}'

print('\n' + len(data_text) * '-')
print(data_text)
print(len(data_text) * '-' + '\n')
print('\n' + len(print_text) * '-')
print(print_text)
print(len(print_text) * '-' + '\n')

self.m_data_storage.open_connection()

attributes = {}

print('Static attributes:')

for key in self.m_data_storage.m_data_bank[data_tag].attrs:
value = self.m_data_storage.m_data_bank[data_tag].attrs[key]
for key, value in self.m_data_storage.m_data_bank[data_tag].attrs.items():
attributes[key] = value
print(f'\n - {key} = {value}')

print('\nNon-static attributes:')

for key in self.m_data_storage.m_data_bank[f'header_{data_tag}']:
value = self.m_data_storage.m_data_bank[f'header_{data_tag}/{key}']
value = list(value)
attributes[key] = value
print(f'\n - {key} = {value}')
for key, value in self.m_data_storage.m_data_bank[f'header_{data_tag}'].items():
attributes[key] = list(value)
print(f'\n - {key} = {list(value)}')

self.m_data_storage.close_connection()

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
astropy ~= 4.1.0
emcee ~= 3.0.0
h5py ~= 3.1.0
numba ~= 0.52.0
numba ~= 0.54.0
numpy ~= 1.19.0
opencv-python ~= 4.4.0
photutils ~= 1.1.0
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'Natural Language :: English',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
tests_require=['pytest'],
)
12 changes: 12 additions & 0 deletions tests/test_core/test_pypeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ def test_get_tags(self) -> None:

assert pipeline.get_tags() == ['images']

def test_list_attributes(self) -> None:

pipeline = Pypeline(self.test_dir, self.test_dir, self.test_dir)

attr_dict = pipeline.list_attributes('images')

assert len(attr_dict) == 11
assert attr_dict['INSTRUMENT'] == 'IMAGER'
assert attr_dict['PIXSCALE'] == 0.027
assert attr_dict['NFRAMES'] == [5]
assert attr_dict['PARANG_START'] == [10.]

def test_set_and_get_attribute(self) -> None:

pipeline = Pypeline(self.test_dir, self.test_dir, self.test_dir)
Expand Down

0 comments on commit 250c253

Please sign in to comment.