Ticket #15200: trac15200.patch

File trac15200.patch, 1.2 KB (added by eviatarbach, 6 years ago)
  • sage/symbolic/function.pyx

    # HG changeset patch
    # User Eviatar Bach <eviatarbach@gmail.com>
    # Date 1379295973 25200
    #      Sun Sep 15 18:46:13 2013 -0700
    # Node ID 5c56acc5be1b6d02ee3ab2f0cacfefe65742cafb
    # Parent  3ffc7319f6fbbfc6dfb9d6e5b6d4513b7c2bc9af
    [mq]: evalf_default
    
    diff --git a/sage/symbolic/function.pyx b/sage/symbolic/function.pyx
    a b  
    900900            # we should never end up here
    901901            raise ValueError, "cannot read pickle"
    902902
     903    def _evalf_(self, *args, **kwargs):
     904        algorithm = kwargs.get('algorithm', None)
     905        if algorithm:
     906            alg_method = getattr(self, '_evalf_{}_'.format(algorithm), None)
     907            if alg_method:
     908                return alg_method(*args, parent=kwargs['parent'])
     909            else:
     910                raise ValueError("algorithm '{}' not defined for this function".format(algorithm))
     911        else:
     912            def_method = getattr(self, '_evalf_default_', None)
     913            if def_method:
     914                return def_method(*args, parent=kwargs['parent'])
     915            else:
     916                raise AttributeError('numeric evaluation method not defined')
     917
    903918
    904919cdef class SymbolicFunction(Function):
    905920    """