Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow additional types when comparing pairwise #139

Merged
merged 1 commit into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cr/cube/cube_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def can_compare_pairwise(self):
if self.ndim != 2:
return False

return all(dt in (DT.CAT, DT.CA_CAT) for dt in self.dim_types)
return all(dt in DT.ALLOWED_PAIRWISE_TYPES for dt in self.dim_types)

@lazyproperty
def dim_types(self):
Expand Down
3 changes: 3 additions & 0 deletions src/cr/cube/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ class DIMENSION_TYPE(object):

# ---subsets---
ARRAY_TYPES = frozenset((CA_SUBVAR, MR_SUBVAR))

# ---allowed types for pairwise comparison---
ALLOWED_PAIRWISE_TYPES = frozenset((CAT, CA_CAT, BINNED_NUMERIC, DATETIME, TEXT))
9 changes: 6 additions & 3 deletions tests/unit/test_cube_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ def it_can_compare_pairwise(
((DT.CA_SUBVAR, DT.CA_CAT), False),
((DT.CA_SUBVAR, DT.MR, DT.CA_CAT), False),
((DT.MR, DT.CAT), False),
((DT.BINNED_NUMERIC, DT.CAT), False),
((DT.DATETIME, DT.CAT), False),
((DT.LOGICAL, DT.CAT), False),
((DT.TEXT, DT.CAT), False),
((DT.CA_CAT, DT.CAT), True),
((DT.CAT, DT.CA_CAT), True),
((DT.CAT, DT.CAT), True),
((DT.BINNED_NUMERIC, DT.CAT), True),
((DT.CAT, DT.BINNED_NUMERIC), True),
((DT.DATETIME, DT.CAT), True),
((DT.CAT, DT.DATETIME), True),
((DT.CAT, DT.TEXT), True),
((DT.TEXT, DT.CAT), True),
]
)
def pairwise_comparisons_fixture(self, request):
Expand Down