Mercurial > pytave
changeset 227:c56b85f405ba
maint: apply Octave whitespace rules
* @pyobject/display.m, @pyobject/dummy.m, @pyobject/methods.m,
@pyobject/pyobject.m, @pyobject/subsref.m, octave_to_python.cc: Use Octave
whitespace conventions around operators and function argument lists.
* pyeval.cc: Break up long line for readability.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Wed, 20 Jul 2016 11:57:14 -0700 |
parents | 382bb1d91239 |
children | 2a9956be24aa |
files | @pyobject/display.m @pyobject/dummy.m @pyobject/methods.m @pyobject/pyobject.m @pyobject/subsref.m octave_to_python.cc pyeval.cc |
diffstat | 7 files changed, 17 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/@pyobject/display.m Wed Jul 20 11:39:23 2016 -0700 +++ b/@pyobject/display.m Wed Jul 20 11:57:14 2016 -0700 @@ -24,8 +24,8 @@ ## Example: ## @example ## @group -## pyexec('import sys') -## sysmodule = pyeval('sys') +## pyexec ("import sys") +## sysmodule = pyeval ("sys") ## @result{} sysmodule = [pyobject ...] ## ## <module 'sys' (built-in)> @@ -44,18 +44,18 @@ printf ("%s = [pyobject %s]\n", inputname (1), getid (x)); s = disp (x); s = make_indented (s); - if (loose), printf("\n"); endif + if (loose), printf ("\n"); endif disp (s) - if (loose), printf("\n"); endif + if (loose), printf ("\n"); endif endfunction -function s = make_indented(s, n) +function s = make_indented (s, n) if (nargin == 1) n = 2; endif - pad = char (double (" ")*ones (1,n)); + pad = char (double (" ") * ones (1,n)); s = strrep (s, "\n", ["\n" pad]); s = [pad s]; # first line endfunction
--- a/@pyobject/dummy.m Wed Jul 20 11:39:23 2016 -0700 +++ b/@pyobject/dummy.m Wed Jul 20 11:57:14 2016 -0700 @@ -68,7 +68,7 @@ ## We can accesss ``callables'' (methods) of objects: ## @example ## @group -## x.keys() +## x.keys () ## @result{} ans = ## @{ ## [1,1] = two
--- a/@pyobject/methods.m Wed Jul 20 11:39:23 2016 -0700 +++ b/@pyobject/methods.m Wed Jul 20 11:57:14 2016 -0700 @@ -60,9 +60,8 @@ # filter the output of `dir(x)` # (to get properties only: # [a for a in dir(x) if not callable(getattr(x, a)) and not a.startswith('__')] - cmd = sprintf ( ... - "[a for a in dir(__InOct__['%s']) if not a.startswith('__')]", ... - getid(x)); + cmd = sprintf ("[a for a in dir(__InOct__['%s']) if not a.startswith('__')]", + getid (x)); # TODO: may need to convert from Python list to Octave list L = pyeval (cmd); endfunction
--- a/@pyobject/pyobject.m Wed Jul 20 11:39:23 2016 -0700 +++ b/@pyobject/pyobject.m Wed Jul 20 11:57:14 2016 -0700 @@ -40,7 +40,7 @@ # at the time of construction but it can disappear later (we # will keep track of the reference). if (! ischar (pyvarname)) - error("pyobject: currently we only take variable names as input") + error ("pyobject: currently we only take variable names as input") endif cmd = sprintf ([ ... 'if not ("__InOct__" in vars() or "__InOct__" in globals()):\n' ...
--- a/@pyobject/subsref.m Wed Jul 20 11:39:23 2016 -0700 +++ b/@pyobject/subsref.m Wed Jul 20 11:57:14 2016 -0700 @@ -40,7 +40,7 @@ case "()" if (! isempty (t.subs)) t - error("not implemented: function calls with arguments") + error ("not implemented: function calls with arguments") endif s = sprintf ("%s()", s); case "." @@ -65,7 +65,7 @@ s = [s "[" strjoin(subsstrs, ", ") "]"]; otherwise t - error("@pyobject/subsref: not implemented") + error ("@pyobject/subsref: not implemented") endswitch endfor r = pyeval (sprintf ("__InOct__['%s']%s", x.id, s));
--- a/octave_to_python.cc Wed Jul 20 11:39:23 2016 -0700 +++ b/octave_to_python.cc Wed Jul 20 11:57:14 2016 -0700 @@ -280,10 +280,9 @@ octmap_to_pyobject (py_object, octvalue.map_value ()); else if (octvalue.is_object ()) { octave_value_list tmp = feval ("getid", ovl (octvalue), 1); - std::string hexid = tmp(0).string_value(); - //std::cerr << "passed in hexid: " << hexid << std::endl; + std::string hexid = tmp(0).string_value (); // FIXME: added a messy ref to __InOct__ in __main__, find a better way - py_object = boost::python::import("__main__").attr("__InOct__")[hexid]; + py_object = boost::python::import ("__main__").attr ("__InOct__")[hexid]; } else throw value_convert_exception ( "Conversion from Octave value not implemented");
--- a/pyeval.cc Wed Jul 20 11:39:23 2016 -0700 +++ b/pyeval.cc Wed Jul 20 11:57:14 2016 -0700 @@ -82,7 +82,9 @@ { res = eval (code.c_str (), main_namespace, main_namespace); // hex(id(res)) - object idtmp = builtins_module.attr("hex")(builtins_module.attr("id")(res)); + object hex_function = builtins_module.attr ("hex"); + object id_function = builtins_module.attr ("id"); + object idtmp = hex_function (id_function (res)); id = extract<std::string> (idtmp); // FIXME: currently, we cannot return the raw object to octave...