Skip to content

Commit 1cc04bf

Browse files
dweindldilpath
andauthored
Fix petab.visualize.data_overview.create_report (#96)
* Fix number of conditions * Handle optional preequilibrationConditionId Co-authored-by: Dilan Pathirana <[email protected]>
1 parent beb7777 commit 1cc04bf

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

petab/visualize/data_overview.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ def create_report(
3131
template_file = "report.html"
3232

3333
data_per_observable = get_data_per_observable(problem.measurement_df)
34-
num_conditions = (len(problem.condition_df.columns)
35-
- 1 * (CONDITION_NAME in problem.condition_df.columns))
34+
num_conditions = len(problem.condition_df.index)
3635

3736
# Setup template engine
3837
import jinja2
@@ -55,17 +54,18 @@ def get_data_per_observable(measurement_df: pd.DataFrame) -> pd.DataFrame:
5554
Arguments:
5655
measurement_df: PEtab measurement data frame
5756
Returns:
58-
data_per_observable:
59-
Pivot table with number of data points per observable and condition
57+
Pivot table with number of data points per observable and condition
6058
"""
6159

6260
my_measurements = measurement_df.copy()
63-
64-
my_measurements[PREEQUILIBRATION_CONDITION_ID].fillna('', inplace=True)
61+
index = [SIMULATION_CONDITION_ID]
62+
if PREEQUILIBRATION_CONDITION_ID in my_measurements:
63+
my_measurements[PREEQUILIBRATION_CONDITION_ID].fillna('', inplace=True)
64+
index.append(PREEQUILIBRATION_CONDITION_ID)
6565

6666
data_per_observable = pd.pivot_table(
6767
my_measurements, values=MEASUREMENT, aggfunc='count',
68-
index=[SIMULATION_CONDITION_ID, PREEQUILIBRATION_CONDITION_ID],
68+
index=index,
6969
columns=[OBSERVABLE_ID], fill_value=0)
7070

7171
# Add row and column sums

0 commit comments

Comments
 (0)