Skip to content

Commit

Permalink
Merge 765e138 into fc1f1ed
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestoarbitrio committed Jun 23, 2020
2 parents fc1f1ed + 765e138 commit 15537f5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/cr/cube/cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,15 @@ 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]
np.testing.assert_almost_equal(
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):
Expand All @@ -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):
Expand All @@ -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):
Expand Down
18 changes: 9 additions & 9 deletions tests/integration/test_cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
)

Expand Down
4 changes: 1 addition & 3 deletions tests/integration/test_multiple_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 15537f5

Please sign in to comment.