Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f65f4bb
remove unittest functionality
mabruzzo Sep 23, 2024
eee0efc
introduce cli arguments for configuring answer-tests. Converted test_…
mabruzzo Sep 23, 2024
85fe2a4
convert test_models and test_initialisation to new answer-testing sys…
mabruzzo Sep 23, 2024
e250b8c
convert test_code_examples.py to new answer-testing system
mabruzzo Sep 23, 2024
0b9210f
remove the now unused ensure_dir function.
mabruzzo Sep 23, 2024
e484a3f
Adding documentation.
mabruzzo Sep 23, 2024
4a9c739
minor bugfix
mabruzzo Sep 24, 2024
c4638be
calc_tdust_3d_g: remove misc unused variables 1/4
mabruzzo Jan 5, 2025
e55c2f9
calc_tdust_3d_g: remove misc unused variables 2/4
mabruzzo Jan 5, 2025
69dfa73
cool1d_multi_g: tweak dust-related calcs
mabruzzo Jan 5, 2025
1f3511f
calc_tdust_3d_g: remove misc unused variables 3/4
mabruzzo Jan 5, 2025
8096834
factor out calc_all_tdust_gasgr_1d_g
mabruzzo Jan 5, 2025
24b313c
calc_tdust_3d_g: remove misc unused variables 4/4
mabruzzo Jan 5, 2025
047c5a4
calc_all_tdust_gasgr_1d_g: remove some arguments
mabruzzo Jan 5, 2025
864c817
calc_tdust_3d_g: cleanup 1st parallel clause
mabruzzo Jan 5, 2025
34d51bb
remove slightly more arguments.
mabruzzo Jan 5, 2025
31c0dac
calc_tdust_3d_g: cleanup 3rd parallel clause
mabruzzo Jan 5, 2025
9f7ff4c
remove even more args.
mabruzzo Jan 5, 2025
0add413
calc_tdust_3d_g: remove dust-chem metal species
mabruzzo Jan 5, 2025
181f5e0
even more tweaks.
mabruzzo Jan 5, 2025
0911133
calc_tdust_3d_g: remove metal-chem metal species
mabruzzo Jan 5, 2025
b3fcb99
calc_all_tdust_gasgr_1d_g: rename mynh -> nh
mabruzzo Jan 5, 2025
4069d89
calc_tdust_3d_g: adopt more consistent type declarations with other p…
mabruzzo Jan 5, 2025
60dd598
calc_tdust_3d_g: start using calc_grain_size_increment_1d
mabruzzo Jan 5, 2025
cc5024a
Remove all places in tests where we change dir
mabruzzo Feb 4, 2025
3d5d216
Modify answer-test args for consistency with discussion on GitHub
mabruzzo Feb 3, 2025
897af23
update the pytest testing instructions
mabruzzo Feb 4, 2025
077d516
Relocate the check for whether we are missing the test-answers
mabruzzo Feb 4, 2025
36c864b
fixing the readthedocs build-problem
mabruzzo Feb 4, 2025
e2c9baa
Merge branch 'main' into answer-test-refactor
mabruzzo Feb 4, 2025
b2511c0
ReadTheDocs has broken CI builds builds unless you explicitly specify…
mabruzzo Feb 20, 2025
bcdd0ba
Merge pull request #257 from mabruzzo/fixing-readthedocs
mabruzzo Mar 12, 2025
a343f39
Merge pull request #245 from mabruzzo/answer-test-refactor
mabruzzo Mar 17, 2025
a49bc64
A few assorted tweaks
mabruzzo Mar 18, 2025
8b30868
remove an unused file
mabruzzo Mar 18, 2025
18a74e5
minor bugfix
mabruzzo Mar 18, 2025
04f74b4
Merge pull request #265 from mabruzzo/FBindingBugfix-3.4Tweaks
brittonsmith Mar 18, 2025
f6ae094
Merge branch 'main' into newchem-cpp
brittonsmith Mar 19, 2025
e9b4960
Move parameter to correct place in fortran interface.
brittonsmith Mar 19, 2025
07c5554
Temporarily disable openmp tests.
brittonsmith Mar 19, 2025
89e109d
Merge pull request #268 from brittonsmith/disable-omp-test
brittonsmith Mar 19, 2025
b202aa3
Merge branch 'newchem-cpp' into ncc-bug3
brittonsmith Mar 19, 2025
cd46e59
Merge pull request #266 from brittonsmith/ncc-bug3
brittonsmith Mar 20, 2025
ca82824
Merge branch 'newchem-cpp' into gen2024-cleanup_calc_tdust_3d_g
mabruzzo Mar 20, 2025
601806a
Merge branch 'gen2024-cleanup_calc_tdust_3d_g' into gen2024-refactor_…
mabruzzo Mar 20, 2025
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
41 changes: 26 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,33 @@ commands:
export PYTEST_CODE_LINK_CHOICE="" # we skip test_code_examples.py
fi

