@@ -72,7 +72,6 @@ def test_partial_materialization(self):
7272 self .assertNotIn ("c" , self .adf .df .columns )
7373
7474 def test_export_import_tree_roundtrip (self ):
75- # Create test DataFrame
7675 df = pd .DataFrame ({
7776 "x" : np .linspace (0 , 10 , 100 ),
7877 "y" : np .linspace (10 , 20 , 100 )
@@ -81,21 +80,17 @@ def test_export_import_tree_roundtrip(self):
8180 adf .add_alias ("z" , "x + y" , dtype = np .float64 )
8281 adf .materialize_all ()
8382
84- # Export to temporary file
8583 with tempfile .NamedTemporaryFile (suffix = ".root" , delete = False ) as tmp :
8684 adf .export_tree (tmp .name , treename = "testTree" , dropAliasColumns = False )
8785 tmp_path = tmp .name
8886
89- # Read back from ROOT
9087 adf_loaded = AliasDataFrame .read_tree (tmp_path , treename = "testTree" )
9188
92- # Check that aliases and data match
9389 assert "z" in adf_loaded .aliases
9490 assert adf_loaded .aliases ["z" ] == "x + y"
9591 adf_loaded .materialize_alias ("z" )
96- pd .testing .assert_series_equal (adf ["z" ], adf_loaded ["z" ], check_names = False )
92+ pd .testing .assert_series_equal (adf . df ["z" ], adf_loaded . df ["z" ], check_names = False )
9793
98- # Clean up
9994 os .remove (tmp_path )
10095
10196class TestAliasDataFrameWithSubframes (unittest .TestCase ):
@@ -162,5 +157,16 @@ def test_save_and_load_integrity(self):
162157 assert abs (mean_diff ) < 1e-3 , f"Mean difference too large: { mean_diff } "
163158 self .assertDictEqual (self .adf_clusters .aliases , adf_clusters_loaded .aliases )
164159
160+ def test_export_tree_read_tree_with_subframe (self ):
161+ with tempfile .NamedTemporaryFile (suffix = ".root" , delete = False ) as tmp :
162+ self .adf_clusters .export_tree (tmp .name , treename = "clusters" )
163+ tmp_path = tmp .name
164+
165+ adf_loaded = AliasDataFrame .read_tree (tmp_path , treename = "clusters" )
166+ with self .assertRaises (KeyError ):
167+ _ = adf_loaded ._subframes ["T" ]
168+
169+ os .remove (tmp_path )
170+
165171if __name__ == "__main__" :
166172 unittest .main ()
0 commit comments