-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #747 from vg3095/model_hdf
[TEP014] Update Model and Density classes to use HDFWriter + Unit Tests
- Loading branch information
Showing
5 changed files
with
100 additions
and
29 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,28 @@ | ||
import os | ||
import pandas as pd | ||
import pytest | ||
from numpy.testing import assert_almost_equal | ||
|
||
### | ||
# Save and Load | ||
### | ||
|
||
@pytest.fixture(scope="module", autouse=True) | ||
def to_hdf_buffer(hdf_file_path,simulation_verysimple): | ||
simulation_verysimple.model.homologous_density.to_hdf(hdf_file_path) | ||
|
||
def test_hdf_density_0(hdf_file_path, simulation_verysimple): | ||
actual = simulation_verysimple.model.homologous_density.density_0 | ||
if hasattr(actual, 'cgs'): | ||
actual = actual.cgs.value | ||
path = os.path.join('homologous_density','density_0') | ||
expected = pd.read_hdf(hdf_file_path, path) | ||
assert_almost_equal(actual, expected.values) | ||
|
||
def test_hdf_time_0(hdf_file_path, simulation_verysimple): | ||
actual = simulation_verysimple.model.homologous_density.time_0 | ||
if hasattr(actual, 'cgs'): | ||
actual = actual.cgs.value | ||
path = os.path.join('homologous_density','scalars') | ||
expected = pd.read_hdf(hdf_file_path, path)['time_0'] | ||
assert_almost_equal(actual, expected) |