From 1dc4842040db6db3c211d5c2c4559e81a48bae92 Mon Sep 17 00:00:00 2001 From: ernestoarbitrio Date: Mon, 12 Oct 2020 12:34:45 +0200 Subject: [PATCH] bug fix for t_stats scale_means --- src/cr/cube/measures/pairwise_significance.py | 2 +- .../cat-x-cat-hs-scale-mean-pw-idxs-alt.py | 14 ++++---- .../cat-x-cat-hs-scale-mean-pw-idxs.py | 12 +++---- .../cat-x-cat-scale-mean-pw-idxs-alt.py | 2 +- .../cat-x-cat-scale-mean-pw-idxs.py | 2 +- .../cat-x-mr-aug-scale-mean-pw-idxs-alt.py | 2 +- .../cat-x-mr-aug-scale-mean-pw-idxs.py | 2 +- .../cat-x-mr-scale-mean-pw-idxs-alt.py | 2 +- .../cat-x-mr-scale-mean-pw-idxs.py | 2 +- .../integration/test_pairwise_significance.py | 34 +++++++++---------- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/cr/cube/measures/pairwise_significance.py b/src/cr/cube/measures/pairwise_significance.py index daf1b569e..befcbad83 100644 --- a/src/cr/cube/measures/pairwise_significance.py +++ b/src/cr/cube/measures/pairwise_significance.py @@ -184,7 +184,7 @@ def t_stats_scale_means(self): ) tstats_scale_means = ( - self._slice.scale_means_row[self._col_idx] - self._slice.scale_means_row + self._slice.scale_means_row - self._slice.scale_means_row[self._col_idx] ) / (standard_deviation * np.sqrt((1 / counts[self._col_idx]) + (1 / counts))) return tstats_scale_means diff --git a/tests/expectations/cat-x-cat-hs-scale-mean-pw-idxs-alt.py b/tests/expectations/cat-x-cat-hs-scale-mean-pw-idxs-alt.py index db3c3a853..28980ef33 100644 --- a/tests/expectations/cat-x-cat-hs-scale-mean-pw-idxs-alt.py +++ b/tests/expectations/cat-x-cat-hs-scale-mean-pw-idxs-alt.py @@ -1,13 +1,13 @@ ( - (3, 4, 5, 8, 10), - (3, 4, 5, 8, 10), - (3, 4, 5, 8, 10), (), (), - (10,), - (3, 4, 5, 8, 10), - (3, 4, 10), (), - (4, 10), + (0, 1, 2, 6, 7), + (0, 1, 2, 6, 7, 9), + (0, 1, 2, 6), (), + (), + (0, 1, 2, 6), + (), + (0, 1, 2, 5, 6, 7, 9), ) diff --git a/tests/expectations/cat-x-cat-hs-scale-mean-pw-idxs.py b/tests/expectations/cat-x-cat-hs-scale-mean-pw-idxs.py index bf8ab6f60..25a0d8fb4 100644 --- a/tests/expectations/cat-x-cat-hs-scale-mean-pw-idxs.py +++ b/tests/expectations/cat-x-cat-hs-scale-mean-pw-idxs.py @@ -1,13 +1,13 @@ ( - (3, 4, 5, 8, 10), - (3, 4, 10), - (3, 4, 5, 8, 10), (), (), (), - (3, 4, 5, 8, 10), - (3, 4, 10), + (0, 1, 2, 6, 7), + (0, 1, 2, 6, 7), + (0, 2, 6), (), - (10,), (), + (0, 2, 6), + (), + (0, 1, 2, 6, 7, 9), ) diff --git a/tests/expectations/cat-x-cat-scale-mean-pw-idxs-alt.py b/tests/expectations/cat-x-cat-scale-mean-pw-idxs-alt.py index e01804530..d3f431bea 100644 --- a/tests/expectations/cat-x-cat-scale-mean-pw-idxs-alt.py +++ b/tests/expectations/cat-x-cat-scale-mean-pw-idxs-alt.py @@ -1 +1 @@ -((), (0,), (0,)) +((1, 2), (), ()) diff --git a/tests/expectations/cat-x-cat-scale-mean-pw-idxs.py b/tests/expectations/cat-x-cat-scale-mean-pw-idxs.py index e01804530..d3f431bea 100644 --- a/tests/expectations/cat-x-cat-scale-mean-pw-idxs.py +++ b/tests/expectations/cat-x-cat-scale-mean-pw-idxs.py @@ -1 +1 @@ -((), (0,), (0,)) +((1, 2), (), ()) diff --git a/tests/expectations/cat-x-mr-aug-scale-mean-pw-idxs-alt.py b/tests/expectations/cat-x-mr-aug-scale-mean-pw-idxs-alt.py index f4b6e7b64..186f80d64 100644 --- a/tests/expectations/cat-x-mr-aug-scale-mean-pw-idxs-alt.py +++ b/tests/expectations/cat-x-mr-aug-scale-mean-pw-idxs-alt.py @@ -1 +1 @@ -((), (0, 4), (0,), (0, 4), ()) +((1, 2, 3), (), (), (), (1, 3)) diff --git a/tests/expectations/cat-x-mr-aug-scale-mean-pw-idxs.py b/tests/expectations/cat-x-mr-aug-scale-mean-pw-idxs.py index 729977dd1..b7bec3fb8 100644 --- a/tests/expectations/cat-x-mr-aug-scale-mean-pw-idxs.py +++ b/tests/expectations/cat-x-mr-aug-scale-mean-pw-idxs.py @@ -1 +1 @@ -((), (0,), (), (0, 4), ()) +((1, 3), (), (), (), (3,)) diff --git a/tests/expectations/cat-x-mr-scale-mean-pw-idxs-alt.py b/tests/expectations/cat-x-mr-scale-mean-pw-idxs-alt.py index 6a1182d55..ecff9fe45 100644 --- a/tests/expectations/cat-x-mr-scale-mean-pw-idxs-alt.py +++ b/tests/expectations/cat-x-mr-scale-mean-pw-idxs-alt.py @@ -1 +1 @@ -((), (0,), (0, 1), (0, 1, 4), (0,)) +((1, 2, 3, 4), (2, 3), (), (), (3,)) diff --git a/tests/expectations/cat-x-mr-scale-mean-pw-idxs.py b/tests/expectations/cat-x-mr-scale-mean-pw-idxs.py index 6a1182d55..ecff9fe45 100644 --- a/tests/expectations/cat-x-mr-scale-mean-pw-idxs.py +++ b/tests/expectations/cat-x-mr-scale-mean-pw-idxs.py @@ -1 +1 @@ -((), (0,), (0, 1), (0, 1, 4), (0,)) +((1, 2, 3, 4), (2, 3), (), (), (3,)) diff --git a/tests/integration/test_pairwise_significance.py b/tests/integration/test_pairwise_significance.py index d6cb09140..8ea52d455 100644 --- a/tests/integration/test_pairwise_significance.py +++ b/tests/integration/test_pairwise_significance.py @@ -147,7 +147,7 @@ def test_pairwise_measures_scale_means_nps_type(self): assert actual.p_vals_scale_means[0] == 1 assert actual.t_stats_scale_means[0] == 0 np.testing.assert_almost_equal( - actual.t_stats_scale_means, [0.0, -1.08966143, 1.27412884, 4.14629088] + actual.t_stats_scale_means, [0.0, 1.08966143, -1.27412884, -4.14629088] ) np.testing.assert_almost_equal( actual.p_vals_scale_means, @@ -164,7 +164,7 @@ def test_pairwise_measures_scale_means_nps_type(self): [2.7638510e-01, 1.0000000e00, 1.4344585e-03, 1.7905266e-09], ) np.testing.assert_almost_equal( - actual.t_stats_scale_means, [1.08966143, 0.0, 3.19741668, 6.10466696] + actual.t_stats_scale_means, [-1.08966143, 0.0, -3.19741668, -6.10466696] ) def test_ttests_scale_means_cat_x_cat_pruning_and_hs(self): @@ -177,7 +177,7 @@ def test_ttests_scale_means_cat_x_cat_pruning_and_hs(self): np.testing.assert_almost_equal( actual.t_stats_scale_means, - [0.0, -1.64461503, -1.92387847, np.nan, -1.06912069], + [0.0, 1.64461503, 1.92387847, np.nan, 1.06912069], ) np.testing.assert_almost_equal( actual.p_vals_scale_means, [1.0, 0.1046981, 0.059721, np.nan, 0.2918845] @@ -189,7 +189,7 @@ def test_ttests_scale_means_cat_x_cat_pruning_and_hs(self): np.testing.assert_almost_equal( actual.t_stats_scale_means, - [0.0, -0.9387958, -1.644615, -1.9238785, np.nan, -1.0691207], + [0.0, 0.9387958, 1.644615, 1.9238785, np.nan, 1.0691207], ) np.testing.assert_almost_equal( @@ -207,7 +207,7 @@ def test_ttests_scale_means_cat_x_cat_pruning_and_hs(self): np.testing.assert_almost_equal( actual.t_stats_scale_means, - [0.0, -0.93879579, -1.64461503, -1.92387847, -1.06912069], + [0.0, 0.93879579, 1.64461503, 1.92387847, 1.06912069], ) np.testing.assert_almost_equal( actual.p_vals_scale_means, [1.0, 0.3500141, 0.1046981, 0.059721, 0.2918845] @@ -222,7 +222,7 @@ def test_ttests_scale_means_cat_x_cat_pruning_and_hs(self): actual = slice_.pairwise_significance_tests[0] np.testing.assert_almost_equal( - actual.t_stats_scale_means, [0.0, -1.64461503, -1.92387847, -1.06912069] + actual.t_stats_scale_means, [0.0, 1.64461503, 1.92387847, 1.06912069] ) np.testing.assert_almost_equal( actual.p_vals_scale_means, [1.0, 0.1046981, 0.059721, 0.2918845] @@ -236,16 +236,16 @@ def test_pairwise_t_stats_scale_means_with_hs(self): actual.t_stats_scale_means, [ 0.0, - 0.70543134, - 0.06749456, - 3.59627589, - 4.15672996, - 3.26353764, - 0.30034779, - 0.8383222, - 3.02379687, - 0.85672124, - 4.26974185, + -0.70543134, + -0.06749456, + -3.59627589, + -4.15672996, + -3.26353764, + -0.30034779, + -0.8383222, + -3.02379687, + -0.85672124, + -4.26974185, ], ) @@ -271,7 +271,7 @@ def test_ttests_scale_means_use_unweighted_n_for_variance(self): actual = slice_.pairwise_significance_tests[0] np.testing.assert_almost_equal( - actual.t_stats_scale_means, [0.0, 4.38871748, 3.99008596, 5.15679647] + actual.t_stats_scale_means, [0.0, -4.38871748, -3.99008596, -5.15679647] ) np.testing.assert_almost_equal( actual.p_vals_scale_means,