|
1 | 1 | """Module handling data (experiment and simulation).""" |
| 2 | + |
| 3 | +from __future__ import annotations |
2 | 4 | from enum import Enum |
3 | 5 | from pathlib import Path |
4 | 6 | from typing import Dict, List, Optional, Union |
5 | 7 |
|
6 | 8 | import pandas as pd |
7 | 9 | from pymetadata import log |
| 10 | +from pymetadata.console import console |
8 | 11 |
|
9 | 12 | from sbmlsim.combine import mathml |
10 | 13 | from sbmlsim.units import DimensionalityError, Quantity, UnitRegistry, UnitsInformation |
@@ -54,7 +57,6 @@ def __init__( |
54 | 57 | # FIXME: get rid of backwards compatibility |
55 | 58 | if not symbol: |
56 | 59 | if index.startswith("[") and index.endswith("]"): |
57 | | - |
58 | 60 | index = index[1:-1] |
59 | 61 | symbol = Data.Symbols.CONCENTRATION |
60 | 62 | logger.debug( |
@@ -181,7 +183,9 @@ def to_dict(self): |
181 | 183 | return d |
182 | 184 |
|
183 | 185 | def get_data( |
184 | | - self, experiment: "SimulationExperiment", to_units: str = None # noqa: F821 |
| 186 | + self, |
| 187 | + experiment, # "SimulationExperiment" |
| 188 | + to_units: str = None, # noqa: F821 |
185 | 189 | ) -> Quantity: |
186 | 190 | """Return actual data from the data object. |
187 | 191 |
|
@@ -234,6 +238,7 @@ def get_data( |
234 | 238 | print(experiment.results.keys()) |
235 | 239 | xres: XResult = experiment.results[self.task_id] |
236 | 240 | if not isinstance(xres, XResult): |
| 241 | + console.print(xres) |
237 | 242 | raise ValueError("Only Result objects supported in task data.") |
238 | 243 |
|
239 | 244 | # units match the symbols |
@@ -381,7 +386,7 @@ def from_df( |
381 | 386 | elif key == "unit": |
382 | 387 | # add unit to "mean" and "value" |
383 | 388 | for key in ["mean", "value", "median"]: |
384 | | - if (key in df.columns) and not (f"{key}_unit" in df.columns): |
| 389 | + if (key in df.columns) and f"{key}_unit" not in df.columns: |
385 | 390 | # FIXME: probably not a good idea to add columns while iterating over them |
386 | 391 | df[f"{key}_unit"] = df.unit |
387 | 392 | unit_keys = df.unit.unique() |
|
0 commit comments