def it_knows_its_selected_categories_labels(self, _dimensions_prop_): _dimensions_prop_.return_value = [ Dimension({"references": {}}, None, None) ] strand_ = _Strand(None, None, None, None, None, None) assert strand_.selected_category_labels == ()
def it_knows_the_population_fraction(self, cube_): cube_.population_fraction = 0.5 strand_ = _Strand(cube_, None, None, None, None, None) population_fraction = strand_.population_fraction assert population_fraction == 0.5
def it_knows_its_title(self, cube_): cube_.title = "Unmarried" strand_ = _Strand(cube_, None, None, None, None, None) title = strand_.title assert title == "Unmarried"
def it_knows_whether_it_is_empty(self, shape, expected_value, shape_prop_): shape_prop_.return_value = shape strand = _Strand(None, None, None, None, None, None) is_empty = strand.is_empty assert is_empty is expected_value
def it_knows_which_of_its_rows_are_inserted(self, _assembler_prop_, assembler_): _assembler_prop_.return_value = assembler_ assembler_.inserted_row_idxs = (1, 3, 5) strand = _Strand(None, None, None, None, None, None) assert strand.inserted_row_idxs == (1, 3, 5)
def it_provides_the_population_counts_moe( self, cube_, _assembler_prop_, assembler_, ): assembler_.population_proportion_stderrs = 0.3 _assembler_prop_.return_value = assembler_ cube_.population_fraction = 0.1 population = 20 strand_ = _Strand(cube_, None, population, None, None, None) assert strand_.population_counts_moe == pytest.approx(0.6 * 1.959964)
def it_computes_the_sort_by_measure_value_row_order_to_help( self, fixture, measure, direction, expected_value): transforms = { "rows_dimension": { "order": { "type": "univariate_measure", "measure": measure, "direction": direction, } } } cube = Cube(fixture, transforms=transforms) stripe = _Strand(cube, transforms, None, False, 0, None) assembler = stripe._assembler assert assembler._row_order.tolist() == expected_value
def it_provides_the_default_repr_when_enhanced_repr_fails(self): cube = _Strand(None, None, None, None, None, None) cube_repr = cube.__repr__() assert cube_repr.startswith("<cr.cube.cubepart._Strand object at 0x")