@@ -133,6 +133,20 @@ def test_contains():
133133 assert "m1" in f
134134
135135
136+ def test_contains_groups_and_datasets ():
137+ with omx .open_file (TEST_FILE , "w" ) as f :
138+ # groups auto-created in writable mode
139+ assert "data" in f
140+ assert "lookup" in f
141+
142+ f .create_mapping ("zones" , entries = np .array ([1 , 2 , 3 ]))
143+ f .create_matrix ("m1" , obj = np .ones ((5 , 5 )))
144+
145+ assert "m1" in f # dataset inside data
146+ assert "zones" in f .lookup # dataset inside lookup group
147+ assert "missing" not in f
148+
149+
136150def test_list_all_attrs ():
137151 with omx .open_file (TEST_FILE , "w" ) as f :
138152 add_m1_node (f )
@@ -204,3 +218,15 @@ def test_mappings():
204218 assert entries == [1 , 2 , 3 ]
205219 with pytest .raises (LookupError ):
206220 f .map_entries ("missing" )
221+
222+
223+ def test_open_existing_with_append_mode ():
224+ # Create file and add a matrix
225+ with omx .open_file (TEST_FILE , "w" ) as f :
226+ data = np .arange (9 , dtype = float ).reshape (3 , 3 )
227+ f .create_matrix ("my_matrix" , obj = data )
228+
229+ # Re-open in append mode and ensure dataset is accessible
230+ with omx .open_file (TEST_FILE , "a" ) as f :
231+ assert "my_matrix" in f
232+ npt .assert_array_equal (f ["my_matrix" ], data )
0 commit comments