small vtk binary improvements
@@ -649,13 +649,11 @@ def _write_cells(f, cells, binary):
for c in cells.values():
n = c.shape[1]
dtype = numpy.dtype(">i4")
- d = numpy.column_stack(
- [numpy.full(c.shape[0], n, dtype=dtype), c.astype(dtype)],
- )
# One must force endianness here:
# <https://github.com/numpy/numpy/issues/15088>
- d = d.astype(dtype)
- f.write(d.tostring())
+ numpy.column_stack(
+ [numpy.full(c.shape[0], n, dtype=dtype), c.astype(dtype)],
+ ).astype(dtype).tofile(f, sep="")
f.write("\n".encode("utf-8"))
else:
# ascii
@@ -673,8 +671,9 @@ def _write_cells(f, cells, binary):
for key in cells:
key_ = key[:7] if key[:7] == "polygon" else key
vtk_type = meshio_to_vtk_type[key_]
- d = numpy.full(len(cells[key]), vtk_type, dtype=numpy.dtype(">i4"))
- f.write(d.tostring())
+ numpy.full(len(cells[key]), vtk_type, dtype=numpy.dtype(">i4")).tofile(
+ f, sep=""
+ )
f.write("\n".encode("utf-8"))
else:
# ascii
