def testStoreInContext( self ) : f = GafferImage.Format( imath.Box2i( imath.V2i( 0 ), imath.V2i( 200, 100 ) ), 0.5 ) d = GafferImage.FormatData( f ) c = Gaffer.Context() c["f"] = d self.assertEqual( c["f"], d )
def testAutoConstructFromFormat( self ) : f = GafferImage.Format( imath.Box2i( imath.V2i( 0 ), imath.V2i( 200, 100 ) ), 0.5 ) d = IECore.CompoundData() d["f"] = f self.assertEqual( d["f"], GafferImage.FormatData( f ) )
def test( self ) : f1 = GafferImage.Format( imath.Box2i( imath.V2i( 0 ), imath.V2i( 200, 100 ) ), 0.5 ) f2 = GafferImage.Format( imath.Box2i( imath.V2i( 0 ), imath.V2i( 200, 100 ) ), 1 ) fd1a = GafferImage.FormatData( f1 ) fd1b = GafferImage.FormatData( f1 ) fd2 = GafferImage.FormatData( f2 ) self.assertEqual( fd1a.value, f1 ) self.assertEqual( fd1b.value, f1 ) self.assertEqual( fd2.value, f2 ) self.assertEqual( fd1a, fd1b ) self.assertNotEqual( fd1a, fd2 ) self.assertEqual( fd1a.hash(), fd1b.hash() ) self.assertNotEqual( fd1a.hash(), fd2.hash() ) fd2c = fd2.copy() self.assertEqual( fd2c, fd2 ) self.assertEqual( fd2c.hash(), fd2.hash() )
def testSerialisation( self ) : f = GafferImage.Format( imath.Box2i( imath.V2i( 10, 20 ), imath.V2i( 200, 100 ) ), 0.5 ) fd = GafferImage.FormatData( f ) m = IECore.MemoryIndexedIO( IECore.CharVectorData(), [], IECore.IndexedIO.OpenMode.Write ) fd.save( m, "f" ) m2 = IECore.MemoryIndexedIO( m.buffer(), [], IECore.IndexedIO.OpenMode.Read ) fd2 = IECore.Object.load( m2, "f" ) self.assertEqual( fd2, fd ) self.assertEqual( fd2.value, f )