Mercurial > pytave
changeset 318:6f03249847fa
Support multi-indexing assignment
* @pyobject/subsasgn.m: Fix multi-indexing.
author | Colin Macdonald <cbm@m.fsf.org> |
---|---|
date | Wed, 10 Aug 2016 00:52:55 -0700 |
parents | 461f333daf67 |
children | 1231dc878600 |
files | @pyobject/subsasgn.m |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/@pyobject/subsasgn.m Wed Aug 10 00:46:53 2016 -0700 +++ b/@pyobject/subsasgn.m Wed Aug 10 00:52:55 2016 -0700 @@ -65,7 +65,7 @@ if (isscalar (idx.subs)) ind = idx.subs{1}; else - error ("not implemented, waiting on #26, #27") + ind = pycall ("tuple", idx.subs); endif xsi = pycall ("getattr", x, "__setitem__"); # x.__setitem__ @@ -117,3 +117,14 @@ %! assert (d{"5"}, 10) %! assert (d{5.5}, 11) %! assert (d{5}, 12) + +%!test +%! % 2D array indexing +%! A = pyobject ([1.1 2 3; 4 5 6]); +%! A{1, 1} = 10; +%! A{1, 3} = 30; +%! A{2, 1} = 40; +%! assert (A{1, 1}, 10) +%! assert (A{1, 3}, 30) +%! assert (A{2, 1}, 40) +%! assert (A{2, 2}, 5)