Need test run in Matlab

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Need test run in Matlab

John W. Eaton
Administrator
Could someone please run some tests in a current version of Matlab for
the functions contained in the attached tar file?

1. Unpack the tar file.  This will create a directory called test-files.

2. In Matlab, cd to that directory and execute the following function calls:

   f1 ()
   f2 ()
   f3 ()
   f3 (2)

and report the output from each here.  I'm trying to understand what
happens when eval parses code that may look like a command or an
expression.  According to the current tests for Octave, we expect the
results above to be 0, 0, cell array of strings, and 0 but I'm not sure
whether that is correct.

Thanks,

jwe

test-files.tar.gz (562 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

Michele Ginesi
Dear jwe,

I attach the resulting diary.

Bests

Michele

On 1/28/19 8:45 PM, John W. Eaton wrote:

> Could someone please run some tests in a current version of Matlab for
> the functions contained in the attached tar file?
>
> 1. Unpack the tar file.  This will create a directory called test-files.
>
> 2. In Matlab, cd to that directory and execute the following function
> calls:
>
>   f1 ()
>   f2 ()
>   f3 ()
>   f3 (2)
>
> and report the output from each here.  I'm trying to understand what
> happens when eval parses code that may look like a command or an
> expression.  According to the current tests for Octave, we expect the
> results above to be 0, 0, cell array of strings, and 0 but I'm not
> sure whether that is correct.
>
> Thanks,
>
> jwe

test-files (978 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

John W. Eaton
Administrator
On 1/28/19 4:03 PM, Michele wrote:
> Dear jwe,
>
> I attach the resulting diary.

Thanks.  Unfortunately, those tests may not have been the right ones to
run to answer my questions.  I'm trying to figure out when eval will
parse something like

   eval ("foo -opt")

as an expression (subtract the value of opt from foo) or as a command
(call the function foo with the character string argument "-opt").  It
seems as though eval may never evaluate its argument as a command-style
function call if it is called with an output value:

   val = eval ("foo -opt")

Is that correct?  I suppose this would be similar to writing

   val = foo -opt

in which case the "foo -opt" part is not recognized as a command-style
function call because that can only happen at the beginning of an
expression.

Also the idea of the test like this:

   function f (foo)
     eval ("foo -opt")
   end
   f ()
   f (1)

was to determine whether the mere existence of a symbol was sufficient
for eval to treat this as a subtraction or is it necessary for the
function parameter "foo" to be defined?

Also, is this different without the eval?  What happens for something like

   function f (foo)
     foo -opt
   end

Is this always handled as a subtraction or does it depend on whether f
is called with an argument?

In both cases, I'm assuming the function "foo" exists.

I'll try to come up with another set of tests.

jwe

Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

John W. Eaton
Administrator
I'm attaching another set of tests.  This time there is just one script
to execute:

1. Unpack the tar file.  This will create a directory called test-files.

2. In Matlab, cd to that directory and execute

      test_script

    to run the tests.

Please report the output here.

Thanks,

jwe


On 1/29/19 10:15 AM, John W. Eaton wrote:

> On 1/28/19 4:03 PM, Michele wrote:
>> Dear jwe,
>>
>> I attach the resulting diary.
>
> Thanks.  Unfortunately, those tests may not have been the right ones to
> run to answer my questions.  I'm trying to figure out when eval will
> parse something like
>
>    eval ("foo -opt")
>
> as an expression (subtract the value of opt from foo) or as a command
> (call the function foo with the character string argument "-opt").  It
> seems as though eval may never evaluate its argument as a command-style
> function call if it is called with an output value:
>
>    val = eval ("foo -opt")
>
> Is that correct?  I suppose this would be similar to writing
>
>    val = foo -opt
>
> in which case the "foo -opt" part is not recognized as a command-style
> function call because that can only happen at the beginning of an
> expression.
>
> Also the idea of the test like this:
>
>    function f (foo)
>      eval ("foo -opt")
>    end
>    f ()
>    f (1)
>
> was to determine whether the mere existence of a symbol was sufficient
> for eval to treat this as a subtraction or is it necessary for the
> function parameter "foo" to be defined?
>
> Also, is this different without the eval?  What happens for something like
>
>    function f (foo)
>      foo -opt
>    end
>
> Is this always handled as a subtraction or does it depend on whether f
> is called with an argument?
>
> In both cases, I'm assuming the function "foo" exists.
>
> I'll try to come up with another set of tests.
>
> jwe
>


test-files.tar.gz (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

himpe
Dear John,

attached is a text file with the requested MATLAB output.

Cheers

Christian

On Tue, 29 Jan 2019 12:07:04 -0500
"John W. Eaton" <[hidden email]> wrote:

> I'm attaching another set of tests.  This time there is just one
> script to execute:
>
> 1. Unpack the tar file.  This will create a directory called
> test-files.
>
> 2. In Matlab, cd to that directory and execute
>
>       test_script
>
>     to run the tests.
>
> Please report the output here.
>
> Thanks,
>
> jwe
>
>
> On 1/29/19 10:15 AM, John W. Eaton wrote:
> > On 1/28/19 4:03 PM, Michele wrote:  
> >> Dear jwe,
> >>
> >> I attach the resulting diary.  
> >
> > Thanks.  Unfortunately, those tests may not have been the right
> > ones to run to answer my questions.  I'm trying to figure out when
> > eval will parse something like
> >
> >    eval ("foo -opt")
> >
> > as an expression (subtract the value of opt from foo) or as a
> > command (call the function foo with the character string argument
> > "-opt").  It seems as though eval may never evaluate its argument
> > as a command-style function call if it is called with an output
> > value:
> >
> >    val = eval ("foo -opt")
> >
> > Is that correct?  I suppose this would be similar to writing
> >
> >    val = foo -opt
> >
> > in which case the "foo -opt" part is not recognized as a
> > command-style function call because that can only happen at the
> > beginning of an expression.
> >
> > Also the idea of the test like this:
> >
> >    function f (foo)
> >      eval ("foo -opt")
> >    end
> >    f ()
> >    f (1)
> >
> > was to determine whether the mere existence of a symbol was
> > sufficient for eval to treat this as a subtraction or is it
> > necessary for the function parameter "foo" to be defined?
> >
> > Also, is this different without the eval?  What happens for
> > something like
> >
> >    function f (foo)
> >      foo -opt
> >    end
> >
> > Is this always handled as a subtraction or does it depend on
> > whether f is called with an argument?
> >
> > In both cases, I'm assuming the function "foo" exists.
> >
> > I'll try to come up with another set of tests.
> >
> > jwe
> >  
>

matlab2018a_output.txt (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

John W. Eaton
Administrator
On 1/29/19 2:26 PM, Christian Himpe wrote:
> Dear John,
>
> attached is a text file with the requested MATLAB output.

Oops, I accidentally left "endif" and "endfunction" in one of the files.

Could someone try the attached version instead?  With some luck, there
won't be other mistakes.

Sorry for the trouble.

jwe


test-files.tar.gz (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

himpe
Here is the output of the corrected script.

Best

Christian

On Tue, 29 Jan 2019 14:35:29 -0500
"John W. Eaton" <[hidden email]> wrote:

> On 1/29/19 2:26 PM, Christian Himpe wrote:
> > Dear John,
> >
> > attached is a text file with the requested MATLAB output.  
>
> Oops, I accidentally left "endif" and "endfunction" in one of the
> files.
>
> Could someone try the attached version instead?  With some luck,
> there won't be other mistakes.
>
> Sorry for the trouble.
>
> jwe
>


matlab2018a_output.txt (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

John W. Eaton
Administrator
On 1/29/19 2:39 PM, Christian Himpe wrote:
> Here is the output of the corrected script.

Thanks!

jwe

Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

John W. Eaton
Administrator
In reply to this post by himpe
On 1/29/19 2:39 PM, Christian Himpe wrote:
> Here is the output of the corrected script.

Thanks.

I'm a bit confused by these results.  Maybe I'm missing something, but I
don't understand the case of f3(1), which shows that "sigma -1" is
evaluated as a command.  Compare this with f1(), which fails when there
is a variable in the local workspace that conflicts with the name of the
function (sigma).  How does that make sense?

Functions:

function f1 ()
   sigma = svd (1);
   eval ('sigma -1;');
end

function f3 (sigma)
   eval ('sigma -1;');
end

function r = sigma (opt)
   global sigma_call;
   if (nargin == 0)
     sigma_call = 'function';
     r = 1;
   elseif (ischar (opt))
     sigma_call = 'command';
     r = 1;
   else
     sigma_call = 'unexpected';
   end
end

Output you sent for calling f1() and f3(1):

f1: error: Error using f1 (line 3)
Error: "sigma" was previously used as a variable, conflicting with its
use here as the name of a function or command.
See "How MATLAB Recognizes Command Syntax" in the MATLAB documentation
for details.
f1 (): none

f3 (1): command

Here are the functions:

function f1 ()
   sigma = svd (1);
   eval ('sigma -1;');
end

function f3 (sigma)
   eval ('sigma -1;');
end

function r = sigma (opt)
   global sigma_call;
   if (nargin == 0)
     sigma_call = 'function';
     r = 1;
   elseif (ischar (opt))
     sigma_call = 'command';
     r = 1;
   else
     sigma_call = 'unexpected';
   end
end

Why should f3(1) succeed in calling sigma as a command-style function
when f1() fails with an error message about sigma defined as a variable
and later being used as a command-style function?  Isn't sigma defined
as a variable in both cases prior to the use as a function?

jwe


Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

apjanke-floss


On 1/31/19 3:05 PM, John W. Eaton wrote:

> On 1/29/19 2:39 PM, Christian Himpe wrote:
>> Here is the output of the corrected script.
>
> Thanks.
>
> I'm a bit confused by these results.  Maybe I'm missing something, but I
> don't understand the case of f3(1), which shows that "sigma -1" is
> evaluated as a command.  Compare this with f1(), which fails when there
> is a variable in the local workspace that conflicts with the name of the
> function (sigma).  How does that make sense?
>
> Functions:
>
> function f1 ()
>   sigma = svd (1);
>   eval ('sigma -1;');
> end
>
> function f3 (sigma)
>   eval ('sigma -1;');
> end
>
> function r = sigma (opt)
>   global sigma_call;
>   if (nargin == 0)
>     sigma_call = 'function';
>     r = 1;
>   elseif (ischar (opt))
>     sigma_call = 'command';
>     r = 1;
>   else
>     sigma_call = 'unexpected';
>   end
> end
>
> Output you sent for calling f1() and f3(1):
>
> f1: error: Error using f1 (line 3)
> Error: "sigma" was previously used as a variable, conflicting with its
> use here as the name of a function or command.
> See "How MATLAB Recognizes Command Syntax" in the MATLAB documentation
> for details.
> f1 (): none
>
> f3 (1): command
>
> Here are the functions:
>
> function f1 ()
>   sigma = svd (1);
>   eval ('sigma -1;');
> end
>
> function f3 (sigma)
>   eval ('sigma -1;');
> end
>
> function r = sigma (opt)
>   global sigma_call;
>   if (nargin == 0)
>     sigma_call = 'function';
>     r = 1;
>   elseif (ischar (opt))
>     sigma_call = 'command';
>     r = 1;
>   else
>     sigma_call = 'unexpected';
>   end
> end
>
> Why should f3(1) succeed in calling sigma as a command-style function
> when f1() fails with an error message about sigma defined as a variable
> and later being used as a command-style function?  Isn't sigma defined
> as a variable in both cases prior to the use as a function?
>
> jwe
>

I've got nothing. It's a surprise to me that f3(1) is not erroring. I
know that's not very helpful, but at least you're not overlooking
anything obvious as far as I can tell.

Cheers,
Andrew

Reply | Threaded
Open this post in threaded view
|

Re: Need test run in Matlab

nrjank

On Fri, Feb 1, 2019 at 6:05 AM Andrew Janke <[hidden email]> wrote:


On 1/31/19 3:05 PM, John W. Eaton wrote:
> On 1/29/19 2:39 PM, Christian Himpe wrote:
>> Here is the output of the corrected script.
>
> Thanks.
>
> I'm a bit confused by these results.  Maybe I'm missing something, but I
> don't understand the case of f3(1), which shows that "sigma -1" is
> evaluated as a command.  Compare this with f1(), which fails when there
> is a variable in the local workspace that conflicts with the name of the
> function (sigma).  How does that make sense?
>
> Functions:
>
> function f1 ()
>   sigma = svd (1);
>   eval ('sigma -1;');
> end
>
> function f3 (sigma)
>   eval ('sigma -1;');
> end
>
> function r = sigma (opt)
>   global sigma_call;
>   if (nargin == 0)
>     sigma_call = 'function';
>     r = 1;
>   elseif (ischar (opt))
>     sigma_call = 'command';
>     r = 1;
>   else
>     sigma_call = 'unexpected';
>   end
> end
>
> Output you sent for calling f1() and f3(1):
>
> f1: error: Error using f1 (line 3)
> Error: "sigma" was previously used as a variable, conflicting with its
> use here as the name of a function or command.
> See "How MATLAB Recognizes Command Syntax" in the MATLAB documentation
> for details.
> f1 (): none
>
> f3 (1): command
>
> Here are the functions:
>
> function f1 ()
>   sigma = svd (1);
>   eval ('sigma -1;');
> end
>
> function f3 (sigma)
>   eval ('sigma -1;');
> end
>
> function r = sigma (opt)
>   global sigma_call;
>   if (nargin == 0)
>     sigma_call = 'function';
>     r = 1;
>   elseif (ischar (opt))
>     sigma_call = 'command';
>     r = 1;
>   else
>     sigma_call = 'unexpected';
>   end
> end
>
> Why should f3(1) succeed in calling sigma as a command-style function
> when f1() fails with an error message about sigma defined as a variable
> and later being used as a command-style function?  Isn't sigma defined
> as a variable in both cases prior to the use as a function?
>
> jwe
>

I've got nothing. It's a surprise to me that f3(1) is not erroring. I
know that's not very helpful, but at least you're not overlooking
anything obvious as far as I can tell.

Cheers,
Andrew



would it be helpful to step through any of those or similar tests and report back any particular details from different scopes?