Fixed database typo and removed unnecessary class identifier.
This commit is contained in:
parent
00ad49a143
commit
45fb349a7d
5098 changed files with 952558 additions and 85 deletions
34
venv/Lib/site-packages/scipy/optimize/tests/test_nnls.py
Normal file
34
venv/Lib/site-packages/scipy/optimize/tests/test_nnls.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
""" Unit tests for nonnegative least squares
|
||||
Author: Uwe Schmitt
|
||||
Sep 2008
|
||||
"""
|
||||
import numpy as np
|
||||
|
||||
from numpy.testing import assert_
|
||||
from pytest import raises as assert_raises
|
||||
|
||||
from scipy.optimize import nnls
|
||||
from numpy import arange, dot
|
||||
from numpy.linalg import norm
|
||||
|
||||
|
||||
class TestNNLS(object):
|
||||
|
||||
def test_nnls(self):
|
||||
a = arange(25.0).reshape(-1,5)
|
||||
x = arange(5.0)
|
||||
y = dot(a,x)
|
||||
x, res = nnls(a,y)
|
||||
assert_(res < 1e-7)
|
||||
assert_(norm(dot(a,x)-y) < 1e-7)
|
||||
|
||||
def test_maxiter(self):
|
||||
# test that maxiter argument does stop iterations
|
||||
# NB: did not manage to find a test case where the default value
|
||||
# of maxiter is not sufficient, so use a too-small value
|
||||
rndm = np.random.RandomState(1234)
|
||||
a = rndm.uniform(size=(100, 100))
|
||||
b = rndm.uniform(size=100)
|
||||
with assert_raises(RuntimeError):
|
||||
nnls(a, b, maxiter=1)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue