Skip to content

Commit

Permalink
Merge pull request #801 from tbowers7/bugfix_empty_ifc
Browse files Browse the repository at this point in the history
Add check for empty IFC in filtering
  • Loading branch information
mwcraig committed May 30, 2023
2 parents 822f645 + b02f2e1 commit dd21411
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2.4.1 (unreleased)
------------------

New Features
^^^^^^^^^^^^

Other Changes and Additions
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Bug Fixes
^^^^^^^^^

- Fixes a crash when attempting to filter an already-empty ImageFileCollection,
instead simply returning an empty ImageFileCollection. [#801]

2.4.0 (2022-11-16)
------------------

Expand Down
4 changes: 4 additions & 0 deletions ccdproc/image_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ def files_filtered(self, **kwd):
Value comparison is case *insensitive* for strings, whether matching
exactly or matching with regular expressions.
"""
# If the collection is empty, self.summary == None; return empty list
if self.summary is None:
return []

# force a copy by explicitly converting to a list
current_file_mask = self.summary['file'].mask.tolist()

Expand Down
1 change: 1 addition & 0 deletions ccdproc/tests/test_image_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ def test_type_of_empty_collection(self, triage_setup):
ic = ImageFileCollection(triage_setup.test_dir)
assert ic.summary is None
assert ic.keywords == []
assert ic.files_filtered() == []

def test_regex_match_for_search(self, triage_setup):
# Test regex matching in searches
Expand Down

0 comments on commit dd21411

Please sign in to comment.