-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (28 loc) · 1.14 KB
/
test.py
File metadata and controls
32 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest
import lsp
import numpy as np
class LspTest(unittest.TestCase):
def test_lstsq_ne(self):
a = np.eye(4)
b = np.ones(a.shape[0])
x, cost, *_ = lsp.lstsq_ne(a, b)
np.testing.assert_allclose(x, np.ones(a.shape[1]), rtol=1e-6)
np.testing.assert_allclose(cost, np.asarray([0.0]), rtol=1e-6)
def test_lstsq_svd(self):
a = np.eye(4)
b = np.ones(a.shape[0])
x, cost, *_ = lsp.lstsq_svd(a, b)
np.testing.assert_allclose(x, np.ones(a.shape[1]), rtol=1e-6)
np.testing.assert_allclose(cost, np.asarray([0.0]), rtol=1e-6)
def test_lstsq_m_ne(self):
a = np.eye(4)
b = np.ones(a.shape[0])
x, cost, *_ = lsp.lstsq(a, b, method="ne")
np.testing.assert_allclose(x, np.ones(a.shape[1]), rtol=1e-6)
np.testing.assert_allclose(cost, np.asarray([0.0]), rtol=1e-6)
def test_lstsq_m_svd(self):
a = np.eye(4)
b = np.ones(a.shape[0])
x, cost, *_ = lsp.lstsq(a, b, method="svd")
np.testing.assert_allclose(x, np.ones(a.shape[1]), rtol=1e-6)
np.testing.assert_allclose(cost, np.asarray([0.0]), rtol=1e-6)