Skip to content

Commit

Permalink
allow height=0
Browse files Browse the repository at this point in the history
because someone might just want the residuals
  • Loading branch information
billbrod committed Dec 2, 2024
1 parent 634aef0 commit 3276e07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ class SteerablePyramidFreq(nn.Module):
image_shape : `list or tuple`
shape of input image
height : 'auto' or `int`
The height of the pyramid. If 'auto', will automatically determine
based on the size of `image`. If an int, must be positive and less than
log2(min(image_shape[1], image_shape[1]))-2.
The height of the pyramid. If 'auto', will automatically determine based on the
size of `image`. If an int, must be non-negative and less than
log2(min(image_shape[1], image_shape[1]))-2. If height=0, this only returns the
residuals.
order : `int`.
The Gaussian derivative order used for the steerable filters, in [1,
15]. Note that to achieve steerability the minimum number of
Expand Down Expand Up @@ -135,8 +136,8 @@ def __init__(
self.num_scales = int(max_ht)
elif height > max_ht:
raise ValueError(f"Cannot build pyramid higher than {max_ht:.0f} levels.")
elif height < 1:
raise ValueError("Height must be a positive int.")
elif height < 0:
raise ValueError("Height must be a non-negative integer.")
else:
self.num_scales = int(height)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_steerable_pyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ def test_scales_arg(self, img, spyr, scales):

@pytest.mark.parametrize("height", range(-1, 8))
def test_height_values(self, img, height):
if height < 1:
if height < 0:
expectation = pytest.raises(
ValueError, match="Height must be a positive int"
ValueError, match="Height must be a non-negative int"
)
elif height > 6:
expectation = pytest.raises(
Expand Down

0 comments on commit 3276e07

Please sign in to comment.