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

Fixes for Python 3.12, NumPy 2.0, and SciPy 1.14 #1050

Merged
merged 26 commits into from
Jun 25, 2024

Conversation

guyer
Copy link
Member

@guyer guyer commented Jun 18, 2024

Fixes #1049
Fixes #997

@guyer guyer requested review from wd15 and tkphd June 18, 2024 17:17
@guyer guyer mentioned this pull request Jun 18, 2024
@wd15
Copy link
Contributor

wd15 commented Jun 18, 2024

@guyer, you've broken Nix again!

@guyer
Copy link
Member Author

guyer commented Jun 18, 2024

@wd15, Nix is broken by design

This library no longer exists in Python 3.12

It looks like it isn't even needed in Python 2.7 to use pickle
and redirecting_html.py should go away (but fixed it anyway).
guyer added 11 commits June 20, 2024 11:59
petsc(4py) 3.21.2 crashes when running tests in parallel:

```
mesh2D (examples.cahnHilliard)
Doctest: examples.cahnHilliard.mesh2D ...  Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 2 in DMUMPS_LOAD_RECV_MSGS  1275068685          52
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 1 (rank 1 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 1
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
Abort(-99) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, -99) - process 0
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 2 in DMUMPS_LOAD_RECV_MSGS  1275068685          52
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
 Internal error 2 in DMUMPS_LOAD_RECV_MSGS  1275068685          52
 Internal error 1 in DMUMPS_LOAD_PROCESS_MESSAGE
 Internal error 1 in DMUMPS_LOAD_RECV_MSGS           1
```
@wd15
Copy link
Contributor

wd15 commented Jun 21, 2024

Nix passes in #1051 with a single tweak. Basically with the master branch with small change to flake.nix. Python still at 3.10.

@guyer guyer changed the title issue1049 numpy 2.0.0 breaks things Fixes for Python 3.12, NumPy 2.0, and SciPy 1.14 Jun 21, 2024
@wd15
Copy link
Contributor

wd15 commented Jun 21, 2024

Nix runs and has some failures (see #1052) when testing this branch with updated Nix to 24.05 with Python 3.12 and Numpy 1.26.4. Latest version of release nixpkgs does not have Numpy 2.0.0, obviously.

@guyer guyer requested review from wd15 and tkphd and removed request for wd15 and tkphd June 21, 2024 23:06
@wd15
Copy link
Contributor

wd15 commented Jun 25, 2024

@guyer, you're not seeing this test failure anywhere, but on the Nix branch, right?

======================================================================
FAIL: CSR (fipy.matrices.scipyMatrix._ScipyMatrix)
Doctest: fipy.matrices.scipyMatrix._ScipyMatrix.CSR
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/nix/store/c7ycrgwv039nqglbif98yggx211sdbcl-python3-3.12.3/lib/python3.12/doctest.py", line 2249, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for fipy.matrices.scipyMatrix._ScipyMatrix.CSR
  File "/home/wd15/git/fipy/fipy/matrices/scipyMatrix.py", line 280, in CSR

----------------------------------------------------------------------
File "/home/wd15/git/fipy/fipy/matrices/scipyMatrix.py", line 302, in fipy.matrices.scipyMatrix._ScipyMatrix.CSR
Failed example:
    print(numerix.asarray(cols))
Expected:
    [0 1 2 1 2 0 2]
Got:
    [0 2 1 2 1 2 0]
----------------------------------------------------------------------
File "/home/wd15/git/fipy/fipy/matrices/scipyMatrix.py", line 304, in fipy.matrices.scipyMatrix._ScipyMatrix.CSR
Failed example:
    print(numerix.asarray(data))
Expected:
    [ 12.3         10.           3.           3.14159265   2.96
       2.5          2.2       ]
Got:
    [ 12.3          3.          10.           2.96         3.14159265
       2.2          2.5       ]


----------------------------------------------------------------------

This is with Numpy 1.26.4 and Scipy 1.13.0.

@wd15
Copy link
Contributor

wd15 commented Jun 25, 2024

This is with Numpy 1.26.4 and Scipy 1.13.0.

@wd15
Copy link
Contributor

wd15 commented Jun 25, 2024

@guyer, can I bring the changes from #1052 into this branch?

@guyer
Copy link
Member Author

guyer commented Jun 25, 2024

@guyer, you're not seeing this test failure anywhere, but on the Nix branch, right?

Nope

@guyer
Copy link
Member Author

guyer commented Jun 25, 2024

@guyer, can I bring the changes from #1052 into this branch?

@wd15, yes, please

wd15 added 2 commits June 25, 2024 13:00
Update Nix build to use Python 3.12, NixOS 24.05. Also, include
aarch4-darwin as a possible build.

Currently, there is a single test failure in
fipy.matrices.scipyMatrix._ScipyMatrix.
Generate the egg_info before executing the tests otherwise setup.py
doesn't register the correct version of the test suite, but possibly
the older version already available in nixpkgs.
@wd15
Copy link
Contributor

wd15 commented Jun 25, 2024

Next step might be to try and build a conda environment with the same numpy and scipy versions as the Nix build to see if it also fails that one test.

@guyer
Copy link
Member Author

guyer commented Jun 25, 2024

Next step might be to try and build a conda environment with the same numpy and scipy versions as the Nix build to see if it also fails that one test.

Agreed. I built such an environment on my Mac and get the same error:

python      3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:13:44) [Clang 16.0.6 ]
fipy        3.4.4+41.ge25c210ec
numpy       1.26.4
pysparse    not installed
scipy       1.13.0
matplotlib  3.8.4
mpi4py      not installed
petsc4py    not installed
pyamgx      not installed
PyTrilinos  not installed
mayavi      4.8.2
gmsh        4.12.2
solver      scipy

 :
 :

