# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
"Verification d'un exemple de la documentation"
-from utExtend import assertAlmostEqualArrays
-
# ==============================================================================
def test1():
"""Test"""
#
return case.get("Analysis")[-1]
+# ==============================================================================
+def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
+ "Compare two vectors, like unittest.assertAlmostEqual"
+ import numpy
+ if msg is not None:
+ print(msg)
+ if delta is not None:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
+ raise AssertionError("%s != %s within %s places"%(first,second,delta))
+ else:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any():
+ raise AssertionError("%s != %s within %i places"%(first,second,places))
+ return max(abs(numpy.asarray(first) - numpy.asarray(second)))
+
# ==============================================================================
if __name__ == "__main__":
print('\nAUTODIAGNOSTIC\n')
# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
"Verification d'un exemple de la documentation"
-from utExtend import assertAlmostEqualArrays
-
# ==============================================================================
def test1():
"""Test"""
#
return case.get("Analysis")[-1]
+# ==============================================================================
+def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
+ "Compare two vectors, like unittest.assertAlmostEqual"
+ import numpy
+ if msg is not None:
+ print(msg)
+ if delta is not None:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
+ raise AssertionError("%s != %s within %s places"%(first,second,delta))
+ else:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any():
+ raise AssertionError("%s != %s within %i places"%(first,second,places))
+ return max(abs(numpy.asarray(first) - numpy.asarray(second)))
+
# ==============================================================================
if __name__ == "__main__":
print('\nAUTODIAGNOSTIC\n')
# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
"Verification d'un exemple de la documentation"
-from utExtend import assertAlmostEqualArrays
-
# ==============================================================================
#
# Construction artificielle d'un exemple de donnees utilisateur
#
return case.get("Analysis")[-1]
+# ==============================================================================
+def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
+ "Compare two vectors, like unittest.assertAlmostEqual"
+ import numpy
+ if msg is not None:
+ print(msg)
+ if delta is not None:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
+ raise AssertionError("%s != %s within %s places"%(first,second,delta))
+ else:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any():
+ raise AssertionError("%s != %s within %i places"%(first,second,places))
+ return max(abs(numpy.asarray(first) - numpy.asarray(second)))
+
# ==============================================================================
if __name__ == "__main__":
print('\nAUTODIAGNOSTIC\n')
# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
"Verification d'un exemple de la documentation"
-from utExtend import assertAlmostEqualArrays
-
# ==============================================================================
#
# Construction artificielle d'un exemple de donnees utilisateur
#
return case.get("Analysis")[-1]
+# ==============================================================================
+def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
+ "Compare two vectors, like unittest.assertAlmostEqual"
+ import numpy
+ if msg is not None:
+ print(msg)
+ if delta is not None:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
+ raise AssertionError("%s != %s within %s places"%(first,second,delta))
+ else:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any():
+ raise AssertionError("%s != %s within %i places"%(first,second,places))
+ return max(abs(numpy.asarray(first) - numpy.asarray(second)))
+
# ==============================================================================
if __name__ == "__main__":
print('\nAUTODIAGNOSTIC\n')
"Verification d'un exemple de la documentation"
import os, pprint
-from utExtend import assertAlmostEqualArrays
# ==============================================================================
def test1():
#
return case.get("Analysis")[-1]
+# ==============================================================================
+def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
+ "Compare two vectors, like unittest.assertAlmostEqual"
+ import numpy
+ if msg is not None:
+ print(msg)
+ if delta is not None:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
+ raise AssertionError("%s != %s within %s places"%(first,second,delta))
+ else:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any():
+ raise AssertionError("%s != %s within %i places"%(first,second,places))
+ return max(abs(numpy.asarray(first) - numpy.asarray(second)))
+
# ==============================================================================
if __name__ == "__main__":
print('\n AUTODIAGNOSTIC\n')
import sys
import unittest
import numpy
-from utExtend import assertAlmostEqualArrays
# ==============================================================================
#
print("Simulation at optimal state.....: %s"%(numpy.ravel(FX_at_optimum),))
print("")
#
+ # Fin du cas
+ # ----------
ecart = assertAlmostEqualArrays(Xoptimum, [ 2., 3., 4.])
#
print(" L'écart absolu maximal obtenu lors du test est de %.2e."%ecart)
#
return Xoptimum
+# ==============================================================================
+def assertAlmostEqualArrays(first, second, places=7, msg=None, delta=None):
+ "Compare two vectors, like unittest.assertAlmostEqual"
+ import numpy
+ if msg is not None:
+ print(msg)
+ if delta is not None:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > float(delta) ).any():
+ raise AssertionError("%s != %s within %s places"%(first,second,delta))
+ else:
+ if ( (numpy.asarray(first) - numpy.asarray(second)) > 10**(-int(places)) ).any():
+ raise AssertionError("%s != %s within %i places"%(first,second,places))
+ return max(abs(numpy.asarray(first) - numpy.asarray(second)))
+
# ==============================================================================
if __name__ == '__main__':
print("\nAUTODIAGNOSTIC\n==============")