Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New create empty observable function (issue 386) #387

Merged
merged 2 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions petab/observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,15 @@ def get_placeholders(observable_df: pd.DataFrame) -> List[str]:
row[formula_column], row.name, placeholder_type)
placeholders.extend(cur_placeholders)
return core.unique_preserve_order(placeholders)


def create_observable_df() -> pd.DataFrame:
"""Create empty observable dataframe

Returns:
Created DataFrame
"""

df = pd.DataFrame(data={col: [] for col in OBSERVABLE_DF_COLS})

return df
6 changes: 6 additions & 0 deletions tests/test_observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ def test_get_formula_placeholders():
assert petab.get_formula_placeholders(1, 'any', 'observable') == []


def test_create_observable_df():
"""Test observables.create_measurement_df."""
df = petab.create_observable_df()
assert set(df.columns.values) == set(OBSERVABLE_DF_COLS)


def test_get_placeholders():
"""Test get_placeholders"""
observable_df = pd.DataFrame(data={
Expand Down