Example #1
0
    def test_ContextAttributes(self):
        myContext = gem.initialize()

        gem.setAttribute(myContext, "CONTEXT", 0, "s_attr", "context attribute")
        gem.setAttribute(myContext, "CONTEXT", 0, "i_attrs", (1111111, 2222222, 3333333, 4444444))
        gem.setAttribute(myContext, "CONTEXT", 0, "r_attrs", (0.1234567890123456, 0.2345678901234567))

        aindex, values = gem.retAttribute(myContext, "CONTEXT", 0, "s_attr")
        self.assertEqual(aindex, 1)
        self.assertEqual(values, "context attribute")

        aindex, values = gem.retAttribute(myContext, "CONTEXT", 0, "i_attrs")
        self.assertEqual(aindex, 2)
        self.assertEqual(values[0], 1111111)
        self.assertEqual(values[1], 2222222)
        self.assertEqual(values[2], 3333333)
        self.assertEqual(values[3], 4444444)

        aindex, values = gem.retAttribute(myContext, "CONTEXT", 0, "r_attrs")
        self.assertEqual(aindex, 3)
        self.assertEqual(values[0], 0.1234567890123456)
        self.assertEqual(values[1], 0.2345678901234567)

        gem.terminate(myContext)
Example #2
0
import numpy
from pygem_quartz import gem
help(gem)

# allow printing of only parts of ndarrays
numpy.set_printoptions(threshold=100)

# initialize GEM
myContext = gem.initialize()                      ;print "myContext      ->", myContext

gem.setAttribute(myContext, "CONTEXT", 0, "s_attr", "context attribute")
gem.setAttribute(myContext, "CONTEXT", 0, "i_attrs", (1111111, 2222222, 3333333, 4444444))
gem.setAttribute(myContext, "CONTEXT", 0, "r_attrs", (0.1234567890123456, 0.2345678901234567))

dum    = 0                                        ;print "s_attr(myContext)"
foo    = gem.retAttribute(myContext, "CONTEXT", 0, "s_attr")
aindex = foo[0]                                   ;print ".  aindex      ->", aindex
values = foo[1]                                   ;print ".  values      ->", values

ydum    = 0                                        ;print "i_attrs(myContext)"
foo    = gem.retAttribute(myContext, "CONTEXT", 0, "i_attrs")
aindex = foo[0]                                   ;print ".  aindex      ->", aindex
values = foo[1]                                   ;print ".  values      ->", values

dum    = 0                                        ;print "r_attrs(myContext)"
foo    = gem.retAttribute(myContext, "CONTEXT", 0, "r_attrs")
aindex = foo[0]                                   ;print ".  aindex      ->", aindex
values = foo[1]                                   ;print ".  values      ->", values

# load the sample OpenCSM Model
myModel = gem.loadModel(myContext,