-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Is your feature request related to a problem? Please describe.
The classes of sasdata/data_util/manipulations.py make up the backend to sasview's slicers. The respective unit tests for these classes are found in test/sasdataloader/utest_averaging.py and these tests leave much to be desired.
There are two classes with tests in utest_averaging.py: Averaging and DataInfoTests.
The tests in Averaging seem largely pointless. For starters only two of the eight slicer averaging methods are tested here. These tests are performed using a 100x100 array of 1s as the test dataset, and the test passes result post-averaging is 1. This does not seem like a good test.
The tests in DataInfoTests are better, and it actually tests the full spectrum of slicers. What is not ideal however is that their data is loaded in from an external file, and so are the expected results (in most cases). I have been told this is not good practice, and it would be better to mathematically construct this data within the test itself. These tests should have an expected answer that can be calculated analytically, probably also from within the test.
There are some other issues too:
test_sectorphi_fullandtest_sectorq_fulldo not actually test an azimuthal range of 2pi like their docstrings claim.- There are no tests for the other aspects of
manipulations.pysuch as the supporting (class agnostic) functions - There are no tests to check how the averagers respond to bad input parameters.
- There are no tests for the mask related classes,
Ringcut,BoxcutandSectorcut.
Describe the solution you'd like
The new unit tests should achieve the following:
- Test all of the averagers under several sets of conditions, particularly where potential bugs may arise.
- Use test data constructed within the test file. Should be of a mathematically simple form, with expected results that are easily calculated and analytical in form.
- Test all general-purpose functions present in
manipulations.pythat are used by the averagers. - Test the masks? This is lower priority, as I am much less familiar with how these are supposed to work, and how/whether they're implemented in SasView.
Additional context
My end goal is a rework of manipulations.py, and in order to do a good job of this I need to know that each of the averagers is working as intended. The current unit tests in DataInfoTests could be sufficient for this, but making them more robust would be better in the long term.
By writing new unit tests, I'll also become more familiar with the key operations in each of the averaging processes, and therefore better able to simplify and generalise these processes.