Mercurial > pytave
changeset 291:a0dc81daf553
Merged in genuinelucifer/pytave_main (pull request #31)
Edit test and functions to adapt to lists, dicts being pyobjects
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Wed, 03 Aug 2016 15:41:39 -0700 |
parents | ccd9fcaae5f8 (diff) f2b4576879a6 (current diff) |
children | 510ed59a61d3 |
files | |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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")