コード例 #1
0
    def test_imresize3(self):
        im = np.random.random((15,30))
        im2 = pilutil.imresize(im, (30,60), interp='nearest')
        assert_equal(im2.shape, (30,60))

    def test_bytescale(self):
        x = np.array([0,1,2],np.uint8)
        y = np.array([0,1,2])
        assert_equal(pilutil.bytescale(x),x)
        assert_equal(pilutil.bytescale(y),[0,127,255])

def tst_fromimage(filename, irange):
    img = pilutil.fromimage(PIL.Image.open(filename))
    imin,imax = irange
    assert_(img.min() >= imin)
    assert_(img.max() <= imax)

@_pilskip
def test_fromimage():
    ''' Test generator for parametric tests '''
    data = {'icon.png':(0,255),
            'icon_mono.png':(0,2),
            'icon_mono_flat.png':(0,1)}
    for fn, irange in data.iteritems():
        yield tst_fromimage, os.path.join(datapath,'data',fn), irange

decorate_methods(TestPILUtil, _pilskip)

if __name__ == "__main__":
    run_module_suite()
コード例 #2
0
            assert_array_almost_equal(P*R*A*Q,L*U)

    def setUp(self):
        random.seed(0)  # make tests repeatable
        self.real_matrices = []
        self.real_matrices.append(spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]],
                                          [0, 1], 5, 5))
        self.real_matrices.append(spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]],
                                          [0, 1], 4, 5))
        self.real_matrices.append(spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]],
                                          [0, 2], 5, 5))
        self.real_matrices.append(rand(3,3))
        self.real_matrices.append(rand(5,4))
        self.real_matrices.append(rand(4,5))

        self.real_matrices = [csc_matrix(x).astype('d') for x
                in self.real_matrices]
        self.complex_matrices = [x.astype(np.complex128)
                                 for x in self.real_matrices]

        _DeprecationAccept.setUp(self)

# Skip methods if umfpack not present
for cls in [TestSolvers, TestFactorization]:
    decorate_methods(cls, _umfpack_skip)


if __name__ == "__main__":
    run_module_suite()
コード例 #3
0

@setastest(False)
def test_false():
   pass

@setastest(True)
def test_true():
   pass

@skipif(True)
def test_skip():
   pass

@knownfailureif(True)
def test_alwaysfail():
     pass


class TestClass():
   def test_true2(self):
      pass


class TestClass2():
   def test_false2(self):
      pass


decorate_methods(TestClass2, setastest(False), 'test_false2')
コード例 #4
0
ファイル: test_umfpack.py プロジェクト: lpp1985/lpp_Script
            Q = eye(A.shape[1])[:,Q]

            assert_array_almost_equal(P*R*A*Q,L*U)


    def setUp(self):
        random.seed(0) #make tests repeatable
        self.real_matrices = []
        self.real_matrices.append(spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]],
                                          [0, 1], 5, 5) )
        self.real_matrices.append(spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]],
                                          [0, 1], 4, 5) )
        self.real_matrices.append(spdiags([[1, 2, 3, 4, 5], [6, 5, 8, 9, 10]],
                                          [0, 2], 5, 5) )
        self.real_matrices.append(rand(3,3))
        self.real_matrices.append(rand(5,4))
        self.real_matrices.append(rand(4,5))

        self.real_matrices = [csc_matrix(x).astype('d') for x \
                in self.real_matrices]
        self.complex_matrices = [x.astype(np.complex128)
                                 for x in self.real_matrices]

# Skip methods if umfpack not present
for cls in [TestSolvers, TestFactorization]:
    decorate_methods(cls, _umfpack_skip)

if __name__ == "__main__":
    import nose
    nose.run(argv=['', __file__])