bugGNU Octave - Bugs: bug #46004, ezplot fails to recognise...

 
 

bug #46004: ezplot fails to recognise functions with 2 arguments passed as handles

Submitted by:  Tasos Papastylianou <tpapastylianou>
Submitted on:  Sun 20 Sep 2015 12:07:16 AM UTC  
 
Category: PlottingSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Tasos Papastylianou <tpapastylianou>Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Tue 22 Sep 2015 11:19:08 AM UTC, comment #6:

This turned out to be quite an involved fix. I simplified 1/3rd of the input processing for _ezplot_ and also fixed this issue on the stable branch in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/c0566df8cde3). It will be a part of the next minor bug fix release (4.0.1).

Rik <rik5>
Project Administrator
Mon 21 Sep 2015 11:37:41 PM UTC, comment #5:

(sorry, just pointing out the bulk of my previous comment has been eaten up at savannah.gnu.org ... though it appears in full on email. Not sure why this happens)

Tasos Papastylianou <tpapastylianou>
Mon 21 Sep 2015 11:32:51 PM UTC, comment #4:

Hi Rik. Thanks for the explanation about nargin; I wasn't aware of this substitution.
I can confirm that

in __ezplot.m__ (placed under line 135) works as expected and fixes the bug.

Tasos Papastylianou <tpapastylianou>
Mon 21 Sep 2015 08:49:15 PM UTC, comment #3:

Which plot is considered the correct one?

or

The reason

doesn't work is that nargin has been declared as a variable which shadows the function declaration. You can always use builtin() to recover the original function.

Rik <rik5>
Project Administrator
Sun 20 Sep 2015 01:55:55 PM UTC, comment #2:

Thanks, Mike! You're right about the caller workspace. This will allow handles to subfunctions to also work.
As for handles to nested functions, octave complains that these are not implemented yet, but in theory when they do, the fix should work for those too.

Also, somewhat less ugly-looking fix. Under line 135 of _ezplot_.m insert:
(in theory, if nargin(fun) == 2 should have worked too since fun was instantiated from varargin{1}, but this produces an error ... don't know why, but let's not waste time figuring out why)

To test:

  • in file Bar.m
  • at the console

Note: For some reason when fixing _ezplot_.m you need to restart octave for the fix to take effect.
Not sure why, presumably private functions are preloaded in memory or sth?
Just pointing this out in case someone tries the fix and runs without restarting and thinks the fix doesn't work.

Tasos Papastylianou <tpapastylianou>
Sun 20 Sep 2015 01:10:27 AM UTC, comment #1:

Confirmed here, thanks for finding this. The equivalent works for me with an anonymous function, a literal string "a-b", a string "f" that evaluates your user function f, or a handle to an anonymous or call to inline(). But not with the case of a handle to a two-argument user function. Have not tried the proposed fix yet. Should the evalin be "caller" instead of "base"? That might cover the case of a function that calls ezplot on a nested function?

Mike Miller <mtmiller>
Project Administrator
Sun 20 Sep 2015 12:07:16 AM UTC, original submission:

To replicate:

Create a function f.m

Then at the terminal, compare:

with:

The results should be the same, but they're not. Octave treats the function as a single argument function.
(The two commands give the same output in Matlab as expected)

The error lies in line 135 of private function _ezplot_.m, which is called by ezplot.m
This assumes erroneously that if the function handle passed in is not an anonymous function, then it must necessarily come from a function with a single argument; clearly this neglects functions with two arguments which are also valid input for ezplot.

Suggested fix:
Add the following line below line 135:

Many thanks,
T.

Tasos Papastylianou <tpapastylianou>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by tpapastylianou (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 22 Sep 2015 11:19:08 AM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Sun 20 Sep 2015 01:10:27 AM UTCmtmillerStatusNone=>Confirmed
      Release4.0.0=>dev

    Back to the top


    Powered by Savane 3.1-cleanup1