Skip to content
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

BLD: Negative zero handling with ifort #18753

Merged
merged 2 commits into from
Apr 12, 2021
Merged

BLD: Negative zero handling with ifort #18753

merged 2 commits into from
Apr 12, 2021

Conversation

h6197627
Copy link
Contributor

Fixes scipy/scipy#11339

What does this implement/fix?

NumPy/SciPy compiled with Intel Fortran compiler using default flags treat both -0.0 and +0.0 as 0.0, however it is not IEEE 754 compliant and some SciPy logic relies on this -0.0 and +0.0 differentiation.

Fixes scipy/scipy#11339

**What does this implement/fix?**

NumPy/SciPy compiled with Intel Fortran compiler using default flags treats both -0.0 and +0.0 as 0.0, however it is not IEEE 754 compliant and some SciPy logic relies on this -0.0 and +0.0 differentiation.
@github-actions github-actions bot added the 36 - Build Build related PR label Apr 11, 2021
@charris
Copy link
Member

charris commented Apr 11, 2021

Can you give an example of the problems?

@h6197627
Copy link
Contributor Author

@charris, one of SciPy test fails because some functionality relies on this difference between -0.0 and +0.0

_____________________________________________ TestExp1.test_branch_cut _____________________________________________
self = <scipy.special.tests.test_exponential_integrals.TestExp1 object at 0x00000296E7953EC8>

    def test_branch_cut(self):
        assert np.isnan(sc.exp1(-1))
>       assert sc.exp1(complex(-1, 0)).imag == (
            -sc.exp1(complex(-1, -0.0)).imag
        )
E       AssertionError: assert -3.141592653589793 == --3.141592653589793
E        +  where -3.141592653589793 = (-1.8951178163559368-3.141592653589793j).imag
E        +    where (-1.8951178163559368-3.141592653589793j) = <ufunc 'exp1'>((-1+0j))
E        +      where <ufunc 'exp1'> = sc.exp1
E        +      and   (-1+0j) = complex(-1, 0)
E        +  and   -3.141592653589793 = (-1.8951178163559368-3.141592653589793j).imag
E        +    where (-1.8951178163559368-3.141592653589793j) = <ufunc 'exp1'>((-1-0j))
E        +      where <ufunc 'exp1'> = sc.exp1
E        +      and   (-1-0j) = complex(-1, -0.0)

self       = <scipy.special.tests.test_exponential_integrals.TestExp1 object at 0x00000296E7953EC8>

C:\Program Files\Python\3.7.6\lib\site-packages\scipy\special\tests\test_exponential_integrals.py:12: AssertionError

After some discussions in scipy/scipy#11339 @rgommers advised to pass this flag at the build system level rather than to specific SciPy module, because it forces NumPy/SciPy to follow closer IEEE floating point standards when building with Intel compilers.

@charris charris merged commit 6ad995f into numpy:main Apr 12, 2021
@charris
Copy link
Member

charris commented Apr 12, 2021

Thanks @h6197627 . I note that there is no get_flags_debug for the Intel compiler on non-windows platforms, do you know if we should have that?

@rgommers
Copy link
Member

Thanks @h6197627

@rgommers
Copy link
Member

Let's not worry about get_flags_debug unless anyone complains about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
36 - Build Build related PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TestExp1.test_branch_cut test failure with Intel Fortran
3 participants