Skip to content

Commit

Permalink
cubepart: add CubePartition.cube_index
Browse files Browse the repository at this point in the history
  • Loading branch information
scanny committed May 2, 2020
1 parent 2b2750d commit a944dae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/cr/cube/cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def factory(
)
return _Slice(cube, slice_idx, transforms, population, mask_size)

@lazyproperty
def cube_index(self):
"""Offset of this partition's cube in its CubeSet.
Used to differentiate certain partitions like a filtered rows-summary strand.
"""
return self._cube.cube_index

@lazyproperty
def cube_is_mr_by_itself(self):
return False
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,7 @@ def it_provides_values_for_univariate_cat(self):
assert strand.base_counts == (10, 5)
assert strand.bases == (15, 15)
assert strand.counts == (10, 5)
assert strand.cube_index == 0
assert strand.cube_is_mr_by_itself is False
assert strand.dimension_types == (DT.CAT,)
assert strand.has_means is False
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ def and_it_constructs_a_nub_for_a_0D_cube(self, request, cube_):
_Nub_.assert_called_once_with(cube_)
assert nub is _Nub_.return_value

def it_knows_the_index_of_its_cube_in_the_cube_set(self, cube_):
cube_.cube_index = 42
cube_partition = CubePartition(cube_)

cube_index = cube_partition.cube_index

assert cube_index == 42

def it_knows_if_cube_is_mr_by_itself(self):
# --- default of False is overridden by subclasses when appropriate ---
assert CubePartition(None).cube_is_mr_by_itself is False
Expand Down

0 comments on commit a944dae

Please sign in to comment.