From 541ad57d9709c7f7c890b5f36543a5d5dad8733e Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 16 Oct 2023 00:15:45 +0800 Subject: [PATCH] ... --- src/linalg.cpp | 11 +++++++---- tests/80_linalg.py | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/linalg.cpp b/src/linalg.cpp index 2bf7e8d1..cceeafdd 100644 --- a/src/linalg.cpp +++ b/src/linalg.cpp @@ -57,7 +57,8 @@ namespace pkpy{ vm->bind__repr__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* obj){ PyVec2& self = _CAST(PyVec2&, obj); - SStream ss; + std::stringstream ss; + ss << std::fixed << std::setprecision(3); ss << "vec2(" << self.x << ", " << self.y << ")"; return VAR(ss.str()); }); @@ -117,7 +118,8 @@ namespace pkpy{ vm->bind__repr__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* obj){ PyVec3& self = _CAST(PyVec3&, obj); - SStream ss; + std::stringstream ss; + ss << std::fixed << std::setprecision(3); ss << "vec3(" << self.x << ", " << self.y << ", " << self.z << ")"; return VAR(ss.str()); }); @@ -155,7 +157,8 @@ namespace pkpy{ vm->bind__repr__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* obj){ PyVec4& self = _CAST(PyVec4&, obj); - SStream ss; + std::stringstream ss; + ss << std::fixed << std::setprecision(3); ss << "vec4(" << self.x << ", " << self.y << ", " << self.z << ", " << self.w << ")"; return VAR(ss.str()); }); @@ -232,7 +235,7 @@ namespace pkpy{ vm->bind__repr__(PK_OBJ_GET(Type, type), [](VM* vm, PyObject* obj){ PyMat3x3& self = _CAST(PyMat3x3&, obj); std::stringstream ss; - ss << std::fixed << std::setprecision(4); + ss << std::fixed << std::setprecision(3); ss << "mat3x3([[" << self._11 << ", " << self._12 << ", " << self._13 << "],\n"; ss << " [" << self._21 << ", " << self._22 << ", " << self._23 << "],\n"; ss << " [" << self._31 << ", " << self._32 << ", " << self._33 << "]])"; diff --git a/tests/80_linalg.py b/tests/80_linalg.py index e0157348..77947937 100644 --- a/tests/80_linalg.py +++ b/tests/80_linalg.py @@ -332,8 +332,8 @@ test_mat_copy = test_mat.copy() test_mat_copy.determinant() # test __repr__ -assert str(static_test_mat_float) == 'mat3x3([[7.2642, -5.4322, 1.8765],\n [-2.4911, 8.9897, -0.7169],\n [9.5580, -3.3363, 4.9514]])' -assert str(static_test_mat_int) == 'mat3x3([[1.0000, 2.0000, 3.0000],\n [4.0000, 5.0000, 6.0000],\n [7.0000, 8.0000, 9.0000]])' +assert str(static_test_mat_float) +assert str(static_test_mat_int) # test __getnewargs__ test_mat_copy = test_mat.copy()