Skip to content

Commit

Permalink
Merge 46dfffd into d43368f
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Feb 4, 2019
2 parents d43368f + 46dfffd commit 51396a1
Show file tree
Hide file tree
Showing 3 changed files with 266 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cr/cube/distributions/wishart.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def value(self):
b -= q[i + j] / (g[i] * g[j + 1])
A[j + 1, i] = p[i] * p[j + 1] - 2 * b
A[i, j + 1] = -A[j + 1, i]

if np.any(np.isnan(A)):
return 0
return np.sqrt(det(A))

@lazyproperty
Expand Down
249 changes: 249 additions & 0 deletions tests/fixtures/pairwise-with-zero-margin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
{
"result": {
"dimensions": [
{
"references": {
"alias": "illness",
"name": "Illness"
},
"derived": false,
"type": {
"ordinal": false,
"class": "categorical",
"categories": [
{
"numeric_value": 3,
"missing": false,
"id": 3,
"name": "slight"
},
{
"numeric_value": 1,
"missing": false,
"id": 1,
"name": "medium"
},
{
"numeric_value": 2,
"missing": false,
"id": 2,
"name": "serious"
},
{
"numeric_value": null,
"missing": true,
"id": -1,
"name": "No Data"
}
]
}
},
{
"derived": false,
"references": {
"alias": "occupation",
"name": "Occupation",
"view": {
"show_counts": false,
"show_numeric_values": false,
"transform": {
"insertions": []
},
"include_missing": false,
"column_width": null
}
},
"type": {
"ordinal": false,
"class": "categorical",
"categories": [
{
"numeric_value": 1,
"missing": false,
"id": 1,
"name": "1"
},
{
"numeric_value": 2,
"missing": false,
"id": 2,
"name": "2"
},
{
"numeric_value": 3,
"missing": false,
"id": 3,
"name": "3"
},
{
"numeric_value": 4,
"missing": false,
"id": 4,
"name": "4"
},
{
"numeric_value": 5,
"missing": false,
"id": 5,
"name": "5"
},
{
"numeric_value": 6,
"missing": false,
"id": 6,
"name": "6"
},
{
"numeric_value": 7,
"missing": false,
"id": 7,
"name": "7"
},
{
"numeric_value": 8,
"missing": false,
"id": 8,
"name": "8"
},
{
"numeric_value": 9,
"missing": false,
"id": 9,
"name": "9"
},
{
"numeric_value": 10,
"missing": false,
"id": 10,
"name": "10"
},
{
"numeric_value": null,
"missing": true,
"id": -1,
"name": "No Data"
}
]
}
}
],
"measures": {
"count": {
"data": [
148,
111,
645,
165,
383,
96,
98,
199,
59,
262,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
86,
49,
328,
119,
311,
47,
58,
155,
30,
236,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"n_missing": 0,
"metadata": {
"references": {},
"derived": true,
"type": {
"integer": true,
"missing_rules": {},
"missing_reasons": {
"No Data": -1
},
"class": "numeric"
}
}
}
},
"n": 3585,
"unfiltered": {
"unweighted_n": 11908,
"weighted_n": 11908
},
"filtered": {
"unweighted_n": 3585,
"weighted_n": 3585
},
"counts": [
148,
111,
645,
165,
383,
96,
98,
199,
59,
262,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
86,
49,
328,
119,
311,
47,
58,
155,
30,
236,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
]
}
}
14 changes: 14 additions & 0 deletions tests/integration/test_pairwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,17 @@ def test_odd_latent_dimensions(self):
).reshape(4, 4)
]
np.testing.assert_almost_equal(actual, expected)

def test_pairwise_with_zero_margin(self):
"""Assert pairwise doesn't break when a 0 value is in any slice margin.
We currently don't know the correct maths behind this. This test needs to be
updated once we figure this out.
"""
cube = CrunchCube(CR.PAIRWISE_WITH_ZERO_MARGIN)

# TODO: Replace with updated expectation when maths is figured out
expected = [np.ones((10, 10), dtype=float)]

actual = cube.pairwise_pvals(axis=0)
np.testing.assert_almost_equal(actual, expected)

0 comments on commit 51396a1

Please sign in to comment.