Ejemplo n.º 1
0
def getFunction(keyStr):
    if keyStr in sympy_action_implementation:
        noArgs = generic_cas_computations.getNoArgs(keyStr)
        if noArgs == 1:
            return lambda x: symbolic_object.symbolicObject(
                sympy_action_implementation[keyStr](x.getComputableObject())
            )
        elif noArgs == 2:
            return lambda x, y: symbolic_object.symbolicObject(
                sympy_action_implementation[keyStr](x.getComputableObject(), y.getComputableObject())
            )
        else:
            error_reporter.reportProgramError(
                "sympy_actions.py:getFunction :- An unhandled number of arguments are required: " + noArgs
            )
    else:
        error_reporter.reportProgramError(
            "sympy_actions.py:getFunction :- Cannot find an entry with the given key: '" + keyStr + "'"
        )
Ejemplo n.º 2
0
def computeResult(keyStr, args):
    '''Calls the relevant function to perform the computation.

        @param keyStr - the key string identifying the computation (operation)
        @param args - the keys of the object on which to apply the computation'''
    noArgs = generic_cas_computations.getNoArgs(keyStr)

    if len(args) > 2:
        error_reporter.reportProgramError("sympy_act.py:compute :- This function does not yet handle arguments of length greater than 2. noArgs = "+noArgs+", arge.length = "+len(args))
        return
    elif len(args) != noArgs:
        error_reporter.reportProgramError("sympy_act.py:compute :- Number of arguments given does not match expected number of arguments. noArgs = "+noArgs+", len(args) = "+len(args))
        return
    
    try:
        if noArgs == 1:
            return generic_cas_computations.getFunction(keyStr)(args[0]) #sympy_computation_list.getFunction(keyStr)(args[0])
        if noArgs == 2:
            return generic_cas_computations.getFunction(keyStr)(args[0], args[1]) #sympy_computation_list.getFunction(keyStr)(args[0], args[1])
    except NotImplementedError:
        return []