Skip to content

Commit

Permalink
Add check for empty IFC in filtering
Browse files Browse the repository at this point in the history
The ``files_filtered()`` method chokes on a ``'NoneType' object is not
subscriptable`` error if the ImageFileCollection is already empty before being
asked to filter further.

This commit adds a check for empty IFC and simply passes an empty list for the
set of files in the collection.

	modified:   CHANGES.rst
	modified:   ccdproc/image_collection.py
  • Loading branch information
tbowers7 committed Jan 24, 2023
1 parent 623162d commit 65ec437
Show file tree
Hide file tree
Showing 2 changed files with 19 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

0 comments on commit 65ec437

Please sign in to comment.