======================================================================
FAIL: CSR (fipy.matrices.scipyMatrix._ScipyMatrix)
Doctest: fipy.matrices.scipyMatrix._ScipyMatrix.CSR
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/guyer/mambaforge-arm/envs/nix-scipy/lib/python3.12/doctest.py", line 2256, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for fipy.matrices.scipyMatrix._ScipyMatrix.CSR
  File "/Users/guyer/Documents/research/FiPy/fipy/fipy/matrices/scipyMatrix.py", line 280, in CSR

----------------------------------------------------------------------
File "/Users/guyer/Documents/research/FiPy/fipy/fipy/matrices/scipyMatrix.py", line 302, in fipy.matrices.scipyMatrix._ScipyMatrix.CSR
Failed example:
    print(numerix.asarray(cols))
Expected:
    [0 1 2 1 2 0 2]
Got:
    [0 2 1 2 1 2 0]
----------------------------------------------------------------------
File "/Users/guyer/Documents/research/FiPy/fipy/fipy/matrices/scipyMatrix.py", line 304, in fipy.matrices.scipyMatrix._ScipyMatrix.CSR
Failed example:
    print(numerix.asarray(data))
Expected:
    [ 12.3         10.           3.           3.14159265   2.96
       2.5          2.2       ]
Got:
    [ 12.3          3.          10.           2.96         3.14159265
       2.2          2.5       ]


----------------------------------------------------------------------
Ran 541 tests in 78.140s

FAILED (failures=1)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Skipped 38 doctest examples because neither `lsmlib` nor `skfmm` can be found on the $PATH
Skipped 1 doctest examples because `skfmm` must be used to run some tests
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@guyer
Copy link
Member Author

guyer commented Jun 25, 2024

SciPy 1.13.0, in combination with all versions of numpy 1.26.x or numpy 2.0.0, exhibits this issue under Python 3.12 (earlier numpy not an option)

@guyer
Copy link
Member Author

guyer commented Jun 25, 2024

The issue goes away with SciPy 1.13.1, with any compatible numpy. Possibly fixed by scipy/scipy#20670.

@wd15
Copy link
Contributor

wd15 commented Jun 25, 2024

The issue goes away with SciPy 1.13.1, with any compatible numpy. Possibly fixed by scipy/scipy#20670.

Oh, great. Let me see if I can get a newer scipy into the mix.

@guyer guyer merged commit 66774ea into master Jun 25, 2024
20 of 24 checks passed
@guyer guyer deleted the issue1049-Numpy_2.0.0_breaks_things branch June 25, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numpy 2.0.0 breaks things future.standard_library breaking python 3.12 compatibility
2 participants