Skip to content

Commit

Permalink
fix: small CR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
scanny committed Oct 30, 2020
1 parent 4d10e24 commit 21d6d76
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/cr/cube/cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def dimension_types(self):
return tuple(d.dimension_type for d in self._dimensions)

def evaluate(self, measure_expr):
"""Returns 1D/2D ndarray, values evaluated given the function specification
"""Return 1D/2D ndarray, values evaluated given the function specification
The `function_spec` contains the function to apply and its parameters, e.g.:
```
Expand Down Expand Up @@ -113,7 +113,7 @@ def ndim(self):

@lazyproperty
def population_fraction(self):
"""Returns the population fraction of the cube"""
"""population fraction of the cube"""
return self._cube.population_fraction

@lazyproperty
Expand Down Expand Up @@ -309,14 +309,16 @@ def columns_percentages_moe(self):

@lazyproperty
def columns_std_dev(self):
"""Returns the standard deviation for column percentages
"""standard deviation for column percentages
`std_deviation = sqrt(variance)`
"""
return np.sqrt(self._columns_variance)

@lazyproperty
def columns_std_err(self):
"""Returns the standard error for column percentages
"""standard error for column percentages
`std_error = sqrt(variance/N)`
"""
return np.sqrt(self._columns_variance / self.columns_margin)
Expand Down Expand Up @@ -780,17 +782,6 @@ def table_margin(self):
def table_margin_unpruned(self):
return self._matrix.table_margin_unpruned

@lazyproperty
def table_percentages_moe(self):
"""1D/2D np.float64 ndarray of margin-of-error (MoE) for table percentages.
The values are represented as percentages, analogue to the `table_percentages`
property. This means that the value of 3.5% will have the value 3.5 (not 0.035).
The values can be np.nan when the corresponding percentage is also np.nan, which
happens when the respective table margin is 0.
"""
return self.Z_975 * 100 * self.table_std_err

@lazyproperty
def table_name(self):
"""Provides differentiated name for each stacked table of a 3D cube."""
Expand All @@ -809,6 +800,17 @@ def table_name(self):
def table_percentages(self):
return self.table_proportions * 100

@lazyproperty
def table_percentages_moe(self):
"""1D/2D np.float64 ndarray of margin-of-error (MoE) for table percentages.
The values are represented as percentages, analogue to the `table_percentages`
property. This means that the value of 3.5% will have the value 3.5 (not 0.035).
The values can be np.nan when the corresponding percentage is also np.nan, which
happens when the respective table margin is 0.
"""
return self.Z_975 * 100 * self.table_std_err

@lazyproperty
def table_proportions(self):
return np.array([row.table_proportions for row in self._matrix.rows])
Expand Down Expand Up @@ -889,7 +891,8 @@ def _columns_dimension_numeric_values(self):

@lazyproperty
def _columns_variance(self):
"""Returns the variance for column percentages
"""variance for column percentages
`variance = p * (1-p)`
"""
return (
Expand Down Expand Up @@ -1265,7 +1268,8 @@ def _table_proportions_as_array(self):

@lazyproperty
def _variance(self):
"""Returns the variance for cell percentages
"""variance for cell percentages
`variance = p * (1-p)`
"""
p = self._table_proportions_as_array
Expand Down

0 comments on commit 21d6d76

Please sign in to comment.