Opened 5 years ago

Closed 5 years ago

#17128 closed defect (fixed)

Problem with solution_dict=True and solving for multiple variables

Reported by: jhpalmieri Owned by:
Priority: major Milestone: sage-6.4
Component: symbolics Keywords:
Cc: Merged in:
Authors: Miguel Marco Reviewers: Ralf Stephan
Report Upstream: N/A Work issues:
Branch: b26dbd4 (Commits) Commit: b26dbd46534be67d92bd808d8f45a6519aac957e
Dependencies: Stopgaps:

Description

This bug was reported at http://ask.sagemath.org/question/24446/problem-with-solution_dicttrue/:

sage: var('x y')
(x, y)
sage: sol=solve(x + y, [x, y], solution_dict=True)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-d24a5a0d9f55> in <module>()
----> 1 sol=solve(x + y, [x, y], solution_dict=True)

/Users/palmieri/Desktop/Sage_stuff/git/sage/local/lib/python2.7/site-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
    732     from sage.symbolic.expression import is_Expression
    733     if is_Expression(f): # f is a single expression
--> 734         ans = f.solve(*args,**kwds)
    735         return ans
    736 

/Users/palmieri/Desktop/Sage_stuff/git/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.solve (build/cythonized/sage/symbolic/expression.cpp:47600)()

AttributeError: 'list' object has no attribute 'left'

I think this was introduced in #16531.

Change History (10)

comment:1 Changed 5 years ago by mmarco

The problem arises in the conversion to dictionary form. This works ok:

sage: var('x,y')
(x, y)
sage: solve(x+y,[x,y])
[[x == -r1, y == r1]]



It should be easy to fix.

comment:2 Changed 5 years ago by mmarco

  • Branch set to u/mmarco/ticket/17128
  • Created changed from 10/10/14 05:57:28 to 10/10/14 05:57:28
  • Modified changed from 10/10/14 12:52:15 to 10/10/14 12:52:15

comment:3 Changed 5 years ago by mmarco

  • Commit set to 88d0e11df6fdfdc6e11c1a9b30e09265c5e3c5fa

This should fix it.


New commits:

88d0e11Fix error converting solutions to dict when solving for multiple variables.

comment:4 Changed 5 years ago by mmarco

  • Status changed from new to needs_review

comment:5 Changed 5 years ago by rws

  • Branch changed from u/mmarco/ticket/17128 to public/17128

comment:6 Changed 5 years ago by rws

  • Authors set to Miguel Marco
  • Commit changed from 88d0e11df6fdfdc6e11c1a9b30e09265c5e3c5fa to 06d61ab93c522511d2e4c60e9953931f2190d858
  • Reviewers set to Ralf Stephan
  • Status changed from needs_review to positive_review

The doctest wold only pass with the r7 variable so I added wildcards. Else a minimal patch.


New commits:

ee44772Merge branch 'develop' into t/17128/ticket/17128
06d61ab17128: reviewer's patch: make doctest pass with any var

comment:7 Changed 5 years ago by vbraun

  • Status changed from positive_review to needs_work

variable sort order is random:

sage -t --long src/sage/symbolic/expression.pyx
**********************************************************************
File "src/sage/symbolic/expression.pyx", line 9448, in sage.symbolic.expression.Expression.solve
Failed example:
    f.solve([x, y], solution_dict=True)
Expected:
    [{x: -r..., y: r...}]
Got:
    [{y: r8, x: -r8}]
**********************************************************************

comment:8 Changed 5 years ago by git

  • Commit changed from 06d61ab93c522511d2e4c60e9953931f2190d858 to b26dbd46534be67d92bd808d8f45a6519aac957e

Branch pushed to git repo; I updated commit sha1. New commits:

8ef5b83Merge branch 'develop' into t/17128/public/17128
b26dbd417128: fix doctest

comment:9 Changed 5 years ago by rws

  • Status changed from needs_work to positive_review

comment:10 Changed 5 years ago by vbraun

  • Branch changed from public/17128 to b26dbd46534be67d92bd808d8f45a6519aac957e
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.