def test_pandas(): pandas = pytest.importorskip("pandas") executor = uproot.ThreadPoolExecutor() with uproot.open( skhep_testdata.data_path( "uproot-sample-6.20.04-uncompressed.root"), interpretation_executor=executor, decompression_executor=executor, )["sample/i4"] as branch: series = branch.array( uproot.interpretation.numerical.AsDtype(">i4"), entry_start=3, entry_stop=-5, library="pd", ) assert isinstance(series, pandas.Series) assert series.values.tolist() == [ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ]
def test_branch_array_3(file_handler): executor = uproot.ThreadPoolExecutor() with uproot.open( skhep_testdata.data_path( "uproot-sample-6.20.04-uncompressed.root"), file_handler=file_handler, interpretation_executor=executor, decompression_executor=executor, )["sample/i4"] as branch: assert branch.array( uproot.interpretation.numerical.AsDtype(">i4"), entry_start=3, entry_stop=-5, library="np", ).tolist() == [ -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ]
def readone(filename): with uproot.open(filename) as f: f.decompression_executor = uproot.ThreadPoolExecutor() t = f["events"] b = t["px1"] b.array(library="np")