def test_filter_n_largest(): cands = np.array((10, 25, 50, 75, 100)) x = np.arange(128, dtype=float) y = np.zeros_like(x) for c, h in zip(cands, (10, 15, 25, 30, 35)): y += gauss_gen(x, c, h, 3) for j in range(1, len(cands) + 2): out = feature.filter_n_largest(y, cands, j) assert (len(out) == np.min([len(cands), j])) assert_raises(ValueError, feature.filter_n_largest, y, cands, 0) assert_raises(ValueError, feature.filter_n_largest, y, cands, -1)
def test_filter_n_largest(): cands = np.array((10, 25, 50, 75, 100)) x = np.arange(128, dtype=float) y = np.zeros_like(x) for c, h in zip(cands, (10, 15, 25, 30, 35)): y += gauss_gen(x, c, h, 3) for j in range(1, len(cands) + 2): out = feature.filter_n_largest(y, cands, j) assert(len(out) == np.min([len(cands), j])) assert_raises(ValueError, feature.filter_n_largest, y, cands, 0) assert_raises(ValueError, feature.filter_n_largest, y, cands, -1)
def test_filter_n_largest(): gauss_gen = lambda x, center, height, width: ( height * np.exp(-((x-center) / width)**2)) cands = np.array((10, 25, 50, 75, 100)) x = np.arange(128, dtype=float) y = np.zeros_like(x) for c, h in zip(cands, (10, 15, 25, 30, 35)): y += gauss_gen(x, c, h, 3) for j in range(1, len(cands) + 2): out = feature.filter_n_largest(y, cands, j) assert(len(out) == np.min([len(cands), j])) assert_raises(ValueError, feature.filter_n_largest, y, cands, 0) assert_raises(ValueError, feature.filter_n_largest, y, cands, -1)