diff --git a/case_study/assertion.py b/case_study/assertion.py index 63ae6dc..799ff55 100644 --- a/case_study/assertion.py +++ b/case_study/assertion.py @@ -96,7 +96,7 @@ def update_namespace(sym: dict): @staticmethod def vector(x: tuple | list): assert isinstance(x, (tuple, list)) and len(x) == 3, f"Vector of length 3 expected. Found {x}" - return x[0] * Assertion.N.i + x[1] * Assertion.N.j + x[2] * Assertion.N.k + return x[0] * Assertion.N.i + x[1] * Assertion.N.j + x[2] * Assertion.N.k # type: ignore def assert_single(self, subs: list[tuple]): """Perform assertion on a single data point. diff --git a/tests/data/BouncingBall0/results_base.js5 b/tests/data/BouncingBall0/results_base.js5 index c39ca48..980d1b7 100644 --- a/tests/data/BouncingBall0/results_base.js5 +++ b/tests/data/BouncingBall0/results_base.js5 @@ -1,10 +1,10 @@ { header : { case : 'base', - dateTime : '2024-11-04T09:28:08.129070', + dateTime : '2024-11-04T11:44:30.119146', cases : 'BouncingBall', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/BouncingBall0/BouncingBall.cases', - casesDate : '2024-11-04T09:04:34.407987', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/BouncingBall0/BouncingBall.cases', + casesDate : '2024-11-03T22:37:08.285872', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/BouncingBall0/results_gravity.js5 b/tests/data/BouncingBall0/results_gravity.js5 index a7773c6..8537749 100644 --- a/tests/data/BouncingBall0/results_gravity.js5 +++ b/tests/data/BouncingBall0/results_gravity.js5 @@ -1,10 +1,10 @@ { header : { case : 'gravity', - dateTime : '2024-11-04T09:28:16.053566', + dateTime : '2024-11-04T11:44:35.921661', cases : 'BouncingBall', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/BouncingBall0/BouncingBall.cases', - casesDate : '2024-11-04T09:04:34.407987', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/BouncingBall0/BouncingBall.cases', + casesDate : '2024-11-03T22:37:08.285872', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/BouncingBall0/results_restitution.js5 b/tests/data/BouncingBall0/results_restitution.js5 index b8f8807..25be84e 100644 --- a/tests/data/BouncingBall0/results_restitution.js5 +++ b/tests/data/BouncingBall0/results_restitution.js5 @@ -1,10 +1,10 @@ { header : { case : 'restitution', - dateTime : '2024-11-04T09:28:12.628607', + dateTime : '2024-11-04T11:44:33.311249', cases : 'BouncingBall', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/BouncingBall0/BouncingBall.cases', - casesDate : '2024-11-04T09:04:34.407987', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/BouncingBall0/BouncingBall.cases', + casesDate : '2024-11-03T22:37:08.285872', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/BouncingBall0/results_restitutionAndGravity.js5 b/tests/data/BouncingBall0/results_restitutionAndGravity.js5 index f485f3a..5e40124 100644 --- a/tests/data/BouncingBall0/results_restitutionAndGravity.js5 +++ b/tests/data/BouncingBall0/results_restitutionAndGravity.js5 @@ -1,10 +1,10 @@ { header : { case : 'restitutionAndGravity', - dateTime : '2024-11-04T09:28:19.217255', + dateTime : '2024-11-04T11:44:38.563853', cases : 'BouncingBall', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/BouncingBall0/BouncingBall.cases', - casesDate : '2024-11-04T09:04:34.407987', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/BouncingBall0/BouncingBall.cases', + casesDate : '2024-11-03T22:37:08.285872', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/BouncingBall3D/base.js5 b/tests/data/BouncingBall3D/base.js5 index 0ea2f0d..d3a6a1c 100644 --- a/tests/data/BouncingBall3D/base.js5 +++ b/tests/data/BouncingBall3D/base.js5 @@ -1,10 +1,10 @@ { header : { case : 'base', - dateTime : '2024-11-04T09:27:57.555042', + dateTime : '2024-11-04T11:44:08.031425', cases : 'BouncingBall3D', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/BouncingBall3D/BouncingBall3D.cases', - casesDate : '2024-11-04T09:04:34.413987', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/BouncingBall3D/BouncingBall3D.cases', + casesDate : '2024-11-03T21:49:56.360601', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/BouncingBall3D/gravity.js5 b/tests/data/BouncingBall3D/gravity.js5 index 0dac86a..aa8be1b 100644 --- a/tests/data/BouncingBall3D/gravity.js5 +++ b/tests/data/BouncingBall3D/gravity.js5 @@ -1,10 +1,10 @@ { header : { case : 'gravity', - dateTime : '2024-11-04T09:27:59.101789', + dateTime : '2024-11-04T11:44:09.197116', cases : 'BouncingBall3D', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/BouncingBall3D/BouncingBall3D.cases', - casesDate : '2024-11-04T09:04:34.413987', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/BouncingBall3D/BouncingBall3D.cases', + casesDate : '2024-11-03T21:49:56.360601', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/BouncingBall3D/restitution.js5 b/tests/data/BouncingBall3D/restitution.js5 index 640207f..76c368c 100644 --- a/tests/data/BouncingBall3D/restitution.js5 +++ b/tests/data/BouncingBall3D/restitution.js5 @@ -1,10 +1,10 @@ { header : { case : 'restitution', - dateTime : '2024-11-04T09:27:58.439740', + dateTime : '2024-11-04T11:44:08.628354', cases : 'BouncingBall3D', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/BouncingBall3D/BouncingBall3D.cases', - casesDate : '2024-11-04T09:04:34.413987', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/BouncingBall3D/BouncingBall3D.cases', + casesDate : '2024-11-03T21:49:56.360601', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/BouncingBall3D/restitutionAndGravity.js5 b/tests/data/BouncingBall3D/restitutionAndGravity.js5 index bd8ac07..f95be8a 100644 --- a/tests/data/BouncingBall3D/restitutionAndGravity.js5 +++ b/tests/data/BouncingBall3D/restitutionAndGravity.js5 @@ -1,10 +1,10 @@ { header : { case : 'restitutionAndGravity', - dateTime : '2024-11-04T09:27:59.673486', + dateTime : '2024-11-04T11:44:09.695343', cases : 'BouncingBall3D', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/BouncingBall3D/BouncingBall3D.cases', - casesDate : '2024-11-04T09:04:34.413987', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/BouncingBall3D/BouncingBall3D.cases', + casesDate : '2024-11-03T21:49:56.360601', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/MobileCrane/results_base.js5 b/tests/data/MobileCrane/results_base.js5 index 14b8bbb..0fd70c3 100644 --- a/tests/data/MobileCrane/results_base.js5 +++ b/tests/data/MobileCrane/results_base.js5 @@ -1,10 +1,10 @@ { header : { case : 'base', - dateTime : '2024-11-04T09:28:27.872834', + dateTime : '2024-11-04T11:44:45.704941', cases : 'MobileCrane', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/MobileCrane/MobileCrane.cases', - casesDate : '2024-11-04T09:04:34.519986', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/MobileCrane/MobileCrane.cases', + casesDate : '2024-11-03T07:06:17.942318', timeUnit : 'second', timeFactor : 1000000000.0}, diff --git a/tests/data/MobileCrane/results_static.js5 b/tests/data/MobileCrane/results_static.js5 index 459dba1..4ce983c 100644 --- a/tests/data/MobileCrane/results_static.js5 +++ b/tests/data/MobileCrane/results_static.js5 @@ -1,10 +1,10 @@ { header : { case : 'static', - dateTime : '2024-11-04T09:28:28.863301', + dateTime : '2024-11-04T11:44:46.599591', cases : 'MobileCrane', - file : 'C:/Users/JORMEN/Documents/SeaCo/case_study/tests/data/MobileCrane/MobileCrane.cases', - casesDate : '2024-11-04T09:04:34.519986', + file : 'C:/Users/eis/Documents/Projects/Simulation_Model_Assurance/case_study/tests/data/MobileCrane/MobileCrane.cases', + casesDate : '2024-11-03T07:06:17.942318', timeUnit : 'second', timeFactor : 1000000000.0}, @@ -40,7 +40,7 @@ header : { x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.6146192678641134,0.0016706887455432758,4.191560790727376]}}, + x_load : [3.6146192678641125,0.001670688745543276,4.191560790727377]}}, 0.3 : { mobileCrane : { @@ -50,37 +50,37 @@ header : { x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.6098303267689977,0.0016725131777828876,4.189097289389069]}}, + x_load : [3.6098303267689964,0.0016725131777828855,4.189097289389067]}}, 0.4 : { mobileCrane : { - T : [-79102.14146566678,-84513.17367630609,494.14998034099153], + T : [-79102.14146566749,-84513.17367630739,494.14998034116917], x_pedestal : [0.0,0.0,3.0], x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.6050235454165396,0.0016743444065856676,4.186628891795709]}}, + x_load : [3.6050235454165374,0.0016743444065856628,4.186628891795709]}}, 0.5 : { mobileCrane : { - T : [-79092.99117590865,-81131.3725644038,484.925063439427], + T : [-79092.99117590723,-81131.37256440127,484.92506343907155], x_pedestal : [0.0,0.0,3.0], x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.6002104179888765,0.0016761780530386073,4.184161528165493]}}, + x_load : [3.6002104179888765,0.0016761780530385995,4.184161528165493]}}, 0.6 : { mobileCrane : { - T : [-79084.0743735005,-77759.14002690287,475.8363028297221], + T : [-79084.07437350121,-77759.1400269041,475.8363028298998], x_pedestal : [0.0,0.0,3.0], x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.5953966336481056,0.0016780119497542727,4.181698119653884]}}, + x_load : [3.5953966336481056,0.0016780119497542634,4.181698119653884]}}, 0.7 : { mobileCrane : { @@ -90,34 +90,34 @@ header : { x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.5905850090110265,0.0016798450236924227,4.179240100981307]}}, + x_load : [3.590585009011029,0.0016798450236924119,4.179240100981308]}}, 0.8 : { mobileCrane : { - T : [-79067.06582688275,-71044.28346353743,458.3500633802192], + T : [-79067.06582688275,-71044.28346353714,458.3500633801303], x_pedestal : [0.0,0.0,3.0], x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.5857769392348664,0.0016816767433431154,4.176788172608904]}}, + x_load : [3.585776939234872,0.0016816767433431034,4.176788172608907]}}, 0.9 : { mobileCrane : { - T : [-79058.9708401786,-67701.668534116,449.9665547836707], + T : [-79058.9708401786,-67701.66853411475,449.96655478331536], x_pedestal : [0.0,0.0,3.0], x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.580973116066061,0.0016835068451732465,4.174342672302927]}}, + x_load : [3.580973116066073,0.0016835068451732328,4.174342672302934]}}, 1.0 : { mobileCrane : { - T : [-79051.13567116468,-64368.86008482016,441.8103059741506], + T : [-79051.13567116397,-64368.86008482007,441.81030597432846], x_pedestal : [0.0,0.0,3.0], x_boom : [0.10961760610884069,0.003005981434384228,10.999248398725133], - x_load : [3.5761738831569434,0.0016853351982623515,4.171903758680079]}}} + x_load : [3.5761738831569576,0.0016853351982623363,4.171903758680086]}}} diff --git a/tests/test_results.py b/tests/test_results.py index 05146be..debf8bf 100644 --- a/tests/test_results.py +++ b/tests/test_results.py @@ -5,10 +5,9 @@ from case_study.case import Cases, Results -@pytest.mark.skip(reason="File contains harcoded absolute path") def test_init(): # init through existing results file - file = Path.cwd().parent / "data" / "BouncingBall3D" / "test_results.js5" + file = Path(__file__).parent / "data" / "BouncingBall3D" / "test_results.js5" print("FILE", file) res = Results(file=file) assert res.res.jspath("$.header.file", Path, True).exists() @@ -34,12 +33,12 @@ def test_add(): assert res.res.jspath("$['0.0'].bb.g") == 9.81 -@pytest.mark.skip(reason="Plots cannot be tested in CI") -def test_plot_time_series(): +def test_plot_time_series( show): file = Path(__file__).parent / "data" / "BouncingBall3D" / "test_results.js5" assert file.exists(), f"File {file} not found" res = Results(file=file) - res.plot_time_series(("bb.x[2]", "bb.v[2]"), "Test plot") + if show: + res.plot_time_series(("bb.x[2]", "bb.v[2]"), "Test plot") def test_inspect(): @@ -57,7 +56,7 @@ def test_inspect(): if __name__ == "__main__": - retcode = pytest.main(["-rA", "-v", __file__]) + retcode = pytest.main(["-rA", "-v", __file__, "--show", "True"]) assert retcode == 0, f"Non-zero return code {retcode}" # import os # os.chdir(Path(__file__).parent.absolute() / "test_working_directory")