rootloader 1.2.3__tar.gz → 1.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rootloader-1.2.3 → rootloader-1.2.4}/PKG-INFO +1 -1
- {rootloader-1.2.3 → rootloader-1.2.4}/rootloader/ttree.py +62 -39
- rootloader-1.2.4/rootloader/version.py +1 -0
- rootloader-1.2.3/rootloader/version.py +0 -1
- {rootloader-1.2.3 → rootloader-1.2.4}/.gitignore +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/LICENSE +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/README.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/README.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/attrdict.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/index.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/tdirectory.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/tfile.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/th1.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/th2.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/tleaf.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/ttree.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/docs/rootloader/version.md +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/gen_documentation.bash +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/pyproject.toml +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/rootloader/__init__.py +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/rootloader/attrdict.py +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/rootloader/tdirectory.py +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/rootloader/tfile.py +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/rootloader/th1.py +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/rootloader/th2.py +0 -0
- {rootloader-1.2.3 → rootloader-1.2.4}/rootloader/tleaf.py +0 -0
|
@@ -11,6 +11,50 @@ import os
|
|
|
11
11
|
import ROOT
|
|
12
12
|
ROOT.EnableImplicitMT()
|
|
13
13
|
|
|
14
|
+
# pre-compile stats functions to avoid memory creep during JIT compilations
|
|
15
|
+
cpp_code = """
|
|
16
|
+
Double_t RDF_min_d(ROOT::RDataFrame df, string col){
|
|
17
|
+
return df.Min<Double_t>(col).GetValue();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
Double_t RDF_max_d(ROOT::RDataFrame df, string col){
|
|
21
|
+
return df.Max<Double_t>(col).GetValue();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Double_t RDF_mean_d(ROOT::RDataFrame df, string col){
|
|
25
|
+
return df.Mean<Double_t>(col).GetValue();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Double_t RDF_std_d(ROOT::RDataFrame df, string col){
|
|
29
|
+
return df.StdDev<Double_t>(col).GetValue();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Double_t RDF_sum_d(ROOT::RDataFrame df, string col){
|
|
33
|
+
return df.Sum<Double_t>(col).GetValue();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
Int_t RDF_min_i(ROOT::RDataFrame df, string col){
|
|
37
|
+
return df.Min<Int_t>(col).GetValue();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Int_t RDF_max_i(ROOT::RDataFrame df, string col){
|
|
41
|
+
return df.Max<Int_t>(col).GetValue();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Int_t RDF_mean_i(ROOT::RDataFrame df, string col){
|
|
45
|
+
return df.Mean<Int_t>(col).GetValue();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
Int_t RDF_std_i(ROOT::RDataFrame df, string col){
|
|
49
|
+
return df.StdDev<Int_t>(col).GetValue();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
Int_t RDF_sum_i(ROOT::RDataFrame df, string col){
|
|
53
|
+
return df.Sum<Int_t>(col).GetValue();
|
|
54
|
+
}
|
|
55
|
+
"""
|
|
56
|
+
ROOT.gInterpreter.Declare(cpp_code)
|
|
57
|
+
|
|
14
58
|
class ttree(object):
|
|
15
59
|
"""Extract ROOT.TTree with lazy operation. Looks like a dataframe in most ways
|
|
16
60
|
|
|
@@ -63,9 +107,6 @@ class ttree(object):
|
|
|
63
107
|
for filt in self._filters:
|
|
64
108
|
self._rdf = self._rdf.Filter(filt, filt)
|
|
65
109
|
|
|
66
|
-
# track stats
|
|
67
|
-
self._stats = {}
|
|
68
|
-
|
|
69
110
|
def __dir__(self):
|
|
70
111
|
superdir = [d for d in super().__dir__() if d[0] != '_']
|
|
71
112
|
return sorted(self._columns) + superdir
|
|
@@ -86,7 +127,6 @@ class ttree(object):
|
|
|
86
127
|
h._columns = self._columns
|
|
87
128
|
h._index = self._index
|
|
88
129
|
h._filters = self._filters
|
|
89
|
-
h._stats = self._stats
|
|
90
130
|
h.name = self.name
|
|
91
131
|
|
|
92
132
|
# get list of keys
|
|
@@ -271,7 +311,6 @@ class ttree(object):
|
|
|
271
311
|
if inplace:
|
|
272
312
|
self._rdf = self._rdf.Filter(expression, expression)
|
|
273
313
|
self._filters.append(expression)
|
|
274
|
-
self._stats = {}
|
|
275
314
|
else:
|
|
276
315
|
new = ttree(self)
|
|
277
316
|
new.set_filter(expression, inplace=True)
|
|
@@ -335,44 +374,28 @@ class ttree(object):
|
|
|
335
374
|
return _ttree_indexed(self)
|
|
336
375
|
@property
|
|
337
376
|
def size(self):
|
|
338
|
-
|
|
339
|
-
return self._stats['size']
|
|
340
|
-
except KeyError:
|
|
341
|
-
self._stats['size'] = self._rdf.Count().GetValue()
|
|
342
|
-
return self.size
|
|
377
|
+
return self._rdf.Count().GetValue()
|
|
343
378
|
|
|
344
379
|
# STATS ================================
|
|
345
|
-
def
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
380
|
+
def _getstat(self, fnname):
|
|
381
|
+
|
|
382
|
+
double_fn = getattr(ROOT, f'RDF_{fnname}_d')
|
|
383
|
+
int_fn = getattr(ROOT, f'RDF_{fnname}_i')
|
|
384
|
+
|
|
385
|
+
vals = []
|
|
386
|
+
for col in self._columns:
|
|
387
|
+
dtype = self._rdf.GetColumnType(col)
|
|
388
|
+
if dtype == 'Double_t':
|
|
389
|
+
vals.append(double_fn(self._rdf, col))
|
|
390
|
+
elif dtype == 'Int_t':
|
|
391
|
+
vals.append(int_fn(self._rdf, col))
|
|
355
392
|
return pd.Series(vals, index=self._columns)
|
|
356
393
|
|
|
357
|
-
def
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
def mean(self):
|
|
363
|
-
vals = [self._get_stats(col).GetMean() for col in self._columns]
|
|
364
|
-
if len(vals) == 1: return vals[0]
|
|
365
|
-
return pd.Series(vals, index=self._columns)
|
|
366
|
-
|
|
367
|
-
def rms(self):
|
|
368
|
-
vals = [self._get_stats(col).GetRMS() for col in self._columns]
|
|
369
|
-
if len(vals) == 1: return vals[0]
|
|
370
|
-
return pd.Series(vals, index=self._columns)
|
|
371
|
-
|
|
372
|
-
def std(self):
|
|
373
|
-
vals = [self._rdf.StdDev(col).GetValue() for col in self._columns]
|
|
374
|
-
if len(vals) == 1: return vals[0]
|
|
375
|
-
return pd.Series(vals, index=self._columns)
|
|
394
|
+
def min(self): return self._getstat('min')
|
|
395
|
+
def max(self): return self._getstat('max')
|
|
396
|
+
def mean(self): return self._getstat('mean')
|
|
397
|
+
def sum(self): return self._getstat('sum')
|
|
398
|
+
def std(self): return self._getstat('std')
|
|
376
399
|
|
|
377
400
|
# ttree but slice on time
|
|
378
401
|
class _ttree_indexed(object):
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.2.4'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '1.2.3'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|