/
pyoadfe
/
hw2-ccd
Обзор
Документация
Войти
/
pyoadfe
/
hw2-ccd
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
master
test.py
32 строки
1 KB
Matwey V. Kornilov
Initial commit
10 фев 2022, 11:14
10 фев 2022, 11:14
71e366c
Код
Авторство
О чём код?
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)