Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PyTest fixtures and updated mainloop to properly compile #1901

Merged
merged 3 commits into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tardis/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def tardis_ref_data(tardis_ref_path, generate_reference):
yield store


@pytest.fixture
@pytest.fixture(scope="function")
def tardis_config_verysimple():
return yaml_load_config_file(
"tardis/io/tests/data/tardis_configv1_verysimple.yml"
Expand All @@ -164,6 +164,13 @@ def config_verysimple():
return config


@pytest.fixture(scope="function")
def config_montecarlo_1e5_verysimple():
filename = "tardis_configv1_verysimple.yml"
path = os.path.abspath(os.path.join("tardis/io/tests/data/", filename))
config = Configuration.from_yaml(path)
return config

@pytest.fixture(scope="session")
def simulation_verysimple(config_verysimple, atomic_dataset):
atomic_data = deepcopy(atomic_dataset)
Expand Down
1 change: 0 additions & 1 deletion tardis/model/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ def test_density(self):
def to_hdf_buffer(hdf_file_path, simulation_verysimple):
simulation_verysimple.model.to_hdf(hdf_file_path, overwrite=True)


model_scalar_attrs = ["t_inner"]


Expand Down
2 changes: 1 addition & 1 deletion tardis/montecarlo/montecarlo_numba/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def montecarlo_radial1d(
packet_seeds = montecarlo_configuration.packet_seeds

number_of_vpackets = montecarlo_configuration.number_of_vpackets

if iteration == 0: montecarlo_main_loop.recompile() # Make sure we update
wkerzendorf marked this conversation as resolved.
Show resolved Hide resolved
(
v_packets_energy_hist,
last_interaction_type,
Expand Down
16 changes: 7 additions & 9 deletions tardis/montecarlo/montecarlo_numba/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_montecarlo_radial1d():
assert False

def test_montecarlo_main_loop(
config_verysimple,
config_montecarlo_1e5_verysimple,
atomic_dataset,
tardis_ref_path,
tmpdir,
Expand All @@ -27,17 +27,15 @@ def test_montecarlo_main_loop(
montecarlo_configuration.LEGACY_MODE_ENABLED = True
# Setup model config from verysimple
atomic_data = deepcopy(atomic_dataset)
config_verysimple.montecarlo.last_no_of_packets = 1e5
config_verysimple.montecarlo.no_of_virtual_packets = 0
config_verysimple.montecarlo.iterations = 1
config_verysimple.montecarlo.single_packet_seed = 0
config_verysimple.plasma.line_interaction_type = 'macroatom'
del config_verysimple["config_dirname"]
config_montecarlo_1e5_verysimple.montecarlo.last_no_of_packets = 1e5
config_montecarlo_1e5_verysimple.montecarlo.no_of_virtual_packets = 0
config_montecarlo_1e5_verysimple.montecarlo.iterations = 1
config_montecarlo_1e5_verysimple.plasma.line_interaction_type = 'macroatom'
del config_montecarlo_1e5_verysimple["config_dirname"]

sim = Simulation.from_config(config_verysimple, atom_data=atomic_data)
sim = Simulation.from_config(config_montecarlo_1e5_verysimple, atom_data=atomic_data)
sim.run()


compare_fname = os.path.join(tardis_ref_path, "montecarlo_1e5_compare_data.h5")
if request.config.getoption("--generate-reference"):
sim.to_hdf(compare_fname, overwrite=True)
Expand Down