Skip to content

Commit

Permalink
Format using black
Browse files Browse the repository at this point in the history
  • Loading branch information
atharva-2001 committed May 24, 2024
1 parent c6dbff6 commit 6ee9556
Showing 1 changed file with 38 additions and 18 deletions.
56 changes: 38 additions & 18 deletions tardis/transport/montecarlo/tests/test_packet_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
from tardis.tests.fixtures.regression_data import RegressionData


class TestBlackBodySimpleSource:
@pytest.fixture(scope="class")
def blackbodysimplesource(self, request):
Expand All @@ -29,14 +30,13 @@ def blackbodysimplesource(self, request):
montecarlo_configuration.LEGACY_MODE_ENABLED = True
bb = BlackBodySimpleSource(
radius=123,
temperature = 10000 * u.K,
base_seed=1963,
legacy_second_seed=2508
temperature=10000 * u.K,
base_seed=1963,
legacy_second_seed=2508,
)
yield bb
montecarlo_configuration.LEGACY_MODE_ENABLED = False


def test_bb_nus(self, regression_data, blackbodysimplesource):
actual_nus = blackbodysimplesource.create_packet_nus(100).value
expected_nus = regression_data.sync_ndarray(actual_nus)
Expand All @@ -46,19 +46,26 @@ def test_bb_mus(self, regression_data, blackbodysimplesource):
actual_mus = blackbodysimplesource.create_packet_mus(100)
expected_mus = regression_data.sync_ndarray(actual_mus)
assert_allclose(actual_mus, expected_mus)

def test_bb_energies(self, regression_data, blackbodysimplesource):
actual_unif_energies = blackbodysimplesource.create_packet_energies(100).value
expected_unif_energies = regression_data.sync_ndarray(actual_unif_energies)
actual_unif_energies = blackbodysimplesource.create_packet_energies(
100
).value
expected_unif_energies = regression_data.sync_ndarray(
actual_unif_energies
)
assert_allclose(actual_unif_energies, expected_unif_energies)

def test_bb_attributes(self, regression_data, blackbodysimplesource):
actual_bb = blackbodysimplesource
expected_bb = regression_data.sync_hdf_store(actual_bb)["/black_body_simple_source/scalars"]
expected_bb = regression_data.sync_hdf_store(actual_bb)[
"/black_body_simple_source/scalars"
]
assert_allclose(expected_bb.base_seed, actual_bb.base_seed)
assert_allclose(expected_bb.temperature, actual_bb.temperature.value)
assert_allclose(expected_bb.radius, actual_bb.radius)


class TestBlackBodySimpleSourceRel:
@pytest.fixture(scope="class")
def blackbody_simplesource_relativistic(self):
Expand All @@ -79,26 +86,39 @@ def blackbody_simplesource_relativistic(self):
montecarlo_configuration.LEGACY_MODE_ENABLED = False

def test_bb_nus(self, regression_data, blackbody_simplesource_relativistic):
actual_nus = blackbody_simplesource_relativistic.create_packet_nus(100).value
actual_nus = blackbody_simplesource_relativistic.create_packet_nus(
100
).value
expected_nus = regression_data.sync_ndarray(actual_nus)
assert_allclose(actual_nus, expected_nus)

def test_bb_energies(self, regression_data, blackbody_simplesource_relativistic):
actual_unif_energies = blackbody_simplesource_relativistic.create_packet_energies(100).value
def test_bb_energies(
self, regression_data, blackbody_simplesource_relativistic
):
actual_unif_energies = (
blackbody_simplesource_relativistic.create_packet_energies(
100
).value
)
gamma = np.sqrt(1 - blackbody_simplesource_relativistic.beta**2) ** -1
expected_unif_energies = regression_data.sync_ndarray(actual_unif_energies)
expected_unif_energies = regression_data.sync_ndarray(
actual_unif_energies
)
assert_allclose(actual_unif_energies, expected_unif_energies)

def test_bb_mus(self, regression_data, blackbody_simplesource_relativistic):
blackbody_simplesource_relativistic._reseed(2508)
actual_mus = blackbody_simplesource_relativistic.create_packet_mus(10)
expected_mus = regression_data.sync_ndarray(actual_mus)
assert_allclose(actual_mus, expected_mus)


def test_bb_attributes(self, regression_data, blackbody_simplesource_relativistic):

def test_bb_attributes(
self, regression_data, blackbody_simplesource_relativistic
):
actual_bb = blackbody_simplesource_relativistic
expected_bb = regression_data.sync_hdf_store(actual_bb)["/black_body_simple_source/scalars"]
expected_bb = regression_data.sync_hdf_store(actual_bb)[
"/black_body_simple_source/scalars"
]
assert_allclose(expected_bb.base_seed, actual_bb.base_seed)
assert_allclose(expected_bb.temperature, actual_bb.temperature.value)
assert_allclose(expected_bb.time_explosion, actual_bb.time_explosion)
assert_allclose(expected_bb.time_explosion, actual_bb.time_explosion)

0 comments on commit 6ee9556

Please sign in to comment.