-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Miscellaneous updates to source and testing commands
- Loading branch information
1 parent
6277b0b
commit 7022918
Showing
3 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,59 @@ | ||
from ROOT import RDataFrame | ||
|
||
|
||
############################################################################### | ||
# (c) Copyright 2023 CERN for the benefit of the LHCb Collaboration # | ||
# # | ||
# This software is distributed under the terms of the GNU General Public # | ||
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # | ||
# # | ||
# In applying this licence, CERN does not waive the privileges and immunities # | ||
# granted to it by virtue of its status as an Intergovernmental Organization # | ||
# or submit itself to any jurisdiction. # | ||
############################################################################### | ||
|
||
def table( | ||
data: RDataFrame, | ||
categories: dict | ||
categories: Union[List[str], Dict[str, str]], | ||
absolute: | ||
output: bool = False, | ||
totals: bool = False, | ||
|
||
): | ||
if type(categories) == list: | ||
return | ||
spacing = 12 | ||
combinations = prod([len(category) for category in categories.values()]) | ||
header = "" | ||
previous_categories = 1 | ||
column_width = combinations | ||
|
||
labels = list(categories.keys()) | ||
values_sets = list(categories.values()) | ||
print(labels) | ||
print(values_sets) | ||
|
||
|
||
|
||
if readable: | ||
|
||
|
||
for n, (label, values) in enumerate(zip(labels, values_sets)): | ||
previous_category_count = len(values_sets[n-1]) if n-1 > 0 and n < len(values_sets) else 1 | ||
next_category_count = len(values_sets[n+1]) if n+1 < len(values_sets) else 1 | ||
combinations = int(combinations / next_category_count) | ||
header += f"{label : <{spacing * combinations * next_category_count}} | " | ||
column_width = spacing * combinations | ||
|
||
for _ in range(previous_category_count): | ||
for value in values: | ||
header += f"{value : <{column_width}} | " | ||
|
||
#"catA | valA1 | valA2 | valA3" | ||
#"catB | valB1 VALB2 | valB2 | valB3" | ||
header += "\n" | ||
print(label) | ||
print(header) | ||
|
||
|
||
print(combinations) | ||
print('a') | ||
|
||
return | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,46 @@ | ||
############################################################################### | ||
# (c) Copyright 2023 CERN for the benefit of the LHCb Collaboration # | ||
# # | ||
# This software is distributed under the terms of the GNU General Public # | ||
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # | ||
# # | ||
# In applying this licence, CERN does not waive the privileges and immunities # | ||
# granted to it by virtue of its status as an Intergovernmental Organization # | ||
# or submit itself to any jurisdiction. # | ||
############################################################################### | ||
|
||
from typing import Dict, List, Union | ||
from ROOT import RDataFrame | ||
|
||
def whisk( | ||
data: RDataFrame, | ||
categories: Union[List[str], Dict[str, str]], | ||
): | ||
|
||
return | ||
|
||
def whisk( | ||
def _calculate_proportions( | ||
data: RDataFrame, | ||
categories: dict | ||
categories: Union[List[str], Dict[str, str]] | ||
): | ||
proportions = {} | ||
if type(categories) == list: | ||
return | ||
|
||
for category, values in categories: | ||
for value in values: | ||
proportions.extend({ | ||
category: { | ||
"total" : data.Filter(f"{category} == {value}").Count().getValue() | ||
} | ||
}) | ||
|
||
|
||
return | ||
|
||
return | ||
{ | ||
"red" : { | ||
"total" : 1, | ||
"square" : {"total": 1} | ||
} | ||
} |