Example #1
0
    def testReturnNan(self):
        """Test values for which log10(value) returns NaN.
        
        Test: NaN, -Inf, and a few negative values.
        """
        testValues = (float('nan'), float('-inf'), -1.0, -sys.float_info.max,
                      -sys.float_info.min)

        for value in testValues:
            logValue = ctools.fastLog10(value)
            self.assertTrue(math.isnan(logValue))
Example #2
0
    def testReturnDefined(self):
        """Test specific values."""
        # Test cases as (value, log10(value))
        testCases = (
            (0.0, float('-inf')),
            (1.0, 0.0),
            (float('inf'), float('inf')),
        )

        for value, refLogValue in testCases:
            logValue = ctools.fastLog10(value)
            self.assertEqual(logValue, refLogValue)
Example #3
0
    def testReturnDefined(self):
        """Test specific values."""
        # Test cases as (value, log10(value))
        testCases = (
            (0.0, float('-inf')),
            (1.0, 0.0),
            (float('inf'), float('inf')),
        )

        for value, refLogValue in testCases:
            logValue = ctools.fastLog10(value)
            self.assertEqual(logValue, refLogValue)
Example #4
0
    def testReturnNan(self):
        """Test values for which log10(value) returns NaN.
        
        Test: NaN, -Inf, and a few negative values.
        """
        testValues = (
            float('nan'),
            float('-inf'),
            -1.0,
            - sys.float_info.max,
            - sys.float_info.min
        )

        for value in testValues:
            logValue = ctools.fastLog10(value)
            self.assertTrue(math.isnan(logValue))