Exemple #1
0
def toRealND(*args):
    """Try to convert the arguments to a RealND, returns the argument,
    if it is already a RealND."""
    if len(args) == 1 and isinstance(args[0], RealND):
        return args[0]
    else:
        return RealND(*args)
Exemple #2
0
def toRealNDFromVector(*args):
    """Try to convert the arguments to a RealND.

    This function will only convert to a RealND if x, y and z are
    specified."""
    arg0 = args[0]
    if isinstance(arg0, RealND):
        return arg0
    elif hasattr(arg0, '__iter__'):
        return RealND(*args)
    else:
        raise TypeError("Something wrong in toRealNDFromVector")