Skip to content

Commit

Permalink
Merge 7b2e3dd into e4c2cfd
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Feb 5, 2019
2 parents e4c2cfd + 7b2e3dd commit 8a8b4cc
Show file tree
Hide file tree
Showing 6 changed files with 6,823 additions and 18 deletions.
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ The detailed description can be found

## Changes

#### 1.9.5
- Fix calculating population counts for CAxCAT slices, that need to be treated as 0th cubes in tabbooks

#### 1.9.4
- Enable `CA_CAT` as a dimension type when calculating Pairwise Comparisons

Expand All @@ -121,16 +124,4 @@ The detailed description can be found
#### 1.9.2
- Fix `scale_means` for Categorical Array (as a 0th slice in Tabbooks) where categorical doesn't have any numerical values

#### 1.9.1
- Fix `scale_means` for Categorical Array (as a 0th slice in Tabbooks)

#### 1.9.0
- Implement pairwise comparisons

#### 1.8.6
- Fix pruning for single element MRs

#### 1.8.5
- Fix `index_table` for MR x MR where either dimension has a only single element

For a complete list of changes see [history](https://github.com/Crunch-io/crunch-cube/blob/master/HISTORY.md).
2 changes: 1 addition & 1 deletion src/cr/cube/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

"""Initialization module for crunch-cube package."""

__version__ = "1.9.4"
__version__ = "1.9.5"
14 changes: 9 additions & 5 deletions src/cr/cube/crunch_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,16 +500,20 @@ def population_counts(
[3000, 1800],
])
"""
return (
self.proportions(
population_counts = [
slice_.population_counts(
population_size,
weighted=weighted,
include_missing=include_missing,
include_transforms_for_dims=include_transforms_for_dims,
prune=prune,
)
* population_size
* self.population_fraction
)
for slice_ in self.slices
]

if len(population_counts) > 1:
return np.array(population_counts)
return population_counts[0]

@lazyproperty
def population_fraction(self):
Expand Down
21 changes: 21 additions & 0 deletions src/cr/cube/cube_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,27 @@ def pairwise_pvals(self, axis=0):
raise NotImplementedError("Pairwise comparison only implemented for colums")
return PairwisePvalues(self, axis=axis).values

def population_counts(
self,
population_size,
weighted=True,
include_missing=False,
include_transforms_for_dims=None,
prune=False,
):
axis = None if not self.ca_as_0th else 1
return (
self.proportions(
axis=axis,
weighted=weighted,
include_missing=include_missing,
include_transforms_for_dims=include_transforms_for_dims,
prune=prune,
)
* population_size
* self._cube.population_fraction
)

def pvals(self, weighted=True, prune=False, hs_dims=None):
"""Return 2D ndarray with calculated P values
Expand Down
Loading

0 comments on commit 8a8b4cc

Please sign in to comment.