# HG changeset patch # User Colin Macdonald # Date 1470766138 25200 # Node ID d9f9156a13c9cf8ef8b3737b203f3b77e62969fe # Parent 77af526c687acc060c2fa36bd10e68a94ac22daa Remove unncessary calls to fromPythonVarName * @pyobject/subsasgn.m: Drop fromPythonVarName * @pyobject/subsref.m: Drop fromPythonVarName diff -r 77af526c687a -r d9f9156a13c9 @pyobject/subsasgn.m --- a/@pyobject/subsasgn.m Tue Aug 09 15:40:52 2016 -0700 +++ b/@pyobject/subsasgn.m Tue Aug 09 11:08:58 2016 -0700 @@ -88,8 +88,7 @@ %!test %! % list indexing -%! pyexec ("L = [10, 20]") -%! L = pyobject.fromPythonVarName ("L"); +%! L = pyeval ("[10, 20]"); %! L{2} = "Octave"; %! assert (length (L) == 2) %! assert (L{1}, 10) @@ -97,8 +96,7 @@ %!test %! % dict assignment, adding new keys -%! pyexec ("d = dict()") -%! d = pyobject.fromPythonVarName ("d"); +%! d = pyeval ("dict()"); %! d{"a"} = 3; %! d{"b"} = 4; %! assert (d{"a"}, 3) @@ -106,15 +104,13 @@ %!test %! % dict assignment, update existing key -%! pyexec ("d = {'a':1}") -%! d = pyobject.fromPythonVarName ("d"); +%! d = pyeval ("{'a':1}"); %! d{"a"} = 3; %! assert (d{"a"}, 3) %!test %! % dict assignment, other keys (e.g., Issue #10). -%! pyexec ("d = dict()") -%! d = pyobject.fromPythonVarName ("d"); +%! d = pyeval ("dict()"); %! d{"5"} = 10; %! d{5.5} = 11; %! d{5} = 12; diff -r 77af526c687a -r d9f9156a13c9 @pyobject/subsref.m --- a/@pyobject/subsref.m Tue Aug 09 15:40:52 2016 -0700 +++ b/@pyobject/subsref.m Tue Aug 09 11:08:58 2016 -0700 @@ -114,15 +114,13 @@ %!test %! % list indexing -%! pyexec ("L = [10, 20]") -%! L = pyobject.fromPythonVarName ("L"); +%! L = pyeval ("[10, 20]"); %! assert (L{1}, 10) %! assert (L{2}, 20) %!test %! % list indexing, slice -%! pyexec ("L = [10, 20, [30, 40]]") -%! L = pyobject.fromPythonVarName ("L"); +%! L = pyeval ("[10, 20, [30, 40]]"); %! L2 = L{:}; %! assert (L2{1}, 10) %! assert (L2{2}, 20) @@ -131,8 +129,7 @@ %!test %! % list indexing, nested list -%! pyexec ("L = [1, 2, [10, 11, 12]]") -%! L = pyobject.fromPythonVarName ("L"); +%! L = pyeval ("[1, 2, [10, 11, 12]]"); %! assert (L{2}, 2) %! assert (L{3}{1}, 10) %! assert (L{3}{3}, 12) @@ -148,40 +145,34 @@ %!test %! % 2D array indexing %! pyexec ("import numpy") -%! pyexec ("A = numpy.array([[1, 2], [3, 4]])") -%! A = pyobject.fromPythonVarName ("A"); +%! A = pyobject (pyeval ("numpy.array([[1, 2], [3, 4]])")); %! assert (A{1, 1}, 1) %! assert (A{2, 1}, 3) %! assert (A{1, 2}, 2) %!test %! % dict: str key access -%! pyexec ("d = {'one':1, 5:5, 6:6}") -%! d = pyobject.fromPythonVarName ("d"); +%! d = pyeval ("{'one':1, 5:5, 6:6}"); %! assert (d{"one"}, 1) %!test %! % dict: integer key access -%! pyexec ("d = {5:42, 6:42}") -%! d = pyobject.fromPythonVarName ("d"); +%! d = pyeval ("{5:42, 6:42}"); %! assert (d{6}, 42) %!test %! % dict: integer key should not subtract one -%! pyexec ("d = {5:40, 6:42}") -%! d = pyobject.fromPythonVarName ("d"); +%! d = pyeval ("{5:40, 6:42}"); %! assert (d{6}, 42) %!test %! % dict: floating point keys should work -%! pyexec ("d = {5.5:'ok'}") -%! d = pyobject.fromPythonVarName ("d"); +%! d = pyeval ("{5.5:'ok'}"); %! assert (d{5.5}, "ok") %!test %! % dict: make sure key ":" doesn't break anything -%! pyexec ("d = {'a':1, ':':2}") -%! d = pyobject.fromPythonVarName ("d"); +%! d = pyeval ("{'a':1, ':':2}"); %! assert (d{'a'}, 1) %! assert (d{':'}, 2)