4
4
import pandas as pd
5
5
6
6
7
+ def check_awkward_accessible (col ):
8
+ 'Check to make sure we can look at every item in column'
9
+ col .flatten ()
10
+
11
+
12
+ def check_pandas_accessible (col ):
13
+ assert len (col .array ) > 0
14
+
15
+
7
16
@pytest .mark .asyncio
8
17
async def test_root_to_pandas (good_root_file_path ):
9
18
df = await DataConverterAdaptor ('root' ).convert_to_pandas (good_root_file_path )
10
19
assert isinstance (df , pd .DataFrame )
11
20
assert len (df ) == 283458
12
-
21
+ check_pandas_accessible ( df [ 'JetPt' ])
13
22
14
23
@pytest .mark .asyncio
15
24
async def test_root_to_pandas_default (good_root_file_path ):
@@ -30,18 +39,21 @@ async def test_parquet_to_pandas(good_uproot_file_path):
30
39
df = await DataConverterAdaptor ('parquet' ).convert_to_pandas (good_uproot_file_path )
31
40
assert isinstance (df , pd .DataFrame )
32
41
assert len (df ) == 115714
42
+ check_pandas_accessible (df ['JetPT' ])
33
43
34
44
35
45
@pytest .mark .asyncio
36
46
async def test_parquet_to_awkward (good_uproot_file_path ):
37
47
df = await DataConverterAdaptor ('parquet' ).convert_to_awkward (good_uproot_file_path )
38
48
assert len (df ['JetPT' ]) == 115714
49
+ check_awkward_accessible (df ['JetPT' ])
39
50
40
51
41
52
@pytest .mark .asyncio
42
53
async def test_root_to_awkward (good_root_file_path ):
43
54
df = await DataConverterAdaptor ('root' ).convert_to_awkward (good_root_file_path )
44
55
assert len (df ['JetPt' ]) == 283458
56
+ check_awkward_accessible (df ['JetPt' ])
45
57
46
58
47
59
@pytest .mark .asyncio
@@ -70,6 +82,7 @@ def load_df():
70
82
combined = DataConverterAdaptor ('root' ).combine_pandas ([df1 , df2 ])
71
83
72
84
assert len (combined ) == len (df1 ) + len (df2 )
85
+ check_pandas_accessible (combined ['JetPt' ])
73
86
74
87
75
88
def test_combine_pandas_from_parquet (good_uproot_file_path ):
@@ -84,22 +97,24 @@ def load_df():
84
97
combined = DataConverterAdaptor ('root' ).combine_pandas ([df1 , df2 ])
85
98
86
99
assert len (combined ) == len (df1 ) + len (df2 )
100
+ check_pandas_accessible (combined ['JetPT' ])
87
101
88
102
89
103
def test_combine_awkward_from_root (good_root_file_path ):
90
104
'Load a dataframe from root files and make sure that they work when we ask them to combine'
91
105
def load_df ():
92
106
import uproot
93
- with uproot .open (good_root_file_path ) as f_in :
94
- df = f_in [f_in .keys ()[0 ]].lazyarrays () # type: ignore
95
- return df
107
+ f_in = uproot .open (good_root_file_path )
108
+ df = f_in [f_in .keys ()[0 ]].lazyarrays () # type: ignore
109
+ return df
96
110
97
111
df1 = load_df ()
98
112
df2 = load_df ()
99
113
100
114
combined = DataConverterAdaptor ('root' ).combine_awkward ([df1 , df2 ])
101
115
102
116
assert len (combined ) == len (df1 ) + len (df2 )
117
+ check_awkward_accessible (combined ['JetPt' ])
103
118
104
119
105
120
def test_combine_awkward_from_parquet (good_uproot_file_path ):
@@ -114,3 +129,4 @@ def load_df():
114
129
combined = DataConverterAdaptor ('root' ).combine_awkward ([df1 , df2 ])
115
130
116
131
assert len (combined ) == len (df1 ) + len (df2 )
132
+ check_awkward_accessible (combined ['JetPT' ])
0 commit comments