@@ -103,24 +103,30 @@ def test_face_attributes(self):
103103 # Test writing face attributes to a ply, by reading
104104 # them back and asserting the written attributes array matches
105105
106- m = g .get_mesh ("box.STL" )
107- test_1d_attribute = g .np .copy (m .face_angles [:, 0 ])
108- test_nd_attribute = g .np .copy (m .face_angles )
109- m .face_attributes ["test_1d_attribute" ] = test_1d_attribute
110- m .face_attributes ["test_nd_attribute" ] = test_nd_attribute
111-
112- export = m .export (file_type = "ply" )
113- reconstructed = g .roundtrip (export , file_type = "ply" )
114-
115- face_attributes = reconstructed .metadata ["_ply_raw" ]["face" ]["data" ]
116- result_1d = face_attributes ["test_1d_attribute" ]
117- result_nd = face_attributes ["test_nd_attribute" ]["f1" ]
118-
119- g .np .testing .assert_almost_equal (result_1d , test_1d_attribute )
120- g .np .testing .assert_almost_equal (result_nd , test_nd_attribute )
121-
122- no_attr = m .export (file_type = "ply" , include_attributes = False )
123- assert len (no_attr ) < len (export )
106+ for encoding in ["binary" , "ascii" ]:
107+ for dt in [g .np .float32 , g .np .float64 ]:
108+ m = g .get_mesh ("box.STL" )
109+ test_1d_attribute = g .np .copy (m .face_angles [:, 0 ])
110+ test_nd_attribute = g .np .copy (m .face_angles )
111+ m .face_attributes ["test_1d_attribute" ] = test_1d_attribute .astype (dt )
112+ m .face_attributes ["test_nd_attribute" ] = test_nd_attribute .astype (dt )
113+
114+ export = m .export (file_type = "ply" , include_attributes = True , encoding = encoding )
115+ reconstructed = g .roundtrip (export , file_type = "ply" , process = False )
116+
117+ face_attributes = reconstructed .metadata ["_ply_raw" ]["face" ]["data" ]
118+ result_1d = face_attributes ["test_1d_attribute" ]
119+ if encoding == "binary" :
120+ # only binary format allows this
121+ result_nd = face_attributes ["test_nd_attribute" ]["f1" ]
122+ else :
123+ result_nd = face_attributes ["test_nd_attribute" ]
124+
125+ g .np .testing .assert_almost_equal (result_1d , test_1d_attribute )
126+ g .np .testing .assert_almost_equal (result_nd , test_nd_attribute )
127+
128+ no_attr = m .export (file_type = "ply" , include_attributes = False )
129+ assert len (no_attr ) < len (export )
124130
125131 def test_cases (self ):
126132 a = g .get_mesh ("featuretype.STL" )
0 commit comments