Skip to content

Commit

Permalink
Load results file as a DataFrame for basic simulation validation
Browse files Browse the repository at this point in the history
lbianchi-lbl committed Jan 11, 2022
1 parent 8aa346d commit 1044dd8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions idaes/tests/prescient/test_prescient.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
from typing import Dict, Union, List

import pytest
import pandas as pd


prescient_simulator = pytest.importorskip("prescient.simulator", reason="prescient (optional dependency) not available")
@@ -83,12 +84,17 @@ def run_simulator(self, prescient_options: PrescientOptions) -> None:
sim.simulate(**prescient_options)

@pytest.fixture
def simulation_output_files(self, run_simulator, output_dir: Path) -> List[Path]:
return list(sorted(output_dir.rglob("*")))
def simulation_results_table(
self,
run_simulator,
output_dir: Path,
name: str = "overall_simulation_output.csv"
) -> pd.DataFrame:

path = output_dir / name
return pd.read_csv(path)

# FIXME this should be changed to pytest.mark.integration, unless we manage to
# set the options so that in runs in < 20 s
@pytest.mark.component
# TODO use a more specific test to validate simulation output
def test_simulation_results(self, simulation_output_files: List[Path], expected_number=2):
assert len(simulation_output_files) >= expected_number
def test_simulation_results(self, simulation_results_table: pd.DataFrame):
assert not simulation_results_table.empty

0 comments on commit 1044dd8

Please sign in to comment.