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

[BUG] Tests fail with NumPy 2.2.0 #1499

Open
penguinpee opened this issue Dec 20, 2024 · 1 comment
Open

[BUG] Tests fail with NumPy 2.2.0 #1499

penguinpee opened this issue Dec 20, 2024 · 1 comment

Comments

@penguinpee
Copy link

Fedora has recently upgraded NumPy to 2.2.0 in the development branch. Building meshio with that version results in a number of tests failing:

=========================== short test summary info ============================
FAILED tests/test_dolfin.py::test_dolfin[mesh3] - ValueError: could not conve...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh9] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh10] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh11] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh12] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh13] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh14] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh8] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh9] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh10] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh11] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh12] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh13] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh8] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh9] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh10] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh11] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh12] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh13] - ValueError: cannot res...
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh0] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh1] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh2] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh3] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh4] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh5] - meshio._exceptions....
============ 25 failed, 714 passed, 6 skipped, 25 warnings in 4.68s ============

The set of errors is:

ValueError: could not convert string to float: 'np.float64(63.69616873214543)'
ValueError: cannot reshape array of size 1 into shape (4,2)
meshio._exceptions.ReadError: Header of ugrid file is ill-formed

The full log of all test failures is too big to post here. But this should be rather easy to reproduce in a venv. On my Fedora box I'd do:

python3.13 -m venv .venv
. .venv/bin/activate
pip installe -e .
pip install pytest netCDF4 h5py
pytest -v

For a quick glance, the log from the latest build attempt is accessible online:

https://kojipkgs.fedoraproject.org/work/tasks/8425/126988425/build.log

It will be cleaned up over time, however.

@penguinpee penguinpee changed the title [BUG] Tests fail with NumPy 2.0.0 [BUG] Tests fail with NumPy 2.2.0 Dec 26, 2024
@musicinmybrain
Copy link

FAILED tests/test_dolfin.py::test_dolfin[mesh3] - ValueError: could not conve...

Fixed by #1506.

FAILED tests/test_gmsh.py::test_gmsh22[False-mesh9] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh10] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh11] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh12] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh13] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh22[False-mesh14] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh8] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh9] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh10] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh11] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh12] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh40[False-mesh13] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh8] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh9] - ValueError: cannot resh...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh10] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh11] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh12] - ValueError: cannot res...
FAILED tests/test_gmsh.py::test_gmsh41[False-mesh13] - ValueError: cannot res...

I am not sure what should be done about these, but they appear to share a common root cause, in which this

if is_ascii:
data = np.fromfile(f, count=num_items * (1 + num_components), sep=" ").reshape(
(num_items, 1 + num_components)
)

raises an exception of the form

E           ValueError: cannot reshape array of size 1 into shape (4,4)

where the “target” shape varies. I spot-checked one failing case and found that the array indeed contained only one scalar value.

FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh0] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh1] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh2] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh3] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh4] - meshio._exceptions....
FAILED tests/test_ugrid.py::test_io[1e-07-.ugrid-mesh5] - meshio._exceptions....

All of these are happening here:

if not nitems.size == 7:
raise ReadError("Header of ugrid file is ill-formed")

but, again, I am not sure what should be done.

All of these errors can be reproduced in a fresh git checkout by simply running tox.

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

No branches or pull requests

2 participants