def it_can_compute_its_blocks(self, request): property_mock(request, _BaseSubtotals, "_subtotal_columns") property_mock(request, _BaseSubtotals, "_subtotal_rows") property_mock(request, _BaseSubtotals, "_intersections") base_subtotals = _BaseSubtotals("_base_values", None) blocks = base_subtotals._blocks assert blocks == [ ["_base_values", base_subtotals._subtotal_columns], [base_subtotals._subtotal_rows, base_subtotals._intersections], ]
def it_assembles_its_intersections_to_help(self, _intersection_, _column_subtotals_prop_, _row_subtotals_prop_): _intersection_.return_value = 10 _column_subtotals_prop_.return_value = [1, 2, 3] _row_subtotals_prop_.return_value = [1, 2] subtotals = _BaseSubtotals(None, None) assert (subtotals._intersections.tolist() == np.full( ( 2, # row subtotals has len 2 3, # column subtotals has len 3 ), 10, # dummy fill value from `_intersection` fixture ).tolist())
def it_assembles_its_subtotal_columns_to_help( self, _column_subtotals_prop_, _nrows_prop_, _subtotal_column_, subtotal_, nrows, n_subtotals, expected_value, ): _column_subtotals_prop_.return_value = (subtotal_, ) * n_subtotals _subtotal_column_.return_value = np.array([1, 2, 3]) _nrows_prop_.return_value = nrows subtotal_columns = _BaseSubtotals(None, None)._subtotal_columns assert subtotal_columns.tolist() == expected_value.tolist()
def it_assembles_its_subtotal_rows_to_help( self, _row_subtotals_prop_, _ncols_prop_, _subtotal_row_, ncols, row_subtotals, shape, expected_value, ): _row_subtotals_prop_.return_value = row_subtotals _subtotal_row_.return_value = np.array([1, 2, 3]) _ncols_prop_.return_value = ncols subtotal_rows = _BaseSubtotals(None, None)._subtotal_rows assert subtotal_rows.shape == shape assert subtotal_rows.tolist() == expected_value
def it_provides_access_to_the_row_subtotals_to_help(self, dimension_): subtotals = _BaseSubtotals(None, (dimension_, None)) assert subtotals._row_subtotals is dimension_.subtotals
def it_knows_how_many_rows_are_in_the_base_matrix_to_help(self): base_values = np.arange(12).reshape(3, 4) assert _BaseSubtotals(base_values, None)._nrows == 3
def it_provides_access_to_the_column_subtotals_to_help(self, dimension_): subtotals = _BaseSubtotals(None, (None, dimension_)) assert subtotals._column_subtotals is dimension_.subtotals