Mercurial > pytave
annotate @pyobject/subsasgn.m @ 343:fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
* @py/py.m, @pyobject/pyobject.m, @pyobject/subsasgn.m, @pyobject/subsref.m:
Add %!xtests for known failures due to bugs in Octave.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Tue, 16 Aug 2016 13:54:25 -0700 |
parents | 15c20ab4b80a |
children | 087e7bc3697f |
rev | line source |
---|---|
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
1 ## Copyright (C) 2016 Colin B. Macdonald |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
2 ## |
266
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
3 ## This file is part of Pytave. |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
4 ## |
266
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
5 ## Pytave is free software; you can redistribute it and/or modify |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
7 ## by the Free Software Foundation; either version 3 of the License, |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
8 ## or (at your option) any later version. |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
9 ## |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
10 ## This software is distributed in the hope that it will be useful, |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
12 ## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
13 ## the GNU General Public License for more details. |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
14 ## |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
16 ## License along with this software; see the file COPYING. |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
17 ## If not, see <http://www.gnu.org/licenses/>. |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
18 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
20 ## @documentencoding UTF-8 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
21 ## @defop Method @@pyobject subsasgn (@var{x}, @var{idx}, @var{rhs}) |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
22 ## @defopx Operator @@pyobject {@var{x}.@var{property} =} {@var{rhs}} |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
23 ## @defopx Operator @@pyobject {@var{x}@{@var{i}@} =} {@var{rhs}} |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
24 ## @defopx Operator @@pyobject {@var{x}@{@var{i}, @var{j}, @dots{}@} =} {@var{rhs}} |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
25 ## @defopx Operator @@pyobject {@var{x}@{@var{a}@} =} {@var{rhs}} |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
26 ## Indexed assignment to Python objects. |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
27 ## |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
28 ## @seealso{@@pyobject/subsref} |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
29 ## @end defop |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
30 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
31 function r = subsasgn(x, idx, rhs) |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
32 |
270
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
33 if (nargin != 3) |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
34 print_usage (); |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
35 endif |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
36 |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
37 ## If rhs is a pyobject but x is not, dispatch to the builtin subsasgn |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
38 if (! isa (x, "pyobject")) |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
39 r = builtin ("subsasgn", x, idx, rhs); |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
40 return; |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
41 endif |
2cb6e2824776
Support indexed assignment of pyobjects into builtin array types
Mike Miller <mtmiller@octave.org>
parents:
269
diff
changeset
|
42 |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
43 switch idx.type |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
44 case "." |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
45 assert (ischar (idx.subs)) |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
46 pycall ("setattr", x, idx.subs, rhs); |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
47 r = x; |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
48 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
49 case "{}" |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
50 ## XXX: doesn't support slices or anything like that yet |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
51 |
267
c7a7d94a142f
fix off-by-one dict indexing error for assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
266
diff
changeset
|
52 ## Subtract one from index: do this for lists, numpy arrays, etc |
c7a7d94a142f
fix off-by-one dict indexing error for assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
266
diff
changeset
|
53 pyexec ("import collections") |
c7a7d94a142f
fix off-by-one dict indexing error for assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
266
diff
changeset
|
54 pyexec ("import numpy") |
c7a7d94a142f
fix off-by-one dict indexing error for assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
266
diff
changeset
|
55 x_is_list = pycall (pyeval ( |
269
8c543a859ba2
* @pyobject/subsasgn.m: Fix small lambda syntax error with Python 3.
Mike Miller <mtmiller@octave.org>
parents:
267
diff
changeset
|
56 "lambda x: isinstance(x, (collections.Sequence, numpy.ndarray))"), |
267
c7a7d94a142f
fix off-by-one dict indexing error for assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
266
diff
changeset
|
57 x); |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
58 for i = 1:length (idx.subs) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
59 j = idx.subs{i}; |
267
c7a7d94a142f
fix off-by-one dict indexing error for assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
266
diff
changeset
|
60 if (x_is_list && isindex (j) && isnumeric (j)) |
266
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
61 idx.subs{i} = cast (j, class (sizemax ())) - 1; |
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
62 endif |
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
63 endfor |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
64 |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
65 if (isscalar (idx.subs)) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
66 ind = idx.subs{1}; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
67 else |
318
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
68 ind = pycall ("tuple", idx.subs); |
266
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
69 endif |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
70 |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
71 xsi = pycall ("getattr", x, "__setitem__"); # x.__setitem__ |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
72 pycall (xsi, ind, rhs); |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
73 r = x; |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
74 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
75 otherwise |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
76 idx |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
77 rhs |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
78 error ("@pyobject/subsasgn: not implemented") |
266
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
79 endswitch |
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
80 endfunction |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
81 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
82 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
83 %!test |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
84 %! pyexec ("class MyClass: a = 1") |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
85 %! t = pyeval ("MyClass()"); |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
86 %! t.b = 6; |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
87 %! assert (t.b, 6) |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
88 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
89 %!test |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
90 %! % list indexing |
327
15c20ab4b80a
Do not automatically convert Python integer types to Octave (see issue #56)
Mike Miller <mtmiller@octave.org>
parents:
318
diff
changeset
|
91 %! L = pyeval ("[10., 20.]"); |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
92 %! L{2} = "Octave"; |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
93 %! assert (length (L) == 2) |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
94 %! assert (L{1}, 10) |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
95 %! assert (L{2}, "Octave") |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
96 |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
97 %!test |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
98 %! % dict assignment, adding new keys |
312
d9f9156a13c9
Remove unncessary calls to fromPythonVarName
Colin Macdonald <cbm@m.fsf.org>
parents:
270
diff
changeset
|
99 %! d = pyeval ("dict()"); |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
100 %! d{"a"} = 3; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
101 %! d{"b"} = 4; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
102 %! assert (d{"a"}, 3) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
103 %! assert (d{"b"}, 4) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
104 |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
105 %!test |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
106 %! % dict assignment, update existing key |
312
d9f9156a13c9
Remove unncessary calls to fromPythonVarName
Colin Macdonald <cbm@m.fsf.org>
parents:
270
diff
changeset
|
107 %! d = pyeval ("{'a':1}"); |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
108 %! d{"a"} = 3; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
109 %! assert (d{"a"}, 3) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
110 |
267
c7a7d94a142f
fix off-by-one dict indexing error for assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
266
diff
changeset
|
111 %!test |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
112 %! % dict assignment, other keys (e.g., Issue #10). |
312
d9f9156a13c9
Remove unncessary calls to fromPythonVarName
Colin Macdonald <cbm@m.fsf.org>
parents:
270
diff
changeset
|
113 %! d = pyeval ("dict()"); |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
114 %! d{"5"} = 10; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
115 %! d{5.5} = 11; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
116 %! d{5} = 12; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
117 %! assert (d{"5"}, 10) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
118 %! assert (d{5.5}, 11) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
119 %! assert (d{5}, 12) |
318
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
120 |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
121 %!test |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
122 %! % 2D array indexing |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
123 %! A = pyobject ([1.1 2 3; 4 5 6]); |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
124 %! A{1, 1} = 10; |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
125 %! A{1, 3} = 30; |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
126 %! A{2, 1} = 40; |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
127 %! assert (A{1, 1}, 10) |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
128 %! assert (A{1, 3}, 30) |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
129 %! assert (A{2, 1}, 40) |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
130 %! assert (A{2, 2}, 5) |
343
fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
Mike Miller <mtmiller@octave.org>
parents:
327
diff
changeset
|
131 |
fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
Mike Miller <mtmiller@octave.org>
parents:
327
diff
changeset
|
132 ## Test of string key assignment, fails in the general case |
fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
Mike Miller <mtmiller@octave.org>
parents:
327
diff
changeset
|
133 %!xtest |
fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
Mike Miller <mtmiller@octave.org>
parents:
327
diff
changeset
|
134 %! d = pyobject (struct ()); |
fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
Mike Miller <mtmiller@octave.org>
parents:
327
diff
changeset
|
135 %! d{"value"} = 1; |