bugGNU Octave - Bugs: bug #63135, [octave forge] (optim) Optim...

 
 

bug #63135: [octave forge] (optim) Optim package does not find function handle

Submitter:  Mark van Rossum <cosine>
Submitted:  Thu 29 Sep 2022 02:15:11 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 6.4.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 09 Jul 2023 12:15:24 PM UTC, comment #3: 
Olaf Till <i7tiol>
Group Member
Tue 08 Nov 2022 01:38:30 AM UTC, comment #2: 

To add further, it works also if the function is called from another function.

function a()
...
learsq(x,y,p,fitfunc,...)
...
end

function [y]=fitfunc(k,l)
 y=k+l;
end

in the same file works.


function [y]=fitfunc(k,l)
 y=k+l;
end

learsq(x,y,p,@fitfunc,...)

does not.

Markus Pristovsek <prissi>
Mon 03 Oct 2022 06:42:59 PM UTC, comment #1: 

Not sure why the change in behavior happened, but I can get the intended behavior to show up by changing the last line to use an anonymous function:

pkg load optim
function y = fitfun2(p,x)
   y=p(1)+p(2)*x;
end

x=rand(1,5); y=rand(1,5);
pinit=[0.1,0.1]';
[pfound]= nonlin_curvefit(@(a,b) fitfun2(a,b), pinit, x,y)
pfound =

   0.6634
  -0.2519


Leaving this report open in case this change in behavior was not intended.

Arun Giridhar <arungiridhar>
Group Member
Thu 29 Sep 2022 02:15:11 PM UTC, original submission:  

Hi

In optim 1.6.2 (but not in 1.6.1), nonlin_curvefit can not find function handles that are defined in the file itself.
It can only find function that are defined in separate files.

Optim 1.6.2 thus breaks previous functionality.

Example:

pkg load optim
function y = fitfun2(p,x)
   y=p(1)+p(2)*x;
end

x=rand(1,5); y=rand(1,5);
pinit=[0.1,0.1]';
[pfound]= nonlin_curvefit(@fitfun2, pinit, x,y)


This is with Octav 6.4.0.
As said, optim 1.6.1 works fine.

Mark van Rossum <cosine>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by i7tiol (Posted a comment)
  • -email is unavailable- added by prissi (Posted a comment)
  • -email is unavailable- added by arungiridhar (Updated the item)
  • -email is unavailable- added by arungiridhar
  • -email is unavailable- added by cosine (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-07-09 i7tiol StatusNone Fixed
        Open/ClosedOpen Closed
    2022-09-29 arungiridhar SummaryOptim package does not find function handle [octave forge] (optim) Optim package does not find function handle
        Carbon-Copy- Added i7tiol

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code