Exemple #1
0
    def it_gathers_the_numeric_values_to_help(self, rows_dimension_,
                                              _has_numeric_value_prop_):
        rows_dimension_.numeric_values = (1, np.nan, 3)
        _has_numeric_value_prop_.return_value = np.array([True, False, True])
        scaled_counts = _ScaledCounts(rows_dimension_, None, None)

        assert scaled_counts._numeric_values.tolist() == [1, 3]
Exemple #2
0
    def it_computes_the_total_scaled_count_to_help(self,
                                                   _weighted_counts_prop_,
                                                   _numeric_values_prop_):
        _weighted_counts_prop_.return_value = np.array([10, 20, 30, 40])
        _numeric_values_prop_.return_value = np.array([1, 2, 3, 4])
        scaled_counts = _ScaledCounts(None, None, None)

        # --- 10 + 40 + 90 + 160 = 300 ---
        assert scaled_counts._total_scaled_count == 300
Exemple #3
0
    def it_knows_the_scale_stddev(
        self,
        _numeric_values_prop_,
        numeric_values,
        _scale_variance_prop_,
        scale_variance,
        expected_value,
    ):
        _numeric_values_prop_.return_value = numeric_values
        _scale_variance_prop_.return_value = scale_variance
        scaled_counts = _ScaledCounts(None, None, None)

        assert scaled_counts.scale_stddev == expected_value
Exemple #4
0
    def it_retrives_the_weighted_counts_to_help(self, request,
                                                _has_numeric_value_prop_):
        weighted_cube_counts_ = instance_mock(request,
                                              _BaseCubeCounts,
                                              counts=np.array([1.1, 2.2, 3.3]))
        property_mock(
            request,
            _ScaledCounts,
            "_weighted_cube_counts",
            return_value=weighted_cube_counts_,
        )
        _has_numeric_value_prop_.return_value = np.array([True, False, True])
        scaled_counts = _ScaledCounts(None, None, None)

        assert scaled_counts._weighted_counts == pytest.approx([1.1, 3.3])
Exemple #5
0
    def it_knows_the_scale_median(
        self,
        _numeric_values_prop_,
        numeric_values,
        _weighted_counts_prop_,
        weighted_counts,
        _total_weighted_count_prop_,
        expected_value,
    ):
        _numeric_values_prop_.return_value = numeric_values
        _weighted_counts_prop_.return_value = weighted_counts
        _total_weighted_count_prop_.return_value = np.sum(weighted_counts)
        scaled_counts = _ScaledCounts(None, None, None)

        assert scaled_counts.scale_median == expected_value
Exemple #6
0
    def it_knows_the_scale_mean(
        self,
        _numeric_values_prop_,
        numeric_values,
        _total_weighted_count_prop_,
        total_weighted_count,
        _total_scaled_count_prop_,
        expected_value,
    ):
        _numeric_values_prop_.return_value = numeric_values
        _total_weighted_count_prop_.return_value = total_weighted_count
        _total_scaled_count_prop_.return_value = 400
        scaled_counts = _ScaledCounts(None, None, None)

        assert scaled_counts.scale_mean == expected_value
Exemple #7
0
    def it_knows_the_scale_stderr(
        self,
        _numeric_values_prop_,
        numeric_values,
        _scale_variance_prop_,
        scale_variance,
        _total_weighted_count_prop_,
        total_weighted_count,
        expected_value,
    ):
        _numeric_values_prop_.return_value = numeric_values
        _scale_variance_prop_.return_value = scale_variance
        _total_weighted_count_prop_.return_value = total_weighted_count
        scaled_counts = _ScaledCounts(None, None, None)

        assert scaled_counts.scale_stderr == expected_value
Exemple #8
0
    def it_computes_the_scale_variance_to_help(
        self,
        request,
        _weighted_counts_prop_,
        _numeric_values_prop_,
        _total_weighted_count_prop_,
    ):
        _weighted_counts_prop_.return_value = np.array([100, 200, 300])
        _numeric_values_prop_.return_value = np.array([1, 2, 3])
        property_mock(request,
                      _ScaledCounts,
                      "scale_mean",
                      return_value=2.333333)
        _total_weighted_count_prop_.return_value = 600
        scaled_counts = _ScaledCounts(None, None, None)

        assert scaled_counts._scale_variance == pytest.approx(0.5555556)
Exemple #9
0
    def it_computes_the_total_weighted_count_to_help(self,
                                                     _weighted_counts_prop_):
        _weighted_counts_prop_.return_value = np.array([10, 20, 30, 40])
        scaled_counts = _ScaledCounts(None, None, None)

        assert scaled_counts._total_weighted_count == 100
Exemple #10
0
    def it_knows_which_elements_have_a_numeric_values_to_help(
            self, rows_dimension_):
        rows_dimension_.numeric_values = (1, np.nan, 3)
        scaled_counts = _ScaledCounts(rows_dimension_, None, None)

        assert scaled_counts._has_numeric_value.tolist() == [True, False, True]