From 8632c43344e0f9822ac3d8ce8172ac960e77051e Mon Sep 17 00:00:00 2001 From: ernestoarbitrio Date: Wed, 24 Jun 2020 10:51:28 +0200 Subject: [PATCH] fix for mr --- src/cr/cube/cubepart.py | 2 ++ tests/integration/test_cubepart.py | 18 +++++++++--------- tests/integration/test_multiple_response.py | 4 +++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/cr/cube/cubepart.py b/src/cr/cube/cubepart.py index 685c08ba6..fe7eae189 100644 --- a/src/cr/cube/cubepart.py +++ b/src/cr/cube/cubepart.py @@ -1034,6 +1034,8 @@ def standard_deviation(self): @lazyproperty def standard_error(self): """ -> np.ndarray, percentages standard error""" + if self.dimension_types[0] == DT.MR: + return np.sqrt(self._variance / self.rows_margin) return np.sqrt(self._variance / np.sum(self.rows_margin)) @lazyproperty diff --git a/tests/integration/test_cubepart.py b/tests/integration/test_cubepart.py index cd0a69039..830e77028 100644 --- a/tests/integration/test_cubepart.py +++ b/tests/integration/test_cubepart.py @@ -1471,15 +1471,15 @@ def it_provides_std_dev_err_univ_mr_with_hs(self): np.testing.assert_almost_equal( strand.standard_error, [ - 0.0022361, - 0.0017264, - 0.0011327, - 0.001562, - 0.0013928, - 0.0011945, - 0.0007275, - 0.0023938, - 0.0006968, + 0.0045332, + 0.0050433, + 0.0053114, + 0.0051373, + 0.0052165, + 0.0052914, + 0.0054104, + 0.0040772, + 0.0054158, ], ) diff --git a/tests/integration/test_multiple_response.py b/tests/integration/test_multiple_response.py index 7ab1c8a4a..3da1fc207 100644 --- a/tests/integration/test_multiple_response.py +++ b/tests/integration/test_multiple_response.py @@ -33,7 +33,9 @@ def test_std_dev_err_simple_mr(): np.testing.assert_almost_equal( strand.standard_deviation, [0.4898979, 0.4714045, 0.0] ) - np.testing.assert_almost_equal(strand.standard_error, [0.185164, 0.1781742, 0.0]) + np.testing.assert_almost_equal( + strand.standard_error, [0.2828427, 0.2357023, np.nan] + ) def test_1D_mr_with_means():