예제 #1
0
    def test_strictly_decreasing_but_less_than_threshold(self):
        data = np.linspace(1.05, 1.0, 10)
        result = zigzag.peak_valley_pivots(data, 0.1, -0.1)
        expected_result = np.zeros_like(data)
        expected_result[0], expected_result[-1] = PEAK, VALLEY

        assert_array_equal(result, expected_result)
예제 #2
0
    def test_strictly_increasing(self):
        data = np.linspace(1, 10, 10)
        result = zigzag.peak_valley_pivots(data, 0.1, -0.1)
        expected_result = np.zeros_like(data)
        expected_result[0], expected_result[-1] = VALLEY, PEAK

        assert_array_equal(result, expected_result)
예제 #3
0
    def test_single_valleyed(self):
        data = np.array([1.0, 0.9, 1.2])
        result = zigzag.peak_valley_pivots(data, 0.1, -0.1)
        expected_result = np.array([PEAK, VALLEY, PEAK])

        assert_array_equal(result, expected_result)
예제 #4
0
 def test_rise_fall_rise(self):
     data = np.array([1.0, 1.05, 1.1, 1.0, 0.9, 1.5])
     pivots = zigzag.peak_valley_pivots(data, 0.1, -0.1)
     assert_array_almost_equal(zigzag.compute_segment_returns(data, pivots),
                               np.array([0.1, -0.181818, 0.6666666]))
예제 #5
0
 def test_strictly_decreasing(self):
     data = np.linspace(100.0, 1.0, 10)
     pivots = zigzag.peak_valley_pivots(data, 0.1, -0.1)
     assert_array_almost_equal(zigzag.compute_segment_returns(data, pivots),
                               np.array([-0.99]))
예제 #6
0
    def test_decreasing_kinked(self):
        data = np.array([1.0, 1.01, 0.9])
        result = zigzag.peak_valley_pivots(data, 0.1, -0.1)
        expected_result = np.array([VALLEY, PEAK, VALLEY])

        assert_array_equal(result, expected_result)