# HG changeset patch # User Mike Miller # Date 1470264099 25200 # Node ID a0dc81daf5537859a9f25a4d810c035047257aeb # Parent ccd9fcaae5f8bec7b5103e26502ea1e91a6a2d63# Parent f2b4576879a6a368bf753d8c61e413c776df17fc Merged in genuinelucifer/pytave_main (pull request #31) Edit test and functions to adapt to lists, dicts being pyobjects diff -r f2b4576879a6 -r a0dc81daf553 @pyobject/pyobject.m --- a/@pyobject/pyobject.m Wed Aug 03 00:26:44 2016 -0700 +++ b/@pyobject/pyobject.m Wed Aug 03 15:41:39 2016 -0700 @@ -145,9 +145,12 @@ endif endfunction - function s = whatclass (x) + function s = class (x) idx = struct ("type", ".", "subs", "__class__"); - s = subsref (x, idx); + class_ref = subsref (x, idx); + idx = struct ("type", ".", "subs", "__name__"); + s = subsref (class_ref, idx); + s = sprintf ("py.%s", char (s)); endfunction function vargout = help (x) @@ -197,3 +200,10 @@ %!assert (isa (pyobject (42.2), "pyobject")) %!assert (isa (pyobject (int32 (42)), "pyobject")) %!assert (isa (pyobject (pyobject ()), "pyobject")) + +%!assert (class (pyeval ("{}")), "py.dict") +%!assert (class (pyeval ("[]")), "py.list") +%!assert (class (pyeval ("()")), "py.tuple") +%!assert (class (pyeval ("set()")), "py.set") +%!assert (class (pyeval ("None")), "py.NoneType") +%!assert (class (pyeval ("2.5")), "double")