Skip to content

Conversation

tdrwenski
Copy link
Collaborator

@tdrwenski tdrwenski commented Jun 24, 2025

Add python interface test based on the examples. The tests compare the energy, population, and pulses at 10 samples of the output values. Some examples were changed slightly to make sure the random numbers were reproducible and they weren't too slow.

Note: If you add more similar pytests just ensure the test function has this signature:

def test_mytest(mpi_exec)

the testname should start with test_ for pytest to recognize it and the mpi_exec is so a pytest fixture will get used and if you pass mpi_exec=mpi_exec to quandary then the tests can run on the CI with the correct run command (srun or flux run instead of mpirun).

@tdrwenski tdrwenski force-pushed the add-python-tests branch 5 times, most recently from 7f61244 to 86da2ea Compare June 25, 2025 18:47
@tdrwenski tdrwenski requested a review from steffi7574 June 25, 2025 19:22
@steffi7574
Copy link
Member

Awesome! Would you mind adding the example_qft.py as a test case?

@tdrwenski tdrwenski changed the title Add python interface test Add python interface tests Jul 1, 2025
@tdrwenski
Copy link
Collaborator Author

tdrwenski commented Jul 2, 2025

Hey @steffi7574, I added all the examples as test cases now! Some have minor differences such as rand_seed, maxcores, and T settings (for instance for example_qft I made T smaller to speed it up).

I also added test_evalControls.py which reproduces the issue you fixed in #58.

I added a utils.py which contains the comparison of the test data that most tests use and a helper function print_expected_values if you need to update the expected values in one of the tests.

I also made a small change to quandary.py that if you set maxcores=1, it will still use the mpi executor, e.g. mpirun -np 1 quandary ... instead of calling quandary .... This seems necessary to run the tests on Ruby-- maybe not all versions of MPI support executing without mpirun/ srun.

@tdrwenski tdrwenski requested a review from steffi7574 July 2, 2025 15:16
@tdrwenski tdrwenski merged commit da7c7ff into main Jul 7, 2025
10 checks passed
@tdrwenski tdrwenski deleted the add-python-tests branch July 7, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants