Skip to content

Commit

Permalink
Fixing Black Test
Browse files Browse the repository at this point in the history
  • Loading branch information
DhruvSondhi committed Apr 30, 2021
1 parent 775cd57 commit 2cc7e0b
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions tardis/io/tests/test_config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ def test_from_config_dict(tardis_config_verysimple):
tardis_config_verysimple, validate=True, config_dirname="test"
)
assert conf.config_dirname == "test"

assert_almost_equal(
conf.spectrum.start.value,
tardis_config_verysimple["spectrum"]["start"].value,
)

assert_almost_equal(
conf.spectrum.stop.value,
tardis_config_verysimple["spectrum"]["stop"].value,
Expand All @@ -77,13 +77,20 @@ def test_model_section_config(tardis_config_verysimple):
conf = Configuration.from_config_dict(
tardis_config_verysimple, validate=True, config_dirname="test"
)

assert conf.model.structure.density.type == "branch85_w7"

tardis_config_verysimple["model"]["structure"]["velocity"]["start"] = "2.0e4 km/s"
tardis_config_verysimple["model"]["structure"]["velocity"]["stop"] = "1.1e4 km/s"
tardis_config_verysimple["model"]["structure"]["velocity"][
"start"
] = "2.0e4 km/s"
tardis_config_verysimple["model"]["structure"]["velocity"][
"stop"
] = "1.1e4 km/s"
with pytest.raises(ValueError) as ve:
if conf.model.structure.velocity.start < conf.model.structure.velocity.stop:
if (
conf.model.structure.velocity.start
< conf.model.structure.velocity.stop
):
raise ValueError("Start Value is greater than Stop Value")
assert ve.type is ValueError

Expand All @@ -93,15 +100,22 @@ def test_supernova_section_config(tardis_config_verysimple):
tardis_config_verysimple, validate=True, config_dirname="test"
)
tardis_config_verysimple["supernova"]["time_explosion"] = "-10 day"
tardis_config_verysimple["supernova"]["luminosity_wavelength_start"] = "15 angstrom"
tardis_config_verysimple["supernova"]["luminosity_wavelength_end"] = "0 angstrom"
tardis_config_verysimple["supernova"][
"luminosity_wavelength_start"
] = "15 angstrom"
tardis_config_verysimple["supernova"][
"luminosity_wavelength_end"
] = "0 angstrom"
with pytest.raises(ValueError) as ve:
if conf.supernova.time_explosion.value > 0:
raise ValueError("Time of Explosion cannot be negative")
assert ve.type is ValueError

with pytest.raises(ValueError) as ve:
if conf.supernova.luminosity_wavelength_start.value < conf.supernova.luminosity_wavelength_end.value:
if (
conf.supernova.luminosity_wavelength_start.value
< conf.supernova.luminosity_wavelength_end.value
):
raise ValueError("End Limit must be Start Limit for Luminosity")
assert ve.type is ValueError

Expand All @@ -113,7 +127,9 @@ def test_plasma_section_config(tardis_config_verysimple):
tardis_config_verysimple["plasma"]["initial_t_inner"] = "-100 K"
tardis_config_verysimple["plasma"]["initial_t_rad"] = "-100 K"
with pytest.raises(ValueError) as ve:
if (conf.plasma.initial_t_inner.value >= -1) and (conf.plasma.initial_t_rad.value >= -1):
if (conf.plasma.initial_t_inner.value >= -1) and (
conf.plasma.initial_t_rad.value >= -1
):
raise ValueError("Initial Temperatures are Invalid")
assert ve.type is ValueError

Expand Down

0 comments on commit 2cc7e0b

Please sign in to comment.