Module EDAssert :: Class EDAssert
[hide private]
[frames] | no frames]

Class EDAssert

source code

This static class is used for comparing two objects.

Static Methods [hide private]
 
equal(_oExpected, _oObtained, _strComment='Equal', _fMaxDelta=1e-06)
Fail if the two objects are unequal as determined by the '==' operator.
source code
 
strAlmostEqual(_oExpected, _oObtained, _strComment='Strings are similar', _fRelError=0.01, _fAbsError=0.0001, _fStrSimilar=1.0, _strExcluded=None, _lstExcluded=[])
Check if two strings (or XML strings) are almost equal, which means that: - all pure text part are equal - floats do not differ more than 1% by default or 0.0001 in absolute difference
source code
 
isFile(_strFilename, _strComment='')
Fail if the filename does not exist.
source code
 
lowerThan(_fValue, _fReference=1.0, _strComment='Lower than')
Fails if the _fValue is greater (or equal) than the reference.
source code
 
greaterThan(_fValue, _fReference=1.0, _strComment='Greater than')
Fails if the _fValue is greater (or equal) than the reference.
source code
 
arraySimilar(_npaValue, _npaRef, _strComment='Arrays are similar', _fAbsMaxDelta=None, _fRelMaxDelta=None, _fRfactor=None, _fScaledMaxDelta=None)
Tests if two arrays are similar.
source code
Method Details [hide private]

equal(_oExpected, _oObtained, _strComment='Equal', _fMaxDelta=1e-06)
Static Method

source code 

Fail if the two objects are unequal as determined by the '==' operator. Saves the two objects to the current working directory using an unique identifier appended with "_obtained.txt" and "_expected.txt".

Parameters:
  • _oExpected - any python object used as reference
  • _oObtained - any python object to be compared with the reference
  • _strComment (python string or unicode string.) - a comment to make your assertion more understandable to the user
  • _fMaxDelta - epsilon to check equivalence for float
  • _fMaxDelta - float

strAlmostEqual(_oExpected, _oObtained, _strComment='Strings are similar', _fRelError=0.01, _fAbsError=0.0001, _fStrSimilar=1.0, _strExcluded=None, _lstExcluded=[])
Static Method

source code 

Check if two strings (or XML strings) are almost equal, which means that: 
- all pure text part are equal
- floats do not differ more than 1% by default or 0.0001 in absolute difference

Saves the two objects to the current working directory using an unique identifier
appended with "_obtained.txt" and "_expected.txt".
@param _oExpected: any python object used as reference, probably a string or an unicode string
@param _oObtained: any python object to be compared with the reference, probably a string or an unicode string
@param _strComment: a comment to make your assertion more understandable to the user
@type _strComment: python string or unicode string. 
@param _fRelError: maximum relative error defined as a float
@param _fAbsError: maximum absolute error defined as a float
@param _strExcluded: if a "word" contains this string, it is not taken into account for the comparison
@type _strExcluded: string 
@param _lstExcluded: list of words to be excluded for the comparison
@type _lstExcluded:  list of strings

isFile(_strFilename, _strComment='')
Static Method

source code 

Fail if the filename does not exist.

Parameters:
  • _strFilename - any python string representing a file that shoul exist
  • _strComment (python string or unicode string.) - a comment to make your assertion more understandable to the user

lowerThan(_fValue, _fReference=1.0, _strComment='Lower than')
Static Method

source code 

Fails if the _fValue is greater (or equal) than the reference.

Parameters:
  • _fValue - any python object that can be compared ...
  • _strComment (python string or unicode string.) - a comment to make your assertion more understandable to the user

greaterThan(_fValue, _fReference=1.0, _strComment='Greater than')
Static Method

source code 

Fails if the _fValue is greater (or equal) than the reference.

Parameters:
  • _fValue - any python object that can be compared ...
  • _strComment (python string or unicode string.) - a comment to make your assertion more understandable to the user

arraySimilar(_npaValue, _npaRef, _strComment='Arrays are similar', _fAbsMaxDelta=None, _fRelMaxDelta=None, _fRfactor=None, _fScaledMaxDelta=None)
Static Method

source code 

Tests if two arrays are similar. Two arrays (vectors, matrices, tensors, ...) if the have : * same shape (always tested), * max(abs(Value - Ref)) < _fAbsMaxDelta if _fAbsMaxDelta is defined * max(abs(Value - Ref)/max(abs(Value),abs(Ref)) < _fRelMaxDelta if _fRelMaxDelta is defined * Sigma(abs(Value - Ref)/max(abs(Value),abs(Ref)) < _fRfactor1 if _fRfactor1 is defined

Parameters:
  • _npaRef (Numpy like array) - reference array
  • _npaValue - array to be compared with the reference
  • _strComment (python string or unicode string.) - a comment to make your assertion more understandable to the user
  • _fAbsMaxDelta (Float)
  • _fRfactor1 (Float)
  • _fRelMaxDelta (Float)