-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add constants + I/O for new conditions/experiments tables
* constants * read/write experiment table * add experiments table to Problem, and populate from yaml * some first validation tasks To be complemented by separate pull requests.
- Loading branch information
Showing
11 changed files
with
338 additions
and
16 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
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Functions operating on the PEtab experiments table.""" | ||
from pathlib import Path | ||
|
||
import pandas as pd | ||
|
||
__all__ = ["get_experiment_df", "write_experiment_df"] | ||
|
||
|
||
def get_experiment_df( | ||
experiments_file: str | pd.DataFrame | Path | None, | ||
) -> pd.DataFrame | None: | ||
""" | ||
Read the provided observable file into a ``pandas.Dataframe``. | ||
Arguments: | ||
experiments_file: Name of the file to read from or pandas.Dataframe. | ||
Returns: | ||
Observable DataFrame | ||
""" | ||
if experiments_file is None: | ||
return experiments_file | ||
|
||
if isinstance(experiments_file, str | Path): | ||
experiments_file = pd.read_csv( | ||
experiments_file, sep="\t", float_precision="round_trip" | ||
) | ||
|
||
return experiments_file | ||
|
||
|
||
def write_experiment_df(df: pd.DataFrame, filename: str | Path) -> None: | ||
"""Write PEtab experiments table | ||
Arguments: | ||
df: PEtab experiments table | ||
filename: Destination file name | ||
""" | ||
df = get_experiment_df(df) | ||
df.to_csv(filename, sep="\t", index=False) |
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
Oops, something went wrong.