Skip to content

Commit

Permalink
Add tests (#1626)
Browse files Browse the repository at this point in the history
Co-authored-by: Belinda Trotta <[email protected]>
  • Loading branch information
btrotta-bom and btrotta-bom authored Nov 29, 2021
1 parent d6bc90f commit 5111381
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions improver_tests/ensemble_copula_coupling/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,28 @@ def test_slow_vs_multi(self):
result_multiple = interpolate_multiple_rows_same_x(self.x, self.xp, self.fp)
np.testing.assert_allclose(result_slow, result_multiple)

@patch.dict("sys.modules", numba=None)
@patch("improver.ensemble_copula_coupling.utilities.slow_interp_same_x")
def test_slow_interp_same_x_called(self, interp_imp):
"""Test that slow_interp_same_x is called if numba is not installed."""
interpolate_multiple_rows_same_x(
mock.sentinel.x, mock.sentinel.xp, mock.sentinel.fp
)
interp_imp.assert_called_once_with(
mock.sentinel.x, mock.sentinel.xp, mock.sentinel.fp
)

@skipIf(not (numba_installed), "numba not installed")
@patch("improver.ensemble_copula_coupling.numba_utilities.fast_interp_same_x")
def test_fast_interp_same_x_called(self, interp_imp):
"""Test that fast_interp_same_x is called if numba is installed."""
interpolate_multiple_rows_same_x(
mock.sentinel.x, mock.sentinel.xp, mock.sentinel.fp
)
interp_imp.assert_called_once_with(
mock.sentinel.x, mock.sentinel.xp, mock.sentinel.fp
)


if __name__ == "__main__":
unittest.main()

0 comments on commit 5111381

Please sign in to comment.