#18360: handle mutable objects better in symbolic evaluation
-------------------------------+------------------------
       Reporter:  rws          |        Owner:
           Type:  enhancement  |       Status:  new
       Priority:  major        |    Milestone:  sage-6.8
      Component:  symbolics    |   Resolution:
       Keywords:               |    Merged in:
        Authors:               |    Reviewers:
Report Upstream:  N/A          |  Work issues:
         Branch:               |       Commit:
   Dependencies:               |     Stopgaps:
-------------------------------+------------------------
Changes (by rws):

 * cc: nbruin (added)
 * milestone:  sage-6.7 => sage-6.8


Old description:

> In examples like this:
> {{{
> sage: f(x)=matrix()
> sage: bool(f(x)-f(x)==0)
> ...
> TypeError: mutable matrices are unhashable
> }}}
> the `f(x)` is expanded into a mutable matrix, but this prevents
> evaluation because Pynac is called by `Expression._sub_` and wants to do
> hashes on the matrix for comparison reasons. However, for the purpose of
> subtraction dealing with a mutable matrix is completely unnecessary. So a
> solution would be to turn mutable objects immutable before doing
> arithmetics in `Expression` or in Pynac.

New description:

 In examples like this:
 {{{
 sage: f(x)=matrix()
 sage: bool(f(x)-f(x)==0)
 ...
 TypeError: mutable matrices are unhashable
 }}}
 the `f(x)` is expanded into a mutable matrix, but this prevents evaluation
 because Pynac is called by `Expression._sub_` and wants to do hashes on
 the matrix for comparison reasons. However, for the purpose of subtraction
 dealing with a mutable matrix is completely unnecessary. So a solution
 would be to turn mutable objects immutable before doing arithmetics in
 `Expression` or in Pynac.

 While the most elegant solution to the specific problem would be an
 expression converter, applied before calling Pynac's `relational_to_bool`
 this will not solve other instances like
 {{{
 sage: f(x)=matrix(ZZ, 8)
 sage: f(x)*1
 ...
 TypeError: mutable matrices are unhashable
 }}}

--

--
Ticket URL: <http://trac.sagemath.org/ticket/18360#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to