From af5e99b7aff02344edd6f1e48d3fbd677f08db7a Mon Sep 17 00:00:00 2001 From: Pedro Bressan Date: Mon, 7 Oct 2024 22:50:31 +0200 Subject: [PATCH 1/3] BUG: Vector encoding breaks MonteCarlo export. --- rocketpy/mathutils/vector_matrix.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rocketpy/mathutils/vector_matrix.py b/rocketpy/mathutils/vector_matrix.py index 82b5475f1..60032793c 100644 --- a/rocketpy/mathutils/vector_matrix.py +++ b/rocketpy/mathutils/vector_matrix.py @@ -418,6 +418,10 @@ def k(): """Returns the k vector, [0, 0, 1].""" return Vector([0, 0, 1]) + def to_dict(self): + """Returns the vector as a JSON compatible element.""" + return list(self.components) + class Matrix: """Pure Python 3x3 Matrix class for simple matrix-matrix and matrix-vector From 97b7734071f8d531544ac2dbf43da306dc86bb5d Mon Sep 17 00:00:00 2001 From: Pedro Bressan Date: Mon, 7 Oct 2024 22:56:33 +0200 Subject: [PATCH 2/3] MNT: add changes to CHANGELOG. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf4da0a72..dfe3c4407 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ Attention: The newest changes should be on top --> ### Fixed -- +- BUG: Vector encoding breaks MonteCarlo export. [#704](https://github.com/RocketPy-Team/RocketPy/pull/704) ## [v1.6.0] - 2024-09-29 From 4be37e447c0bf8df671e29e6741e3f38ef9e5509 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Wed, 9 Oct 2024 01:45:42 -0300 Subject: [PATCH 3/3] ENH: make the Matrix class JSON serializable --- rocketpy/mathutils/vector_matrix.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rocketpy/mathutils/vector_matrix.py b/rocketpy/mathutils/vector_matrix.py index 60032793c..0da44935d 100644 --- a/rocketpy/mathutils/vector_matrix.py +++ b/rocketpy/mathutils/vector_matrix.py @@ -1002,6 +1002,10 @@ def __repr__(self): + f" [{self.zx}, {self.zy}, {self.zz}])" ) + def to_dict(self): + """Returns the matrix as a JSON compatible element.""" + return [list(row) for row in self.components] + @staticmethod def identity(): """Returns the 3x3 identity matrix."""