def test_constant(): # Should detect *no* zero crossings with a constant array # Specify `AC_coupled` = False to prevent computation of DC offset, # which is only a well-defined operation when there are two or more # zero crossings of the same type. zc = ZeroCrossing(np.array([1, 1]), 1, auto=False) tools.assert_equal(len(zc._getRisingZeroCrossingIndices()), 0) tools.assert_equal(len(zc._getRisingZeroCrossingTimesLerp()), 0)
def test_linear(): # Should detect *one* rising zero crossing # Specify `AC_coupled` = False to prevent computation of DC offset, # which is only a well-defined operation when there are two or more # zero crossings of the same type. zc = ZeroCrossing(np.array([-1, 0, 1]), 1, auto=False) tools.assert_equal(zc._getRisingZeroCrossingIndices(), np.array([0])) tools.assert_equal(zc._getRisingZeroCrossingTimesLerp(), np.array([1]))