Skip to content

Commit

Permalink
parametrize the test for interpcode
Browse files Browse the repository at this point in the history
  • Loading branch information
kratsg committed Sep 14, 2018
1 parent 65ac604 commit 62d0b60
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ def filled_shapes(histogramssets,alphasets):
'tensorflow',
'pytorch',
])
def test_interpcode(backend, random_histosets_alphasets_pair):
@pytest.mark.parametrize("interpcode", [0, 1])
def test_interpcode(backend, interpcode, random_histosets_alphasets_pair):
pyhf.set_backend(backend)
histogramssets, alphasets = random_histosets_alphasets_pair

kitchensink_result = np.asarray(pyhf.tensorlib.tolist(pyhf.interpolate.interpolator(0, do_optimal=False)(histogramssets=histogramssets, alphasets=alphasets)))
optimized_result = np.asarray(pyhf.tensorlib.tolist(pyhf.interpolate.interpolator(0, do_optimal=True)(histogramssets=pyhf.tensorlib.astensor(histogramssets), alphasets=pyhf.tensorlib.astensor(alphasets))))
kitchensink_result = np.asarray(pyhf.tensorlib.tolist(pyhf.interpolate.interpolator(interpcode, do_optimal=False)(histogramssets=histogramssets, alphasets=alphasets)))
optimized_result = np.asarray(pyhf.tensorlib.tolist(pyhf.interpolate.interpolator(interpcode, do_optimal=True)(histogramssets=pyhf.tensorlib.astensor(histogramssets), alphasets=pyhf.tensorlib.astensor(alphasets))))

assert pytest.approx(kitchensink_result[~np.isnan(kitchensink_result)].ravel().tolist()) == optimized_result[~np.isnan(optimized_result)].ravel().tolist()

Expand Down

0 comments on commit 62d0b60

Please sign in to comment.