# configure variables for generating test answers
if [ << parameters.generate >> == 'true' ]; then
export GENERATE_PYGRACKLE_TEST_RESULTS=1
else
export GENERATE_PYGRACKLE_TEST_RESULTS=0
fi

# actually execute the tests
if [ << parameters.omp >> == 'true' ]; then
export OMP_NUM_THREADS=4
cd example
make cxx_omp_example
./cxx_omp_example
make clean
else
elif [ ! -f ./python/tests/conftest.py ]; then
# this is the old way to control the answer-test mode
# - We can stop supporting this case once the most recent gold
# standard tags a repository version containing conftest.py
if [ << parameters.generate >> == 'true' ]; then
export GENERATE_PYGRACKLE_TEST_RESULTS=1
else
export GENERATE_PYGRACKLE_TEST_RESULTS=0
fi
py.test python/tests
else
# ANSWER_DIR was picked to ensure that it matches up with the old
# hardcoded location (we can change it once the most recent gold
# standard tags a repository version containing conftest.py)
ANSWER_DIR=./python/tests/test_answers
if [ << parameters.generate >> == 'true' ]; then
py.test --answer-dir=${ANSWER_DIR} --answer-store python/tests
else
py.test --answer-dir=${ANSWER_DIR} python/tests
fi
fi

build-docs:
Expand Down Expand Up @@ -281,14 +292,14 @@ jobs:
build_kind: 'classic'
generate: 'true'

- install-grackle:
omp: 'true'
classic_build: 'true'
tag: $CIRCLE_BRANCH
# - install-grackle:
# omp: 'true'
# classic_build: 'true'
# tag: $CIRCLE_BRANCH

- run-tests:
omp: 'true'
build_kind: 'classic'
# - run-tests:
# omp: 'true'
# build_kind: 'classic'

- install-grackle:
omp: 'false'
Expand Down
4 changes: 4 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ build:
python:
install:
- requirements: doc/source/requirements.txt

sphinx:
# Path to your Sphinx configuration file.
configuration: doc/source/conf.py
16 changes: 6 additions & 10 deletions doc/source/Python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ a parcel of gas at constant density or in a free-fall model. Each example
will produce a figure as well as a dataset that can be loaded and analyzed
with `yt <http://yt-project.org/>`__.

Configuring the path to Grackle input data
++++++++++++++++++++++++++++++++++++++++++
Editable Install Requirement
++++++++++++++++++++++++++++

All of the example scripts discussed below use the following line to
make a guess at where the Grackle input files are located.
Expand All @@ -195,19 +195,15 @@ make a guess at where the Grackle input files are located.

from pygrackle.utilities.data_path import grackle_data_dir

This will typically work for any 'editable' Pygrackle installation
This currently **ONLY** works for an 'editable' Pygrackle installation
(i.e., one installed with ``pip install -e .`` as directed
above). In this case, it will be assumed that the data files can be
found in a directory called ``input`` in the top level of the source
repository. However, this will not work with non-editable
installations. In this case you can use the ``GRACKLE_DATA_DIR``
environment variable to set the path to the data. This will be picked
up by the Python code above and the ``grackle_data_dir`` variable will
contain the proper path.
repository.

.. code-block:: shell-session
.. note::

export GRACKLE_DATA_DIR=/path/to/data
`GitHub PR #235 <https://github.com/grackle-project/grackle/pull/235>`__ is a pending pull request that seeks to add functionality to make this work in a regular Pygrackle installation (i.e. a non-'editable' install).

Cooling Rate Figure Example
+++++++++++++++++++++++++++
Expand Down
85 changes: 56 additions & 29 deletions doc/source/Testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ the following:
Answer tests are those whose correct answers must be generated from a
prior, trusted version of Grackle (i.e., the "gold standard"). The
tests are first run using this trusted version to generate the
results, then run again on the latest version to compate. These tests
include:
results (in *store-mode*), then run again on the latest version to
compare (in *compare-mode*).
These tests include:

- all code examples build, run, and return correct results

Expand All @@ -37,40 +38,51 @@ include:
- all grackle 'calculate' functions return correct results for sets
of random field values

Tests Without Answer Verification
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We refer to the location where the results of answer-tests are stored as the "answer-directory." This is an arbitrary user-specified location.

If you only want to quickly verify that everything runs, you can skip
generating the answer test results using the latest gold standard. To
run this way, first set the ``GENERATE_PYGRACKLE_TEST_RESULTS``
environment variable to 1.
Quick Primer on the Test Runner's CLI
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: shell-session
By default, the pytest test-runner always runs all available test cases.

~ $ export GENERATE_PYGRACKLE_TEST_RESULTS=1
- The unit tests are **ALWAYS** available.

This will tell the test suite to simply generate new answers and not
compare with previously existing ones.
- By default, **all** answer-tests are fully disabled.
Command-line options make them available in *store-mode* or *compare-mode*.
The ``--answer-dir=<PATH/TO/ANSWER-DIR>`` flag is required for both modes; it specifies the path to the user's chosen "answer-directory" (where answer-tests results are stored/read-from).
The ``--answer-store`` flag enables *store-mode*, while its absence enables *compare-mode*.

