From 12b55e4d50015cafebe0b771479e9960489b7d55 Mon Sep 17 00:00:00 2001 From: zhs628 <2067144018@qq.com> Date: Tue, 18 Jul 2023 02:31:21 +0800 Subject: [PATCH 1/3] Create build.ps1 --- build.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 00000000..268a89ce --- /dev/null +++ b/build.ps1 @@ -0,0 +1,9 @@ +mkdir -p output/windows/x86_64 +mkdir build +cd build +cmake .. +cmake --build . --config Release +cp Release/main.exe ../output/windows/x86_64 +cp Release/pocketpy.dll ../output/windows/x86_64 +cp Release/main.exe ../ +cp Release/pocketpy.dll ../ \ No newline at end of file From edbbde55c9f1500222cb01345580f45f4eddfbcd Mon Sep 17 00:00:00 2001 From: zhs628 <2067144018@qq.com> Date: Tue, 18 Jul 2023 18:39:03 +0800 Subject: [PATCH 2/3] update build.ps1 --- build.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.ps1 b/build.ps1 index 268a89ce..5c4ea9ad 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,4 +1,10 @@ mkdir -p output/windows/x86_64 +cd dylib +xmake f -p windows -a x64 +xmake +cp build/windows/x64/release/test.dll ../output/windows/x86_64 +cd .. +mkdir -p output/windows/x86_64 mkdir build cd build cmake .. From 6e5a7312c615bfb58c56d66c5199fbfbd1e00169 Mon Sep 17 00:00:00 2001 From: zhs628 <2067144018@qq.com> Date: Sat, 29 Jul 2023 16:48:51 +0800 Subject: [PATCH 3/3] Update 80_linalg.py --- tests/80_linalg.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/80_linalg.py b/tests/80_linalg.py index 95baf206..987d0357 100644 --- a/tests/80_linalg.py +++ b/tests/80_linalg.py @@ -1,4 +1,4 @@ -from linalg import mat3x3, vec2 +from linalg import mat3x3, vec2, vec3 import random import sys @@ -45,6 +45,29 @@ test_mat = mat3x3([[random.uniform(min_num, max_num) for _ in range(3)] for _ in # [7, 8, 9]] # ) +# test incorrect number of parameters is passed +for i in range(20): + + if i in [0, 9]: + continue + + try: + test_mat_copy = mat3x3(*tuple([e+0.1 for e in range(i)])) + + # 既然参数数量不是合法的0个或9个,并且这里也没有触发TypeError,那么引发测试失败 + print(f'When there are {i} arguments, no TypeError is triggered') + exit(1) + + except TypeError: + pass + +# test 9 floating parameters is passed +test_mat_copy = test_mat.copy() +element_name_list = [e for e in dir(test_mat_copy) if e[:2] != '__' and e[0] == '_'] +element_value_list = [getattr(test_mat, attr) for attr in element_name_list] +assert mat3x3(*tuple(element_value_list)) == test_mat + + # test copy test_mat_copy = test_mat.copy() assert test_mat is not test_mat_copy @@ -127,4 +150,9 @@ assert result_mat == correct_result_mat test_mat_copy = test_mat.copy() for i in range(3): for j in range(3): - test_mat_copy[i, j] = test_mat[j, i] \ No newline at end of file + test_mat_copy[i, j] = test_mat[j, i] + +# test __repr__ +test_mat_copy = test_mat.copy() +print(test_mat_copy[0,0]) +assert test_mat_copy.__repr__() == f'mat3x3([[{test_mat_copy[0,0].round(4)}, {test_mat_copy[1,0].round(4)}, {test_mat_copy[2,0].round(4)}],\n [{test_mat_copy[0,1].round(4)}, {test_mat_copy[1,1].round(4)}, {test_mat_copy[2,1].round(4)}],\n [{test_mat_copy[0,2].round(4)}, {test_mat_copy[1,2].round(4)}, {test_mat_copy[2,2].round(4)}]])'