Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Added test for strided inputs in sepfir2d #14558

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions scipy/signal/tests/test_bsplines.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,33 @@ def test_sepfir2d_invalid_image():
with pytest.raises(ValueError, match="object of too small depth"):
signal.sepfir2d(image[0], filt, filt)

def test_sepfir2d():
np.random.seed(1234)
filt = np.array([1.0, 2.0, 4.0, 2.0, 1.0, 3.0, 2.0])
image = np.random.rand(4, 4)

expected = array([[36.018162, 30.239061, 38.71187 , 43.878183],
[38.180999, 35.824583, 43.525247, 43.874945],
[43.269533, 40.834018, 46.757772, 44.276423],
[49.120928, 39.681844, 43.596067, 45.085854]])
assert_allclose(signal.sepfir2d(image, filt, filt[::3]), expected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MacOS CI failure looks related at least:

=================================== FAILURES ===================================
________________________________ test_sepfir2d _________________________________
scipy/signal/tests/test_bsplines.py:267: in test_sepfir2d
    assert_allclose(signal.sepfir2d(image, filt, filt[::3]), expected)
E   AssertionError: 
E   Not equal to tolerance rtol=1e-07, atol=0
E   
E   Mismatched elements: 2 / 16 (12.5%)
E   Max absolute difference: 31.99999962
E   Max relative difference: 1.02353683

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to do something else for MacOS. Locally, running the tests for signal submodule on Linux passes for me:

scipy/signal/tests/test_bsplines.py::test_sepfir2d PASSED                [  0%]
...
============== 2787 passed, 2 skipped, 10475 deselected in 53.99s ==============

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This passes for me on macOS 11 with the conda compilers. The issue may be specific to GCC.


filt = np.array([1, 2, 4, 2, 1, 3, 2])
image = np.random.randint(4, size=(5, 5))

expected = array([[123., 101., 91., 136., 127.],
[133., 125., 126., 152., 160.],
[136., 137., 150., 162., 177.],
[133., 124., 132., 148., 147.],
[173., 158., 152., 164., 141.]])
assert_allclose(signal.sepfir2d(image, filt, filt[::3]), expected)

expected = array([[22., 35., 41., 31., 47.],
[27., 39., 48., 47., 55.],
[33., 42., 49., 53., 59.],
[39., 44., 41., 36., 48.],
[67., 62., 47., 34., 46.]])
assert_allclose(signal.sepfir2d(image, filt[::3], filt[::3]), expected)

def test_cspline2d():
np.random.seed(181819142)
Expand Down