File: test_nnls.py

package info (click to toggle)
python-scipy 0.7.2%2Bdfsg1-1%2Bdeb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 28,572 kB
  • ctags: 36,183
  • sloc: cpp: 216,880; fortran: 76,016; python: 71,833; ansic: 62,118; makefile: 243; sh: 17
file content (24 lines) | stat: -rw-r--r-- 470 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
""" Unit tests for nonnegative least squares
Author: Uwe Schmitt
Sep 2008
"""

from numpy.testing import *

from scipy.optimize import nnls
from numpy import arange, dot
from numpy.linalg import norm


class TestNNLS(TestCase):

    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

if __name__ == "__main__":
    run_module_suite()