Skip to content

Commit

Permalink
test: add xfail for #161344294
Browse files Browse the repository at this point in the history
* Add single-cube fixture that triggers "mask/data size mismatch" error.
* Add integration test that uses the fixture to trigger that error.
  • Loading branch information
scanny authored and slobodan-ilic committed Nov 1, 2018
1 parent 34b2ced commit ecb6dc6
Show file tree
Hide file tree
Showing 3 changed files with 306 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/integration/fixtures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ def _load(cube_file):
CA_SUBVAR_HS_X_MR_X_CA_CAT = _load('ca-subvar-hs-x-mr-x-ca-cat.json')
CAT_X_NUM_X_DATETIME = _load('cat-x-num-x-datetime.json')
SIMPLE_MR = _load('simple-mr.json')
CAT_X_MR_SIMPLE = _load('cat-x-mr.json')
CAT_X_MR_PRUNED_ROW = _load('cat-x-mr-pruned-row.json')
CAT_X_MR_PRUNED_COL = _load('cat-x-mr-pruned-col.json')
CAT_X_MR_PRUNED_ROW_COL = _load('cat-x-mr-pruned-row-col.json')
CAT_X_MR_SIMPLE = _load('cat-x-mr.json')
CAT_X_MR_SENTRY = _load('cat-x-mr-sentry.json')
MR_X_CAT_PRUNED_COL = _load('mr-x-cat-pruned-col.json')
MR_X_CAT_PRUNED_ROW = _load('mr-x-cat-pruned-row.json')
MR_X_CAT_PRUNED_ROW_COL = _load('mr-x-cat-pruned-row-col.json')
Expand Down
286 changes: 286 additions & 0 deletions tests/integration/fixtures/cubes/cat-x-mr-sentry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
{
"result": {
"counts": [
0,
108,
1,
14,
94,
1,
94,
14,
1,
192,
791,
41,
406,
577,
41,
385,
598,
41
],
"dimensions": [
{
"derived": true,
"references": {
"alias": "wealth_rc1",
"description": "",
"name": "Emerging Affluent",
"notes": ""
},
"type": {
"categories": [
{
"id": 1,
"missing": false,
"name": "Emerging Affluent",
"numeric_value": null
},
{
"id": -1,
"missing": true,
"name": "No Data",
"numeric_value": null
}
],
"class": "categorical",
"ordinal": false
}
},
{
"derived": true,
"references": {
"alias": "localincome_hk_rc",
"description": "Monthly household income",
"name": "Monthly household income (NET)",
"notes": "",
"subreferences": [
{
"alias": "localincome_hk_rc_1",
"name": "Low (below HKD 25,000)"
},
{
"alias": "localincome_hk_rc_2",
"name": "Mid (HKD 25,000 - 49,999)"
},
{
"alias": "localincome_hk_rc_3",
"name": "High (HKD 50,000 or above)"
}
]
},
"type": {
"class": "enum",
"elements": [
{
"id": 1,
"missing": false,
"value": {
"derived": false,
"id": "0001",
"references": {
"alias": "localincome_hk_rc_1",
"name": "Low (below HKD 25,000)"
},
"type": {
"categories": [
{
"id": 1,
"missing": false,
"name": "Selected",
"numeric_value": 1,
"selected": true
},
{
"id": 0,
"missing": false,
"name": "Other",
"numeric_value": 0
},
{
"id": -1,
"missing": true,
"name": "No Data",
"numeric_value": null
}
],
"class": "categorical",
"ordinal": false
}
}
},
{
"id": 2,
"missing": false,
"value": {
"derived": false,
"id": "0002",
"references": {
"alias": "localincome_hk_rc_2",
"name": "Mid (HKD 25,000 - 49,999)"
},
"type": {
"categories": [
{
"id": 1,
"missing": false,
"name": "Selected",
"numeric_value": 1,
"selected": true
},
{
"id": 0,
"missing": false,
"name": "Other",
"numeric_value": 0
},
{
"id": -1,
"missing": true,
"name": "No Data",
"numeric_value": null
}
],
"class": "categorical",
"ordinal": false
}
}
},
{
"id": 3,
"missing": false,
"value": {
"derived": false,
"id": "0003",
"references": {
"alias": "localincome_hk_rc_3",
"name": "High (HKD 50,000 or above)"
},
"type": {
"categories": [
{
"id": 1,
"missing": false,
"name": "Selected",
"numeric_value": 1,
"selected": true
},
{
"id": 0,
"missing": false,
"name": "Other",
"numeric_value": 0
},
{
"id": -1,
"missing": true,
"name": "No Data",
"numeric_value": null
}
],
"class": "categorical",
"ordinal": false
}
}
}
],
"subtype": {
"class": "variable"
}
}
},
{
"derived": true,
"references": {
"alias": "localincome_hk_rc",
"description": "Monthly household income",
"name": "Monthly household income (NET)",
"notes": "",
"subreferences": [
{
"alias": "localincome_hk_rc_1",
"name": "Low (below HKD 25,000)"
},
{
"alias": "localincome_hk_rc_2",
"name": "Mid (HKD 25,000 - 49,999)"
},
{
"alias": "localincome_hk_rc_3",
"name": "High (HKD 50,000 or above)"
}
]
},
"type": {
"categories": [
{
"id": 1,
"missing": false,
"name": "Selected",
"numeric_value": 1,
"selected": true
},
{
"id": 0,
"missing": false,
"name": "Other",
"numeric_value": 0
},
{
"id": -1,
"missing": true,
"name": "No Data",
"numeric_value": null
}
],
"class": "categorical",
"ordinal": false,
"subvariables": [
"0001",
"0002",
"0003"
]
}
}
],
"measures": {
"count": {
"data": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"metadata": {
"derived": true,
"references": {},
"type": {
"class": "numeric",
"integer": false,
"missing_reasons": {
"No Data": -1
},
"missing_rules": {}
}
},
"n_missing": 1133
}
},
"n": 1133
}
}
22 changes: 18 additions & 4 deletions tests/integration/test_crunch_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from .fixtures import (
ADMIT_X_DEPT_UNWEIGHTED, ADMIT_X_GENDER_WEIGHTED, BINNED, CAT_X_CAT,
CAT_X_CAT_FILTERED_POP, CAT_X_CAT_GERMAN_WEIGHTED,
CAT_X_CAT_WITH_EMPTY_COLS, CAT_X_DATETIME, CAT_X_LOGICAL, CAT_X_MR_X_CAT,
CAT_X_NUM_X_DATETIME, CA_SINGLE_CAT, CA_SUBVAR_HS_X_MR_X_CA_CAT,
CA_SUBVAR_X_CAT_HS, CA_X_MR_WEIGHTED_HS, CA_X_SINGLE_CAT,
ECON_BLAME_WITH_HS, ECON_BLAME_X_IDEOLOGY_ROW_HS,
CAT_X_CAT_WITH_EMPTY_COLS, CAT_X_DATETIME, CAT_X_LOGICAL,
CAT_X_MR_SENTRY, CAT_X_MR_X_CAT, CAT_X_NUM_X_DATETIME, CA_SINGLE_CAT,
CA_SUBVAR_HS_X_MR_X_CA_CAT, CA_SUBVAR_X_CAT_HS, CA_X_MR_WEIGHTED_HS,
CA_X_SINGLE_CAT, ECON_BLAME_WITH_HS, ECON_BLAME_X_IDEOLOGY_ROW_HS,
ECON_GENDER_X_IDEOLOGY_WEIGHTED, ECON_MEAN_AGE_BLAME_X_GENDER,
ECON_MEAN_NO_DIMS, FRUIT_X_PETS, FRUIT_X_PETS_ARRAY,
FRUIT_X_PETS_ARRAY_PETS_FIRST, FRUIT_X_PETS_ARRAY_SUBVARS_FIRST,
Expand Down Expand Up @@ -49,6 +49,20 @@ def it_knows_the_main_axis_of_a_univariate_ca_cube(self):
univariate_ca_main_axis = cube.univariate_ca_main_axis
assert univariate_ca_main_axis == 1

@pytest.mark.xfail(reason='WIP', strict=True)
def it_provides_array_for_single_valid_cat_CAT_X_MR(self):
# --we're not sure yet what is distinctive about this cube, but it
# --broke .as_array() in _prune_body with mask size mismatch. The
# --cat dimension has only one valid cat, so that's one thing, the
# --other is that all weighted counts are 0 (zero) even though
# --unweighted counts are non-zero.
cube = CrunchCube(CAT_X_MR_SENTRY)
arr = cube.as_array(prune=True)
# ---!!! not sure what expected form is, maybe [] since all values
# ---are zero and prune=True. It raises mask exception so haven't
# ---ever seen the right answer and can't confidently predict it yet.
np.testing.assert_array_equal(arr, np.array([[0, 0, 0]]))

# fixtures -------------------------------------------------------

@pytest.fixture(params=[
Expand Down

0 comments on commit ecb6dc6

Please sign in to comment.