summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-05-19 14:51:03 -0600
committerGitHub <noreply@github.com>2021-05-19 14:51:03 -0600
commit098b4d1045b5e30de039749390bd721ce160a7db (patch)
treeb74c2f45282ce96bf77c5af67b74c23c8e460a53 /numpy/lib/tests/test_function_base.py
parent3a61a14b46535d1ce552d06f1be8172c0fc233c4 (diff)
parent8bdeaebe0c82590a135d5b815fa41ffda0b9a9dd (diff)
downloadnumpy-098b4d1045b5e30de039749390bd721ce160a7db.tar.gz
Merge pull request #16987 from scimax/master
ENH: Phase unwrapping generalized to arbitrary interval size
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r--numpy/lib/tests/test_function_base.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py
index 0b66ccf8c..a4f49a78b 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -1798,6 +1798,24 @@ class TestUnwrap:
assert_array_equal(unwrap([1, 1 + 2 * np.pi]), [1, 1])
# check that unwrap maintains continuity
assert_(np.all(diff(unwrap(rand(10) * 100)) < np.pi))
+
+ def test_period(self):
+ # check that unwrap removes jumps greater that 255
+ assert_array_equal(unwrap([1, 1 + 256], period=255), [1, 2])
+ # check that unwrap maintains continuity
+ assert_(np.all(diff(unwrap(rand(10) * 1000, period=255)) < 255))
+ # check simple case
+ simple_seq = np.array([0, 75, 150, 225, 300])
+ wrap_seq = np.mod(simple_seq, 255)
+ assert_array_equal(unwrap(wrap_seq, period=255), simple_seq)
+ # check custom discont value
+ uneven_seq = np.array([0, 75, 150, 225, 300, 430])
+ wrap_uneven = np.mod(uneven_seq, 250)
+ no_discont = unwrap(wrap_uneven, period=250)
+ assert_array_equal(no_discont, [0, 75, 150, 225, 300, 180])
+ sm_discont = unwrap(wrap_uneven, period=250, discont=140)
+ assert_array_equal(sm_discont, [0, 75, 150, 225, 300, 430])
+ assert sm_discont.dtype == wrap_uneven.dtype
class TestFilterwindows: