#4972: [with patch, positive review] matrix setitem should deal with slicing
----------------------------------+------------------------
Reporter: jason | Owner: was
Type: defect | Status: closed
Priority: major | Milestone: sage-3.3
Component: linear algebra | Resolution: fixed
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
----------------------------------+------------------------
Changes (by chapoton):
* upstream: => N/A
Old description:
> The following should work:
>
> {{{
> a=matrix(QQ,3,[1,3,4,3,2,3,6,4,5])
> a[1,:]=a[0,:]
> }}}
>
> Instead, I get an error:
>
> {{{
>
> Traceback (click to the left for traceback)
> ...
> TypeError: 'slice' object cannot be interpreted as an index
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/home/grout/.sage/sage_notebook/worksheets/admin/143/code/10.py",
> line 7, in <module>
> a[_sage_const_1 ,:]=a[_sage_const_0 ,:]
> File "/home/grout/sage/local/lib/python2.5/site-
> packages/SQLAlchemy-0.4.6-py2.5.egg/", line 1, in <module>
>
> File "matrix0.pyx", line 798, in sage.matrix.matrix0.Matrix.__setitem__
> (sage/matrix/matrix0.c:4517)
> TypeError: 'slice' object cannot be interpreted as an index
>
> }}}
New description:
The following should work:
{{{
a=matrix(QQ,3,[1,3,4,3,2,3,6,4,5])
a[1,:]=a[0,:]
}}}
Instead, I get an error:
{{{
Traceback (click to the left for traceback)
...
TypeError: 'slice' object cannot be interpreted as an index
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/grout/.sage/sage_notebook/worksheets/admin/143/code/10.py",
line 7, in <module>
a[_sage_const_1 ,:]=a[_sage_const_0 ,:]
File "/home/grout/sage/local/lib/python2.5/site-
packages/SQLAlchemy-0.4.6-py2.5.egg/", line 1, in <module>
File "matrix0.pyx", line 798, in sage.matrix.matrix0.Matrix.__setitem__
(sage/matrix/matrix0.c:4517)
TypeError: 'slice' object cannot be interpreted as an index
}}}
--
--
Ticket URL: <http://trac.sagemath.org/ticket/4972#comment:12>
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.