Mercurial > pytave
annotate @pyobject/subsasgn.m @ 411:3613ffbd52b2
Overhaul implicit conversion of arguments and return values
* oct-py-types.cc, oct-py-types.h (pytave::py_implicitly_convert_argument,
pytave::py_implicitly_convert_return_value): New functions.
* __py_struct_from_dict__.cc, oct-py-eval.cc, pycall.cc, pyeval.cc, pyexec.cc:
Use them instead of legacy conversion functions. Add necessary #includes,
remove #includes of legacy header files.
* @pyobject/subsasgn.m, @pyobject/subsref.m: Change %!tests that depend on
NumPy implicit conversion into %!xtests.
* octave_to_python.cc, octave_to_python.h, python_to_octave.cc,
python_to_octave.h: Delete, no longer used.
* Makefile.am (COMMON_SOURCE_FILES, PYTAVE_HEADER_FILES): Remove the files.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Wed, 03 May 2017 16:30:45 -0700 |
parents | 540b36e797c8 |
children |
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 |
367
9d7188514f2c
Use pyobject.isa instead of lambda to check Python types
Mike Miller <mtmiller@octave.org>
parents:
365
diff
changeset
|
53 x_is_sequence = any (isa (x, {"py.collections.Sequence", ... |
9d7188514f2c
Use pyobject.isa instead of lambda to check Python types
Mike Miller <mtmiller@octave.org>
parents:
365
diff
changeset
|
54 "py.numpy.ndarray"})); |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
55 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
|
56 j = idx.subs{i}; |
367
9d7188514f2c
Use pyobject.isa instead of lambda to check Python types
Mike Miller <mtmiller@octave.org>
parents:
365
diff
changeset
|
57 if (x_is_sequence && isindex (j) && isnumeric (j)) |
266
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
58 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
|
59 endif |
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
60 endfor |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
61 |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
62 if (isscalar (idx.subs)) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
63 ind = idx.subs{1}; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
64 else |
318
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
65 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
|
66 endif |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
67 |
369
540b36e797c8
Reduce number of function calls, clean up formatting in subasgn and subsref
Mike Miller <mtmiller@octave.org>
parents:
367
diff
changeset
|
68 pycall ("operator.setitem", x, ind, rhs); |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
69 r = x; |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
70 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
71 otherwise |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
72 idx |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
73 rhs |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
74 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
|
75 endswitch |
b337b733d6f8
maint: fix copyright header, cast int, block endings
Colin Macdonald <cbm@m.fsf.org>
parents:
265
diff
changeset
|
76 endfunction |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
77 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
78 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
79 %!test |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
80 %! pyexec ("class MyClass: a = 1") |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
81 %! t = pyeval ("MyClass()"); |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
82 %! t.b = 6; |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
83 %! assert (t.b, 6) |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
84 |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
85 %!test |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
86 %! % 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
|
87 %! L = pyeval ("[10., 20.]"); |
264
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
88 %! L{2} = "Octave"; |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
89 %! assert (length (L) == 2) |
5a516155d730
pyobject: support indexed assignment (fixes issue #17)
Colin Macdonald <cbm@m.fsf.org>
parents:
diff
changeset
|
90 %! assert (L{1}, 10) |
365
087e7bc3697f
Do not automatically convert Python strings to Octave strings (fixes issue #65)
Mike Miller <mtmiller@octave.org>
parents:
343
diff
changeset
|
91 %! assert (char (L{2}), "Octave") |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
92 |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
93 %!test |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
94 %! % dict assignment, adding new keys |
312
d9f9156a13c9
Remove unncessary calls to fromPythonVarName
Colin Macdonald <cbm@m.fsf.org>
parents:
270
diff
changeset
|
95 %! d = pyeval ("dict()"); |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
96 %! d{"a"} = 3; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
97 %! d{"b"} = 4; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
98 %! assert (d{"a"}, 3) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
99 %! assert (d{"b"}, 4) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
100 |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
101 %!test |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
102 %! % dict assignment, update existing key |
312
d9f9156a13c9
Remove unncessary calls to fromPythonVarName
Colin Macdonald <cbm@m.fsf.org>
parents:
270
diff
changeset
|
103 %! 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
|
104 %! d{"a"} = 3; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
105 %! assert (d{"a"}, 3) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
106 |
267
c7a7d94a142f
fix off-by-one dict indexing error for assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
266
diff
changeset
|
107 %!test |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
108 %! % 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
|
109 %! d = pyeval ("dict()"); |
265
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
110 %! d{"5"} = 10; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
111 %! d{5.5} = 11; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
112 %! d{5} = 12; |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
113 %! assert (d{"5"}, 10) |
07ca24d7627f
indexed assignment: support string index, e.g., for dicts
Colin Macdonald <cbm@m.fsf.org>
parents:
264
diff
changeset
|
114 %! 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
|
115 %! assert (d{5}, 12) |
318
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
116 |
411
3613ffbd52b2
Overhaul implicit conversion of arguments and return values
Mike Miller <mtmiller@octave.org>
parents:
369
diff
changeset
|
117 ## Test that depends on implicit creation of NumPy arrays, do we want this? |
3613ffbd52b2
Overhaul implicit conversion of arguments and return values
Mike Miller <mtmiller@octave.org>
parents:
369
diff
changeset
|
118 %!xtest |
318
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
119 %! % 2D array indexing |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
120 %! A = pyobject ([1.1 2 3; 4 5 6]); |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
121 %! A{1, 1} = 10; |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
122 %! A{1, 3} = 30; |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
123 %! A{2, 1} = 40; |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
124 %! assert (A{1, 1}, 10) |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
125 %! assert (A{1, 3}, 30) |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
126 %! assert (A{2, 1}, 40) |
6f03249847fa
Support multi-indexing assignment
Colin Macdonald <cbm@m.fsf.org>
parents:
312
diff
changeset
|
127 %! 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
|
128 |
fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
Mike Miller <mtmiller@octave.org>
parents:
327
diff
changeset
|
129 ## 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
|
130 %!xtest |
fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
Mike Miller <mtmiller@octave.org>
parents:
327
diff
changeset
|
131 %! d = pyobject (struct ()); |
fe6b9e618c98
Add %!xtests for known failures due to bugs in Octave
Mike Miller <mtmiller@octave.org>
parents:
327
diff
changeset
|
132 %! d{"value"} = 1; |