8000 Test errors from inplace power operator · Issue #8307 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Test errors from inplace power operator #8307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rgommers opened this issue Nov 24, 2016 · 13 comments
Closed

Test errors from inplace power operator #8307

rgommers opened this issue Nov 24, 2016 · 13 comments

Comments

@rgommers
Copy link
Member

They're new, likely due to gh-8231. It doesn't happen on all platforms, this is on OS X with Python 3.5:

In [1]: x = np.arange(3)

In [2]: x **= 4

In [3]: x = np.arange(3, dtype=np.longdouble)

In [4]: x **= 4
/Library/Frameworks/Python.framework/Versions/3.5/bin/ipython:1: RuntimeWarning: divide by zero encountered in power
  #!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5

The 4 test errors:

======================================================================
ERROR: test_linalg.TestNormDouble.test_vector_return_type
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/linalg/tests/test_linalg.py", line 882, in test_vector_return_type
    an = norm(at, 4)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 2224, in norm
    absx **= ord
RuntimeWarning: divide by zero encountered in power

======================================================================
ERROR: test_linalg.TestNormInt64.test_vector_return_type
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/linalg/tests/test_linalg.py", line 882, in test_vector_return_type
    an = norm(at, 4)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 2224, in norm
    absx **= ord
RuntimeWarning: divide by zero encountered in power

======================================================================
ERROR: test_linalg.TestNormSingle.test_vector_return_type
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/linalg/tests/test_linalg.py", line 882, in test_vector_return_type
    an = norm(at, 4)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 2224, in norm
    absx **= ord
RuntimeWarning: divide by zero encountered in power

======================================================================
ERROR: test_linalg.TestNorm_NonSystematic.test_longdouble_norm
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/linalg/tests/test_linalg.py", line 1116, in test_longdouble_norm
    old_assert_almost_equal(norm(x, ord=3), 12.65, decimal=2)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/numpy/linalg/linalg.py", line 2224, in norm
    absx **= ord
RuntimeWarning: divide by zero encountered in power
@charris
Copy link
Member
charris commented Nov 24, 2016
8000

That is a very strange bug, especially if it is OS X specific. Are the actual results correct? If so, I'd suspect a bug in a library, there should be no divisions.

@charris
Copy link
Member
charris commented Nov 24, 2016

Ralf, can you check that the ufunc itself works without warnings? I'd like to determine if this is specific to the inplace operator.

@rgommers
Copy link
Member Author

It's not:

In [9]: x = np.arange(3, dtype=np.longdouble)

In [10]: np.power(x, 4)
/Library/Frameworks/Python.framework/Versions/3.5/bin/ipython:1: RuntimeWarning: divide by zero encountered in power
  #!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Out[10]: array([ 0.0,  1.0,  16.0], dtype=float128)

It's specific to float128 though.

@charris
Copy link
Member
charris commented Nov 24, 2016

So it is located in the powl function. The remaining question is: ours or theirs? Do you have a local build so that you can grep for 'HAVE_POWL' in the config.h file?

@charris
Copy link
Member
charris commented Nov 24, 2016

And our fallback version of powl simply calls the double version. Are you are using the PyPI wheel?

@charris
Copy link
Member
charris commented Nov 25, 2016

So I think it is the Mac powl function. That can be verified by blacklisting it in numpy/core/src/private/config.h.

@rgommers
Copy link
Member Author
rgommers commented Nov 26, 2016

Do you have a local build so that you can grep for 'HAVE_POWL' in the config.h file?

$ grin HAVE_POWL
./numpy/core/include/numpy/config.h:
114 : #define HAVE_POWL 1

Are you are using the PyPI wheel?

No, a local build of recent master. Checked PyPI wheel for 1.11.2 - has the same issue.

So I think it is the Mac powl function. That can be verified by blacklisting it in numpy/core/src/private/config.h.

That fixes it.

EDIT: removed last section of this comment, was incorrect.

@charris
Copy link
Member
charris commented Nov 26, 2016

Any idea why we didn't detect this earlier? Perhaps Sebastian's work to make sure warnings are cleared correctly is responsible.

@rgommers
Copy link
Member Author

Not sure, but that sounds like a plausible explanation.

@charris
Copy link
Member
charris commented Nov 26, 2016

And the error didn't show up on the wheel builds because it was a release. Hmm..., we really need to start testing on the Mac platform. IIRC, we cannot do both on travis.

@pv
Copy link
Member
pv commented Nov 26, 2016

iirc travis does support osx hosts for open source, so maybe add one in the matrix?

@matthew-brett
Copy link
Contributor

Yes, I think travis-ci quietly enabled this feature for open-source accounts a few months ago. See https://github.com/scikit-image/scikit-image/blob/master/.travis.yml#L52 for an example.

@rgommers
Copy link
Member Author

WarrenWeckesser added a commit to WarrenWeckesser/numpy that referenced this issue Aug 27, 2020
The use of the math library powl was blacklisted on Mac OSX
(numpygh-8318) because powl(0, y) would trigger a divide-by-zero
warning even when y > 0 (issue numpygh-8307).

This change creates npy_powl on OSX that avoids the spurious
warning by not calling powl when x = 0 and y > 0.

The change in npy_math_internal.h.src moves the handling
of pow out of a template repeat-loop, so powl and powf
are handled individually.  This allows the creation of
npy_powl to be specialized when NPY_OS_DARWIN is defined.

Closes numpygh-8608.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0