From c7c46838c750eeda794fd568d7c57e6eca1af5a2 Mon Sep 17 00:00:00 2001 From: Thomas BAUDIER Date: Thu, 19 Sep 2024 17:05:28 +0200 Subject: [PATCH] Debug tuple print of np.float With numpy>=2.0.0, tuple(vectors[0]) returns the type of the number (eg: np.float64()) instead of the number Adding .tolist() to the vector converts the vector to a python list and could be printed. Work also with numpy <2.0.0 --- stl/stl.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/stl.py b/stl/stl.py index d44ae8c..b6bcd2d 100644 --- a/stl/stl.py +++ b/stl/stl.py @@ -319,11 +319,11 @@ def p(s, file): for row in self.data: vectors = row['vectors'] - p('facet normal %r %r %r' % tuple(row['normals']), file=fh) + p('facet normal %r %r %r' % tuple(row['normals'].tolist()), file=fh) p(' outer loop', file=fh) - p(' vertex %r %r %r' % tuple(vectors[0]), file=fh) - p(' vertex %r %r %r' % tuple(vectors[1]), file=fh) - p(' vertex %r %r %r' % tuple(vectors[2]), file=fh) + p(' vertex %r %r %r' % tuple(vectors[0].tolist()), file=fh) + p(' vertex %r %r %r' % tuple(vectors[1].tolist()), file=fh) + p(' vertex %r %r %r' % tuple(vectors[2].tolist()), file=fh) p(' endloop', file=fh) p('endfacet', file=fh)