Esempio n. 1
0
    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
Esempio n. 2
0
 def it_knows_the_only_larger_flag_state_to_help(self,
                                                 _transforms_dict_prop_,
                                                 pw_indices_dict,
                                                 expected_value):
     _transforms_dict_prop_.return_value = {
         "pairwise_indices": pw_indices_dict
     }
     assert CubePartition(None)._only_larger == expected_value
Esempio n. 3
0
    def it_interprets_the_provided_alpha_values_to_help(
            self, pw_indices_dict, expected_value):
        cube_partition = CubePartition(None,
                                       {"pairwise_indices": pw_indices_dict})

        alpha_values = cube_partition._alpha_values

        assert alpha_values == expected_value
Esempio n. 4
0
    def but_it_raises_on_invalid_alpha_values(self, pw_indices_dict,
                                              exception_type,
                                              expected_message):
        cube_partition = CubePartition(None,
                                       {"pairwise_indices": pw_indices_dict})

        with pytest.raises(exception_type) as e:
            cube_partition._alpha_values

        assert str(e.value) == expected_message
Esempio n. 5
0
    def it_can_evaluate_a_measure_expression(self, request):
        single_sided_moving_avg_smoother_ = instance_mock(
            request,
            SingleSidedMovingAvgSmoother,
            values=[[0.1, 0.2], [0.3, 0.4]])
        SingleSidedMovingAvgSmoother_ = class_mock(
            request,
            "cr.cube.cubepart.SingleSidedMovingAvgSmoother",
            return_value=single_sided_moving_avg_smoother_,
        )
        measure_expr = {
            "function": "one_sided_moving_avg",
            "base_measure": "col_percent",
            "window": 2,
        }
        cube_partition = CubePartition(None, None)

        values = cube_partition.evaluate(measure_expr)

        SingleSidedMovingAvgSmoother_.assert_called_once_with(
            cube_partition, measure_expr)
        assert values == [[0.1, 0.2], [0.3, 0.4]]
Esempio n. 6
0
 def it_provides_the_transforms_dict_to_help(self, transforms,
                                             expected_value):
     """Handles defaulting of transforms arg."""
     assert CubePartition(None,
                          transforms)._transforms_dict == expected_value
Esempio n. 7
0
 def it_knows_the_secondary_alpha_value_to_help(self, _alpha_values_prop_,
                                                alpha_values,
                                                expected_value):
     _alpha_values_prop_.return_value = alpha_values
     assert CubePartition(None)._alpha_alt == expected_value
Esempio n. 8
0
 def it_knows_the_primary_alpha_value_to_help(self, _alpha_values_prop_):
     """alpha is the primary confidence-interval threshold specified by the user."""
     _alpha_values_prop_.return_value = (0.042, 0.084)
     assert CubePartition(None)._alpha == 0.042