Ejemplo n.º 1
0
    def test_inflate(self):
        st = SingleTransform([0, 0, 0, 0, 0, 0])
        st.inflate(reshape(matrix([1, 0, 0, 0, 0, 0], float), (-1, 1)))
        expected = numpy.matrix(
            [[1, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]], float)

        print ""
        print st.transform

        self.assertAlmostEqual(numpy.linalg.norm(st.transform - expected), 0.0,
                               6)
    def test_deflate(self):

        st = SingleTransform([0, 0, 0, 0, 1, 0])
        for i in range(5):
            print "next test_deflate"
            p = numpy.random.rand(6, 1)
            st.inflate(p)
            result = st.deflate()
            print result
            print p
            self.assertAlmostEqual(numpy.linalg.norm(p - result), 0.0, 6)
    def test_inflate(self):
        st = SingleTransform([0, 0, 0, 0, 0, 0])
        st.inflate( reshape( matrix([1, 0, 0, 0, 0, 0], float), (-1,1) ))
        expected = numpy.matrix( [[ 1, 0, 0, 1],
                                  [ 0, 1, 0, 0],
                                  [ 0, 0, 1, 0],
                                  [ 0, 0, 0, 1]], float )

        print ""
        print st.transform

        self.assertAlmostEqual(numpy.linalg.norm(st.transform-expected), 0.0, 6)
 def test_equality(self):
     st = SingleTransform()
     for i in range(5):
         print "------next-------"
         p = numpy.random.rand(6, 1)
         new = st.inflate(p, True)
         old = st.inflate_old(p)
         print new
         print old
         print "diff: "
         print old - new
         self.assertAlmostEqual(numpy.linalg.norm(old - new), 0.0, 6)
Ejemplo n.º 5
0
 def test_deflate(self):
     st = SingleTransform([0, 0, 0, 0, 0, 0])
     p = reshape(matrix([1, 0, 0, 0, 0, 0], float), (-1, 1))
     st.inflate(p)
     result = st.deflate()
     self.assertAlmostEqual(numpy.linalg.norm(p - result), 0.0, 6)
 def test_deflate(self):
     st = SingleTransform([0, 0, 0, 0, 0, 0])
     p = reshape( matrix([1, 0, 0, 0, 0, 0], float), (-1,1) )
     st.inflate(p)
     result = st.deflate()
     self.assertAlmostEqual(numpy.linalg.norm(p-result), 0.0, 6)