コード例 #1
0
    def test_CompositionOperator_direct3(self):
        ig = self.ig
        data = self.data
        G = Gradient(domain_geometry=ig)
        

        Id1 = 2 * Identity(ig)
        Id2 = Identity(ig)
        
        d = CompositionOperator(G, Id2)

        out1 = G.direct(data)
        
        d_out = d.direct(data)

        d1 = Id2.direct(data)
        d2 = G.direct(d1)

        numpy.testing.assert_array_almost_equal(d2.get_item(0).as_array(),
                                                d_out.get_item(0).as_array())
        numpy.testing.assert_array_almost_equal(d2.get_item(1).as_array(),
                                                d_out.get_item(1).as_array())

        G2Id = G.compose(2*Id2)
        d2g = G2Id.direct(data)

        numpy.testing.assert_array_almost_equal(d2g.get_item(0).as_array(),
                                                2 * d_out.get_item(0).as_array())
        numpy.testing.assert_array_almost_equal(d2g.get_item(1).as_array(),
                                                2 * d_out.get_item(1).as_array())
コード例 #2
0
    def stest_NestedBlockDataContainer2(self):
        M, N = 2, 3
        ig = ImageGeometry(voxel_num_x=M, voxel_num_y=N)
        ag = ig
        u = ig.allocate(1)
        op1 = Gradient(ig)
        op2 = Identity(ig, ag)

        operator = BlockOperator(op1, op2, shape=(2, 1))

        d1 = op1.direct(u)
        d2 = op2.direct(u)

        d = operator.direct(u)

        dd = operator.domain_geometry()
        ww = operator.range_geometry()

        print(d.get_item(0).get_item(0).as_array())
        print(d.get_item(0).get_item(1).as_array())
        print(d.get_item(1).as_array())

        c1 = d + d

        c2 = 2 * d

        c3 = d / (d + 0.0001)

        c5 = d.get_item(0).power(2).sum()
コード例 #3
0
 def test_Identity(self):
     print ("test_Identity")
     ig = ImageGeometry(10,20,30)
     img = ig.allocate()
     # img.fill(numpy.ones((30,20,10)))
     self.assertTrue(img.shape == (30,20,10))
     #self.assertEqual(img.sum(), 2*float(10*20*30))
     self.assertEqual(img.sum(), 0.)
     Id = Identity(ig)
     y = Id.direct(img)
     numpy.testing.assert_array_equal(y.as_array(), img.as_array())