Skip to content

Commit

Permalink
fix counts for mr mr augmented matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestoarbitrio committed Jul 10, 2020
1 parent 10a11fd commit 6082f2e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
13 changes: 8 additions & 5 deletions src/cr/cube/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,23 @@ def factory(cls, cube, dimensions, slice_idx):
base_counts,
counts_with_missings,
)

# These are apparent dimensions which hide 'selections' dims behind 'MR'
dimensions = cube.dimensions[:-1]
counts = np.sum(counts[:, :, :, 0], axis=3)
base_counts = np.sum(base_counts[:, :, :, 0], axis=3)
counts_with_missings = np.sum(counts_with_missings[:, :, :, 0], axis=3)
if cube.dimension_types[0] == DT.MR:
counts = np.sum(counts[:, :, :, :, 0], axis=4)
base_counts = np.sum(base_counts[:, :, :, :, 0], axis=4)
counts_with_missings = np.sum(
counts_with_missings[:, :, :, :, 0], axis=4
)
return _MrXMrMatrix(
dimensions,
counts,
base_counts,
counts_with_missings,
overlap_tstats,
)
counts = np.sum(counts[:, :, :, 0], axis=3)
base_counts = np.sum(base_counts[:, :, :, 0], axis=3)
counts_with_missings = np.sum(counts_with_missings[:, :, :, 0], axis=3)
return _CatXMrMatrix(
dimensions, counts, base_counts, counts_with_missings, overlap_tstats
)
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/test_multiple_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,11 +896,11 @@ def test_mr_x_num_with_means_pruned():
def test_mr_x_mr_itself_zscore():
slice_ = Cube(CR.MR_X_MR_ITSELF).partitions[0]
expected = [
[-2.09809816e-01, -2.47663660e-01, 0.00000000e00],
[2.79428953e-01, 1.54988917e-01, 0.00000000e00],
[-2.15682422e-01, -6.37644486e-02, -3.01876861e-15],
[3.68523425e-01, 5.62052405e-01, 7.96003449e-15],
[-1.87152853e-01, -3.78529911e-01, 0.00000000e00],
[2.02358771, 4.40571894, -4.73781476],
[1.6374635, 2.98524415, -2.88925509],
[1.40611428, -0.26969232, -1.03556062],
[1.67279974, -0.46401375, 0.06965056],
[-3.37595335, -1.34855138, 3.10157807],
]

np.testing.assert_almost_equal(slice_.zscore, expected)
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/test_pairwise_significance.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,10 @@ def test_mr_x_mr_itself_pairwise_compare_columns(self):
np.testing.assert_array_almost_equal(
actual.p_vals,
[
[3.00272449e-01, 1, 3.60013917e-01],
[3.03167992e-01, 1, 1.52766688e-13],
[5.63934548e-01, 1, 0.00000000e00],
[7.32894024e-01, 1, 0.00000000e00],
[3.68215623e-02, 1, 0.00000000e00],
[3.00368306e-01, 1.00000000e00, 3.60015180e-01],
[3.03263297e-01, 1.00000000e00, 1.53432822e-13],
[5.63984270e-01, 1.00000000e00, 0.00000000e00],
[7.32921470e-01, 1.00000000e00, 0.00000000e00],
[3.69178553e-02, 1.00000000e00, 0.00000000e00],
],
)

0 comments on commit 6082f2e

Please sign in to comment.