Skip to content
Open
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
8 changes: 4 additions & 4 deletions docs/contribution_tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,16 @@ Further filtering is possible, for example running only the ``test_face_to_cell`

Which runs any test containing the string expression ``face_to_cell``.

Where appropiate, please add tests for your changes.
Where appropriate, please add tests for your changes.

An important class of test is the sim test. These are integration tests running
the configs in the ``torax/tests/test_data/`` directory, and comparing to the ground-truth
the configs in the ``torax/_src/test_data/`` directory, and comparing to the ground-truth
``.nc`` TORAX outputs found in the same directory. Sim tests can be triggered separately
by a command (from the TORAX root directory) such as:

.. code-block:: console

pytest -n <num_workers> torax/tests/sim_test.py
pytest -n <num_workers> torax/_src/integration_tests/sim_test.py

If any sim tests fail, they write their output to the ``/tmp/torax_failed_sim_test_outputs/<test_name>.nc``.
This is useful for debugging, and also to stage new output files for replacing the ground-truth files,
Expand All @@ -163,7 +163,7 @@ the TORAX repository. Using ``test_qlknnheat`` as an example:

.. code-block:: console

plot_torax --outfile torax/tests/test_data/test_qlknnheat.nc /tmp/torax_failed_sim_test_outputs/test_qlknnheat.nc
plot_torax --outfile torax/_src/test_data/test_qlknnheat.nc /tmp/torax_failed_sim_test_outputs/test_qlknnheat.nc

If it is deemed that the new outputs should replace the ground-truth files,
they can be copied over using the following command, again with this example working
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ exclude = ["*tests*"]

[tool.pytest.ini_options]
addopts = [
"--ignore=torax/tests/test_data",
"--ignore=torax/_src/test_data",
"--ignore=torax/tests/scripts",
"--ignore-glob=*lib*",
# Leads to an ImportError in collection for `pytest` without qualikiz_tools.
"--ignore=torax/_src/transport_model/qualikiz_wrapper.py",
]
testpaths = "**/tests"
testpaths = ["**/tests", "**/integration_tests"]
python_files = "*.py"
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
python_files = torax/**/tests/*_test.py
python_files = torax/**/*tests/*_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_persistent_cache(self):
cache = cache.full_path

flags = [
'--config=tests/test_data/test_iterhybrid_rampup_short.py',
'--config=_src/test_data/test_iterhybrid_rampup_short.py',
f'--jax_compilation_cache_dir={cache}',
'--jax_persistent_cache_min_entry_size_bytes=-1',
'--jax_persistent_cache_min_compile_time_secs=0.0',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion torax/_src/test_utils/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ def test_data_dir() -> pathlib.Path:
"""Absolute path of "test_data" directory."""
src_dir = pathlib.Path(absltest.TEST_SRCDIR.value)
torax_dir = 'torax/'
path = src_dir.joinpath(torax_dir, 'tests/test_data')
path = src_dir.joinpath(torax_dir, '_src/test_data')
assert path.is_dir(), f'Path {path} is not a directory.'
return path
Loading