MCPcopy Create free account
hub / github.com/numpy/numpy / test_period

Method test_period

numpy/lib/tests/test_function_base.py:1989–2005  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1987 assert_(np.all(diff(unwrap(rand(10) * 100)) < np.pi))
1988
1989 def test_period(self):
1990 # check that unwrap removes jumps greater that 255
1991 assert_array_equal(unwrap([1, 1 + 256], period=255), [1, 2])
1992 # check that unwrap maintains continuity
1993 assert_(np.all(diff(unwrap(rand(10) * 1000, period=255)) < 255))
1994 # check simple case
1995 simple_seq = np.array([0, 75, 150, 225, 300])
1996 wrap_seq = np.mod(simple_seq, 255)
1997 assert_array_equal(unwrap(wrap_seq, period=255), simple_seq)
1998 # check custom discont value
1999 uneven_seq = np.array([0, 75, 150, 225, 300, 430])
2000 wrap_uneven = np.mod(uneven_seq, 250)
2001 no_discont = unwrap(wrap_uneven, period=250)
2002 assert_array_equal(no_discont, [0, 75, 150, 225, 300, 180])
2003 sm_discont = unwrap(wrap_uneven, period=250, discont=140)
2004 assert_array_equal(sm_discont, [0, 75, 150, 225, 300, 430])
2005 assert sm_discont.dtype == wrap_uneven.dtype
2006
2007
2008@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 6

assert_array_equalFunction · 0.90
unwrapFunction · 0.90
assert_Function · 0.90
diffFunction · 0.90
randFunction · 0.85
allMethod · 0.45

Tested by

no test coverage detected