do not copy data if same dtype
@@ -559,16 +559,16 @@ def write(filename, mesh, binary=True, compression="zlib", header_type=None):
# swap the data to match the system byteorder
# Don't use byteswap to make sure that the dtype is changed; see
# <https://github.com/numpy/numpy/issues/10372>.
- points = mesh.points.astype(mesh.points.dtype.newbyteorder("="))
+ points = mesh.points.astype(mesh.points.dtype.newbyteorder("="), copy=False)
for k, (cell_type, data) in enumerate(mesh.cells):
- mesh.cells[k] = CellBlock(cell_type, data.astype(data.dtype.newbyteorder("=")))
+ mesh.cells[k] = CellBlock(cell_type, data.astype(data.dtype.newbyteorder("="), copy=False))
for key, data in mesh.point_data.items():
- mesh.point_data[key] = data.astype(data.dtype.newbyteorder("="))
+ mesh.point_data[key] = data.astype(data.dtype.newbyteorder("="), copy=False)
for data in mesh.cell_data.values():
for k, dat in enumerate(data):
- data[k] = dat.astype(dat.dtype.newbyteorder("="))
+ data[k] = dat.astype(dat.dtype.newbyteorder("="), copy=False)
for key, data in mesh.field_data.items():
- mesh.field_data[key] = data.astype(data.dtype.newbyteorder("="))
+ mesh.field_data[key] = data.astype(data.dtype.newbyteorder("="), copy=False)
def numpy_to_xml_array(parent, name, data):
vtu_type = numpy_to_vtu_type[data.dtype]