Once you have installed :ref:`pygrackle and the development
dependencies <pygrackle-dev>`, the tests can be run from the **src**
directory by typing ``make test``:
*For contributors:* you may find pytest's `build-in command-line interface <https://docs.pytest.org/en/stable/how-to/usage.html>`__ useful during debugging (e.g. you can instruct pytest to only run a subset of all available tests).

.. code-block:: shell-session
.. _test_without_answer_verification:

~ $ cd grackle/src
~/grackle/src $ make test
Tests Without Answer Verification
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you only want to quickly verify that everything runs, you can skip
generating the answer test results using the latest gold standard.

or from the **src/python** directory by typing ``py.test``:
Once you have installed :ref:`pygrackle and the development dependencies <pygrackle-dev>`, this is relatively straight-forward.

Simply invoke ``py.test`` from the **src/python** directory with the ``--answer-dir=<PATH/TO/ANSWER-DIR>`` option **and** the ``--answer-store`` option.
For the former You can specify an arbitrary path where the test-answers will be recorded.
A concrete example of what this looks like is shown down below.

.. code-block:: shell-session

~ $ cd grackle/src/python
~/grackle/src $ py.test
~/grackle/src/python $ py.test --answer-dir=./my_test_answers --answer-store

The above snippet instructs each answer-test to store the test result in the directory called **./my_test_answers**; an answer-test reports that it has "passed" as long as it is able to successfully store the result.
After you run the test-suite, you can delete the **./my_test_answers** directory (since we don't actually care about the test results).

When you launch the tests, the output will look like the following:

.. code-block:: shell-session

==================================== test session starts ====================================
platform darwin -- Python 3.11.9, pytest-8.2.1, pluggy-1.5.0
rootdir: /Users/britton/Documents/work/research/simulation/grackle/grackle-git/src
rootdir: /Users/britton/Documents/work/research/simulation/grackle/grackle-git/src/python
plugins: cov-5.0.0
collected 65 items

Expand Down Expand Up @@ -112,11 +124,18 @@ steps:
#. Re-compile the Grackle library and :ref:`re-install pygrackle
<install-pygrackle>`.

#. Set the ``GENERATE_PYGRACKLE_TEST_RESULTS`` environment variable to
1.
#. Execute the test suite using command-line flags to instruct the test-runner to run answer tests in *store-mode*.
This was already illustrated :ref:`above <test_without_answer_verification>`, we repeat the instructions here:

- Execute ``py.test`` from the **src/python** directory while specifing the path to the *answer-directory* with ``--answer-dir=<PATH/TO/ANSWER-DIR>`` **and** specifying the ``--answer-store`` option.

- Be aware, this will directly overwrite any files that were previously stored in the answer-dir.

- If we wanted to store the test-answers in **./my-test-answers**, we would invoke:

#. Run the test suite as described above. This will create test result
files in the directory **src/python/tests/test_answers**.
.. code-block:: shell-session

~/grackle/src/python $ py.test --answer-dir=./my_test_answers --answer-store

#. Return to the branch of the repository you started with. If you just
cloned the main repository, this will be called 'main', in which
Expand All @@ -125,8 +144,16 @@ steps:
#. Re-compile the Grackle library and :ref:`re-install pygrackle
<install-pygrackle>`.

#. Set the ``GENERATE_PYGRACKLE_TEST_RESULTS`` environment variable to
0.
#. Run the test suite again using a command-line flag to instruct the test runner to evaluate the answer-tests in *compare-mode*:

- you just need to specify the *answer-directory* path with ``--answer-dir=<PATH/TO/ANSWER-DIR>``.

- Do **NOT** pass the ``--answer-store`` flag.
The absence of this flag is how the test-runner knows to use *compare-mode*.
(If the flag were present, then the answer-tests would overwrite the answers)

- To compare against the results previously written to **./my-test-answers**, you would invoke:

.. code-block:: shell-session

#. Run the test suite again. This time, the answer tests will be
compared with the previously generated results.
~/grackle/src/python $ py.test --answer-dir=./my_test_answers --answer-store
1 change: 1 addition & 0 deletions src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ add_library(Grackle_Grackle
${CMAKE_CURRENT_BINARY_DIR}/auto_general.c

# Fortran Source Files
calc_all_tdust_gasgr_1d_g.F
calc_tdust_1d_g.F
calc_tdust_3d_g.F
calc_temp1d_cloudy_g.F
Expand Down
1 change: 1 addition & 0 deletions src/clib/Make.config.objects
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ OBJS_CONFIG_LIB = \
solve_rate_cool_g.lo \
update_UVbackground_rates.lo \
lookup_cool_rates0d.lo \
calc_all_tdust_gasgr_1d_g.lo \
calc_tdust_1d_g.lo \
calc_tdust_3d_g.lo \
calc_grain_size_increment_1d.lo \
Expand Down
60 changes: 0 additions & 60 deletions src/clib/c_wrappers/wrap_interpolators_g.c

This file was deleted.

Loading