示例#1
0
    def it_knows_its_valid_counts_summary_to_help(self, _cubes_prop_, cube_):
        cube_.valid_counts_summary = np.array([1, 2, 3])
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        valid_counts_summary = cube_set.valid_counts_summary

        np.testing.assert_array_equal(valid_counts_summary, [1, 2, 3])
示例#2
0
    def it_knows_its_description(self, _cubes_prop_, cube_):
        cube_.description = "Are you male or female?"
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        description = cube_set.description

        assert description == "Are you male or female?"
示例#3
0
    def it_knows_its_n_reposnes_to_help(self, _cubes_prop_, cube_):
        cube_.n_responses = 6
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        n_responses = cube_set.n_responses

        assert n_responses == 6
示例#4
0
    def it_knows_its_name(self, _cubes_prop_, cube_):
        cube_.name = "Beverage"
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        name = cube_set.name

        assert name == "Beverage"
示例#5
0
    def it_knows_its_missing_count(self, first_cube_missing_count,
                                   expected_value, _cubes_prop_, cube_):
        cube_.missing = first_cube_missing_count
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        missing_count = cube_set.missing_count

        assert missing_count == expected_value
示例#6
0
    def it_knows_when_it_is_ca_as_0th(self, ncubes, expected_value,
                                      _cubes_prop_, cube_):
        cubes_ = (cube_, ) * ncubes
        cubes_[0].dimension_types = (DT.CA_SUBVAR, ) * ncubes
        _cubes_prop_.return_value = cubes_
        cube_set = CubeSet(cubes_, None, None, None)

        is_ca_as_0th = cube_set.is_ca_as_0th

        assert is_ca_as_0th == expected_value
示例#7
0
    def it_knows_whether_it_has_weighted_counts(self, first_cube_has_w_counts,
                                                expected_value, _cubes_prop_,
                                                cube_):
        cube_.has_weighted_counts = first_cube_has_w_counts
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        has_weighted_counts = cube_set.has_weighted_counts

        assert has_weighted_counts == expected_value
示例#8
0
    def it_has_proper_population_fraction(self, population_fraction,
                                          expected_value, cube_, _cubes_prop_):
        cube_.population_fraction = population_fraction
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        cubeset_population_fraction = cube_set.population_fraction

        np.testing.assert_almost_equal(cubeset_population_fraction,
                                       expected_value)
示例#9
0
    def it_provides_access_to_the_partition_sets(self, cube_partitions,
                                                 expected_value, _cubes_prop_,
                                                 cube_):
        cube_.partitions = cube_partitions
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        partition_sets = cube_set.partition_sets

        assert partition_sets == expected_value
示例#10
0
    def but_it_inflates_the_cubes_in_special_case_of_numeric_mean_payload(
            self, request, Cube_, cube_, _is_numeric_measure_prop_):
        cubes_ = tuple(instance_mock(request, Cube) for _ in range(4))
        cube_.inflate.side_effect = iter(cubes_)
        Cube_.return_value = cube_
        _is_numeric_measure_prop_.return_value = True
        cube_set = CubeSet(
            cube_responses=[{
                "cube": "resp-1"
            }, {
                "cube": "resp-2"
            }, {
                "cube": "resp-3"
            }],
            transforms=[{
                "xfrms": 1
            }, {
                "xfrms": 2
            }, {
                "xfrms": 3
            }],
            population=1000,
            min_base=10,
        )

        cubes = cube_set._cubes

        assert Cube_.call_args_list == [
            call(
                {"cube": "resp-1"},
                cube_idx=0,
                transforms={"xfrms": 1},
                population=1000,
                mask_size=10,
            ),
            call(
                {"cube": "resp-2"},
                cube_idx=1,
                transforms={"xfrms": 2},
                population=1000,
                mask_size=10,
            ),
            call(
                {"cube": "resp-3"},
                cube_idx=2,
                transforms={"xfrms": 3},
                population=1000,
                mask_size=10,
            ),
        ]
        assert cube_.inflate.call_args_list == [call(), call(), call()]
        assert cubes == cubes_[:3]
示例#11
0
    def it_knows_whether_it_can_show_pairwise(self, request, cubes_dimtypes,
                                              expected_value, _cubes_prop_):
        _cubes_prop_.return_value = tuple(
            instance_mock(request,
                          Cube,
                          dimension_types=cube_dimtypes,
                          ndim=len(cube_dimtypes))
            for cube_dimtypes in cubes_dimtypes)
        cube_set = CubeSet(None, None, None, None)

        can_show_pairwise = cube_set.can_show_pairwise

        assert can_show_pairwise is expected_value
示例#12
0
    def it_constructs_its_sequence_of_cube_objects_to_help(
            self, request, Cube_, _is_numeric_measure_prop_):
        cubes_ = tuple(instance_mock(request, Cube) for _ in range(4))
        Cube_.side_effect = iter(cubes_)
        _is_numeric_measure_prop_.return_value = False
        cube_set = CubeSet(
            cube_responses=[{
                "cube": "resp-1"
            }, {
                "cube": "resp-2"
            }, {
                "cube": "resp-3"
            }],
            transforms=[{
                "xfrms": 1
            }, {
                "xfrms": 2
            }, {
                "xfrms": 3
            }],
            population=1000,
            min_base=10,
        )

        cubes = cube_set._cubes

        assert Cube_.call_args_list == [
            call(
                {"cube": "resp-1"},
                cube_idx=0,
                transforms={"xfrms": 1},
                population=1000,
                mask_size=10,
            ),
            call(
                {"cube": "resp-2"},
                cube_idx=1,
                transforms={"xfrms": 2},
                population=1000,
                mask_size=10,
            ),
            call(
                {"cube": "resp-3"},
                cube_idx=2,
                transforms={"xfrms": 3},
                population=1000,
                mask_size=10,
            ),
        ]
        assert cubes == cubes_[:3]
示例#13
0
    def it_knows_whether_it_is_numeric_measure_to_help(
        self,
        _is_multi_cube_prop_,
        is_multi_cube,
        Cube_,
        cube_,
        cube_0_ndim,
        expected_value,
    ):
        _is_multi_cube_prop_.return_value = is_multi_cube
        cube_.ndim = cube_0_ndim
        Cube_.return_value = cube_
        cube_set = CubeSet(({"cube": 0}, {"cube": 1}), None, None, None)

        is_numeric_mean = cube_set._is_numeric_measure

        assert Cube_.call_args_list == ([call({"cube": 0})]
                                        if is_multi_cube else [])
        assert is_numeric_mean == expected_value
示例#14
0
    def it_knows_its_availabe_measures(self, cube_, _cubes_prop_):
        cube_.available_measures = {"mean", "sum"}
        _cubes_prop_.return_value = (cube_, )
        cube_set = CubeSet(None, None, None, None)

        assert cube_set.available_measures == {"mean", "sum"}