Skip to content
Snippets Groups Projects
Commit 1391c4ef authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Fix user_has_octave_forge_package

Packages are no longer autoloaded, so testing whether they are "Loaded" does
not work in all cases.

The function now ensures that the package is loaded.

(cherry picked from commit 7cbac0c9)
parent 02f87ad2
Branches
Tags
No related merge requests found
......@@ -135,11 +135,7 @@ switch minimizer_algorithm
simulated_annealing(objective_function,start_par_value,sa_options,LB,UB,varargin{:});
case 3
if isoctave && ~user_has_octave_forge_package('optim')
try
pkg load optim
catch
error('Optimization algorithm 3 requires the optim package')
end
error('Optimization algorithm 3 requires the optim package')
elseif ~isoctave && ~user_has_matlab_license('optimization_toolbox')
error('Optimization algorithm 3 requires the Optimization Toolbox')
end
......
......@@ -20,4 +20,11 @@ function [hasPackage] = user_has_octave_forge_package(package)
[desc,flag] = pkg('describe', package);
hasPackage = isequal(flag{1,1}, 'Loaded');
if isequal(flag{1,1}, 'Not installed')
hasPackage = 0;
else
if isequal(flag{1,1}, 'Not loaded')
pkg('load', package);
end
hasPackage = 1;
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment