Skip to content

test_pareto on 32-bit got even worse #18387

Open

Description

@bnavigator

Hi,
NumPy 1.20.0 on openSUSE Tumbleweed 32-bit looks even worse than Ubuntu some years ago (#430):

[ 1044s] __________________________ TestRandomDist.test_pareto __________________________
[ 1044s] [gw4] linux -- Python 3.8.7 /usr/bin/python3.8
[ 1044s] 
[ 1044s] self = <numpy.random.tests.test_generator_mt19937.TestRandomDist object at 0xf06d9bc8>
[ 1044s] 
[ 1044s]     def test_pareto(self):
[ 1044s]         random = Generator(MT19937(self.seed))
[ 1044s]         actual = random.pareto(a=.123456789, size=(3, 2))
[ 1044s]         desired = np.array([[1.0394926776069018e+00, 7.7142534343505773e+04],
[ 1044s]                             [7.2640150889064703e-01, 3.4650454783825594e+05],
[ 1044s]                             [4.5852344481994740e+04, 6.5851383009539105e+07]])
[ 1044s]         # For some reason on 32-bit x86 Ubuntu 12.10 the [1, 0] entry in this
[ 1044s]         # matrix differs by 24 nulps. Discussion:
[ 1044s]         #   https://mail.python.org/pipermail/numpy-discussion/2012-September/063801.html
[ 1044s]         # Consensus is that this is probably some gcc quirk that affects
[ 1044s]         # rounding but not in any important way, so we just use a looser
[ 1044s]         # tolerance on this test:
[ 1044s] >       np.testing.assert_array_almost_equal_nulp(actual, desired, nulp=30)
[ 1044s] E       AssertionError: X and Y are not equal to 30 ULP (max is 31)
[ 1044s] 
[ 1044s] ../../../BUILDROOT/python-numpy-1.20.0-90.1.i386/usr/lib/python3.8/site-packages/numpy/random/tests/test_generator_mt19937.py:1520: AssertionError
(Pdb) (actual-desired)
array([[ 4.44089210e-16,  0.00000000e+00],
       [-2.22044605e-16,  0.00000000e+00],
       [ 0.00000000e+00, -2.30967999e-07]])
(Pdb) np.spacing(max(abs(actual).max(), abs(desired).max()))*30
2.2351741790771484e-07

Activity

  1. added this to the 1.20.2 release milestone on Feb 10, 2021
  2. seberg commented on Feb 10, 2021

    @seberg
    Member

    I am surprised anything changed here, but marking for 1.20.2, just so that its not lost by accident. For what its worth, the mailing list link is slightly off for me, and this gives the right one:
    https://mail.python.org/pipermail/numpy-discussion/2012-September/063764.html

    Out of curiosity, do you know that this is a regression in that the 1.19 passed fine with the same compiler versions, etc?

  3. bnavigator commented on Feb 10, 2021

    @bnavigator
    ContributorAuthor

    See #18388 for build logs. Here is a passing one for 1.19.5:
    numpy-1.19-i586_log.txt

  4. bashtage commented on Feb 11, 2021

    @bashtage
    Contributor

    What is a little interesting is that it doesn't occur in the same test for RandomState. Even though the underlying code is the same, the seeding of the MT19937 generator in the failing file is different from that in the RandomState, and so the test values are different.

  5. removed this from the 1.20.2 release milestone on Mar 27, 2021
  6. charris commented on Mar 27, 2021

    @charris
    Member

    I cleared the milestone here. @bashtage Seems this is a value issue/

  7. bashtage commented on Mar 27, 2021

    @bashtage
    Contributor

    I think it would be reasonable to relax the tolerance on 32-bit Linux as a pragmatic fix. It seems to be compiler-specific since the test doesn't fail on other 32-bit platforms including other 32-bit variants of Linux.

  8. apteryks commented on Apr 19, 2022

    @apteryks

    I also reproduce this on i686-linux (GNU Guix). The test_float_remainder_overflow test also failed there:

    =================================== FAILURES ===================================
    _________________ TestRemainder.test_float_remainder_overflow __________________
    [gw15] linux -- Python 3.9.9 /gnu/store/iabliixhj5hirckni5wr3d75vjfcw74i-python-3.9.9/bin/python3
    
    self = <numpy.core.tests.test_umath.TestRemainder object at 0xf1c7d958>
    
        def test_float_remainder_overflow(self):
            a = np.finfo(np.float64).tiny
            with np.errstate(over='ignore', invalid='ignore'):
                div, mod = np.divmod(4, a)
                np.isinf(div)
                assert_(mod == 0)
            with np.errstate(over='raise', invalid='ignore'):
                assert_raises(FloatingPointError, np.divmod, 4, a)
            with np.errstate(invalid='raise', over='ignore'):
    >           assert_raises(FloatingPointError, np.divmod, 4, a)
    
    a          = 2.2250738585072014e-308
    div        = inf
    mod        = 0.0
    self       = <numpy.core.tests.test_umath.TestRemainder object at 0xf1c7d958>
    
    /gnu/store/vbhm2gxkfhmdx085yy2kkrwc34y40778-python-numpy-1.21.6/lib/python3.9/site-packages/numpy/core/tests/test_umath.py:607: 
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    /gnu/store/iabliixhj5hirckni5wr3d75vjfcw74i-python-3.9.9/lib/python3.9/unittest/case.py:739: in assertRaises
        return context.handle('assertRaises', args, kwargs)
            args       = (<ufunc 'divmod'>, 4, 2.2250738585072014e-308)
            context    = None
            expected_exception = <class 'FloatingPointError'>
            kwargs     = {}
            self       = <numpy.testing._private.utils._Dummy testMethod=nop>
    /gnu/store/iabliixhj5hirckni5wr3d75vjfcw74i-python-3.9.9/lib/python3.9/unittest/case.py:201: in handle
        callable_obj(*args, **kwargs)
            args       = [4, 2.2250738585072014e-308]
            callable_obj = <ufunc 'divmod'>
            kwargs     = {}
            name       = 'assertRaises'
            self       = None
    /gnu/store/iabliixhj5hirckni5wr3d75vjfcw74i-python-3.9.9/lib/python3.9/unittest/case.py:223: in __exit__
        self._raiseFailure("{} not raised by {}".format(exc_name,
            exc_name   = 'FloatingPointError'
            exc_type   = None
            exc_value  = None
            self       = <unittest.case._AssertRaisesContext object at 0xf1c7dcd0>
            tb         = None
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
    
    self = <unittest.case._AssertRaisesContext object at 0xf1c7dcd0>
    standardMsg = 'FloatingPointError not raised by divmod'
    
        def _raiseFailure(self, standardMsg):
            msg = self.test_case._formatMessage(self.msg, standardMsg)
    >       raise self.test_case.failureException(msg)
    E       AssertionError: FloatingPointError not raised by divmod
    
    msg        = 'FloatingPointError not raised by divmod'
    self       = <unittest.case._AssertRaisesContext object at 0xf1c7dcd0>
    standardMsg = 'FloatingPointError not raised by divmod'
    
    /gnu/store/iabliixhj5hirckni5wr3d75vjfcw74i-python-3.9.9/lib/python3.9/unittest/case.py:163: AssertionError
    __________________________ TestRandomDist.test_pareto __________________________
    [gw2] linux -- Python 3.9.9 /gnu/store/iabliixhj5hirckni5wr3d75vjfcw74i-python-3.9.9/bin/python3
    
    self = <numpy.random.tests.test_generator_mt19937.TestRandomDist object at 0x8fee2340>
    
        def test_pareto(self):
            random = Generator(MT19937(self.seed))
            actual = random.pareto(a=.123456789, size=(3, 2))
            desired = np.array([[1.0394926776069018e+00, 7.7142534343505773e+04],
                                [7.2640150889064703e-01, 3.4650454783825594e+05],
                                [4.5852344481994740e+04, 6.5851383009539105e+07]])
            # For some reason on 32-bit x86 Ubuntu 12.10 the [1, 0] entry in this
            # matrix differs by 24 nulps. Discussion:
            #   https://mail.python.org/pipermail/numpy-discussion/2012-September/063801.html
            # Consensus is that this is probably some gcc quirk that affects
            # rounding but not in any important way, so we just use a looser
            # tolerance on this test:
    >       np.testing.assert_array_almost_equal_nulp(actual, desired, nulp=30)
    E       AssertionError: X and Y are not equal to 30 ULP (max is 31)
    
    actual     = array([[1.03949268e+00, 7.71425343e+04],
           [7.26401509e-01, 3.46504548e+05],
           [4.58523445e+04, 6.58513830e+07]])
    desired    = array([[1.03949268e+00, 7.71425343e+04],
           [7.26401509e-01, 3.46504548e+05],
           [4.58523445e+04, 6.58513830e+07]])
    random     = Generator(MT19937) at 0xEEDC8028
    self       = <numpy.random.tests.test_generator_mt19937.TestRandomDist object at 0x8fee2340>
    
    /gnu/store/vbhm2gxkfhmdx085yy2kkrwc34y40778-python-numpy-1.21.6/lib/python3.9/site-packages/numpy/random/tests/test_generator_mt19937.py:1528: AssertionError
    =========================== short test summary info ============================
    FAILED ../../core/tests/test_umath.py::TestRemainder::test_float_remainder_overflow
    FAILED ../../random/tests/test_generator_mt19937.py::TestRandomDist::test_pareto
    = 2 failed, 15026 passed, 623 skipped, 18 xfailed, 4 xpassed in 189.89s (0:03:09) =
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions