Skip to content

Commit

Permalink
cr: address ernesto's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Nov 12, 2020
1 parent 5f32bd5 commit 42de36e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cr/cube/cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def columns_margin(self):
def columns_proportions_moe(self):
"""1D/2D np.float64 ndarray of margin-of-error (MoE) for columns proportions.
The values are represented as fractions, analogue to the `table_proportions`
The values are represented as fractions, analogue to the `column_proportions`
property. This means that the value of 3.5% will have the value 0.035.
The values can be np.nan when the corresponding percentage is also np.nan, which
happens when the respective columns margin is 0.
Expand Down Expand Up @@ -465,7 +465,7 @@ def population_moe(self):
The values are represented as population estimates, analogue to the
`population_counts` property. This means that the values will be presented by
actual estimated counts of the population The values can be np.nan when the
actual estimated counts of the population. The values can be np.nan when the
corresponding percentage is also np.nan, which happens when the respective
table margin is 0.
"""
Expand Down Expand Up @@ -552,9 +552,14 @@ def rows_proportions_moe(self):

@lazyproperty
def rows_std_err(self):
"""2D np.float64 ndarray of standard errors for row percentages """
"""2D np.float64 ndarray of standard errors for row percentages."""
return np.sqrt(self._rows_variance / self.rows_margin[:, None])

@lazyproperty
def rows_std_dev(self):
"""2D np.float64 ndarray of standard deviation for row percentages."""
return np.sqrt(self._rows_variance)

@lazyproperty
def scale_mean_pairwise_indices(self):
"""Sequence of column-idx tuples indicating pairwise-t result of scale-means.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
[0.24824605, 0.3801874, 0.47777249, 0.42403103, 0.35142393, 0.16151057],
[0.26765143, 0.39099102, 0.48949758, 0.40430337, 0.26765143, 0.22288691],
]
4 changes: 4 additions & 0 deletions tests/integration/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,10 @@ def test_calculate_various_measures_axis_0(self):
slice_.rows_proportions_moe,
load_python_expression("econ-gender-x-ideology-weighted-row-prop-moe"),
)
np.testing.assert_almost_equal(
slice_.rows_std_dev,
load_python_expression("econ-gender-x-ideology-weighted-row-std-dev"),
)
np.testing.assert_almost_equal(
slice_.table_proportions_moe,
load_python_expression("econ-gender-x-ideology-weighted-table-prop-moe"),
Expand Down

0 comments on commit 42de36e

Please sign in to comment.