def test_mav_custom_weights(): x = np.ones((4, 10)) w = np.zeros(x.shape[1]) w[0:2] = 0.4 truth = (2*0.4/x.shape[1])*np.ones(x.shape[0]) assert_equal(features.mean_absolute_value(x, weights=w), truth)
def test_mav(): x = np.array([[0, 2], [0, -4]]) truth = np.array([1, 2]) assert_equal(features.mean_absolute_value(x), truth)
def test_mav_bad_custom_weights(): # custom weights not the same length as the input data x = np.zeros((4, 10)) w = np.zeros(5) with pytest.raises(ValueError): features.mean_absolute_value(x, weights=w)
def test_mav_bad_weights(): # weights not one of the built-in types of MAV with pytest.raises(ValueError): features.mean_absolute_value(np.zeros(2), weights='asdf')
def test_mav2(): x = np.vstack([np.ones(8), np.zeros(8)]) # weights should be [0.5, 1, 1, 1, 1, 1, 0.5, 0] truth = np.array([0.75, 0]) assert_equal(features.mean_absolute_value(x, weights='mav2'), truth)