Commit b462fcb4 authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

temporarily fix failing tests by making copies of array views

1 merge request!1release v0.1.0.0
Pipeline #43097 passed with stage
in 2 minutes and 58 seconds
Showing with 24 additions and 10 deletions
+24 -10
...@@ -90,9 +90,14 @@ class TestMasking(unittest.TestCase): ...@@ -90,9 +90,14 @@ class TestMasking(unittest.TestCase):
def test_masks(self): def test_masks(self):
msk = numpy.ones(_obs.shape, dtype=bool) msk = numpy.ones(_obs.shape, dtype=bool)
msk[..., :99] = False msk[..., :99] = False
# TODO: figure out why passing views would not work
obs = _obs[..., 99:].copy()
prd = _prd[..., 99:].copy()
numpy.testing.assert_almost_equal( numpy.testing.assert_almost_equal(
evalhyd.evald(_obs, _prd, ["NSE"], t_msk=msk)[0], evalhyd.evald(_obs, _prd, ["NSE"], t_msk=msk)[0],
evalhyd.evald(_obs[..., 99:], _prd[..., 99:], ["NSE"])[0] evalhyd.evald(obs, prd, ["NSE"])[0]
) )
def test_conditions(self): def test_conditions(self):
...@@ -101,8 +106,9 @@ class TestMasking(unittest.TestCase): ...@@ -101,8 +106,9 @@ class TestMasking(unittest.TestCase):
msk = (_obs[0] < 2000) | (_obs[0] > 3000) msk = (_obs[0] < 2000) | (_obs[0] > 3000)
obs = _obs[..., msk] # TODO: figure out why passing views would not work
prd = _prd[..., msk] obs = _obs[..., msk].copy()
prd = _prd[..., msk].copy()
numpy.testing.assert_almost_equal( numpy.testing.assert_almost_equal(
evalhyd.evald(_obs, _prd, ["NSE"], m_cdt=cdt)[0], evalhyd.evald(_obs, _prd, ["NSE"], m_cdt=cdt)[0],
...@@ -114,8 +120,9 @@ class TestMasking(unittest.TestCase): ...@@ -114,8 +120,9 @@ class TestMasking(unittest.TestCase):
msk = _obs[0] >= numpy.median(_obs) msk = _obs[0] >= numpy.median(_obs)
obs = _obs[..., msk] # TODO: figure out why passing views would not work
prd = _prd[..., msk] obs = _obs[..., msk].copy()
prd = _prd[..., msk].copy()
numpy.testing.assert_almost_equal( numpy.testing.assert_almost_equal(
evalhyd.evald(_obs, _prd, ["NSE"], m_cdt=cdt)[0], evalhyd.evald(_obs, _prd, ["NSE"], m_cdt=cdt)[0],
......
...@@ -81,9 +81,14 @@ class TestMasking(unittest.TestCase): ...@@ -81,9 +81,14 @@ class TestMasking(unittest.TestCase):
def test_masks(self): def test_masks(self):
msk = numpy.ones((_prd.shape[0], _prd.shape[1], 1, _prd.shape[3]), dtype=bool) msk = numpy.ones((_prd.shape[0], _prd.shape[1], 1, _prd.shape[3]), dtype=bool)
msk[..., :99] = False msk[..., :99] = False
# TODO: figure out why passing views would not work
obs = _obs[..., 99:].copy()
prd = _prd[..., 99:].copy()
numpy.testing.assert_almost_equal( numpy.testing.assert_almost_equal(
evalhyd.evalp(_obs, _prd, ["QS"], t_msk=msk)[0], evalhyd.evalp(_obs, _prd, ["QS"], t_msk=msk)[0],
evalhyd.evalp(_obs[..., 99:], _prd[..., 99:], ["QS"])[0] evalhyd.evalp(obs, prd, ["QS"])[0]
) )
def test_conditions(self): def test_conditions(self):
...@@ -92,8 +97,9 @@ class TestMasking(unittest.TestCase): ...@@ -92,8 +97,9 @@ class TestMasking(unittest.TestCase):
msk = (_obs[0] < 2000) | (_obs[0] > 3000) msk = (_obs[0] < 2000) | (_obs[0] > 3000)
obs = _obs[..., msk] # TODO: figure out why passing views would not work
prd = _prd[..., msk] obs = _obs[..., msk].copy()
prd = _prd[..., msk].copy()
numpy.testing.assert_almost_equal( numpy.testing.assert_almost_equal(
evalhyd.evalp(_obs, _prd, ["QS"], m_cdt=cdt)[0], evalhyd.evalp(_obs, _prd, ["QS"], m_cdt=cdt)[0],
...@@ -106,8 +112,9 @@ class TestMasking(unittest.TestCase): ...@@ -106,8 +112,9 @@ class TestMasking(unittest.TestCase):
median = numpy.squeeze(numpy.median(_prd, 2)) median = numpy.squeeze(numpy.median(_prd, 2))
msk = median <= numpy.quantile(median, 0.7) msk = median <= numpy.quantile(median, 0.7)
obs = _obs[..., msk] # TODO: figure out why passing views would not work
prd = _prd[..., msk] obs = _obs[..., msk].copy()
prd = _prd[..., msk].copy()
numpy.testing.assert_almost_equal( numpy.testing.assert_almost_equal(
evalhyd.evalp(_obs, _prd, ["QS"], m_cdt=cdt)[0], evalhyd.evalp(_obs, _prd, ["QS"], m_cdt=cdt)[0],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment