Skip to content

Commit

Permalink
Add integration test for Stratified W7 setup.
Browse files Browse the repository at this point in the history
- setup method initializes the filepaths to the
  config file and atom data file, brings in the
  benchmark data and performs a run.

- methods to perform asserions for j_estimators
  and j_blue_estimators have been added.
  • Loading branch information
karandesai-96 committed Mar 12, 2016
1 parent ef38eab commit 8b93732
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
Binary file modified tardis/tests/data/w7_13d/expected_ndarrays.npz
Binary file not shown.
Binary file modified tardis/tests/data/w7_13d/expected_quantities.npz
Binary file not shown.
2 changes: 0 additions & 2 deletions tardis/tests/data/w7_13d/w7_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,3 @@ def collect_astropy_quantities_from_radial1d_model(expected_model):
if __name__ == '__main__':
# Quickly do the task the script it supposed to do if executed directly from terminal
mdl = collect_expected_data()
import dill
dill.dump(mdl, open('session.pkl', 'w+'))
39 changes: 39 additions & 0 deletions tardis/tests/test_tardis_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,42 @@ def test_legacy_model_properties(self):
for prop, prop_type in required_props.items():

assert type(getattr(self.model, prop)) == prop_type, ("wrong type of attribute '{}': expected {}, found {}".format(prop, prop_type, type(getattr(self.model, prop))))


@pytest.mark.skipif(not pytest.config.getoption("--run-slow"),
reason='this is a slow test, add --run-slow to run')
class TestW7:
"""
Integration test for a run with the Stratified W7 setup.
"""

@classmethod
@pytest.fixture(scope="class", autouse=True)
def setup(self):
self.w7_config_filepath = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/w7_13d/tardis_w7.yml')
assert os.path.exists(self.w7_config_filepath), ("%s w7 config file doesn't exist" % self.w7_config_filepath)

self.atom_data_filepath = 'tmp/kurucz_cd23_chianti_H_He.h5'
assert os.path.exists(self.atom_data_filepath), ("%s atomic datafile doesn't exist" % self.atom_data_filepath)

self.obtained_w7_radial1d_model = tardis.run_tardis(
config=self.w7_config_filepath,
atom_data=self.atom_data_filepath)

self.expected_w7_ndarrays = np.load(
os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/w7_13d/expected_ndarrays.npz')
)

self.expected_w7_astropy_quantities = np.load(
os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/w7_13d/expected_quantities.npz')
)

def test_j_estimators(self):
np.testing.assert_allclose(
self.expected_w7_ndarrays['j_estimators'],
self.obtained_w7_radial1d_model.j_estimators)

def test_j_blue_estimators(self):
np.testing.assert_allclose(
self.expected_w7_ndarrays['j_blue_estimators'],
self.obtained_w7_radial1d_model.j_blue_estimators)

0 comments on commit 8b93732

Please sign in to comment.