From 765e138e0d95bfab55701cdb71886b7193484f5a Mon Sep 17 00:00:00 2001 From: ernestoarbitrio Date: Tue, 23 Jun 2020 16:08:21 +0200 Subject: [PATCH] rfctr: change test expectaiton after std_err denominator fix --- src/cr/cube/cubepart.py | 2 +- tests/integration/test_cube.py | 8 ++++---- tests/integration/test_cubepart.py | 18 +++++++++--------- tests/integration/test_multiple_response.py | 4 +--- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/cr/cube/cubepart.py b/src/cr/cube/cubepart.py index 9a993f6b2..685c08ba6 100644 --- a/src/cr/cube/cubepart.py +++ b/src/cr/cube/cubepart.py @@ -1034,7 +1034,7 @@ def standard_deviation(self): @lazyproperty def standard_error(self): """ -> np.ndarray, percentages standard error""" - return np.sqrt(self._variance / self.rows_margin) + return np.sqrt(self._variance / np.sum(self.rows_margin)) @lazyproperty def table_base(self): diff --git a/tests/integration/test_cube.py b/tests/integration/test_cube.py index 198ebb518..2591ef551 100644 --- a/tests/integration/test_cube.py +++ b/tests/integration/test_cube.py @@ -499,7 +499,7 @@ def test_std_dev_err_univariate_cat_axis_none(self): np.testing.assert_almost_equal( strand.standard_deviation, [0.47140452, 0.47140452] ) - np.testing.assert_almost_equal(strand.standard_error, [0.1490712, 0.21081851]) + np.testing.assert_almost_equal(strand.standard_error, [0.1217161, 0.1217161]) def test_std_dev_err_numeric(self): strand = Cube(CR.VOTER_REGISTRATION).partitions[0] @@ -507,7 +507,7 @@ def test_std_dev_err_numeric(self): strand.standard_deviation, [0.31902194, 0.30655342, 0.09949874] ) np.testing.assert_almost_equal( - strand.standard_error, [0.01072381, 0.02991655, 0.03146427] + strand.standard_error, [0.0100884, 0.0096941, 0.0031464] ) def test_std_dev_err_datetime(self): @@ -516,7 +516,7 @@ def test_std_dev_err_datetime(self): strand.standard_deviation, [0.4330127, 0.4330127, 0.4330127, 0.4330127] ) np.testing.assert_almost_equal( - strand.standard_error, [0.4330127, 0.4330127, 0.4330127, 0.4330127] + strand.standard_error, [0.2165064, 0.2165064, 0.2165064, 0.2165064] ) def test_std_dev_err_text(self): @@ -527,7 +527,7 @@ def test_std_dev_err_text(self): ) np.testing.assert_almost_equal( strand.standard_error, - [0.372678, 0.372678, 0.372678, 0.372678, 0.372678, 0.372678], + [0.1521452, 0.1521452, 0.1521452, 0.1521452, 0.1521452, 0.1521452], ) def test_proportions_cat_x_cat_axis_none(self): diff --git a/tests/integration/test_cubepart.py b/tests/integration/test_cubepart.py index 6269d02fe..cd0a69039 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.00453318, - 0.00504326, - 0.00531142, - 0.00513733, - 0.00521646, - 0.0052914, - 0.00541038, - 0.00407718, - 0.00541584, + 0.0022361, + 0.0017264, + 0.0011327, + 0.001562, + 0.0013928, + 0.0011945, + 0.0007275, + 0.0023938, + 0.0006968, ], ) diff --git a/tests/integration/test_multiple_response.py b/tests/integration/test_multiple_response.py index 3da1fc207..7ab1c8a4a 100644 --- a/tests/integration/test_multiple_response.py +++ b/tests/integration/test_multiple_response.py @@ -33,9 +33,7 @@ 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.2828427, 0.2357023, np.nan] - ) + np.testing.assert_almost_equal(strand.standard_error, [0.185164, 0.1781742, 0.0]) def test_1D_mr_with_means():