Skip to content

Commit 7985241

Browse files
minor fix
1 parent ca8a4f0 commit 7985241

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

src/sbmlsim/data.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""Module handling data (experiment and simulation)."""
2+
3+
from __future__ import annotations
24
from enum import Enum
35
from pathlib import Path
46
from typing import Dict, List, Optional, Union
57

68
import pandas as pd
79
from pymetadata import log
10+
from pymetadata.console import console
811

912
from sbmlsim.combine import mathml
1013
from sbmlsim.units import DimensionalityError, Quantity, UnitRegistry, UnitsInformation
@@ -54,7 +57,6 @@ def __init__(
5457
# FIXME: get rid of backwards compatibility
5558
if not symbol:
5659
if index.startswith("[") and index.endswith("]"):
57-
5860
index = index[1:-1]
5961
symbol = Data.Symbols.CONCENTRATION
6062
logger.debug(
@@ -181,7 +183,9 @@ def to_dict(self):
181183
return d
182184

183185
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
185189
) -> Quantity:
186190
"""Return actual data from the data object.
187191
@@ -234,6 +238,7 @@ def get_data(
234238
print(experiment.results.keys())
235239
xres: XResult = experiment.results[self.task_id]
236240
if not isinstance(xres, XResult):
241+
console.print(xres)
237242
raise ValueError("Only Result objects supported in task data.")
238243

239244
# units match the symbols
@@ -381,7 +386,7 @@ def from_df(
381386
elif key == "unit":
382387
# add unit to "mean" and "value"
383388
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:
385390
# FIXME: probably not a good idea to add columns while iterating over them
386391
df[f"{key}_unit"] = df.unit
387392
unit_keys = df.unit.unique()

src/sbmlsim/result/xresult.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pandas as pd
77
import xarray as xr
88
from pymetadata import log
9-
from pymetadata.console import console
109

1110
from sbmlsim.simulation import Dimension, ScanSim
1211
from sbmlsim.units import UnitsInformation
@@ -199,17 +198,3 @@ def from_netcdf(path):
199198
"""Read from netCDF."""
200199
ds = xr.open_dataset(path)
201200
return XResult(xdataset=ds, uinfo=None)
202-
203-
204-
if __name__ == "__main__":
205-
from sbmlsim.model import RoadrunnerSBMLModel
206-
from sbmlsim.test import MODEL_REPRESSILATOR
207-
208-
r = RoadrunnerSBMLModel(source=MODEL_REPRESSILATOR)._model
209-
dfs = []
210-
for _ in range(10):
211-
s = r.simulate(0, 10, steps=10)
212-
dfs.append(pd.DataFrame(s, columns=s.colnames))
213-
214-
xres = XResult.from_dfs(dfs)
215-
console.print(xres)

0 commit comments

Comments
 (0)