def test_shape( self ): 'test shape getters and setters' space = PSpace('adc', n1=10, n2=10 ) self.failUnlessEqual(space.shape, [10,10]) space = PSpace('adc', n1=10, n2=10 ,n3=1) self.failUnlessEqual(space.shape, [10,10]) self.failUnlessEqual( space.size, 100 ) self.failUnlessEqual( len(space), 100 ) space.shape = [20,20] self.failUnlessEqual( space.shape , [20,20] ) self.failUnlessEqual( space['n1'] , 20 ) self.failUnlessEqual( space['n2'] , 20 ) self.failIf( space.has_key('n3') ) space = PSpace('adc' ) self.failUnlessEqual( space.shape , () ) space = PSpace('adc' ,n1=0 ) self.failUnlessRaises(TypeError, getattr, space, 'shape') space = PSpace('adc' , n1=UnknownValue ) self.failUnlessEqual( space.shape , [UnknownValue] ) self.failUnlessEqual( space.size, None )
def testhas_key( self ): space = PSpace( 'adc' , data_type='complex' ) self.failUnless( space.has_key( 'data_type' ) ) self.failIf( space.has_key( 'does not have this key' ) )