TestCenter Reference
|
Functions | |
generateTestDictionary (function, testDictionaries) | |
Concatenates test dictionaries and sets a function that needs to be tested in the final dictionary. | |
initModuleFromTemplate (targetModuleName, templateModuleName=None, fieldValueOverrides=None, alsoInitNonEditableFields=False) | |
Copies all values from a reference module's editable parameter fields to the target ('test') module. | |
getMinMax (fv1, fv2=None) | |
Determines max/min value of given fill value(s). | |
getNumComponentsFromImage (imageField) | |
Returns the number of components of an ML-image data type. | |
getNumComponentsFromString (dataType) | |
Returns the number of components of a data type given as string. | |
getNumpyTypeFromImage (imageField, context=None) | |
Returns the NumPy data type of an ML-Image. | |
getNumpyTypeFromString (dataType) | |
Returns the NumPy data type appropriate to a data type given as string. | |
castToNumpy (value, numpyType) | |
Casts a value to a NumPy type. | |
convertVoxelType (voxel, oldType, newType) | |
Converts a voxel to a new data type. | |
getImage3D (imageField, imageStart=(0, 0, 0), imageSize=None, context=None) | |
Returns ML image output of given module in 3 dimensions. | |
getImage6D (imageField, imageStart=(0, 0, 0, 0, 0, 0), imageSize=None, context=None) | |
Returns ML image output of given module in 6 dimensions. | |
compareImages3D (resultImage, expectedImage) | |
Compares voxels of a result image with an expected image in 3 dimensions. | |
compareImages6D (resultImage, expectedImage) | |
Compares voxels of a result image with an expected image in 6 dimensions. | |
Variables | |
bool | LOGVOXEL = False |
bool | LOGONSUCCESS = False |
float | EPSILON = 0.0001 |
dict | INTTYPES |
TestSupport.HelperFunctions.castToNumpy | ( | value, | |
numpyType ) |
Casts a value to a NumPy type.
A special case is to cast an integer value to (u)int32 which is outside of the data type range. This is not possible with NumPy, so the value needs to be scaled manually before casted, what is the task of this function.
value | The value that needs to be casted. |
numpyType | The NumPy data type. |
Returns the value casted to the given NumPy data type.
Definition at line 207 of file HelperFunctions.py.
Referenced by TestSupport.HelperFunctions.convertVoxelType().
TestSupport.HelperFunctions.compareImages3D | ( | resultImage, | |
expectedImage ) |
Compares voxels of a result image with an expected image in 3 dimensions.
resultImage | The output result for the image. Needs to be in the shape of [z][y][x] or [component][z][y][x] with adv. data types. |
expectedImage | The expected result for the image. Needs to be in the shape of [z][y][x] or [component][z][y][x] with adv. data types. |
Definition at line 300 of file HelperFunctions.py.
TestSupport.HelperFunctions.compareImages6D | ( | resultImage, | |
expectedImage ) |
Compares voxels of a result image with an expected image in 6 dimensions.
resultImage | The output result for the image. Needs to be in the shape of [u][t][c][z][y][x] or [component][u][t][c][z][y][x] with adv. data types. |
expectedImage | The expected result for the image. Needs to be in the shape of [u][t][c][z][y][x] or [component][u][t][c][z][y][x] with adv. data types. |
Definition at line 375 of file HelperFunctions.py.
TestSupport.HelperFunctions.convertVoxelType | ( | voxel, | |
oldType, | |||
newType ) |
Converts a voxel to a new data type.
voxel | The voxel value(s). |
oldType | Name of the old data type. |
newType | Name of the new data type. |
Coverts fill values of any input data type to std output data type.
Definition at line 228 of file HelperFunctions.py.
References TestSupport.HelperFunctions.castToNumpy(), and TestSupport.HelperFunctions.getNumpyTypeFromString().
TestSupport.HelperFunctions.generateTestDictionary | ( | function, | |
testDictionaries ) |
Concatenates test dictionaries and sets a function that needs to be tested in the final dictionary.
function | A string of the function that needs to be tested. |
testDictionaries | The test dictionaries that shall be concatenate. Value of a dictionary needs to be a list or tuple with first element an temp value. |
Definition at line 37 of file HelperFunctions.py.
TestSupport.HelperFunctions.getImage3D | ( | imageField, | |
imageStart = (0, 0, 0), | |||
imageSize = None, | |||
context = None ) |
Returns ML image output of given module in 3 dimensions.
imageField | The Module image field. A MLABField* object is needed. |
imageStart | Used if image start position is not default. |
context | Parameter "context = ctx" needed if adv. data types are used. |
Definition at line 247 of file HelperFunctions.py.
References TestSupport.HelperFunctions.getNumComponentsFromImage().
TestSupport.HelperFunctions.getImage6D | ( | imageField, | |
imageStart = (0, 0, 0, 0, 0, 0), | |||
imageSize = None, | |||
context = None ) |
Returns ML image output of given module in 6 dimensions.
imageField | The Module image field. A MLABField* object is needed. |
imageStart | Used if image start position is not default. |
context | Parameter "context = ctx" needed if adv. data types are used. |
Definition at line 274 of file HelperFunctions.py.
References TestSupport.HelperFunctions.getNumComponentsFromImage().
TestSupport.HelperFunctions.getMinMax | ( | fv1, | |
fv2 = None ) |
Determines max/min value of given fill value(s).
Implemented especially for adv. data type with several value components.
fv1 | A fill/voxel value. Can be a string or list. |
fv2 | An optional second fill/voxel value. Can be a string or list. |
Determines max/min value of given fill value(s).
Definition at line 90 of file HelperFunctions.py.
TestSupport.HelperFunctions.getNumComponentsFromImage | ( | imageField | ) |
Returns the number of components of an ML-image data type.
imageField | The Module image field. A MLABField* object is needed. |
Returns the number of components of the image data type.
Definition at line 116 of file HelperFunctions.py.
Referenced by TestSupport.HelperFunctions.getImage3D(), and TestSupport.HelperFunctions.getImage6D().
TestSupport.HelperFunctions.getNumComponentsFromString | ( | dataType | ) |
Returns the number of components of a data type given as string.
dataType | Name of the data type. |
Definition at line 125 of file HelperFunctions.py.
TestSupport.HelperFunctions.getNumpyTypeFromImage | ( | imageField, | |
context = None ) |
Returns the NumPy data type of an ML-Image.
imageField | The Module image field. A MLABField* object is needed. |
context | Parameter "context = ctx" needed if adv. data types are used. |
Returns a NumPy data type object used with the image.
Definition at line 148 of file HelperFunctions.py.
TestSupport.HelperFunctions.getNumpyTypeFromString | ( | dataType | ) |
Returns the NumPy data type appropriate to a data type given as string.
mlType | Name of the data type. |
Definition at line 168 of file HelperFunctions.py.
Referenced by TestSupport.HelperFunctions.convertVoxelType().
TestSupport.HelperFunctions.initModuleFromTemplate | ( | targetModuleName, | |
templateModuleName = None, | |||
fieldValueOverrides = None, | |||
alsoInitNonEditableFields = False ) |
Copies all values from a reference module's editable parameter fields to the target ('test') module.
Helpful to reset the test module before running a test function to a fixed, documented state that does not depend on the module's default parameterization (which may change over time).
targetModuleName | Name of the target module of the assignment |
templateModuleName | Name of the source module ("template module") of the assignment. If omitted, <targetModuleName>_ParameterTemplate is assumed. |
fieldValueOverrides | If selected field shall differ from the template, specify these as a dictionary (use an ordered one, if order matters) |
alsoInitNonEditableFields | If enabled, also non-editable fields will be overwritten with the template module value |
Definition at line 57 of file HelperFunctions.py.
float TestSupport.HelperFunctions.EPSILON = 0.0001 |
Definition at line 19 of file HelperFunctions.py.
dict TestSupport.HelperFunctions.INTTYPES |
Definition at line 21 of file HelperFunctions.py.
bool TestSupport.HelperFunctions.LOGONSUCCESS = False |
Definition at line 18 of file HelperFunctions.py.
bool TestSupport.HelperFunctions.LOGVOXEL = False |
Definition at line 17 of file HelperFunctions.py.