33import platform
44import unittest
55
6- import ROOT
7-
86import numpy
7+ import ROOT
98
109
1110class DatasetContext :
1211 """A helper class to create the dataset for the tutorial below."""
1312
14- filenames = [
15- "rdataframe_misc_1.root" ,
16- "rdataframe_misc_2.root" ,
17- "rdataframe_misc_3.root"
18- ]
13+ filenames = ["rdataframe_misc_1.root" , "rdataframe_misc_2.root" , "rdataframe_misc_3.root" ]
1914 treename = "dataset"
2015 nentries = 5
2116
@@ -48,6 +43,7 @@ def __exit__(self, *_):
4843 for filename in self .filenames :
4944 os .remove (filename )
5045
46+
5147class RDataFrameMisc (unittest .TestCase ):
5248 """Miscellaneous RDataFrame tests"""
5349
@@ -59,10 +55,7 @@ def test_empty_filenames(self):
5955 # https://bugs.llvm.org/show_bug.cgi?id=49692 :
6056 # llvm JIT fails to catch exceptions on MacOS ARM, so we disable their testing
6157 # Also fails on Windows for the same reason
62- if (
63- (platform .processor () != "arm" or platform .mac_ver ()[0 ] == '' ) and not
64- platform .system () == "Windows"
65- ):
58+ if (platform .processor () != "arm" or platform .mac_ver ()[0 ] == "" ) and not platform .system () == "Windows" :
6659 # With implicit conversions, cppyy also needs to try dispatching to the various
6760 # constructor overloads. The C++ exception will be thrown, but will be incapsulated
6861 # in a more generic TypeError telling the user that none of the overloads worked
@@ -83,7 +76,7 @@ def _get_rdf(self, dataset):
8376 chain .Add (filename )
8477
8578 return ROOT .RDataFrame (chain )
86-
79+
8780 def _get_chain (self , dataset ):
8881 chain = ROOT .TChain (dataset .treename )
8982 for filename in dataset .filenames :
@@ -95,9 +88,8 @@ def _define_col(self, rdf):
9588
9689 def _filter_x (self , rdf ):
9790 return rdf .Filter ("x > 2" )
98-
99- def _test_rdf_in_function (self , chain ):
10091
92+ def _test_rdf_in_function (self , chain ):
10193 rdf = ROOT .RDataFrame (chain )
10294 meanx = rdf .Mean ("x" )
10395 meany = rdf .Mean ("y" )
@@ -117,8 +109,8 @@ def test_ttree_ownership(self):
117109 rdf = self ._get_rdf (dataset )
118110
119111 npy_dict = rdf .AsNumpy ()
120- self .assertIsNone (numpy .testing .assert_array_equal (npy_dict ["x" ], numpy .array ([1 ,2 , 3 , 4 , 5 ] * 3 )))
121- self .assertIsNone (numpy .testing .assert_array_equal (npy_dict ["y" ], numpy .array ([2 ,4 , 6 , 8 , 10 ]* 3 )))
112+ self .assertIsNone (numpy .testing .assert_array_equal (npy_dict ["x" ], numpy .array ([1 , 2 , 3 , 4 , 5 ] * 3 )))
113+ self .assertIsNone (numpy .testing .assert_array_equal (npy_dict ["y" ], numpy .array ([2 , 4 , 6 , 8 , 10 ] * 3 )))
122114
123115 chain = self ._get_chain (dataset )
124116
@@ -157,5 +149,5 @@ def test_regression_gh_20291(self):
157149 os .remove (out_path )
158150
159151
160- if __name__ == ' __main__' :
152+ if __name__ == " __main__" :
161153 unittest .main ()
0 commit comments