#9989: easier access to operands of a symbolic expression
----------------------------------------------------+-----------------------
   Reporter:  burcin                                |          Owner:  burcin   
      
       Type:  enhancement                           |         Status:  
positive_review
   Priority:  major                                 |      Milestone:  
sage-4.7.1     
  Component:  symbolics                             |       Keywords:           
      
Work_issues:                                        |       Upstream:  N/A      
      
   Reviewer:  Robert Bradshaw, Karl-Dieter Crisman  |         Author:  Burcin 
Erocal  
     Merged:                                        |   Dependencies:           
      
----------------------------------------------------+-----------------------

Old description:

> Attached patch adds an `op` attribute to symbolic expressions which gives
> easy access to its operands. We now have:
>
> {{{
> sage: x,y,z = var('x,y,z')
> sage: e = x + x*y + z^y + 3*y*z; e
> x*y + 3*y*z + z^y + x
> sage: e.op[1]
> 3*y*z
> sage: e.op[1,1]
> z
> sage: e.op[-1]
> x
> sage: e.op[1:]
> [3*y*z, z^y, x]
> }}}
>
> Using `__getitem__()` directly was not an option since it breaks
> conversion to numpy.
>

> Apply [attachment:trac_9989-operands.take3.patch]

New description:

 Attached patch adds an `op` attribute to symbolic expressions which gives
 easy access to its operands. We now have:

 {{{
 sage: x,y,z = var('x,y,z')
 sage: e = x + x*y + z^y + 3*y*z; e
 x*y + 3*y*z + z^y + x
 sage: e.op[1]
 3*y*z
 sage: e.op[1,1]
 z
 sage: e.op[-1]
 x
 sage: e.op[1:]
 [3*y*z, z^y, x]
 }}}

 Using `__getitem__()` directly was not an option since it breaks
 conversion to numpy.


 Apply [attachment:trac_9989-operands.take4.patch]

--

Comment(by burcin):

 Good catch. Thanks, Francois.

 I uploaded a new patch that just changes `module_list.py` to use
 `SAGE_LOCAL` instead of `SAGE_ROOT`.

 Francois, why don't you open a ticket to rename `SAGE_ROOT` in
 `module_list.py` to something like `SAGE_ROOT_DO_NOT_USE` with a comment
 above it to point out why `SAGE_LOCAL` is better.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9989#comment:16>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to