Skip to content

Commit

Permalink
Fix missing warnings import in phase_cross_correlation (#7175)
Browse files Browse the repository at this point in the history
* Add missing warnings import

Hups, 05e84c2 removed the import of warnings thus breaking the merge
result after merging #7147!

* Test no warning is raised in phase_cross_correlation

when disambiguate=True. See
#7146
  • Loading branch information
lagru committed Sep 28, 2023
1 parent 0ea32e0 commit 97b3ecb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions skimage/registration/_phase_cross_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import itertools
import warnings

import numpy as np
from scipy.fft import fftn, ifftn, fftfreq
Expand Down
12 changes: 12 additions & 0 deletions skimage/registration/tests/test_phase_cross_correlation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
import warnings

import numpy as np
import pytest
Expand Down Expand Up @@ -206,6 +207,17 @@ def test_disambiguate_2d(shift0, shift1):
np.testing.assert_equal(shift, computed_shift)


def test_invalid_value_in_division_warnings():
"""Regression test for https://github.com/scikit-image/scikit-image/issues/7146."""
im1 = np.zeros((100, 100))
im1[50, 50] = 1
im2 = np.zeros((100, 100))
im2[60, 60] = 1
with warnings.catch_warnings():
warnings.simplefilter("error")
phase_cross_correlation(im1, im2, disambiguate=True)


@pytest.mark.parametrize('disambiguate', [True, False])
def test_disambiguate_zero_shift(disambiguate):
"""When the shift is 0, disambiguation becomes degenerate.
Expand Down

0 comments on commit 97b3ecb

Please sign in to comment.