Skip to content

Commit

Permalink
Merge pull request #151 from sot/support-slicing
Browse files Browse the repository at this point in the history
Support slicing of ACAReviewTable
  • Loading branch information
taldcroft authored Apr 1, 2021
2 parents f9e1247 + 6ec1d36 commit c44fa5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sparkles/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ def __init__(self, *args, **kwargs):
# Make a copy of input aca table along with a deepcopy of its meta.
super().__init__(*args, **kwargs)

# If no data were provided then skip all the rest of the initialization.
# This happens during slicing. The result is not actually
# a functional ACAReviewTable, but it allows inspection of data.
if len(self.colnames) == 0:
return

self.is_roll_option = is_roll_option

# Add row and col columns from yag/zag, if not already there.
Expand Down
13 changes: 13 additions & 0 deletions sparkles/tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
from .. import ACAReviewTable


def test_check_slice_index():
"""Test slice and index"""
stars = StarsTable.empty()
stars.add_fake_constellation(n_stars=8, mag=10.25)
aca = get_aca_catalog(**STD_INFO, stars=stars, dark=DARK40)
acar = aca.get_review_table()
for item in (1, slice(5, 10)):
acar1 = acar[item]
assert acar1.colnames == acar.colnames
for name in acar1.colnames:
assert np.all(acar1[name] == acar[name][item])


def test_check_P2():
"""Test the check of acq P2"""
stars = StarsTable.empty()
Expand Down

0 comments on commit c44fa5c

Please sign in to comment.