@@ -488,6 +488,7 @@ def test_local_field_append():
488488 with field_to_local .as_local_field () as f :
489489 for i in range (1 , num_entities + 1 ):
490490 f .append ([0.1 * i , 0.2 * i , 0.3 * i ], i )
491+ assert f ._is_set == True
491492 field = dpf .core .fields_factory .create_3d_vector_field (num_entities )
492493 for i in range (1 , num_entities + 1 ):
493494 field .append ([0.1 * i , 0.2 * i , 0.3 * i ], i )
@@ -520,7 +521,7 @@ def test_local_elemental_nodal_field_append():
520521 with field_to_local .as_local_field () as f :
521522 for i in range (1 , num_entities + 1 ):
522523 f .append ([0.1 * i , 0.2 * i , 0.3 * i , 0.1 * i , 0.2 * i , 0.3 * i ], i )
523-
524+ assert f . _is_set == True
524525 assert np .allclose (field .data , field_to_local .data )
525526 assert np .allclose (field .scoping .ids , field_to_local .scoping .ids )
526527 assert len (field_to_local ._data_pointer ) == num_entities
@@ -532,6 +533,7 @@ def test_local_array_field_append():
532533 with field_to_local .as_local_field () as f :
533534 for i in range (1 , num_entities + 1 ):
534535 f .append (np .array ([0.1 * i , 0.2 * i , 0.3 * i ]), i )
536+ assert f ._is_set is True
535537 field = dpf .core .fields_factory .create_3d_vector_field (num_entities )
536538 for i in range (1 , num_entities + 1 ):
537539 field .append (np .array ([0.1 * i , 0.2 * i , 0.3 * i ]), i )
@@ -588,6 +590,7 @@ def test_local_get_entity_data():
588590 assert np .allclose (
589591 f .get_entity_data_by_id (i ), [[0.1 * i , 0.2 * i , 0.3 * i ]]
590592 )
593+ assert hasattr (f , "_is_set" ) is True
591594
592595 with field_to_local .as_local_field () as f :
593596 for i in range (1 , num_entities + 1 ):
@@ -596,6 +599,8 @@ def test_local_get_entity_data():
596599 f .get_entity_data_by_id (i ), [[0.1 * i , 0.2 * i , 0.3 * i ]]
597600 )
598601
602+ assert hasattr (f , "_is_set" ) is False
603+
599604
600605def test_local_elemental_nodal_get_entity_data ():
601606 num_entities = 100
@@ -615,6 +620,8 @@ def test_local_elemental_nodal_get_entity_data():
615620 f .get_entity_data_by_id (i ),
616621 [[0.1 * i , 0.2 * i , 0.3 * i ], [0.1 * i , 0.2 * i , 0.3 * i ]],
617622 )
623+ assert hasattr (f , "_is_set" ) is True
624+ assert f ._is_set is True
618625
619626 with field_to_local .as_local_field () as f :
620627 for i in range (1 , num_entities + 1 ):
@@ -626,6 +633,7 @@ def test_local_elemental_nodal_get_entity_data():
626633 f .get_entity_data_by_id (i ),
627634 [[0.1 * i , 0.2 * i , 0.3 * i ], [0.1 * i , 0.2 * i , 0.3 * i ]],
628635 )
636+ assert hasattr (f , "_is_set" ) is False
629637
630638
631639def test_auto_delete_field_local ():
@@ -689,6 +697,8 @@ def test_get_set_data_elemental_nodal_local_field():
689697 assert np .allclose (f ._data_pointer , [0 , 6 ])
690698 assert np .allclose (f .get_entity_data (0 ), [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.3 ]])
691699 assert np .allclose (f .get_entity_data (1 ), [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.4 ]])
700+ assert hasattr (f , "_is_set" ) is True
701+ assert f ._is_set is True
692702
693703 assert np .allclose (
694704 field_to_local .data ,
@@ -712,6 +722,8 @@ def test_get_set_data_elemental_nodal_local_field():
712722 assert np .allclose (f ._data_pointer , [0 , 6 ])
713723 assert np .allclose (f .get_entity_data (0 ), [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.3 ]])
714724 assert np .allclose (f .get_entity_data (1 ), [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.4 ]])
725+ assert hasattr (f , "_is_set" ) is True
726+ assert f ._is_set is True
715727
716728 assert np .allclose (
717729 field_to_local .data ,
@@ -737,6 +749,8 @@ def test_get_set_data_elemental_nodal_local_field():
737749 assert np .allclose (f ._data_pointer , [0 , 6 ])
738750 assert np .allclose (f .get_entity_data (0 ), [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.3 ]])
739751 assert np .allclose (f .get_entity_data (1 ), [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.4 ]])
752+ assert hasattr (f , "_is_set" ) is True
753+ assert f ._is_set is True
740754
741755 assert np .allclose (
742756 field_to_local .data ,
@@ -751,6 +765,20 @@ def test_get_set_data_elemental_nodal_local_field():
751765 )
752766
753767
768+ def test_get_set_scoping_local_field ():
769+ field_to_local = dpf .core .fields_factory .create_3d_vector_field (
770+ 2 , location = dpf .core .locations .elemental_nodal
771+ )
772+ with field_to_local .as_local_field () as f :
773+ f .data = [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.3 ]]
774+ f .scoping = dpf .core .Scoping (ids = [3 , 4 ])
775+ assert np .allclose (f .data , [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.3 ]])
776+ assert np .allclose (f .scoping_ids , [3 , 4 ])
777+ assert np .allclose (f .scoping .ids , [3 , 4 ])
778+ assert np .allclose (field_to_local .data , [[0.1 , 0.2 , 0.3 ], [0.1 , 0.2 , 0.3 ]])
779+ assert np .allclose (field_to_local .scoping .ids , [3 , 4 ])
780+
781+
754782def test_empty_data_field ():
755783 field_to_local = dpf .core .fields_factory .create_3d_vector_field (100 )
756784 data = [1.0 , 2.0 , 3.0 ]
0 commit comments