From 2bc6d279996391a6705963686f1873d53bbb38f8 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Thu, 26 Oct 2023 11:04:05 +0200 Subject: [PATCH] fixe to_list() --- Matrix_test.py | 18 ++++++++++++++++++ docs/Matrix.md | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 Matrix_test.py diff --git a/Matrix_test.py b/Matrix_test.py new file mode 100644 index 0000000..7f44363 --- /dev/null +++ b/Matrix_test.py @@ -0,0 +1,18 @@ +from QElephant.Matrix import * +from pytest import * + +m = Matrix([[1, 2, 3], [4, 5, 6]]) + +assert m._Matrix__m == [[1, 2, 3], [4, 5, 6]] +assert m._Matrix__size == (2, 3) +m_ = m * Matrix([[1, 1], [0, 0]]) +assert m_._Matrix__m == [ + [1, 1, 2, 2, 3, 3], + [0, 0, 0, 0, 0, 0], + [4, 4, 5, 5, 6, 6], + [0, 0, 0, 0, 0, 0], + ] +m_ = m._Matrix__apply([1, 2, 3]) +assert m_ == [14, 32] +assert str(m) == "[[1, 2, 3], [4, 5, 6]]" +assert m.to_list() == [[1, 2, 3], [4, 5, 6]] \ No newline at end of file diff --git a/docs/Matrix.md b/docs/Matrix.md index 10f4c66..3a762be 100644 --- a/docs/Matrix.md +++ b/docs/Matrix.md @@ -32,13 +32,13 @@ Matrix(l: list[list[complexe]]) returns a string representation of the matrix - -### Staticmethods - -- ```to_list(matrix: Matrix) -> list[list[complex]]``` +- ```to_list() -> list[list[complex]]``` returns the a list representing the given Matrix. + +### Staticmethods + - ```I() -> Matrix``` returns the matrix