Mercurial > pytave
changeset 286:9e8faa439d1d
Merged in macdonald/pytave (pull request #35)
use pyobject instead of accessing the InOct dict
author | Mike Miller <mike@mtmxr.com> |
---|---|
date | Tue, 02 Aug 2016 12:11:02 -0700 |
parents | 46d9b2972901 (current diff) 06a4b461b141 (diff) |
children | ccd9fcaae5f8 f5282c87e5d5 |
files | @pyobject/pyobject.m |
diffstat | 3 files changed, 10 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/@pyobject/fieldnames.m Tue Aug 02 12:04:12 2016 -0700 +++ b/@pyobject/fieldnames.m Tue Aug 02 12:11:02 2016 -0700 @@ -47,14 +47,13 @@ function names = fieldnames (x) - cmd = sprintf (["[a for x in (__InOct__['%s'],) for a in dir(x) " ... - " if not callable(getattr(x, a))" ... - " and not isinstance(getattr(x, a), __import__('types').ModuleType)" ... - " and not a.startswith('_')]"], - getid (x)); + cmd = pyeval (["lambda x: [a for a in dir(x)" ... + " if not callable(getattr(x, a))" ... + " and not isinstance(getattr(x, a), __import__('types').ModuleType)" ... + " and not a.startswith('_')]"]); # FIXME: may need to convert from Python list to Octave cell array - names = pyeval (cmd); + names = pycall (cmd, x); names = names(:); endfunction
--- a/@pyobject/methods.m Tue Aug 02 12:04:12 2016 -0700 +++ b/@pyobject/methods.m Tue Aug 02 12:11:02 2016 -0700 @@ -68,13 +68,11 @@ function mtds = methods (x) # filter the output of `dir(x)` to get callable methods only - cmd = sprintf (["[a for x in (__InOct__['%s'],) for a in dir(x) " ... - " if callable(getattr(x, a))" ... - " and not a.startswith('__')]"], - getid (x)); + cmd = pyeval (["lambda x: [a for a in dir(x)" ... + " if callable(getattr(x, a)) and not a.startswith('_')]"]); # FIXME: may need to convert from Python list to Octave cell array - mtds_list = pyeval (cmd); + mtds_list = pycall (cmd, x) if (nargout == 0) ## FIXME: should this be available as @pyobject/ismodule.m ?
--- a/@pyobject/pyobject.m Tue Aug 02 12:04:12 2016 -0700 +++ b/@pyobject/pyobject.m Tue Aug 02 12:11:02 2016 -0700 @@ -146,7 +146,8 @@ endfunction function s = whatclass (x) - s = pyeval (sprintf ("str(__InOct__['%s'].__class__)", x.id)); + idx = struct ("type", ".", "subs", "__class__"); + s = subsref (x, idx); endfunction function vargout = help (x)