Skip to content

Commit

Permalink
Implement check if a cube is univ CA
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Mar 22, 2018
1 parent a3fdadc commit 756354a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cr/cube/crunch_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,12 +458,20 @@ def _mr_proportions(self, axis, weighted):

return res[np.ix_(*valid_indices)]

@property
def is_univariate_ca(self):
types = [d.type for d in self.dimensions]
return types == ['categorical_array', 'categorical']

def _proportions(self, axis=None, weighted=True, adjusted=False,
include_transforms_for_dims=None, include_missing=False,
prune=False):
if self.has_mr:
return self._mr_proportions(axis, weighted)

if self.is_univariate_ca and axis != 1:
raise ValueError('CA props only defined for row direction.')

margin = self._margin(
axis=axis, weighted=weighted, adjusted=adjusted,
include_transforms_for_dims=include_transforms_for_dims,
Expand Down

0 comments on commit 756354a

Please sign in to comment.