Skip to content

Commit 31099a7

Browse files
committed
Write scalars without type information (#1499)
NumPy 2.x changed the representation of scalaras including type information. That lead to failing tests, since the test files were written with the new representation (e.g. `np.int64(0)`). This reverts to the old behavior of using plain `0`. Though, the actual fix is likely to use `str()` or `f"{scalar!s}"` as described in the release notes.
1 parent b2ee998 commit 31099a7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/meshio/_helpers.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
reader_map = {}
1616
_writer_map = {}
1717

18+
# NumPy 2.x changed the representaion of scalars.
19+
# This reverts to the old behavior.
20+
# https://numpy.org/doc/2.2/release/2.0.0-notes.html#representation-of-numpy-scalars-changed
21+
if np.lib.NumpyVersion(np.__version__) >= '2.0.0':
22+
np.set_printoptions(legacy="1.25")
1823

1924
def register_format(
2025
format_name: str, extensions: list[str], reader, writer_map

0 commit comments

Comments
 (0)