Skip to content

Commit

Permalink
Miscellaneous updates to source and testing commands
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodingJamie committed Sep 28, 2023
1 parent 6277b0b commit 7022918
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: '3.10'
python-version: '3.9'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
Expand All @@ -30,5 +30,6 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install .
conda install pytest
pytest
59 changes: 54 additions & 5 deletions src/whisk/_table.py
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
42 changes: 39 additions & 3 deletions src/whisk/_whisk.py
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}
}
}

0 comments on commit 7022918

Please sign in to comment.