fixe to_list()

This commit is contained in:
Didictateur 2023-10-26 11:04:05 +02:00
parent 77ee550046
commit 2bc6d27999
2 changed files with 22 additions and 4 deletions

18
Matrix_test.py Normal file
View file

@ -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]]

View file

@ -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