diff --git a/tests/test_contexts.py b/tests/test_contexts.py deleted file mode 100644 index 06e3677..0000000 --- a/tests/test_contexts.py +++ /dev/null @@ -1,24 +0,0 @@ -import saltax - - -RUNID = 53169 - - -def test_import_cutax(): - import saltax.contexts - - -def test_contexts_import(): - from saltax.contexts import sxenonnt - - -def test_contexts_definition(): - from saltax.contexts import SALTAX_MODES - - for saltax_mode in SALTAX_MODES: - if saltax_mode == "salt": - runid = RUNID - else: - runid = None - st = saltax.contexts.sxenonnt(runid=runid, saltax_mode=saltax_mode) - assert st is not None, "sxenonnt should be defined for saltax_mode %s" % (saltax_mode) diff --git a/tests/test_instructions.py b/tests/test_instructions.py deleted file mode 100644 index 5784e23..0000000 --- a/tests/test_instructions.py +++ /dev/null @@ -1,85 +0,0 @@ -import numpy as np -from saltax.instructions.generator import * -import pytest - - -RUNID = 53169 - - -def test_generate_vertex(): - # Test that the function returns the expected number of vertices - x, y, z = generate_vertex(size=10) - assert len(x) == 10 - assert len(y) == 10 - assert len(z) == 10 - - # Test that the function generates vertices within the specified ranges - x, y, z = generate_vertex(size=1000) - assert np.all(x >= -R_RANGE[1]) - assert np.all(x <= R_RANGE[1]) - assert np.all(y >= -R_RANGE[1]) - assert np.all(y <= R_RANGE[1]) - assert np.all(z >= Z_RANGE[0]) - assert np.all(z <= Z_RANGE[1]) - - # Test that the function generates random vertices - x1, y1, z1 = generate_vertex(size=1000) - x2, y2, z2 = generate_vertex(size=1000) - assert not np.all(x1 == x2) - assert not np.all(y1 == y2) - assert not np.all(z1 == z2) - - -def test_generate_times(): - # Test that the function generates event times within the specified range - start_time = 0 - end_time = 1e9 - times = generate_times(start_time, end_time, size=1000) - assert times.min() >= start_time - assert times.max() <= end_time - - # Test that the function generates event times with the expected rate - rate = 1e6 - times = generate_times(start_time, end_time, size=1000, rate=rate) - assert len(times) == 1000 - - # Test that the function generates event times in the expected mode - times = generate_times(start_time, end_time, size=1000, time_mode="realistic") - assert (np.diff(times) >= 0).all() - - times = generate_times(start_time, end_time, size=1000, time_mode="uniform") - assert (np.diff(times) >= 0).all() - - -def test_get_run_start_end(): - # Test with a non-integer runid - with pytest.raises(AssertionError): - get_run_start_end("abc") - - # Test with a runid that does not exist in RunDB - with pytest.raises(RuntimeError): - get_run_start_end(999999) - - # Test with runid RUNID - runid = RUNID - start_time, end_time = get_run_start_end(runid) - - # Check that the start and end times are integers - assert isinstance(start_time, int) - assert isinstance(end_time, int) - - # Check that the start time is before the end time - assert start_time < end_time - - -def test_generator_flat(): - # Test with default parameters - instr = generator_flat(RUNID, n_tot=20) - assert isinstance(instr, np.ndarray) - assert len(instr) > 0 - - # Test with non-default parameters - instr = generator_flat(1, en_range=(10, 20), n_tot=20) - assert isinstance(instr, np.ndarray) - assert len(instr) > 0 - assert np.all(instr["e_dep"] >= 10) and np.all(instr["e_dep"] <= 20)