data-manipulation-utilities 0.2.2__py3-none-any.whl → 0.2.3__py3-none-any.whl
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.
- {data_manipulation_utilities-0.2.2.dist-info → data_manipulation_utilities-0.2.3.dist-info}/METADATA +19 -1
- {data_manipulation_utilities-0.2.2.dist-info → data_manipulation_utilities-0.2.3.dist-info}/RECORD +7 -7
- dmu/rdataframe/utilities.py +27 -1
- {data_manipulation_utilities-0.2.2.data → data_manipulation_utilities-0.2.3.data}/scripts/publish +0 -0
- {data_manipulation_utilities-0.2.2.dist-info → data_manipulation_utilities-0.2.3.dist-info}/WHEEL +0 -0
- {data_manipulation_utilities-0.2.2.dist-info → data_manipulation_utilities-0.2.3.dist-info}/entry_points.txt +0 -0
- {data_manipulation_utilities-0.2.2.dist-info → data_manipulation_utilities-0.2.3.dist-info}/top_level.txt +0 -0
{data_manipulation_utilities-0.2.2.dist-info → data_manipulation_utilities-0.2.3.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: data_manipulation_utilities
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.3
|
4
4
|
Description-Content-Type: text/markdown
|
5
5
|
Requires-Dist: logzero
|
6
6
|
Requires-Dist: PyYAML
|
@@ -578,6 +578,24 @@ These are utility functions meant to be used with ROOT dataframes.
|
|
578
578
|
|
579
579
|
## Adding a column from a numpy array
|
580
580
|
|
581
|
+
### With numba
|
582
|
+
|
583
|
+
For this do:
|
584
|
+
|
585
|
+
```python
|
586
|
+
import dmu.rdataframe.utilities as ut
|
587
|
+
|
588
|
+
arr_val = numpy.array([10, 20, 30])
|
589
|
+
rdf = ut.add_column_with_numba(rdf, arr_val, 'values', identifier='some_name')
|
590
|
+
```
|
591
|
+
|
592
|
+
where the identifier needs to be unique, every time the function is called.
|
593
|
+
This is the case, because the addition is done internally by declaring a numba function whose name
|
594
|
+
cannot be repeated as mentioned
|
595
|
+
[here](https://root-forum.cern.ch/t/ways-to-work-around-the-redefinition-of-compiled-functions-in-one-single-notebook-session/41442/1)
|
596
|
+
|
597
|
+
### With awkward
|
598
|
+
|
581
599
|
For this do:
|
582
600
|
|
583
601
|
```python
|
{data_manipulation_utilities-0.2.2.dist-info → data_manipulation_utilities-0.2.3.dist-info}/RECORD
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
data_manipulation_utilities-0.2.
|
1
|
+
data_manipulation_utilities-0.2.3.data/scripts/publish,sha256=-3K_Y2_4CfWCV50rPB8CRuhjxDu7xMGswinRwPovgLs,1976
|
2
2
|
dmu/arrays/utilities.py,sha256=PKoYyybPptA2aU-V3KLnJXBudWxTXu4x1uGdIMQ49HY,1722
|
3
3
|
dmu/generic/utilities.py,sha256=0Xnq9t35wuebAqKxbyAiMk1ISB7IcXK4cFH25MT1fgw,1741
|
4
4
|
dmu/logging/log_store.py,sha256=umdvjNDuV3LdezbG26b0AiyTglbvkxST19CQu9QATbA,4184
|
@@ -13,7 +13,7 @@ dmu/plotting/plotter_1d.py,sha256=g6H2xAgsL9a6vRkpbqHICb3qwV_qMiQPZxxw_oOSf9M,51
|
|
13
13
|
dmu/plotting/plotter_2d.py,sha256=J-gKnagoHGfJFU7HBrhDFpGYH5Rxy0_zF5l8eE_7ZHE,2944
|
14
14
|
dmu/plotting/utilities.py,sha256=SI9dvtZq2gr-PXVz71KE4o0i09rZOKgqJKD1jzf6KXk,1167
|
15
15
|
dmu/rdataframe/atr_mgr.py,sha256=FdhaQWVpsm4OOe1IRbm7rfrq8VenTNdORyI-lZ2Bs1M,2386
|
16
|
-
dmu/rdataframe/utilities.py,sha256=
|
16
|
+
dmu/rdataframe/utilities.py,sha256=pNcQARMP7txMhy6k27UnDcYf0buNy5U2fshaJDl_h8o,3661
|
17
17
|
dmu/rfile/rfprinter.py,sha256=mp5jd-oCJAnuokbdmGyL9i6tK2lY72jEfROuBIZ_ums,3941
|
18
18
|
dmu/rfile/utilities.py,sha256=XuYY7HuSBj46iSu3c60UYBHtI6KIPoJU_oofuhb-be0,945
|
19
19
|
dmu/stats/fitter.py,sha256=vHNZ16U3apoQyeyM8evq-if49doF48sKB3q9wmA96Fw,18387
|
@@ -47,8 +47,8 @@ dmu_scripts/rfile/compare_root_files.py,sha256=T8lDnQxsRNMr37x1Y7YvWD8ySHrJOWZki
|
|
47
47
|
dmu_scripts/rfile/print_trees.py,sha256=Ze4Ccl_iUldl4eVEDVnYBoe4amqBT1fSBR1zN5WSztk,941
|
48
48
|
dmu_scripts/ssh/coned.py,sha256=lhilYNHWRCGxC-jtyJ3LQ4oUgWW33B2l1tYCcyHHsR0,4858
|
49
49
|
dmu_scripts/text/transform_text.py,sha256=9akj1LB0HAyopOvkLjNOJiptZw5XoOQLe17SlcrGMD0,1456
|
50
|
-
data_manipulation_utilities-0.2.
|
51
|
-
data_manipulation_utilities-0.2.
|
52
|
-
data_manipulation_utilities-0.2.
|
53
|
-
data_manipulation_utilities-0.2.
|
54
|
-
data_manipulation_utilities-0.2.
|
50
|
+
data_manipulation_utilities-0.2.3.dist-info/METADATA,sha256=STJ7vYfcSIM9dtMRzywGLwDzH1sUBE5DL9FqvskMcxo,27923
|
51
|
+
data_manipulation_utilities-0.2.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
52
|
+
data_manipulation_utilities-0.2.3.dist-info/entry_points.txt,sha256=1TIZDed651KuOH-DgaN5AoBdirKmrKE_oM1b6b7zTUU,270
|
53
|
+
data_manipulation_utilities-0.2.3.dist-info/top_level.txt,sha256=n_x5J6uWtSqy9mRImKtdA2V2NJNyU8Kn3u8DTOKJix0,25
|
54
|
+
data_manipulation_utilities-0.2.3.dist-info/RECORD,,
|
dmu/rdataframe/utilities.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
'''
|
2
2
|
Module containing utility functions to be used with ROOT dataframes
|
3
3
|
'''
|
4
|
+
# pylint: disable=no-name-in-module
|
4
5
|
|
5
6
|
import re
|
6
7
|
from dataclasses import dataclass
|
@@ -10,7 +11,7 @@ import pandas as pnd
|
|
10
11
|
import awkward as ak
|
11
12
|
import numpy
|
12
13
|
|
13
|
-
from ROOT import RDataFrame, RDF
|
14
|
+
from ROOT import RDataFrame, RDF, Numba
|
14
15
|
|
15
16
|
from dmu.logging.log_store import LogStore
|
16
17
|
|
@@ -34,6 +35,8 @@ def add_column(rdf : RDataFrame, arr_val : Union[numpy.ndarray,None], name : str
|
|
34
35
|
exclude_re : Regex with patter of column names that we won't pick
|
35
36
|
'''
|
36
37
|
|
38
|
+
log.warning(f'Adding column {name} with awkward')
|
39
|
+
|
37
40
|
d_opt = {} if d_opt is None else d_opt
|
38
41
|
if arr_val is None:
|
39
42
|
raise ValueError('Array of values not introduced')
|
@@ -72,6 +75,29 @@ def add_column(rdf : RDataFrame, arr_val : Union[numpy.ndarray,None], name : str
|
|
72
75
|
|
73
76
|
return rdf
|
74
77
|
# ---------------------------------------------------------------------
|
78
|
+
def add_column_with_numba(
|
79
|
+
rdf : RDataFrame,
|
80
|
+
arr_val : Union[numpy.ndarray,None],
|
81
|
+
name : str,
|
82
|
+
identifier : str) -> RDataFrame:
|
83
|
+
'''
|
84
|
+
Will take a dataframe, an array of numbers and a string
|
85
|
+
Will add the array as a colunm to the dataframe
|
86
|
+
|
87
|
+
The `identifier` argument is a string need in order to avoid collisions
|
88
|
+
when using Numba to define a function to get the value from.
|
89
|
+
'''
|
90
|
+
identifier=f'fun_{identifier}'
|
91
|
+
|
92
|
+
@Numba.Declare(['int'], 'float', name=identifier)
|
93
|
+
def get_value(index):
|
94
|
+
return arr_val[index]
|
95
|
+
|
96
|
+
log.debug(f'Adding column {name} with numba')
|
97
|
+
rdf = rdf.Define(name, f'Numba::{identifier}(rdfentry_)')
|
98
|
+
|
99
|
+
return rdf
|
100
|
+
# ---------------------------------------------------------------------
|
75
101
|
def rdf_report_to_df(rep : RDF.RCutFlowReport) -> pnd.DataFrame:
|
76
102
|
'''
|
77
103
|
Takes the output of rdf.Report(), i.e. an RDataFrame cutflow report.
|
{data_manipulation_utilities-0.2.2.data → data_manipulation_utilities-0.2.3.data}/scripts/publish
RENAMED
File without changes
|
{data_manipulation_utilities-0.2.2.dist-info → data_manipulation_utilities-0.2.3.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
File without changes
|