Automatic test listing generated by testlister.py at 2023-07-10T12:18:49.902047
Basic tests.
Tests on basic datum operations such as serialization
This ensures that a Datum can serialise and deserialise an image with uncertainty and DQ as well as nominal pixel data. This relies on Value working.
Parser/Evaluator tests - not PCOT specific, just the shunting yard algorithm and VM. This was written with unittest, but you don't need to write every test suite that way - it's just that this was done first.
This has become rather more PCOT specific recently because of Value(), but these functions don't test uncertainty. That's done elsewhere.
Note that there are a lot of tests for how expr nodes manage sources in test_source_principles.py
Test the basics of binary operations WITHOUT uncertainty or DQ. All integer operations to make the tests simple (we're working with float32 values).
addition test, 6+6
division test, 16/2
multiplication test, 8*4
subtraction test, 8+2
Test that precedence rules are correct and that brackets work
10*12+4*3
10*(12+4)*3
(2+2)*(3+3)
10/2+9/3
10/2-9/3
10*(9-2)*3
(10-2)*2
10-2*2
Tests of the syntax for the unary minus operator (and by extension other unary operators that might be defined)
-43
-43+10
43*-1
43+-3
-4--3
(-4)
-(-4)
-(2*8)
-(2*-8)
Test simple variable fetches - these are implemented by wiring two Python global values (variable_1 and variable_2) to the var1 and var2 idents.
Single variable fetch
var1-var2
var1-(var2)
var1-(var2/2)
The parser can be set to push strings onto the stack when unrecognised identifiers are found (so-called "naked idents").
Check that naked idents work when the flag is set in execute()
Check an assertion is raised when we try to use naked idents without the flag
Test that function calls work. The functions defined are min and max of lists, sqrt, and a function noargs() that returns 100.
sqrt(16)
max(0,3,2)+min(7,2,45,3)
max(min(100,50,200),1,2,4+7,5+1)
max(1,2,4+7,5+1,min(100,50,200))
min(45,1,56,12,2)
max(45,1,56,12,2)
10+noargs()
max(1,2,4+7,5+1,2*6)
max(1,2,4+7,2*6,5+1)
max(1,2,4+7,min(100,50,200),5+1)
Tests on basic geometric entities, such as Rect()
Test that Rect constructor gives the right members
Intersection of two rectangles, one contained entirely within the other. Done both ways.
More complex rectangle intersection test
More complex rectangle intersection test
More complex rectangle intersection test
Test the Rect.corners() method for getting rectangle corners
Tests on basic imagecube operations
Test that we can load a 32x32 solid white image from a PNG. It just does some very basic checks on the image pixels.
A slightly tougher image - a white rect with colour blobs at the corners. Let's make sure the orientation is good, and that we are converting 8bit into 32bit float correctly. Again, it just loads an image from a PNG.
Checks that we can split a colour RGB image and remerge it. Only tests the pixels, not uncertainty or DQ.
Just check that we created this image OK, and that we have some kind of mapping in there.
Create an image with some weird bands in it - bands with combined wavelengths - and check that wavelengthBand() works, correctly getting the single wavelength bands.
Create an image with multiple RGB bands (among others) with the same CWL and make sure that wavelengthBand gets the widest one. This gets used in guessing RGB channels.
test that we can index into an imagecube to get a pixel value for both mono and multichannel image. We don't check limits here but we do check all coords, but all pixels are the same.
test that indexing works on a more complex RGB image with coloured corners, so we know the coordinate indexing is correct. Also double checks Value.approxeq.
Test indexing on coordinates out of range: -ve indices count from the end, but not too -ve or too +ve
Test that images have the correct numpy array shapes (i.e. a single band image is (h,w) and a multiband image is (h,w,d).
Test a 2D image is OK
Should also be possible to create a 2D image from a 3D image with 1 band
Test a 3D image is OK
A 4D image is right out
Basic tests on nodes in a document graph
Just make sure all nodes can perform without inputs. This could be made to pass by just having create() do nothing, or having perform() do nothing, but them's the breaks.
Test every XForm type by creating an empty document with one node of that type, and ensure it produces the correct output from its output 0 (if it has one) when unconnected. Generally this is None - not Datum of type NONE (i.e. Datum.null). There are exceptions, such as constant and spectrum.
Try to create a node we know doesn't exist and assert we get a dummy node back.
We define a simple node type below - but can we still create it in a document? If we couldn't, we should get a dummy node back from the create
Create a simple node, wire it up, and make sure it does the thing it should.
It's quite difficult to test ROIs, but we'll try to at least do rect, circle and poly. Some tests here mainly work by performing a change to part of an image selected by an ROI and checking the results are correct. Does not test DQ or uncertainty!
Check that trying to get the subimage for an ROI which doesn't intersect the image throws an exception
As test_nonintersecting_rois, but the ROI starts at negative coords - this should raise an ROIBoundsException
Test a rect ROI that gets clipped to the bottom-right of the image (i.e. ROI is too big)
Now an ROI that's been clipped at top-left (i.e. xy -ve)
Test that a rectangular ROI entirely within a black image, when modified, only changes the right number of pixels
Test that a rectangular ROI entirely within a red image, when modified, only changes the right number of pixels to cyan
change a circle in black image to red, count red pixels.
change a circle in a red image to cyan, count cyan pixels.
Two circles within an image - we should change the union of those two circles
change a polygon in a red image to cyan, count cyan pixels. No points selected, so entire image changes.
Change a polygon in a red image to cyan - rectangle
Change a polygon in a red image to cyan - triangle
Change a polygon in a red image to cyan - triangle
Change a polygon in a red image to cyan - triangle
Simple test of painted using a single circle
Simple test of painted using a single circle; won't set an ROI because the image size needs to be set
Test low-level source operations. Higher level operations, such as combining in expr nodes, are tested in test_source_principles.py
Make sure that the different valid forms of SourceSet constructor arguments work
Make sure that getOnlyItem() fails when we try to get the only Source in a SourceSet with more than one item. And that it actually works, of course.
Test that for some purposes, a SourceSet can be interacted with directly as if one were interacting with the underlying set (the sourceSet member). SourceSet implements:
- iter
- contains
- len
Test that source set unions contain union of all subsidiary sets
Source set brief description test
Source set long description test
str(sourceset) should be the same as sourceset.brief()
" "matches" checks to see if any source in a set matches some criterion; in this case we test that the name matches
Test that input source brief() and long() are correct
Test that multiband source brief() is correct
Test that multibands act as an array of SourceSets
A test for the testing framework itself, and a PCOT-independent template for other tests.
Check a file exists in the data directory with the same name as the module but with _data added
Test that we can correctly read a file from the data directory
Check file exists in the global data directory
Check that a file in the global data directory has the correct contents
Test the basics principles of the Value type for values with uncertainty - doesn't test the uncertainty parts themselves, that's done in uncertainty/test_ops.py.
For binary operations, each test function is actually a "minisuite" and takes three arguments. Each of these is a function which generates a value, either a scalar or an array. Two functions generate the operands, the other generates the result. Then the main test functions call each of these four times, with combinations of the different types (scalar and array).
More complex tests are done at the node level in uncertainty/test_ops.py, but if those tests fail and these pass then there is a likely to be a problem in the nodes or expression parser.
Test the "approximately equal" function for both scalars and arrays
Test the equality operator
Test addition - see notes for this module
Test subtraction - see notes for this module
Test multiplication - see notes for this module
Test division - see notes for this module
Test exponentiation - see notes for this module
Test min and max - see notes for this module
Test DQ propagation - see notes for this module
Test unary operations
Calibration tests (not done)
Tests of the basic calibration line-fitting technique
Perform some basic tests - we generate some data around a known slope and intercept, and check we recover that slope and intercept correctly
Test input methods (probably not RGB, that gets tested as part of imagecube tests).
Test the direct input method
Use the special 'direct' input method to bring an ImageCube directly into the graph.
Tests of the ENVI input method
Check we can load an ENVI - check the image values and filter names
Multifile input tests
Load up a set of images using the default filter pattern, which will give duff sources
Load up a set of images using a uncompilable pattern
Here we set up a custom pattern to work out filter positions from file names, assuming that these are PANCAM filters.
Very basic tests for PDS4 input - more work needs to be done on how PDS4 input will work, particularly for HK data (which could be time series) and we need a corpus of known data.
Load some PDS4 data, check the channel count in the result, the LIDs, the filter properties but NOT the image pixels (we need a small test image for that)
RGB input tests
Test we can load an RGB file (a PNG)
Tests of basic operating principles
Test operations - a lot of operations are covered already by things in test_roi_principles, however, and also uncertainty/test_ops.py!
Basic scalar ops, testing precedence and brackets.
Smoke test for a basic image+scalar operation, no ROI
Very basic image ops
Test functions that take an entire image and produce a scalar
Test scalar division by zero
Test of dividing an image by scalar zero. Also checks that 0/0 comes out as undefined and divzero.
Dividing by zero. We're trying to reciprocate an image where two of the bands are zero, which should lead to errors in those bands.
Check that we can index into a multichannel ImageCube
Check that we can index into a 1-channel ImageCube.
now test that greyscaling with human perception of RGB works.
Make sure all expr inputs work.
Test that a null input (Datum of type NONE) into a binop produces an appropriate error. The error will actually be thrown before the binop even runs.
Test that a null input (Datum of type None) into a binop produces an appropriate error
Test that a null image input (Datum of type Image) into a binop produces an appropriate error
Tests on basic ROI operations. Note that these mostly work by using the ROI control modification of an image and then testing pixels in the result. Only nominal data is checked, not uncertainty or DQ.
Test that a single 'standard operation' - one which uses modifyWithSub - works correctly on an image with a single ROI. ROIs and modifyWithSub are tested at a lower level in basic/test_roi.py; this tests that the layers above use the right code.
Test using expr to intersect two ROIs
Test that we can union two ROIs correctly with expr and importroi
Union two ROIs by applying them in series
Test image with ROI on LHS of binary operation where RHS is image with no binop. The left image is entirely red, and has a square ROI in the middle. The right image is entirely green. Adding the two images should result in a red image with a yellow square.
Test image with ROI on RHS of binary operation where LHS is image with no binop. The left image is entirely green. The right image is entirely blue and has a square ROI in the middle. Adding the two images should result in a green image with a cyan square.
Test that operations on two images (e.g. a+b) don't work when there is an ROI on both sides. This test looks overcomplicated, and that's because it is. Originally the principle was that if we had two unions of ROIs being fed into both sides of a binop, that the operation would only modify the intersection - with the LHS being passed through for the rest. This is OK, but really breaks the principle of least astonishment. If the user has fed two images with ROIs into a binary operation it probably means they've done something wrong. Therefore, we should throw an error.
It can happen that the ROIs on both sides of a binop are the same ROI, which is fine. This can happen when two channels of the same image are being manipulated.
Test that a imageWithROI+scalar uses the ROI
Test that we can intersect two ROIs correctly with expr and importroi
Test that we can difference two ROIs correctly with expr and importroi
Test that we can difference two ROIs correctly with expr and importroi
Unary negate is not implemented (yet?)
Test the basic principles behind how sources are propagated through the graph
make sure ENVI sources work as expected
Make sure conversion to greyscale using the grey() function works with regard to sources - this will stand in for certain aspects of the sources principles.
Make sure conversion to greyscale using the grey() function works with regard to sources - this will stand in for certain aspects of the sources principles. As test_greyscale_sources(), but uses an actual expr node.
Make sure that an expression of the form a$n works as expected with sources, this time using an actual expr node
Make sure that sources work with two images combined in an expr node.
Make sure that sources work with two images combined in an expr node, but where both images are converted to numbers (using mean). We should get a single source set made up of all the sources.
Make sure that sources work with two images combined in an expr node, but where both images are converted to numbers (using mean). We should get a single source set made up of all the sources.
Similar to test_binop_image_and_number, but we do it the other way around and use a different binop
Similar to test_binop_image_and_number, but we do it the other way around and use a different binop AND the number is a literal.
Test that sources are propagated correctly through a unary op
Turn image into number, perform unop on number. Should produce a single source set of all channels in the image.
Test the creation of image with uncertainty and DQ bits
Test that imagecube ctor throws when unc data is not the same shape as image
Test that an incorrect type passed as uncertainty is not accepted.
Test that imagecube ctor throws when DQ data is not the same shape as image
Test that a float array passed as DQ is not accepted in imagecube ctor.
Test that a int array passed as DQ is not accepted in imagecube ctor.
Test that a scalar passed as DQ is not accepted in imagecube ctor
Basic test of creating a 2-band image with uncertainty
Test that creating an image with uncertainty creates zero DQ (assuming no other problems)
Test that creating an image with no uncertainty data creates NOUNC dq bits
Test binary and unary operators for uncertainty at the top (graph) level. Some of these tests might seem redundant, because we also do them at the lower (Value) level. But it's good to do some basic tests up here too.
If these tests fail, but those tests in basic/test_values.py pass, the problem is probably in the nodes or expression parser.
There's a very handy calculator with uncertainties at https://uncertaintycalculator.com/
Test that the scalar+uncertainty generator works
Test that unary operations in expr nodes on numbers with uncertainty work. In the case of unary negation and inverse, (- and !) the uncertainty is passed through unchanged
Test that unary operations in expr nodes on images with uncertainty work. Also ensure that the operation only acts on areas covered by an ROI and that DQs are passed through.
Test that binary operations in expr nodes on numbers with uncertainty work.
Test than binops in expr nodes on numbers and images work, with the image on the RHS. We want to ensure that the part outside an ROI - and any "bad" parts of the image (with dq.BAD bits) - are unchanged.
Test than binops in expr nodes on images and numbers work, with the image on the LHS. We want to ensure that the part outside an ROI - and any "bad" parts of the image (with dq.BAD bits) - are unchanged.
Test that binops work on image/image pairs, where the LHS image has an ROI on it.
test image/image operations without a region of interest.
Test that DQ is propagated correctly in the binary operators on images