@@ -240,15 +240,44 @@ def test_closest_vertex( grid ):
240240 if result != answer :
241241 raise ValueError ( "[Test] Wrong result for closest vertex for query p4" )
242242
243- def test_attribute ( grid ):
243+ def test_attribute_3d ( grid ):
244244 attribute = grid .cell_attribute_manager ().find_or_create_attribute_variable_double ( "toto" , - 1 )
245245 attribute .set_value ( 10 , 10 )
246+ attribute = grid .polyhedron_attribute_manager ().find_attribute_double ( "toto" )
246247 if attribute .value ( 0 ) != - 1 :
247248 raise ValueError ( "[Test] Wrong attribute value" )
248249 if attribute .value ( 10 ) != 10 :
249250 raise ValueError ( "[Test] Wrong attribute value" )
250251 if attribute .value ( grid .nb_cells () - 1 ) != - 1 :
251252 raise ValueError ( "[Test] Wrong attribute value" )
253+ attribute = grid .vertex_attribute_manager ().find_or_create_attribute_variable_double ( "toto_vertex" , 1 )
254+ attribute .set_value ( 10 , 10 )
255+ if attribute .value ( 0 ) != 1 :
256+ raise ValueError ( "[Test] Wrong attribute value" )
257+ if attribute .value ( 10 ) != 10 :
258+ raise ValueError ( "[Test] Wrong attribute value" )
259+ if attribute .value ( grid .nb_cells () - 1 ) != 1 :
260+ raise ValueError ( "[Test] Wrong attribute value" )
261+
262+ def test_attribute_2d ():
263+ grid = mesh .LightRegularGrid2D (geom .Point2D ([1.5 , 0 ]), [5 , 10 ], [1. , 2. ])
264+ attribute = grid .cell_attribute_manager ().find_or_create_attribute_variable_double ( "toto" , - 1 )
265+ attribute .set_value ( 10 , 10 )
266+ attribute = grid .polygon_attribute_manager ().find_attribute_double ( "toto" )
267+ if attribute .value ( 0 ) != - 1 :
268+ raise ValueError ( "[Test] Wrong attribute value" )
269+ if attribute .value ( 10 ) != 10 :
270+ raise ValueError ( "[Test] Wrong attribute value" )
271+ if attribute .value ( grid .nb_cells () - 1 ) != - 1 :
272+ raise ValueError ( "[Test] Wrong attribute value" )
273+ attribute = grid .vertex_attribute_manager ().find_or_create_attribute_variable_double ( "toto_vertex" , 1 )
274+ attribute .set_value ( 10 , 10 )
275+ if attribute .value ( 0 ) != 1 :
276+ raise ValueError ( "[Test] Wrong attribute value" )
277+ if attribute .value ( 10 ) != 10 :
278+ raise ValueError ( "[Test] Wrong attribute value" )
279+ if attribute .value ( grid .nb_cells () - 1 ) != 1 :
280+ raise ValueError ( "[Test] Wrong attribute value" )
252281
253282def test_io (grid , filename ):
254283 mesh .save_light_regular_grid3D (grid , filename )
@@ -266,5 +295,6 @@ def test_io(grid, filename):
266295 test_cell_query ( grid )
267296 test_boundary_box ( grid )
268297 test_closest_vertex ( grid )
269- test_attribute ( grid )
298+ test_attribute_3d ( grid )
299+ test_attribute_2d ()
270300 test_io (grid , "test." + grid .native_extension ())
0 commit comments