Tests
This is the documentation for the test module.
The tests are not comprehensive, but they do test that the most core functionality is working. The tests mostly check that correct files and directories are created and they do have some content. The actual content is not checked in most cases.
Things that are tested:
Target generation
Resampling
Slab simulation using the default:
optimizer
surface fitting
nn
Slab training
System simulation
Warning
System simulation bundles are not tested at all as there was no time to write tests for it.
Test slab simulation
Test slab simulation with different solvers.
- class TestSlabs(methodName='runTest')
- _classSetupFailed = False
- _class_cleanups = []
- check_existance_of_signal_result_files(slab_sim_name, signal_ids)
Check that the result files for the signals exist.
- Parameters:
slab_sim_name – Name of the slab simulation.
signal_ids – List of signal IDs (int) to check.
- check_existence_of_common_files(slab_sim_name)
Check that required result files exist after running the slab simulation.
Files common to optimizer, surface fitting and NN are checked here. Files specific to each solver are checked in their respective tests.
- check_nn_and_surf_result_files(solver: str, solver_dirname: str = None)
Check that the result files for the neural network and surface fitting solvers exist.
- Parameters:
solver – Solver to check. Either ‘nn’ or ‘surf’.
- run_advanced_solvers(solver_dirname: str = None)
Tests that the slab simulation run with the advanced solvers works as expected.
The advanced solvers are the neural network and surface fitting solvers.
- run_slab_optimization(solver_dirname: str = None)
Tests that the slab simulation run with the optimization solver works as expected.
The optimizer is run mainly when training the nn model, so it is important to be tested.
- setUp()
Hook method for setting up the test fixture before exercising it.
- tearDown()
Hook method for deconstructing the test fixture after testing it.
- test_advanced_solvers()
- test_custom_solver()
Tests that the slab simulation run with a custom solver works as expected.
- test_sampling()
Tests that the slab simulation sampling works as expected.
- test_slab_optimization()
Test system lights
- class TestSystemLight(methodName='runTest')
Tests system simulation light loading functionality.
Cleans up the test light file after the test.
- _classSetupFailed = False
- _class_cleanups = []
- setUp() None
Hook method for setting up the test fixture before exercising it.
- tearDown() None
Hook method for deconstructing the test fixture after testing it.
- test_load_light() None
Test loading light data.
- write_test_light_file(path_light_spectra)
Write a test light file with 1 nm resolution for loading.
Test system simulation
This module test the system simulation functionality.
- class TestSystemSimulation(methodName='runTest')
- _classSetupFailed = False
- _class_cleanups = []
- check_system_simulation_file_existence(system_sim_name: str, slab_material_names)
- setUp() None
Hook method for setting up the test fixture before exercising it.
- tearDown() None
Hook method for deconstructing the test fixture after testing it.
- test_forest_pipe() None
This is a testing box for all system_simulation canopy simulation functionality.
Test training
This module will test the training of slab models.
- Test plan:
Test the normal starting guess generation to a custom dir
- Test iterative training
First round with just starting guess
Following rounds with surf model
The last round trains surf and nn
- Trained model does not to be good so just a few training points
can be used
We are mostly just testing that everything can be run without errors