Skip to content

Commit

Permalink
Bring coverage back to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Jan 16, 2019
1 parent b63ef00 commit dd504f5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/cr/cube/crunch_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from cr.cube.dimension import AllDimensions
from cr.cube.enum import DIMENSION_TYPE as DT
from cr.cube.measures.index import Index
from cr.cube.measures.pairwise_pvalues import PairwisePvalues
from cr.cube.measures.scale_means import ScaleMeans
from cr.cube.util import lazyproperty

Expand Down Expand Up @@ -724,7 +723,7 @@ def pairwise_pvals(self, axis=0):
are implemented currently.
:returns pvals: list of symmetric matrices of column-comparison p-values.
"""
return [PairwisePvalues(slice_, axis=axis).values for slice_ in self.slices]
return [slice_.pairwise_pvals(axis=axis) for slice_ in self.slices]

def _adjust_axis(self, axis):
"""Return raw axis/axes corresponding to apparent axis/axes.
Expand Down
4 changes: 3 additions & 1 deletion src/cr/cube/cube_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

try:
xrange
except NameError:
except NameError: # pragma: no cover
xrange = range


Expand Down Expand Up @@ -318,6 +318,8 @@ def pairwise_pvals(self, axis=0):
are implemented currently.
:returns pvals: square, symmetric matrix of column-comparison p-values.
"""
if axis != 0:
raise NotImplementedError("Pairwise comparison only implemented for colums")
return PairwisePvalues(self, axis=axis).values

def pvals(self, weighted=True, prune=False, hs_dims=None):
Expand Down
2 changes: 1 addition & 1 deletion src/cr/cube/distributions/wishart.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

try:
xrange
except NameError:
except NameError: # pragma: no cover
xrange = range


Expand Down
2 changes: 1 addition & 1 deletion src/cr/cube/measures/pairwise_pvalues.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

try:
xrange
except NameError:
except NameError: # pragma: no cover
xrange = range


Expand Down
9 changes: 7 additions & 2 deletions tests/integration/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"""Integration tests for pairwise comparisons."""

from unittest import TestCase
import pytest

import numpy as np

from ..fixtures import CR

from cr.cube.crunch_cube import CrunchCube
from cr.cube.measures.pairwise_pvalues import PairwisePvalues

from ..fixtures import CR


# pylint: disable=missing-docstring, invalid-name, no-self-use
class TestStandardizedResiduals(TestCase):
Expand Down Expand Up @@ -162,6 +163,10 @@ def test_same_col_pvals(self):
actual = cube.pairwise_pvals(axis=0)
np.testing.assert_equal(actual, expected)

# Assert correct exception in case of not-implemented direction
with pytest.raises(NotImplementedError):
cube.pairwise_pvals(axis=1)

def test_hirotsu_pvals(self):
cube = CrunchCube(CR.PAIRWISE_HIROTSU_ILLNESS_X_OCCUPATION)
actual = cube.pairwise_pvals(axis=0)
Expand Down

0 comments on commit dd504f5

Please sign in to comment.