Exemple #1
0
def quiet_evaluate(expr, vars, evaluation, expect_list=False):
    """ Evaluates expr with given dynamic scoping values
    without producing arithmetic error messages. """
    expr = Expression('N', expr)
    quiet_expr = Expression('Quiet', expr, Expression(
        'List', Expression('MessageName', Symbol('Power'), String('infy'))))
    value = dynamic_scoping(quiet_expr.evaluate, vars, evaluation)
    if expect_list:
        if value.has_form('List', None):
            value = [chop(item).get_real_value() for item in value.leaves]
            if any(item is None for item in value):
                return None
            return value
        else:
            return None
    else:
        return chop(value).get_real_value()
Exemple #2
0
 def eval_f(x_value, y_value):
     value = stored.get((x_value, y_value), False)
     if value == False:
         value = dynamic_scoping(f.evaluate, {x: Real(x_value), y: Real(y_value)}, evaluation)
         value = chop(value).get_real_value()
         value = float(value)
         stored[(x_value, y_value)] = value
     return value
Exemple #3
0
 def eval_f(x_value, y_value):
     value = stored.get((x_value, y_value), False)
     if value == False:
         value = dynamic_scoping(f.evaluate, {
             x: Real(x_value),
             y: Real(y_value)
         }, evaluation)
         value = chop(value).get_real_value()
         value = float(value)
         stored[(x_value, y_value)] = value
     return value
Exemple #4
0
 def eval_f(f, x_value):
     value = dynamic_scoping(f.evaluate, {x: x_value}, evaluation)
     value = chop(value).get_real_value()
     return value
Exemple #5
0
 def eval_f(f, x_value):
     value = dynamic_scoping(f.evaluate, {x: x_value}, evaluation)
     value = chop(value).get_real_value()
     return value