Exemplo n.º 1
0
 def __init__(self, data=None, data_sorting='none', **kw):
     "See set_data() for description."
     self._data = array([])
     HasStrictTraits.__init__(self, **kw)
     if data is not None:
         self.set_data(data, data_sorting)
     return
Exemplo n.º 2
0
    def __init__(self, shtypestring):

        shtype = eval("surfShape."+shtypestring) # eval = evil due to unauthorized code execution

        self.__class__.add_class_trait('_sh', Instance(shtype, shtype())) # create class instance with standard constructor

        HasStrictTraits.__init__(self)
        for trait in (name for name in dir(self._sh) if not name.startswith('__') \
                      and not name == 'listOfOptimizableVariables' \
                      and not callable(getattr(self._sh, name))): # remove listOfOptimizableVariables
            attrfromclass = getattr(self._sh, trait) # get attribute from class

            if isinstance(attrfromclass, float):
                self.__class__.add_class_trait( # add trait generated from class dict
                    trait,
                    Property(
                             lambda: getattr(self._sh, trait), # getter function
                             lambda attr: setattr(self._sh, trait, attr) # setter function
                    )
                )


            if isinstance(attrfromclass, optimize.OptimizableVariable): # if attribute is optimizableVar, add it

                self.__class__.add_class_trait( # add trait generated from class dict
                    trait,
                    Property(
                             lambda: attrfromclass.val, # getter function
                             lambda attr: setattr(attrfromclass, 'val', attr) # setter function
                    )
                )
Exemplo n.º 3
0
    def __init__(self, mattypestring):

        mattype = eval("material."+mattypestring)

        self.__class__.add_class_trait('_m', Instance(mattype, mattype())) # create class instance with standard constructor

        HasStrictTraits.__init__(self)
        for trait in (name for name in dir(self._m) if not name.startswith('__') \
                      and not name == 'listOfOptimizableVariables' \
                      and not callable(getattr(self._m, name))): # remove listOfOptimizableVariables
            attrfromclass = getattr(self._m, trait) # get attribute from class

            if isinstance(attrfromclass, optimize.OptimizableVariable): # if attribute is optimizableVar, add it

                self.__class__.add_class_trait( # add trait generated from class dict
                    trait,
                    Property(
                             lambda: attrfromclass.val, # getter function
                             lambda attr: setattr(attrfromclass, 'val', attr) # setter function
                    )
                )
Exemplo n.º 4
0
 def __init__(self):
     HasStrictTraits.__init__(self)
     self._assert_h5library()