Ticket #14270: trac_14270-raise_error_on_function-call.patch

File trac_14270-raise_error_on_function-call.patch, 14.0 KB (added by ppurka, 7 years ago)

Apply to devel/sage

  • doc/en/prep/Symbolics-and-Basic-Plotting.rst

    # HG changeset patch
    # User Punarbasu Purkayastha <ppurka@gmail.com>
    # Date 1363533380 -28800
    # Node ID 026cb54b9815ccf6af8bcd78116e2e6cd3b8a7a2
    # Parent  b25de44a7205ae135833540dbc6657abf3cc2be1
    remove function call syntax from symbolic expressions
    
    diff --git a/doc/en/prep/Symbolics-and-Basic-Plotting.rst b/doc/en/prep/Symbolics-and-Basic-Plotting.rst
    a b  
    120120    128.402541668774
    121121    128.402541668774
    122122
    123 This is why we receive a deprecation error message when we try to do
    124 :math:`FV` without explicitly mentioning the variables.
    125 
    126 ::
    127 
    128     sage: FV(5,.05)
    129     doctest:...: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
    130     See http://trac.sagemath.org/5930 for details.
    131     128.402541668774
    132 
    133 In this case, the outcome is the same, since :math:`rt=tr`!  Of course,
    134 in most expressions, one would not be so lucky, as the following example
    135 indicates.
    136 
    137 ::
    138 
    139     sage: y = var('y')
    140     sage: G = x*y^2
    141     sage: G(1,2); G(2,1)
    142     4
    143     2
    144 
    145123Also remember that when we don't use function notation, we'll need to
    146124define our variables.
    147125
  • sage/calculus/calculus.py

    diff --git a/sage/calculus/calculus.py b/sage/calculus/calculus.py
    a b  
    168168
    169169It was formerly the case that if there was no ambiguity of variable
    170170names, we didn't have to specify them; that still works for the moment,
    171 but the behavior is deprecated::
     171but the behavior is now raises a syntax error::
    172172
    173173    sage: f = sin(x)
    174174    sage: f(y)
    175     doctest:...: DeprecationWarning: Substitution using function-call
    176     syntax and unnamed arguments is deprecated and will be removed
    177     from a future release of Sage; you can use named arguments instead,
    178     like EXPR(x=..., y=...)
    179     See http://trac.sagemath.org/5930 for details.
    180     sin(y)
    181     sage: f(pi)
     175    Traceback (most recent call last):
     176    ...
     177    SyntaxError: Substitution using function-call syntax and unnamed
     178    arguments has been removed. You can use named arguments instead, like
     179    EXPR(x=..., y=...)
     180    sage: f(x=pi)
    182181    0
    183182
    184183However if there is ambiguity, we should explicitly state what
  • sage/calculus/functional.py

    diff --git a/sage/calculus/functional.py b/sage/calculus/functional.py
    a b  
    260260   
    261261    ::
    262262   
    263         sage: [float(h(i)) for i in range(5)] #random
     263        sage: [float(h(x=i)) for i in range(5)] #random
    264264       
    265265        [0.0,
    266266         -1.1102230246251565e-16,
  • sage/ext/fast_callable.pyx

    diff --git a/sage/ext/fast_callable.pyx b/sage/ext/fast_callable.pyx
    a b  
    409409                        vars = ['EXTRA_VAR0']
    410410                else:
    411411                    if _autocompute_vars_for_backward_compatibility_with_deprecated_fast_float_functionality:
    412                         from sage.misc.superseded import deprecation
    413                         deprecation(5413, "Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)")
     412                        raise SyntaxError("Substitution using function-call syntax "
     413                            "and unnamed arguments has been removed. You "
     414                            "can use named arguments instead, like "
     415                            "EXPR(x=..., y=...)")
    414416                    else:
    415417                        raise ValueError, "List of variables must be specified for symbolic expressions"
    416418            from sage.rings.all import is_PolynomialRing, is_MPolynomialRing
  • sage/matrix/matrix_symbolic_dense.pyx

    diff --git a/sage/matrix/matrix_symbolic_dense.pyx b/sage/matrix/matrix_symbolic_dense.pyx
    a b  
    660660            [sin(x) + cos(x)               0]
    661661            [              0 sin(x) + cos(x)]
    662662            sage: h(1)
    663             doctest:...: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
    664             See http://trac.sagemath.org/4513 for details.
    665             doctest:...: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
    666             See http://trac.sagemath.org/5930 for details.
    667             [sin(1) + cos(1)               0]
    668             [              0 sin(1) + cos(1)]
    669             sage: h(x)
    670             [sin(x) + cos(x)               0]
    671             [              0 sin(x) + cos(x)]
     663            Traceback (most recent call last):
     664            ...
     665            SyntaxError: Substitution using function-call syntax and
     666            unnamed arguments has been removed. You can use named arguments
     667            instead, like EXPR(x=..., y=...)
    672668
    673669            sage: f = M([0,x,y,z]); f
    674670            [0 x]
     
    678674            sage: f()
    679675            [0 x]
    680676            [y z]
    681             sage: f(1)
    682             [0 1]
    683             [y z]
    684             sage: f(1,2)
    685             [0 1]
    686             [2 z]
    687             sage: f(1,2,3)
    688             [0 1]
    689             [2 3]
    690677            sage: f(x=1)
    691678            [0 1]
    692679            [y z]
     
    704691            Traceback (most recent call last):
    705692            ...
    706693            ValueError: args and kwargs cannot both be specified
    707             sage: f(1,2,3,4)
    708             Traceback (most recent call last):
    709             ...
    710             ValueError: the number of arguments must be less than or equal to 3
    711694        """
    712695        if kwargs and args:
    713696            raise ValueError, "args and kwargs cannot both be specified"
     
    727710            #Handle the case where args are specified
    728711
    729712            if args:
    730                 from sage.misc.superseded import deprecation
    731                 deprecation(4513, "Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)")
     713                raise SyntaxError("Substitution using function-call syntax "
     714                            "and unnamed arguments has been removed. You "
     715                            "can use named arguments instead, like "
     716                            "EXPR(x=..., y=...)")
    732717            #Get all the variables
    733718            variables = list( self.arguments() )
    734719
    735720            if len(args) > self.number_of_arguments():
    736721                raise ValueError, "the number of arguments must be less than or equal to %s"%self.number_of_arguments()
    737            
     722
    738723            new_entries = []
    739724            for entry in self.list():
    740725                try:
  • sage/symbolic/expression.pyx

    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    40364036            3
    40374037            sage: (sin(x+y)).number_of_arguments()
    40384038            2
    4039        
     4039
    40404040        ::
    4041        
     4041
    40424042            sage: ( 2^(8/9) - 2^(1/9) )(x-1)
    40434043            Traceback (most recent call last):
    40444044            ...
    4045             ValueError: the number of arguments must be less than or equal to 0
     4045            SyntaxError: Substitution using function-call syntax and
     4046            unnamed arguments has been removed. You can use named arguments
     4047            instead, like EXPR(x=..., y=...)
    40464048        """
    40474049        return len(self.arguments())
    40484050
     
    40514053        Returns the number of arguments of this expression.
    40524054
    40534055        EXAMPLES::
    4054        
     4056
    40554057            sage: var('a,b,c,x,y')
    40564058            (a, b, c, x, y)
    40574059            sage: a.number_of_operands()
  • sage/symbolic/expression_conversions.py

    diff --git a/sage/symbolic/expression_conversions.py b/sage/symbolic/expression_conversions.py
    a b  
    10791079            sage: ff(1.0,2.0,3.0)
    10801080            4.1780638977...
    10811081
    1082         Using _fast_float_ without specifying the variable names is 
     1082        Using _fast_float_ without specifying the variable names is
    10831083        deprecated::
    1084        
     1084
    10851085            sage: f = x._fast_float_()
    1086             doctest:...: DeprecationWarning: Substitution using
    1087             function-call syntax and unnamed arguments is deprecated
    1088             and will be removed from a future release of Sage; you
    1089             can use named arguments instead, like EXPR(x=..., y=...)
    1090             See http://trac.sagemath.org/5930 for details.
    1091             sage: f(1.2)
    1092             1.2
     1086            Traceback (most recent call last):
     1087            ...
     1088            SyntaxError: Substitution using function-call syntax and
     1089            unnamed arguments has been removed. You can use named arguments
     1090            instead, like EXPR(x=..., y=...)
    10931091
    1094         Using _fast_float_ on a function which is the identity is 
    1095         now supported (see Trac 10246)::
    1096        
     1092        Using _fast_float_ on a function which is the identity is
     1093        now supported (see :trac:`10246`)::
     1094
    10971095            sage: f = symbolic_expression(x).function(x)
    10981096            sage: f._fast_float_(x)
    10991097            <sage.ext.fast_eval.FastDoubleFunc object at ...>
     
    11091107                vars = ex.variables()
    11101108
    11111109            if vars:
    1112                 from sage.misc.superseded import deprecation
    1113                 deprecation(5930, "Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)")
    1114 
    1115        
     1110                raise SyntaxError("Substitution using function-call syntax "
     1111                            "and unnamed arguments has been removed. You "
     1112                            "can use named arguments instead, like "
     1113                            "EXPR(x=..., y=...)")
    11161114        self.vars = vars
    11171115
    11181116        import sage.ext.fast_eval as fast_float
  • sage/symbolic/ring.pyx

    diff --git a/sage/symbolic/ring.pyx b/sage/symbolic/ring.pyx
    a b  
    606606    def _call_element_(self, _the_element, *args, **kwds):
    607607        """
    608608        EXAMPLES::
    609        
     609
    610610            sage: x,y=var('x,y')
    611611            sage: f = x+y
    612612            sage: f.variables()
     
    614614            sage: f()
    615615            x + y
    616616            sage: f(3)
    617             doctest:...: DeprecationWarning: Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)
    618             See http://trac.sagemath.org/5930 for details.
    619             y + 3
     617            Traceback (most recent call last):
     618            ...
     619            SyntaxError: Substitution using function-call syntax and
     620            unnamed arguments has been removed. You can use named arguments
     621            instead, like EXPR(x=..., y=...)
    620622            sage: f(x=3)
    621623            y + 3
    622             sage: f(3,4)
    623             7
    624624            sage: f(x=3,y=4)
    625625            7
    626             sage: f(2,3,4)
    627             Traceback (most recent call last):
    628             ...
    629             ValueError: the number of arguments must be less than or equal to 2
    630626            sage: f(x=2,y=3,z=4)
    631627            5
    632        
     628
    633629        ::
    634        
     630
    635631            sage: f({x:3})
    636632            y + 3
    637633            sage: f({x:3,y:4})
     
    640636            y + 3
    641637            sage: f(x=3,y=4)
    642638            7
    643        
     639
    644640        ::
    645        
     641
    646642            sage: a = (2^(8/9))
    647643            sage: a(4)
    648644            Traceback (most recent call last):
    649645            ...
    650             ValueError: the number of arguments must be less than or equal to 0
    651        
     646            SyntaxError: Substitution using function-call syntax and
     647            unnamed arguments has been removed. You can use named arguments
     648            instead, like EXPR(x=..., y=...)
     649
    652650
    653651        Note that you make get unexpected results when calling
    654652        symbolic expressions and not explicitly giving the variables::
     
    656654            sage: f = function('Gamma', var('z'), var('w')); f
    657655            Gamma(z, w)
    658656            sage: f(2)
    659             Gamma(z, 2)
     657            Traceback (most recent call last):
     658            ...
     659            SyntaxError: Substitution using function-call syntax and
     660            unnamed arguments has been removed. You can use named arguments
     661            instead, like EXPR(x=..., y=...)
    660662            sage: f(2,5)
    661             Gamma(5, 2)
     663            Traceback (most recent call last):
     664            ...
     665            SyntaxError: Substitution using function-call syntax and
     666            unnamed arguments has been removed. You can use named arguments
     667            instead, like EXPR(x=..., y=...)
    662668
    663669        Thus, it is better to be explicit::
    664670
     
    670676        elif len(args) == 1 and isinstance(args[0], dict):
    671677            d = args[0]
    672678        else:
    673             from sage.misc.superseded import deprecation
    674             vars = _the_element.operands()
    675             deprecation(5930, "Substitution using function-call syntax and unnamed arguments is deprecated and will be removed from a future release of Sage; you can use named arguments instead, like EXPR(x=..., y=...)")
    676             d = {}
    677            
    678             vars = _the_element.variables()
    679             for i, arg in enumerate(args):
    680                 try:
    681                     d[ vars[i] ] = arg
    682                 except IndexError:
    683                     raise ValueError, "the number of arguments must be less than or equal to %s"%len(vars)
    684 
     679            raise SyntaxError("Substitution using function-call syntax "
     680                            "and unnamed arguments has been removed. You "
     681                            "can use named arguments instead, like "
     682                            "EXPR(x=..., y=...)")
    685683        return _the_element.subs(d, **kwds)
    686684
    687685SR = SymbolicRing()