Exemple #1
0
    def test__transform_min_max(self, mock_sys):
        """Test that the method ``_transform`` performs a normalization of values between ``min``
        and ``max`` with a max and min value set in.
        """
        # setup
        _min = 0.0
        _max = 10.0
        instance = FloatHyperParam(min=_min, max=_max)
        values = np.array([[0.1], [0.9]])

        # run
        result = instance._transform(values)

        # assert
        expected_result = np.array([[0.01],
                                    [0.09]])

        np.testing.assert_array_equal(result, expected_result)
Exemple #2
0
    def test__transform_no_min_no_max(self, mock_sys):
        """Test that the method ``_transform`` performs a normalization of values between ``min``
        and ``max`` with no limit set on them.
        """
        # setup
        mock_sys.float_info.max = 1000.0  # This values can be different in each OS.
        mock_sys.float_info.min = 0.0

        instance = FloatHyperParam()
        values = np.array([[0.9], [100.8]])

        # run
        result = instance._transform(values)

        # assert
        expected_result = np.array([[0.0009],
                                    [0.1008]])

        np.testing.assert_array_equal(result, expected_result)
Exemple #3
0
    def test__transform_min_no_max(self, mock_sys):
        """Test that the method ``_transform`` performs a normalization of values between ``min``
        and ``max`` with a min value set in.
        """
        # setup
        mock_sys.float_info.max = 10.0
        _min = 1.0

        instance = FloatHyperParam(min=_min)
        values = np.array([[7.3], [4.6]])

        # run
        result = instance._transform(values)

        # assert
        expected_result = np.array([[0.7],
                                    [0.4]])

        np.testing.assert_allclose(result, expected_result)