Skip to content

Commit

Permalink
Further tests
Browse files Browse the repository at this point in the history
  • Loading branch information
teschlg committed Oct 30, 2024
1 parent 22c6eb2 commit 28cd95a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kryptools/la.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __getitem__(self, item):
if isinstance(item, int):
i, j = divmod(item, self.cols)
return self.matrix[i][j]
return self.__class__([self.matrix[k // self.cols][k % self.cols] for k in range(self.cols * self.rows)[item]])
return [self.matrix[k // self.cols][k % self.cols] for k in range(self.cols * self.rows)[item]]

def __setitem__(self, item, value):
if isinstance(item, tuple):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_la.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

def test_Matrix():
M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 12]])
assert len(M) == 3 * 3
assert M[0] == 1
assert M[:] == [1, 2, 3, 4, 5, 6, 7, 8, 12]
assert 2 * M - M == M
M.map(Fraction)
Mi = M.inv()
Expand Down

0 comments on commit 28cd95a

Please sign in to comment.