From: Jean-Philippe ARGAUD Date: Sat, 2 Feb 2019 20:16:36 +0000 (+0100) Subject: Fixup for tests details X-Git-Tag: V9_3_0.1-prealpha1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=251ce7462e2d06e5004b9015514cfefcb000c8ad;p=modules%2Fadao.git Fixup for tests details --- diff --git a/test/test6701/Doc_TUI_Exemple_01.py b/test/test6701/Doc_TUI_Exemple_01.py index f2bacb9..4846741 100644 --- a/test/test6701/Doc_TUI_Exemple_01.py +++ b/test/test6701/Doc_TUI_Exemple_01.py @@ -21,8 +21,6 @@ # 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""" @@ -40,6 +38,20 @@ 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('\nAUTODIAGNOSTIC\n') diff --git a/test/test6702/Doc_TUI_Exemple_02.py b/test/test6702/Doc_TUI_Exemple_02.py index 0877647..e6af4ac 100644 --- a/test/test6702/Doc_TUI_Exemple_02.py +++ b/test/test6702/Doc_TUI_Exemple_02.py @@ -21,8 +21,6 @@ # 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""" @@ -65,6 +63,20 @@ def test2(): # 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') diff --git a/test/test6703/Doc_TUI_Exemple_03.py b/test/test6703/Doc_TUI_Exemple_03.py index 5e578da..8db3f8e 100644 --- a/test/test6703/Doc_TUI_Exemple_03.py +++ b/test/test6703/Doc_TUI_Exemple_03.py @@ -21,8 +21,6 @@ # 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 @@ -103,6 +101,20 @@ 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('\nAUTODIAGNOSTIC\n') diff --git a/test/test6704/Doc_TUI_Exemple_03_en_multifonction.py b/test/test6704/Doc_TUI_Exemple_03_en_multifonction.py index 18abfd3..7b9e5f3 100644 --- a/test/test6704/Doc_TUI_Exemple_03_en_multifonction.py +++ b/test/test6704/Doc_TUI_Exemple_03_en_multifonction.py @@ -21,8 +21,6 @@ # 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 @@ -110,6 +108,20 @@ 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('\nAUTODIAGNOSTIC\n') diff --git a/test/test6711/Doc_TUI_Exemple_01_Savings.py b/test/test6711/Doc_TUI_Exemple_01_Savings.py index d5402f9..b5ef7a7 100644 --- a/test/test6711/Doc_TUI_Exemple_01_Savings.py +++ b/test/test6711/Doc_TUI_Exemple_01_Savings.py @@ -22,7 +22,6 @@ "Verification d'un exemple de la documentation" import os, pprint -from utExtend import assertAlmostEqualArrays # ============================================================================== def test1(): @@ -81,6 +80,20 @@ 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') diff --git a/test/test6904/Definition_complete_de_cas_3DVAR.py b/test/test6904/Definition_complete_de_cas_3DVAR.py index 9785127..5b8e0a7 100644 --- a/test/test6904/Definition_complete_de_cas_3DVAR.py +++ b/test/test6904/Definition_complete_de_cas_3DVAR.py @@ -24,7 +24,6 @@ import sys import unittest import numpy -from utExtend import assertAlmostEqualArrays # ============================================================================== # @@ -141,6 +140,8 @@ class InTest(unittest.TestCase): 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) @@ -149,6 +150,20 @@ class InTest(unittest.TestCase): # 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==============")