Skip to content

Commit

Permalink
Fix typos in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexHls committed Nov 27, 2023
1 parent fdf9399 commit 4076649
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 17 deletions.
12 changes: 10 additions & 2 deletions tardis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,17 @@ def tardis_config_verysimple():


@pytest.fixture(scope="function")
def tardis_config_verysimple_nlte():
def tardis_config_verysimple_nlte_root():
return yaml_load_file(
"tardis/io/configuration/tests/data/tardis_configv1_nlte.yml",
"tardis/io/configuration/tests/data/tardis_configv1_nlte_root.yml",
YAMLLoader,
)


@pytest.fixture(scope="function")
def tardis_config_verysimple_nlte_lu():
return yaml_load_file(
"tardis/io/configuration/tests/data/tardis_configv1_nlte_lu.yml",
YAMLLoader,
)

Expand Down
104 changes: 89 additions & 15 deletions tardis/io/configuration/tests/test_config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ def test_plasma_section_config(key, tardis_config_verysimple):
)


def test_plasma_nlte_section_config(
tardis_config_verysimple_nlte,
nlte_raw_model,
def test_plasma_nlte_root_section_config(
tardis_config_verysimple_nlte_root,
nlte_raw_model_root,
nlte_atom_data,
):
"""
Expand All @@ -182,27 +182,65 @@ def test_plasma_nlte_section_config(
Parameter
---------
`tardis_config_verysimple_nlte` : YAML File
`tardis_config_verysimple_nlte_root` : YAML File
`nlte_raw_model` : A simple model
`nlte_atom_data` : An example atomic dataset
Result
------
Assertion based on validation for specified values
"""
tardis_config_verysimple_nlte["plasma"]["continuum_interaction"][
tardis_config_verysimple_nlte_root["plasma"]["continuum_interaction"][
"species"
] = [
"He I",
]
tardis_config_verysimple_nlte["plasma"]["nlte_ionization_species"] = ["H I"]
config = Configuration.from_config_dict(tardis_config_verysimple_nlte)
tardis_config_verysimple_nlte_root["plasma"]["nlte_ionization_species"] = [
"H I"
]
tardis_config_verysimple_nlte_root["plasma"]["nlte_solver"] = "root"
config = Configuration.from_config_dict(tardis_config_verysimple_nlte_root)
with pytest.raises(PlasmaConfigError) as ve:
assemble_plasma(config, nlte_raw_model_root, nlte_atom_data)


def test_plasma_nlte_lu_section_config(
tardis_config_verysimple_nlte_lu,
nlte_raw_model_lu,
nlte_atom_data,
):
"""
Configuration Validation Test for Plasma Section of the Tardis Config YAML File.
Validates:
nlte_ionization_species: should be included in continuum_interaction
Parameter
---------
`tardis_config_verysimple_nlte_lu` : YAML File
`nlte_raw_model` : A simple model
`nlte_atom_data` : An example atomic dataset
Result
------
Assertion based on validation for specified values
"""
tardis_config_verysimple_nlte_lu["plasma"]["continuum_interaction"][
"species"
] = [
"He I",
]
tardis_config_verysimple_nlte_lu["plasma"]["nlte_ionization_species"] = [
"H I"
]
tardis_config_verysimple_nlte_lu["plasma"]["nlte_solver"] = "lu"
config = Configuration.from_config_dict(tardis_config_verysimple_nlte_lu)
with pytest.raises(PlasmaConfigError) as ve:
assemble_plasma(config, nlte_raw_model, nlte_atom_data)
assemble_plasma(config, nlte_raw_model_lu, nlte_atom_data)


def test_plasma_nlte_exc_section_config(
tardis_config_verysimple_nlte, nlte_raw_model, nlte_atom_data
def test_plasma_nlte_root_exc_section_config(
tardis_config_verysimple_nlte_root, nlte_raw_model_root, nlte_atom_data
):
"""
Configuration Validation Test for Plasma Section of the Tardis Config YAML File.
Expand All @@ -212,23 +250,59 @@ def test_plasma_nlte_exc_section_config(
Parameter
---------
`tardis_config_verysimple_nlte` : YAML File
`tardis_config_verysimple_nlte_root` : YAML File
`nlte_raw_model` : A simple model
`nlte_atom_data` : An example atomic dataset
Result
------
Assertion based on validation for specified values
"""
tardis_config_verysimple_nlte["plasma"]["continuum_interaction"][
tardis_config_verysimple_nlte_root["plasma"]["continuum_interaction"][
"species"
] = [
"He I",
]
tardis_config_verysimple_nlte["plasma"]["nlte_excitation_species"] = ["H I"]
config = Configuration.from_config_dict(tardis_config_verysimple_nlte)
tardis_config_verysimple_nlte_root["plasma"]["nlte_excitation_species"] = [
"H I"
]
tardis_config_verysimple_nlte_root["plasma"]["nlte_solver"] = "root"
config = Configuration.from_config_dict(tardis_config_verysimple_nlte_root)
with pytest.raises(PlasmaConfigError):
plasma = assemble_plasma(config, nlte_raw_model_root, nlte_atom_data)


def test_plasma_nlte_lu_exc_section_config(
tardis_config_verysimple_nlte_lu, nlte_raw_model_lu, nlte_atom_data
):
"""
Configuration Validation Test for Plasma Section of the Tardis Config YAML File.
Validates:
nlte_excitation_species: should be included in continuum_interaction
Parameter
---------
`tardis_config_verysimple_nlte_lu` : YAML File
`nlte_raw_model` : A simple model
`nlte_atom_data` : An example atomic dataset
Result
------
Assertion based on validation for specified values
"""
tardis_config_verysimple_nlte_lu["plasma"]["continuum_interaction"][
"species"
] = [
"He I",
]
tardis_config_verysimple_nlte_lu["plasma"]["nlte_excitation_species"] = [
"H I"
]
tardis_config_verysimple_nlte_lu["plasma"]["nlte_solver"] = "lu"
config = Configuration.from_config_dict(tardis_config_verysimple_nlte_lu)
with pytest.raises(PlasmaConfigError):
plasma = assemble_plasma(config, nlte_raw_model, nlte_atom_data)
plasma = assemble_plasma(config, nlte_raw_model_lu, nlte_atom_data)


def test_spectrum_section_config(tardis_config_verysimple):
Expand Down

0 comments on commit 4076649

Please sign in to comment.