Ticket #13286: trac_13286-allow_list_in_solve.patch

File trac_13286-allow_list_in_solve.patch, 2.4 KB (added by ppurka, 8 years ago)

Apply to devel/sage

  • sage/symbolic/expression.pyx

    # HG changeset patch
    # User Punarbasu Purkayastha <ppurka@gmail.com>
    # Date 1343733499 -28800
    # Node ID bd88c770c7296f94dfa8d610379fcae6751c9a56
    # Parent  79d77c717499ade7a62afcdc1efedf0f4b1112e1
    Take care of cases like solve([x-4], [x]) for consistency with multivariable input
    
    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    82838283
    82848284        TESTS:
    82858285
    8286         Trac #7325 (solving inequalities)::
     8286        :trac:`7325` (solving inequalities)::
    82878287
    82888288            sage: (x^2>1).solve(x)
    82898289            [[x < -1], [x > 1]]
     
    82988298            sage: solve(acot(x),x,to_poly_solve=True)
    82998299            []
    83008300
    8301         Trac #7491 fixed::
     8301        :trac:`7491` fixed::
    83028302
    83038303            sage: y=var('y')
    83048304            sage: solve(y==y,y)
    83058305            [y == r1]
    83068306            sage: solve(y==y,y,multiplicities=True)
    83078307            ([y == r1], [])
    8308        
     8308
    83098309            sage: from sage.symbolic.assumptions import GenericDeclaration
    83108310            sage: GenericDeclaration(x, 'rational').assume()
    83118311            sage: solve(x^2 == 2, x)
    83128312            []
    83138313            sage: forget()
    83148314
    8315         Trac #8390 fixed::
     8315        :trac:`8390` fixed::
    83168316
    83178317            sage: solve(sin(x)==1/2,x)
    83188318            [x == 1/6*pi]
     
    83278327            sage: solve(sin(x)==1/2,x,to_poly_solve='force')
    83288328            [x == 5/6*pi + 2*pi*z116, x == 1/6*pi + 2*pi*z114]
    83298329
    8330         Trac #11618 fixed::
     8330        :trac:`11618` fixed::
    83318331
    83328332            sage: g(x)=0
    83338333            sage: solve(g(x)==0,x,solution_dict=True)
    83348334            [{x: r1}]
     8335
     8336        :trac:`13286` fixed::
     8337
     8338            sage: solve([x-4], [x])
     8339            [x == 4]
    83358340        """
    83368341        import operator
    83378342        cdef Expression ex
     
    83538358        if multiplicities and to_poly_solve:
    83548359            raise NotImplementedError, "to_poly_solve does not return multiplicities"
    83558360
     8361        # Take care of cases like solve([x^2-1], [x]) for consistency with
     8362        # multiple variable input in sage.symbolic.relation.solve().
     8363        # There *should* be only one variable in the list, since it is
     8364        # passed from sage.symbolic.relation.solve() and multiple variables
     8365        # there don't call this function.
     8366        if isinstance(x, (list, tuple)):
     8367            x = x[0]
     8368
    83568369        if x is None:
    83578370            v = ex.variables()
    83588371            if len(v) == 0: