Beispiel #1
0
    def test__learn_rounding_digits_more_than_15_decimals(data):
        """Test the _learn_rounding_digits method with more than 15 decimals.

        If the data has more than 15 decimals, None should be returned.

        Input:
        - An array that contains floats with more than 15 decimals.
        Output:
        - None
        """
        data = np.random.random(size=10).round(20)

        output = NumericalTransformer._learn_rounding_digits(data)

        assert output is None
Beispiel #2
0
    def test__learn_rounding_digits_less_than_15_decimals(data):
        """Test the _learn_rounding_digits method with less than 15 decimals.

        If the data has less than 15 decimals, the maximum number of decimals
        should be returned.

        Input:
        - An array that contains floats with a maximum of 3 decimals and a NaN.
        Output:
        - 3
        """
        data = np.array([10, 0., 0.1, 0.12, 0.123, np.nan])

        output = NumericalTransformer._learn_rounding_digits(data)

        assert output == 3
Beispiel #3
0
    def test__learn_rounding_digits_negative_decimals_integer(data):
        """Test the _learn_rounding_digits method with integers multiples of powers of 10.

        If the data has all multiples of 10, 100, or any other higher power of 10,
        the output is the negative number of decimals representing the corresponding
        power of 10.

        Input:
        - An array that contains integers that are multiples of powers of 10, 100 and 1000
          and a NaN.
        Output:
        - -1
        """
        data = np.array([1230, 12300, 123000, np.nan])

        output = NumericalTransformer._learn_rounding_digits(data)

        assert output == -1