From 73205c345ba1ada81377532c67b77cd68c1048c0 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Fri, 31 Jan 2025 11:22:17 -0500 Subject: [PATCH] Do not rely on `repr()` of `np.float64` Use `.item()` to extract a `float` before applying `repr()`. Fixes a regression in numpy 2.2: FAILED tests/test_dolfin.py::test_dolfin[mesh3] - ValueError: could not convert string to float: 'np.float64(63.69616873214543)' --- src/meshio/dolfin/_dolfin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshio/dolfin/_dolfin.py b/src/meshio/dolfin/_dolfin.py index e43dbd54..39c2238b 100644 --- a/src/meshio/dolfin/_dolfin.py +++ b/src/meshio/dolfin/_dolfin.py @@ -207,7 +207,7 @@ def _write_cell_data(filename, dim, cell_data): ) for k, value in enumerate(cell_data): - ET.SubElement(mesh_function, "entity", index=str(k), value=repr(value)) + ET.SubElement(mesh_function, "entity", index=str(k), value=repr(value.item())) tree = ET.ElementTree(dolfin) tree.write(filename)