0.12.0a1 add Matrix()
This commit is contained in:
parent
eca16d781f
commit
d123b9c196
4 changed files with 173 additions and 1 deletions
47
tests/test_mat.py
Normal file
47
tests/test_mat.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
|
||||
import unittest
|
||||
|
||||
from suou.mat import Matrix
|
||||
|
||||
|
||||
class TestMat(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.m_a = Matrix([
|
||||
[2, 2],
|
||||
[1, 3]
|
||||
])
|
||||
self.m_b = Matrix([
|
||||
[1], [-4]
|
||||
])
|
||||
def tearDown(self) -> None:
|
||||
...
|
||||
def test_transpose(self):
|
||||
self.assertEqual(
|
||||
self.m_a.T,
|
||||
Matrix([
|
||||
[2, 1],
|
||||
[2, 3]
|
||||
])
|
||||
)
|
||||
self.assertEqual(
|
||||
self.m_b.T,
|
||||
Matrix([[1, -4]])
|
||||
)
|
||||
def test_mul(self):
|
||||
self.assertEqual(
|
||||
self.m_b.T @ self.m_a,
|
||||
Matrix([
|
||||
[-2, -10]
|
||||
])
|
||||
)
|
||||
self.assertEqual(
|
||||
self.m_a @ self.m_b,
|
||||
Matrix([
|
||||
[-6], [-11]
|
||||
])
|
||||
)
|
||||
def test_shape(self):
|
||||
self.assertEqual(self.m_a.shape(), (2, 2))
|
||||
self.assertEqual(self.m_b.shape(), (2, 1))
|
||||
self.assertEqual(self.m_b.T.shape(), (1, 2))
|
||||
Loading…
Add table
Add a link
Reference in a new issue