Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
acp29 committed Jul 15, 2022
1 parent 48fa6d3 commit 53193b9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 27 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: iboot
version: 4.1.0
date: 2022-07-14
version: 4.1.1
date: 2022-07-15
author: Andrew Penn <andy.c.penn@gmail.com>
maintainer: Andrew Penn <andy.c.penn@gmail.com>
title: A statistics package with a variety of bootstrap resampling tools
Expand Down
53 changes: 29 additions & 24 deletions inst/bootknife.m
Original file line number Diff line number Diff line change
Expand Up @@ -271,37 +271,42 @@
% If applicable, setup a parallel pool
if ~isoctave
% MATLAB
if ~vectorized
% bootfun is not vectorized
if (ncpus > 0)
% MANUAL
try
pool = gcp ('nocreate');
if isempty (pool)
% bootfun is not vectorized
if (ncpus > 0)
% MANUAL
try
pool = gcp ('nocreate');
if isempty (pool)
if (ncpus > 1)
% Start parallel pool with ncpus workers
parpool (ncpus);
else
% Parallel pool is not running and ncpus is 1 so run function evaluations in serial
ncpus = 1;
end
else
if (pool.NumWorkers ~= ncpus)
% Check if number of workers matches ncpus and correct it accordingly if not
delete (pool);
if (ncpus > 1)
% Start parallel pool with ncpus workers
parpool (ncpus);
else
% Parallel pool is not running and ncpus is 1 so run function evaluations in serial
ncpus = 1;
end
else
if (pool.NumWorkers ~= ncpus)
% Check if number of workers matches ncpus and correct it accordingly if not
delete (pool);
if (ncpus > 1)
parpool (ncpus);
end
end
end
catch
% Parallel toolbox not installed, run function evaluations in serial
ncpus = 1;
end
catch
% MATLAB Parallel Computing Toolbox is not installed
warning('MATLAB Parallel Computing Toolbox is not installed. Falling back to serial processing.')
ncpus = 1;
end
end
else
if (ncpus > 1) && ~isparallel
% OCTAVE Parallel Computing Package is not installed or loaded
warning('OCTAVE Parallel Computing Package is not installed and/or loaded. Falling back to serial processing.')
ncpus = 1;
end
end

% If the function of the data is a vector, calculate the statistics for each element
m = numel(T0);
if m > 1
Expand Down Expand Up @@ -451,7 +456,7 @@
else
% MATLAB
T = zeros (n, 1);
parfor i = 1:n; T(i) = jackfun(i); end
parfor i = 1:n; T(i) = feval(jackfun,i); end
end
else
% SERIAL evaluation of bootfun on each jackknife resample
Expand Down
11 changes: 10 additions & 1 deletion inst/bootnhst.m
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,9 @@
end
end
catch
% Parallel toolbox not installed, run function evaluations in serial
% MATLAB Parallel Computing Toolbox is not installed
warning('MATLAB Parallel Computing Toolbox is not installed. Falling back to serial processing.')
paropt.UseParallel = false;
paropt.nproc = 1;
end
else
Expand All @@ -986,6 +988,13 @@
end
end
end
else
if paropt.UseParallel && (paropt.nproc > 1) && ~isparallel
% OCTAVE Parallel Computing Package is not installed or loaded
warning('OCTAVE Parallel Computing Package is not installed and/or loaded. Falling back to serial processing.')
paropt.UseParallel = false;
paropt.nproc = 1;
end
end

% Define a function to calculate maxT
Expand Down

0 comments on commit 53193b9

Please sign in to comment.