Beispiel #1
0
                                               'vtkPiecewiseFunction').module()
        of_module.vtkInstance  = of
        
        cf_module = reg.get_descriptor_by_name(vtk_pkg_identifier, 
                                               'vtkColorTransferFunction').module()
        cf_module.vtkInstance  = cf
        
        self.setResult('vtkPicewiseFunction', of_module)
        self.setResult('vtkColorTransferFunction', cf_module)

string_conversion = staticmethod(lambda x: x.serialize())
conversion = staticmethod(lambda x: TransferFunction.parse(x))
validation = staticmethod(lambda x: isinstance(x, TransferFunction))
TransferFunctionConstant = new_constant('TransferFunction',
                                        conversion,
                                        default_tf,
                                        validation,
                                        TransferFunctionWidget)
TransferFunctionConstant.translate_to_string = string_conversion

##############################################################################

def initialize():
    init_constant(TransferFunctionConstant)
    
##############################################################################
class TestTransferFunction(unittest.TestCase):
    def test_serialization(self):
        tf = TransferFunction()
        tf._min_range = 0.1
        tf._max_range = 2.0
Beispiel #2
0
    elif is_str and (desired_type is None or desired_type == str):
        res = [str(elt) for elt in v_list]
        return robjects.StrVector(res)

    if desired_type is not None:
        raise TypeException("Cannot coerce vector to type '%s'" % desired_type)
    return robjects.RVector(v_list)


def vector_conv(v, desired_type=None):
    v_list = literal_eval(v)
    return create_vector(v_list, desired_type)


RVector = new_constant(
    "RVector", staticmethod(vector_conv), robjects.Vector([]), staticmethod(lambda x: isinstance(x, robjects.Vector))
)


def bool_vector_conv(v):
    return vector_conv(v, bool)


RBoolVector = new_constant(
    "RBoolVector",
    staticmethod(bool_vector_conv),
    robjects.BoolVector([]),
    staticmethod(lambda x: isinstance(x, robjects.Vector)),
    base_class=RVector,
)
Beispiel #3
0
        res = [float(elt) for elt in v_list]
        return robjects.FloatVector(res)
    elif is_str and (desired_type is None or desired_type == str):
        res = [str(elt) for elt in v_list]
        return robjects.StrVector(res)
    
    if desired_type is not None:
        raise TypeException("Cannot coerce vector to type '%s'" % desired_type)
    return robjects.RVector(v_list)

def vector_conv(v, desired_type=None):
    v_list = eval(v)
    return create_vector(v_list, desired_type)

RVector = new_constant('RVector', staticmethod(vector_conv),
                       robjects.Vector([]),
                       staticmethod(lambda x: isinstance(x, robjects.Vector)))

def bool_vector_conv(v):
    return vector_conv(v, bool)

RBoolVector = new_constant('RBoolVector' , staticmethod(bool_vector_conv), 
                            robjects.BoolVector([]),
                            staticmethod(lambda x: isinstance(x, robjects.Vector)),
                            base_class=RVector)
                       
def int_vector_conv(v):
    return vector_conv(v, int)

RIntVector = new_constant('RIntVector' , staticmethod(int_vector_conv), 
                            robjects.IntVector([]),
Beispiel #4
0
    elif is_str and (desired_type is None or desired_type == str):
        res = [str(elt) for elt in v_list]
        return robjects.StrVector(res)

    if desired_type is not None:
        raise TypeException("Cannot coerce vector to type '%s'" % desired_type)
    return robjects.RVector(v_list)


def vector_conv(v, desired_type=None):
    v_list = literal_eval(v)
    return create_vector(v_list, desired_type)


RVector = new_constant('RVector', staticmethod(vector_conv),
                       robjects.Vector([]),
                       staticmethod(lambda x: isinstance(x, robjects.Vector)))


def bool_vector_conv(v):
    return vector_conv(v, bool)


RBoolVector = new_constant(
    'RBoolVector',
    staticmethod(bool_vector_conv),
    robjects.BoolVector([]),
    staticmethod(lambda x: isinstance(x, robjects.Vector)),
    base_class=RVector)