From f38966925340efc1a3a627ae8b308b138851603e Mon Sep 17 00:00:00 2001 From: Wolfgang Kerzendorf Date: Tue, 26 Aug 2014 15:26:25 -0400 Subject: [PATCH 1/3] fixing the problem with repreparing an atomic dataset --- tardis/atomic.py | 2 +- tardis/tests/test_atomic.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tardis/atomic.py b/tardis/atomic.py index 8435253a187..c33d1364553 100644 --- a/tardis/atomic.py +++ b/tardis/atomic.py @@ -465,7 +465,7 @@ def prepare_atom_data(self, selected_atomic_numbers, line_interaction_type='scat self.selected_atomic_numbers = selected_atomic_numbers self.nlte_species = nlte_species - + self._levels = self._levels.reset_index() self._levels = self._levels[self._levels['atomic_number'].isin(self.selected_atomic_numbers)] if max_ion_number is not None: self._levels = self._levels[self._levels['ion_number'] <= max_ion_number] diff --git a/tardis/tests/test_atomic.py b/tardis/tests/test_atomic.py index a01b8f82e2b..84e2d12883b 100644 --- a/tardis/tests/test_atomic.py +++ b/tardis/tests/test_atomic.py @@ -26,3 +26,4 @@ def test_atomic_symbol(): def test_atomic_symbol_reverse(): assert atomic.symbol2atomic_number['Si'] == 14 + From 9038375eeaa8f6d775bdb82975698e7df98dd60f Mon Sep 17 00:00:00 2001 From: Wolfgang Kerzendorf Date: Tue, 26 Aug 2014 21:47:00 -0400 Subject: [PATCH 2/3] adding tests for atomic --- tardis/tests/test_atomic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tardis/tests/test_atomic.py b/tardis/tests/test_atomic.py index 84e2d12883b..182ec5be920 100644 --- a/tardis/tests/test_atomic.py +++ b/tardis/tests/test_atomic.py @@ -27,3 +27,5 @@ def test_atomic_symbol(): def test_atomic_symbol_reverse(): assert atomic.symbol2atomic_number['Si'] == 14 + +def test_atomic_reprepare(): From bacbe64e5fd1c888ae21617a61d66dc30d22702a Mon Sep 17 00:00:00 2001 From: Wolfgang Kerzendorf Date: Wed, 27 Aug 2014 11:58:08 -0400 Subject: [PATCH 3/3] added testing for repreparing atomic data --- tardis/tests/test_atomic.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tardis/tests/test_atomic.py b/tardis/tests/test_atomic.py index 182ec5be920..a25892bb509 100644 --- a/tardis/tests/test_atomic.py +++ b/tardis/tests/test_atomic.py @@ -1,6 +1,7 @@ from tardis import atomic from numpy import testing import pytest +import os def test_atomic_h5_readin(): data = atomic.read_basic_atom_data(atomic.default_atom_h5_path) @@ -27,5 +28,17 @@ def test_atomic_symbol(): def test_atomic_symbol_reverse(): assert atomic.symbol2atomic_number['Si'] == 14 - +@pytest.mark.skipif(not pytest.config.getvalue("atomic-dataset"), + reason='--atomic_database was not specified') def test_atomic_reprepare(): + atom_data_filename = os.path.expanduser(os.path.expandvars( + pytest.config.getvalue('atomic-dataset'))) + assert os.path.exists(atom_data_filename), ("{0} atomic datafiles " + "does not seem to " + "exist".format( + atom_data_filename)) + atom_data = atomic.AtomData.from_hdf5(atom_data_filename) + atom_data.prepare_atom_data([14]) + atom_data.prepare_atom_data([20]) + +