~jtaylor/ubuntu/precise/python-numpy/multiarch-fix-818867

« back to all changes in this revision

Viewing changes to numpy/lib/tests/test_function_base.py

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2010-10-07 10:19:13 UTC
  • mfrom: (7.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20101007101913-8b1kmt8ho4upcl9s
Tags: 1:1.4.1-5
* debian/patches/10_use_local_python.org_object.inv_sphinx.diff
  - fixed small typo in description
* debian/patches/changeset_r8364.diff
  - fix memory corruption (double free); thanks to Joseph Barillari for the
    report and to Michael Gilbert for pushing resolution; Closes: #581058

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import numpy.lib
5
5
from numpy.lib import *
6
6
from numpy.core import *
 
7
from numpy import matrix, asmatrix
7
8
 
8
9
class TestAny(TestCase):
9
10
    def test_basic(self):
133
134
        assert_equal(len(choices),3)
134
135
        assert_equal(len(conditions),3)
135
136
 
136
 
class TestLogspace(TestCase):
137
 
    def test_basic(self):
138
 
        y = logspace(0,6)
139
 
        assert(len(y)==50)
140
 
        y = logspace(0,6,num=100)
141
 
        assert(y[-1] == 10**6)
142
 
        y = logspace(0,6,endpoint=0)
143
 
        assert(y[-1] < 10**6)
144
 
        y = logspace(0,6,num=7)
145
 
        assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])
146
 
 
147
 
class TestLinspace(TestCase):
148
 
    def test_basic(self):
149
 
        y = linspace(0,10)
150
 
        assert(len(y)==50)
151
 
        y = linspace(2,10,num=100)
152
 
        assert(y[-1] == 10)
153
 
        y = linspace(2,10,endpoint=0)
154
 
        assert(y[-1] < 10)
155
 
        y,st = linspace(2,10,retstep=1)
156
 
        assert_almost_equal(st,8/49.0)
157
 
        assert_array_almost_equal(y,mgrid[2:10:50j],13)
158
 
 
159
 
    def test_corner(self):
160
 
        y = list(linspace(0,1,1))
161
 
        assert y == [0.0], y
162
 
        y = list(linspace(0,1,2.5))
163
 
        assert y == [0.0, 1.0]
164
 
 
165
 
    def test_type(self):
166
 
        t1 = linspace(0,1,0).dtype
167
 
        t2 = linspace(0,1,1).dtype
168
 
        t3 = linspace(0,1,2).dtype
169
 
        assert_equal(t1, t2)
170
 
        assert_equal(t2, t3)
171
 
 
172
137
class TestInsert(TestCase):
173
138
    def test_basic(self):
174
139
        a = [1,2,3]
754
719
                                   [ 0.59541557,  0.87964135,  0.70543747],
755
720
                                   [ 0.91084584,  0.84386844,  0.37068164]]))
756
721
 
 
722
    def test_nanmin_allnan_on_axis(self):
 
723
        assert_array_equal(isnan(nanmin([[nan]*2]*3, axis=1)),
 
724
                     [True, True, True])
 
725
 
757
726
 
758
727
class TestCorrCoef(TestCase):
759
728
    def test_simple(self):
803
772
 
804
773
class TestKaiser(TestCase):
805
774
    def test_simple(self):
806
 
        assert_almost_equal(kaiser(0,1.0), array([]))
807
 
        assert isnan(kaiser(1,1.0))
808
 
        assert_almost_equal(kaiser(2,1.0), array([ 0.78984831,  0.78984831]))
809
 
        assert_almost_equal(kaiser(5,1.0),
810
 
                            array([ 0.78984831,  0.94503323,  1.        ,
811
 
                                    0.94503323,  0.78984831]))
812
 
        assert_almost_equal(kaiser(5,1.56789),
813
 
                            array([ 0.58285404,  0.88409679,  1.        ,
814
 
                                    0.88409679,  0.58285404]))
 
775
        assert_almost_equal(kaiser(0, 1.0), array([]))
 
776
        assert isfinite(kaiser(1, 1.0))
 
777
        assert_almost_equal(kaiser(2, 1.0), array([ 0.78984831, 0.78984831]))
 
778
        assert_almost_equal(kaiser(5, 1.0),
 
779
                            array([ 0.78984831, 0.94503323, 1.        ,
 
780
                                    0.94503323, 0.78984831]))
 
781
        assert_almost_equal(kaiser(5, 1.56789),
 
782
                            array([ 0.58285404, 0.88409679, 1.        ,
 
783
                                    0.88409679, 0.58285404]))
815
784
 
816
785
    def test_int_beta(self):
817
786
        kaiser(3, 4)