Skip to content

Commit

Permalink
Code review fixups.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtauraso committed Aug 27, 2024
1 parent da5320f commit 9cd3680
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/fibad/data_loaders/hsc_data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def _scan_file_dimensions(self) -> dict[str, tuple[int, int]]:
def _prune_objects(self, filters_ref: list[str]) -> list[str]:
"""Class initialization helper. Prunes objects from the list of objects.
1) Removes any objects which do not ahve all the filters specified in filters_ref
1) Removes any objects which do not have all the filters specified in filters_ref
2) If a cutout_shape was provided in the constructor, prunes files that are too small
for the chosen cutout size
Expand Down Expand Up @@ -210,7 +210,7 @@ def _fits_file_dims(self, filepath):
return hdul[1].shape

def _check_file_dimensions(self) -> tuple[int, int]:
"""Class initialization helper. Find the minimal pixel size that all images can support
"""Class initialization helper. Find the maximal pixel size that all images can support
It is assumed that all the cutouts will be of very similar size; however, HSC's cutout
server does not return exactly the same number of pixels for every query, even when it
Expand All @@ -227,7 +227,7 @@ def _check_file_dimensions(self) -> tuple[int, int]:
The minimum width and height in pixels of the entire dataset. In other words: the maximal image
size in pixels that can be generated from ALL cutout images via cropping.
"""
# Find the minimum cutout size that all images can support
# Find the makximal cutout size that all images can support
all_widths = [shape[0] for shape_list in self.dims.values() for shape in shape_list]
cutout_width = np.min(all_widths)

Expand Down
9 changes: 6 additions & 3 deletions tests/fibad/test_hsc_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ def test_prune_warn_1_percent(caplog):
# We should Error log because greater than 5% of the objects were pruned
assert "Greater than 1% of objects in the data directory were pruned." in caplog.text

# We should warn that we dropped an object explicitly
assert "Dropping object" in caplog.text


def test_prune_error_5_percent(caplog):
"""Test to ensure when >5% of loaded objects are missing a filter, that is an error
Expand Down Expand Up @@ -232,7 +235,7 @@ def test_crop_warn_2px_larger(caplog):
assert len(a) == 70
assert a.shape() == (5, 99, 99)

# No warnings should be printed since we're within 1px of the mean size
# We should warn that images differ
assert "Some images differ" in caplog.text


Expand All @@ -258,7 +261,7 @@ def test_crop_warn_2px_smaller(caplog):
assert len(a) == 70
assert a.shape() == (5, 98, 98)

# No warnings should be printed since we're within 1px of the mean size
# We should warn that images differ
assert "Some images differ" in caplog.text


Expand All @@ -279,6 +282,6 @@ def test_prune_size(caplog):
assert len(a) == 20
assert a.shape() == (5, 99, 99)

# No warnings should be printed since we're within 1px of the mean size
# We should warn that we are dropping objects and the reason
assert "Dropping object" in caplog.text
assert "too small" in caplog.text

0 comments on commit 9cd3680

Please sign in to comment.