From e4f8d0817ed2fe1029c973a994b6394cbc80c35c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Feb 2015 19:10:22 -0600 Subject: [PATCH 1/9] Streamline eval functions --- pymatbridge/matlab/matlabserver.m | 6 +-- pymatbridge/matlab/util/pymat_eval.m | 32 ++++++---------- pymatbridge/matlab/util/pymat_feval.m | 54 --------------------------- pymatbridge/pymatbridge.py | 9 +++-- pymatbridge/tests/test_functions.py | 2 + 5 files changed, 21 insertions(+), 82 deletions(-) delete mode 100644 pymatbridge/matlab/util/pymat_feval.m diff --git a/pymatbridge/matlab/matlabserver.m b/pymatbridge/matlab/matlabserver.m index 8fa7507..ca1d60b 100644 --- a/pymatbridge/matlab/matlabserver.m +++ b/pymatbridge/matlab/matlabserver.m @@ -19,11 +19,7 @@ function matlabserver(socket_address) clear mex; break; - case {'run_function'} - resp = pymat_feval(req); - messenger('respond', resp); - - case {'run_code'} + case {'run'} resp = pymat_eval(req); messenger('respond', resp); diff --git a/pymatbridge/matlab/util/pymat_eval.m b/pymatbridge/matlab/util/pymat_eval.m index 64d081b..8ccf280 100644 --- a/pymatbridge/matlab/util/pymat_eval.m +++ b/pymatbridge/matlab/util/pymat_eval.m @@ -12,30 +12,24 @@ % Based on Max Jaderberg's web_feval response.success = 'false'; -field_names = fieldnames(req); - response.content = ''; -code_check = false; -if size(field_names) - if isfield(req, 'code') - code_check = true; - end -end - -if ~code_check - response.message = 'No code provided as POST parameter'; - json_response = json_dump(response); - return; -end - -code = req.code; - try % tempname is less likely to get bonked by another process. diary_file = [tempname() '_diary.txt']; diary(diary_file); - evalin('base', code); + if strcmp(req.type, 'eval') + evalin('base', req.code); + response.content.code = code; + elseif strcmp(req.type, 'feval') + [resp{1:req.nargout}] = run_dot_m(req.func_path, req.func_args, ... + req.nargout); + if req.nargout == 1 + response.result = resp{1}; + else + response.result = resp; + end + end diary('off'); datadir = fullfile(tempdir(),'MatlabData'); @@ -68,8 +62,6 @@ response.content.stdout = ME.message; end -response.content.code = code; - json_response = json_dump(response); end %function diff --git a/pymatbridge/matlab/util/pymat_feval.m b/pymatbridge/matlab/util/pymat_feval.m deleted file mode 100644 index 8aef44b..0000000 --- a/pymatbridge/matlab/util/pymat_feval.m +++ /dev/null @@ -1,54 +0,0 @@ -% Max Jaderberg 2011 - -function json_response = pymat_feval(req) - - response.success = 'false'; - field_names = fieldnames(req); - - response.result = ''; - - func_path_check = false; - arguments_check = false; - if size(field_names) - if isfield(req, 'func_path') - func_path_check = true; - end - if isfield(req, 'func_args') - arguments_check = true; - end - end - - if ~func_path_check - response.message = 'No function given as func_path POST parameter'; - json_response = json_dump(response); - return - end - - func_path = req.func_path; - if arguments_check - arguments = req.func_args; - else - arguments = ''; - end - - try - [resp{1:req.nargout}] = run_dot_m(func_path, arguments, req.nargout); - catch ME - response.message = ME.message; - json_response = json_dump(response); - return - end - - if req.nargout == 1 - response.result = resp{1}; - else - response.result = resp; - end - response.success = 'true'; - response.message = 'Successfully completed request'; - - json_response = json_dump(response); - - return - -end diff --git a/pymatbridge/pymatbridge.py b/pymatbridge/pymatbridge.py index c69120e..5432df3 100644 --- a/pymatbridge/pymatbridge.py +++ b/pymatbridge/pymatbridge.py @@ -288,10 +288,13 @@ def run_func(self, func_path, *func_args, **kwargs): nargout = kwargs.pop('nargout', 1) func_args += tuple(item for pair in zip(kwargs.keys(), kwargs.values()) for item in pair) - return self._json_response(cmd='run_function', + if not func_args: + func_args = '' + return self._json_response(cmd='run', func_path=func_path, func_args=func_args, - nargout=nargout) + nargout=nargout, + type='feval') def run_code(self, code): """Run some code in Matlab command line provide by a string @@ -301,7 +304,7 @@ def run_code(self, code): code : str Code to send for evaluation. """ - return self._json_response(cmd='run_code', code=code) + return self._json_response(cmd='run', code=code, type='eval') def get_variable(self, varname, default=None): response = self._json_response(cmd='get_var', varname=varname) diff --git a/pymatbridge/tests/test_functions.py b/pymatbridge/tests/test_functions.py index 4fed51c..6942e1b 100644 --- a/pymatbridge/tests/test_functions.py +++ b/pymatbridge/tests/test_functions.py @@ -53,5 +53,7 @@ def test_create_func(self): def test_pass_kwargs(self): resp = self.mlab.run_func('plot', [1, 2, 3], Linewidth=3) assert resp['success'] == 'true' + assert len(resp['content']['figures']) resp = self.mlab.plot([1, 2, 3], Linewidth=3) assert resp['result'] is not None + assert len(resp['content']['figures']) From 5ddd221dbe378a871c1fd60d7d6cd66ac317ba68 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Feb 2015 19:12:28 -0600 Subject: [PATCH 2/9] Simplify func_args handling --- pymatbridge/pymatbridge.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pymatbridge/pymatbridge.py b/pymatbridge/pymatbridge.py index 5432df3..1f29574 100644 --- a/pymatbridge/pymatbridge.py +++ b/pymatbridge/pymatbridge.py @@ -288,11 +288,9 @@ def run_func(self, func_path, *func_args, **kwargs): nargout = kwargs.pop('nargout', 1) func_args += tuple(item for pair in zip(kwargs.keys(), kwargs.values()) for item in pair) - if not func_args: - func_args = '' return self._json_response(cmd='run', func_path=func_path, - func_args=func_args, + func_args=func_args or '', nargout=nargout, type='feval') From b4138b029a129313cdc6f976b3bb2dd813c8870d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Feb 2015 19:14:27 -0600 Subject: [PATCH 3/9] Clean up eval function --- pymatbridge/matlab/util/pymat_eval.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymatbridge/matlab/util/pymat_eval.m b/pymatbridge/matlab/util/pymat_eval.m index 8ccf280..9c01518 100644 --- a/pymatbridge/matlab/util/pymat_eval.m +++ b/pymatbridge/matlab/util/pymat_eval.m @@ -19,9 +19,10 @@ diary_file = [tempname() '_diary.txt']; diary(diary_file); if strcmp(req.type, 'eval') + response.content.code = req.code; evalin('base', req.code); - response.content.code = code; elseif strcmp(req.type, 'feval') + response.result = ''; [resp{1:req.nargout}] = run_dot_m(req.func_path, req.func_args, ... req.nargout); if req.nargout == 1 From bc26f327d090acff4818b44178b7f0e4dfd77176 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Feb 2015 19:26:30 -0600 Subject: [PATCH 4/9] Simplify command names --- pymatbridge/matlab/matlabserver.m | 2 +- pymatbridge/matlab/util/pymat_eval.m | 4 ++-- pymatbridge/pymatbridge.py | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pymatbridge/matlab/matlabserver.m b/pymatbridge/matlab/matlabserver.m index ca1d60b..17c05ea 100644 --- a/pymatbridge/matlab/matlabserver.m +++ b/pymatbridge/matlab/matlabserver.m @@ -19,7 +19,7 @@ function matlabserver(socket_address) clear mex; break; - case {'run'} + case {'eval, feval'} resp = pymat_eval(req); messenger('respond', resp); diff --git a/pymatbridge/matlab/util/pymat_eval.m b/pymatbridge/matlab/util/pymat_eval.m index 9c01518..6c18be4 100644 --- a/pymatbridge/matlab/util/pymat_eval.m +++ b/pymatbridge/matlab/util/pymat_eval.m @@ -18,10 +18,10 @@ % tempname is less likely to get bonked by another process. diary_file = [tempname() '_diary.txt']; diary(diary_file); - if strcmp(req.type, 'eval') + if strcmp(req.cmd, 'eval') response.content.code = req.code; evalin('base', req.code); - elseif strcmp(req.type, 'feval') + elseif strcmp(req.cmd, 'feval') response.result = ''; [resp{1:req.nargout}] = run_dot_m(req.func_path, req.func_args, ... req.nargout); diff --git a/pymatbridge/pymatbridge.py b/pymatbridge/pymatbridge.py index 1f29574..c0a5763 100644 --- a/pymatbridge/pymatbridge.py +++ b/pymatbridge/pymatbridge.py @@ -288,11 +288,10 @@ def run_func(self, func_path, *func_args, **kwargs): nargout = kwargs.pop('nargout', 1) func_args += tuple(item for pair in zip(kwargs.keys(), kwargs.values()) for item in pair) - return self._json_response(cmd='run', + return self._json_response(cmd='feval', func_path=func_path, func_args=func_args or '', - nargout=nargout, - type='feval') + nargout=nargout) def run_code(self, code): """Run some code in Matlab command line provide by a string @@ -302,7 +301,7 @@ def run_code(self, code): code : str Code to send for evaluation. """ - return self._json_response(cmd='run', code=code, type='eval') + return self._json_response(cmd='eval', code=code) def get_variable(self, varname, default=None): response = self._json_response(cmd='get_var', varname=varname) From 53ae6187abba918f3cc3df545855b9aafe1e600e Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Feb 2015 19:43:26 -0600 Subject: [PATCH 5/9] Fix matlabserver error --- pymatbridge/matlab/matlabserver.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymatbridge/matlab/matlabserver.m b/pymatbridge/matlab/matlabserver.m index 17c05ea..04906b6 100644 --- a/pymatbridge/matlab/matlabserver.m +++ b/pymatbridge/matlab/matlabserver.m @@ -19,7 +19,7 @@ function matlabserver(socket_address) clear mex; break; - case {'eval, feval'} + case {'eval', 'feval'} resp = pymat_eval(req); messenger('respond', resp); From 8b31f8e2f326fcb9baa3df3f94a75d9d84712680 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Feb 2015 21:36:15 -0600 Subject: [PATCH 6/9] Streamlime get_variable --- pymatbridge/matlab/matlabserver.m | 4 -- pymatbridge/matlab/util/pymat_get_variable.m | 43 -------------------- pymatbridge/pymatbridge.py | 6 ++- 3 files changed, 4 insertions(+), 49 deletions(-) delete mode 100644 pymatbridge/matlab/util/pymat_get_variable.m diff --git a/pymatbridge/matlab/matlabserver.m b/pymatbridge/matlab/matlabserver.m index 04906b6..de5cd21 100644 --- a/pymatbridge/matlab/matlabserver.m +++ b/pymatbridge/matlab/matlabserver.m @@ -23,10 +23,6 @@ function matlabserver(socket_address) resp = pymat_eval(req); messenger('respond', resp); - case {'get_var'} - resp = pymat_get_variable(req); - messenger('respond', resp); - otherwise messenger('respond', 'i dont know what you want'); end diff --git a/pymatbridge/matlab/util/pymat_get_variable.m b/pymatbridge/matlab/util/pymat_get_variable.m deleted file mode 100644 index 1b22952..0000000 --- a/pymatbridge/matlab/util/pymat_get_variable.m +++ /dev/null @@ -1,43 +0,0 @@ -function json_response = pymat_get_variable(req) -% Reach into the current namespace get a variable in json format that can -% be returned as part of a response - -response.success = 'false'; - -field_names = fieldnames(req); - -response.content = ''; - -varname_check = false; -if size(field_names) - if isfield(req, 'varname') - varname_check = true; - end -end - -if ~varname_check - response.message = 'No variable name provided as input argument'; - json_response = json_dump(response); - return -end - - -varname = req.varname; - - -% if the var doesn't exist in the workspace, inform adequately -expr = strcat('exist(''', varname, ''',''var'')'); -var_exists = evalin('base', expr); -if ~var_exists - response.exists = false; - response.var = ''; -else - response.exists = true; - response.var = evalin('base', varname); - response.success = 'true'; -end - -json_response = json_dump(response); - -return -end diff --git a/pymatbridge/pymatbridge.py b/pymatbridge/pymatbridge.py index c0a5763..d9bb936 100644 --- a/pymatbridge/pymatbridge.py +++ b/pymatbridge/pymatbridge.py @@ -304,8 +304,10 @@ def run_code(self, code): return self._json_response(cmd='eval', code=code) def get_variable(self, varname, default=None): - response = self._json_response(cmd='get_var', varname=varname) - return response['var'] if response['exists'] else default + response = self._json_response(cmd='feval', func_path='evalin', + func_args=('base', varname), + nargout=1) + return response['result'] if response['success'] == 'true' else default def set_variable(self, varname, value): if isinstance(value, spmatrix): From abae6b8ddfa1f09e43aaa7562662a53117ccbf83 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Feb 2015 21:45:05 -0600 Subject: [PATCH 7/9] Unify handling of set_variable --- pymatbridge/matlab/util/pymat_set_variable.m | 7 ------- pymatbridge/pymatbridge.py | 9 +++------ 2 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 pymatbridge/matlab/util/pymat_set_variable.m diff --git a/pymatbridge/matlab/util/pymat_set_variable.m b/pymatbridge/matlab/util/pymat_set_variable.m deleted file mode 100644 index e3936f4..0000000 --- a/pymatbridge/matlab/util/pymat_set_variable.m +++ /dev/null @@ -1,7 +0,0 @@ -function res = pymat_set_variable(args) -% Setup a variable in Matlab workspace - - assignin('base', args.name, args.value); - res = 1; - -end %function diff --git a/pymatbridge/pymatbridge.py b/pymatbridge/pymatbridge.py index d9bb936..d28786c 100644 --- a/pymatbridge/pymatbridge.py +++ b/pymatbridge/pymatbridge.py @@ -304,16 +304,13 @@ def run_code(self, code): return self._json_response(cmd='eval', code=code) def get_variable(self, varname, default=None): - response = self._json_response(cmd='feval', func_path='evalin', - func_args=('base', varname), - nargout=1) - return response['result'] if response['success'] == 'true' else default + resp = self.run_func('evalin', 'base', varname) + return resp['result'] if resp['success'] == 'true' else default def set_variable(self, varname, value): if isinstance(value, spmatrix): return self._set_sparse_variable(varname, value) - return self.run_func('pymat_set_variable.m', - {'name': varname, 'value': value}) + return self.run_func('assignin', 'base', varname, value, nargout=0) def set_default_plot_size(self, width=512, height=384): code = "set(0, 'defaultfigurepaperunits', 'inches');\n" From 8fd9f8f042eded46892a28c2ef8172e6fcafac61 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 17 Feb 2015 21:58:33 -0600 Subject: [PATCH 8/9] Use booleans for success attribute --- pymatbridge/matlab/util/pymat_eval.m | 8 +++----- pymatbridge/matlab_magic.py | 4 ++-- pymatbridge/pymatbridge.py | 6 +++--- pymatbridge/tests/test_functions.py | 2 +- pymatbridge/tests/test_run_code.py | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/pymatbridge/matlab/util/pymat_eval.m b/pymatbridge/matlab/util/pymat_eval.m index 6c18be4..681a2ff 100644 --- a/pymatbridge/matlab/util/pymat_eval.m +++ b/pymatbridge/matlab/util/pymat_eval.m @@ -11,7 +11,7 @@ % % Based on Max Jaderberg's web_feval -response.success = 'false'; +response.success = true; response.content = ''; try @@ -40,8 +40,6 @@ end fig_files = make_figs(datadir); - - response.success = 'true'; response.content.figures = fig_files; % this will not work on Windows: @@ -53,13 +51,13 @@ fclose(FID); response.content.stdout = stdout; else - response.success = 'false'; + response.success = false; response.content.stdout = sprintf('could not open %s for read',diary_file); end delete(diary_file) catch ME diary('off'); - response.success = 'false'; + response.success = false; response.content.stdout = ME.message; end diff --git a/pymatbridge/matlab_magic.py b/pymatbridge/matlab_magic.py index f8b441e..17debc8 100644 --- a/pymatbridge/matlab_magic.py +++ b/pymatbridge/matlab_magic.py @@ -93,7 +93,7 @@ def eval(self, line): """ run_dict = self.Matlab.run_code(line) - if run_dict['success'] == 'false': + if not run_dict['success']: raise MatlabInterperterError(line, run_dict['content']['stdout']) # This is the matlab stdout: @@ -105,7 +105,7 @@ def set_matlab_var(self, name, value): """ run_dict = self.Matlab.set_variable(name, value) - if run_dict['success'] == 'false': + if not run_dict['success']: raise MatlabInterperterError(line, run_dict['content']['stdout']) diff --git a/pymatbridge/pymatbridge.py b/pymatbridge/pymatbridge.py index d28786c..94e9eb3 100644 --- a/pymatbridge/pymatbridge.py +++ b/pymatbridge/pymatbridge.py @@ -15,7 +15,7 @@ .MATLAB started and connected! True >>> m.run_code('a=1;') -{'content': {'stdout': '', 'datadir': '/private/tmp/MatlabData/', 'code': 'a=1;', 'figures': []}, 'success': 'true'} +{'content': {'stdout': '', 'datadir': '/private/tmp/MatlabData/', 'code': 'a=1;', 'figures': []}, 'success': True} >>> m.get_variable('a') 1 @@ -260,7 +260,7 @@ def is_connected(self): def is_function_processor_working(self): result = self.run_func('%s/usrprog/test_sum.m' % MATLAB_FOLDER, {'echo': '%s: Function processor is working!' % self._program_name()}) - return result['success'] == 'true' + return result['success'] def _json_response(self, **kwargs): return json.loads(self._response(**kwargs), object_hook=decode_pymat) @@ -305,7 +305,7 @@ def run_code(self, code): def get_variable(self, varname, default=None): resp = self.run_func('evalin', 'base', varname) - return resp['result'] if resp['success'] == 'true' else default + return resp['result'] if resp['success'] else default def set_variable(self, varname, value): if isinstance(value, spmatrix): diff --git a/pymatbridge/tests/test_functions.py b/pymatbridge/tests/test_functions.py index 6942e1b..e0367fc 100644 --- a/pymatbridge/tests/test_functions.py +++ b/pymatbridge/tests/test_functions.py @@ -52,7 +52,7 @@ def test_create_func(self): def test_pass_kwargs(self): resp = self.mlab.run_func('plot', [1, 2, 3], Linewidth=3) - assert resp['success'] == 'true' + assert resp['success'] assert len(resp['content']['figures']) resp = self.mlab.plot([1, 2, 3], Linewidth=3) assert resp['result'] is not None diff --git a/pymatbridge/tests/test_run_code.py b/pymatbridge/tests/test_run_code.py index abd903e..816f3b2 100644 --- a/pymatbridge/tests/test_run_code.py +++ b/pymatbridge/tests/test_run_code.py @@ -59,7 +59,7 @@ def test_undefined_code(self): success = self.mlab.run_code("this_is_nonsense")['success'] message = self.mlab.run_code("this_is_nonsense")['content']['stdout'] - npt.assert_equal(success, "false") + assert not success if tu.on_octave(): npt.assert_equal(message, "'this_is_nonsense' undefined near line 1 column 1") else: From 06852026e943ff2d8a2d2778758de351fe3c9f28 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 18 Feb 2015 10:31:29 -0600 Subject: [PATCH 9/9] Trim down to a single eval method on both ends --- pymatbridge/matlab/matlabserver.m | 2 +- pymatbridge/matlab/util/pymat_eval.m | 32 +++++++++++++++++----------- pymatbridge/matlab/util/run_dot_m.m | 30 -------------------------- pymatbridge/pymatbridge.py | 12 ++++++++--- 4 files changed, 29 insertions(+), 47 deletions(-) delete mode 100644 pymatbridge/matlab/util/run_dot_m.m diff --git a/pymatbridge/matlab/matlabserver.m b/pymatbridge/matlab/matlabserver.m index de5cd21..3337b1e 100644 --- a/pymatbridge/matlab/matlabserver.m +++ b/pymatbridge/matlab/matlabserver.m @@ -19,7 +19,7 @@ function matlabserver(socket_address) clear mex; break; - case {'eval', 'feval'} + case {'eval'} resp = pymat_eval(req); messenger('respond', resp); diff --git a/pymatbridge/matlab/util/pymat_eval.m b/pymatbridge/matlab/util/pymat_eval.m index 681a2ff..60912b2 100644 --- a/pymatbridge/matlab/util/pymat_eval.m +++ b/pymatbridge/matlab/util/pymat_eval.m @@ -13,24 +13,30 @@ response.success = true; response.content = ''; +response.result = ''; try % tempname is less likely to get bonked by another process. diary_file = [tempname() '_diary.txt']; diary(diary_file); - if strcmp(req.cmd, 'eval') - response.content.code = req.code; - evalin('base', req.code); - elseif strcmp(req.cmd, 'feval') - response.result = ''; - [resp{1:req.nargout}] = run_dot_m(req.func_path, req.func_args, ... - req.nargout); - if req.nargout == 1 - response.result = resp{1}; - else - response.result = resp; - end - end + + % Add function path to current path + if req.dname + addpath(req.dname); + end + + if iscell(req.func_args) + [resp{1:req.nargout}] = feval(req.func_name, req.func_args{:}); + else + [resp{1:req.nargout}] = feval(req.func_name, req.func_args); + end + + if req.nargout == 1 + response.result = resp{1}; + else + response.result = resp; + end + diary('off'); datadir = fullfile(tempdir(),'MatlabData'); diff --git a/pymatbridge/matlab/util/run_dot_m.m b/pymatbridge/matlab/util/run_dot_m.m deleted file mode 100644 index e60aeac..0000000 --- a/pymatbridge/matlab/util/run_dot_m.m +++ /dev/null @@ -1,30 +0,0 @@ -% Max Jaderberg 2011 - -function varargout = run_dot_m( func_to_run, arguments, nout ) -%RUN_DOT_M Runs the given function or .m file with the arguments given -% and the nout selected -% For exmaple run_dot_m('/path/to/function.m', args, 1); -% arguments can be a scalar, as cell, or struct containing the arguments. -% If it is a struct, func_to_run must take only one parameter, the argument structure - - [dname, func_name, ext] = fileparts(func_to_run); - - if size(ext) - if ~strcmp(ext, '.m') - varargout = 'Error: Need to give path to .m file'; - return - end - end - - % Add function path to current path - if size(dname) - addpath(dname); - end - - if iscell(arguments) - [varargout{1:nout}] = feval(func_name, arguments{:}); - else - [varargout{1:nout}] = feval(func_name, arguments); - end - -end diff --git a/pymatbridge/pymatbridge.py b/pymatbridge/pymatbridge.py index 94e9eb3..ea2da87 100644 --- a/pymatbridge/pymatbridge.py +++ b/pymatbridge/pymatbridge.py @@ -288,9 +288,15 @@ def run_func(self, func_path, *func_args, **kwargs): nargout = kwargs.pop('nargout', 1) func_args += tuple(item for pair in zip(kwargs.keys(), kwargs.values()) for item in pair) - return self._json_response(cmd='feval', - func_path=func_path, + dname = os.path.dirname(func_path) + fname = os.path.basename(func_path) + func_name, ext = os.path.splitext(fname) + if ext and not ext == '.m': + raise TypeError('Need to give path to .m file') + return self._json_response(cmd='eval', + func_name=func_name, func_args=func_args or '', + dname=dname, nargout=nargout) def run_code(self, code): @@ -301,7 +307,7 @@ def run_code(self, code): code : str Code to send for evaluation. """ - return self._json_response(cmd='eval', code=code) + return self.run_func('evalin', 'base', code, nargout=0) def get_variable(self, varname, default=None): resp = self.run_func('evalin', 'base', varname)