New statistics-bootstrap package

Hi there,

I have:

  1. forked my iboot repo and renamed it bootstrap,
  2. added the files and folders from pkg-example,
  3. put the files and folders of all the m-files from iboot into the src directory
  4. edited the README.md and DESCRIPTION files

I must be missing something though because in Octave when I run pkg install I’m getting a failed download error:

octave:7> pkg install “https://github.com/gnu-octave/bootstrap/archive/main.zip
error: pkg: failed downloading ‘https://github.com/gnu-octave/bootstrap/archive/main.zip’: HTTP response code said error
error: called from
pkg at line 529 column 19

Thanks in advance for your help

Best

Andy

IIUC, the download link to your tagged version is https://github.com/gnu-octave/bootstrap/archive/refs/tags/v2.8.8.zip

Edit: If you wanted to test with the current HEAD of your repository, that download link should be https://github.com/gnu-octave/bootstrap/archive/refs/heads/master.zip

OT: I was a little bit confused by the package name. I don’t have a statistics background. And “bootstrapping” meant something different to me, e.g.: Bootstrapping (compilers) - Wikipedia
Maybe a name that would suggest that the package is related to statistics might help users to find your package…

thanks @mmuetzel], I renamed the package statistics-bootstrap and I have fixed a few things to make in install and load as per the information in README.md. The problem I’ve noticed is that when installing, it’s not finding the functions in the ‘helper’ and ‘private’ subdirectories in ‘inst’. other function whose files are located in the ‘inst’ directory seem be installed ok since I can get their help information. Any idea how I can get octave to recognise the m-files contained in the subdirectories?

PKG_ADD files are executed when Octave adds a directory to the load path. PKG_DEL files are executed when that directory is removed from the load path.

You could add those files with commands to add or remove the subfolders to or from the load path (addpath or rmpath respectively) when the package is loaded or unloaded.

Edit: See e.g. the “ocs” package for a possible implementation:
Octave Forge / ocs / [57d769] (sourceforge.net)

Edit2: private directories shouldn’t be added to the load path. Files in that folder are considered to be private to functions in the same folder. They aren’t meant to be callable directly by the user.

1 Like

thanks @mmuetzel that did the trick (when I included all three folders to the load path).

But if I remove private from PKG_ADD and PKG_DEL then the functions in private are not found (e.g. by bootci) when I try to run it even though private is a subdirectory in the same folder as bootci and the other main functions. Weird because normally it is visible to these functions (only) (seed2state is a function in the private folder).

octave:201> bootci(10000,@smoothmedian,randn(10,1))
error: 'seed2state' undefined near line 158, column 158
error: called from
    boot1 at line 158 column 5
    ibootci at line 949 column 21
    bootci at line 291 column 21

After installation, the files and folders are installed:

octave:197> ls -l /Users/andrewcpenn/octave/statistics-bootstrap-2.8.8/
total 336
-rw-r--r--   1 andrewcpenn  staff    599 Dec 16 15:39 PKG_ADD
-rw-r--r--   1 andrewcpenn  staff    504 Dec 16 15:39 PKG_DEL
-rw-r--r--   1 andrewcpenn  staff  11989 Dec 16 15:39 bootci.m
-rw-r--r--   1 andrewcpenn  staff   8401 Dec 16 15:39 bootmode.m
-rw-r--r--   1 andrewcpenn  staff   2526 Dec 16 15:39 bootperm.m
-rw-r--r--   1 andrewcpenn  staff   2435 Dec 16 15:39 bootperm2.m
-rw-r--r--   1 andrewcpenn  staff   5045 Dec 16 15:39 bootstrp.m
-rw-r--r--   1 andrewcpenn  staff  42750 Dec 16 15:39 doc-cache
drwxr-xr-x  15 andrewcpenn  staff    480 Dec 16 15:39 helper
-rw-r--r--   1 andrewcpenn  staff  46633 Dec 16 15:39 ibootci.m
-rw-r--r--   1 andrewcpenn  staff   4347 Dec 16 15:39 ibootp.m
-rw-r--r--   1 andrewcpenn  staff   2967 Dec 16 15:39 iboottest.m
-rw-r--r--   1 andrewcpenn  staff   9075 Dec 16 15:39 iboottest2.m
drwxr-xr-x   5 andrewcpenn  staff    160 Dec 16 15:39 packinfo
drwxr-xr-x   5 andrewcpenn  staff    160 Dec 16 15:39 param
-rw-r--r--   1 andrewcpenn  staff   2134 Dec 16 15:39 plotboot.m
drwxr-xr-x  15 andrewcpenn  staff    480 Dec 16 15:39 private

And loading the package adds the (other) subfolders to the path…

octave:198> pkg load statistics-bootstrap
ans = /Users/andrewcpenn/octave/statistics-bootstrap-2.8.8/helper
ans = /Users/andrewcpenn/octave/statistics-bootstrap-2.8.8/param

And running help on one of the main functions says it’s in the directory (where the private folder is…

octave:199> help bootci
'bootci' is a function from the file /Users/andrewcpenn/octave/statistics-bootstrap-2.8.8/bootci.m

The functions are indeed in the private folder…

octave:200> ls -l /Users/andrewcpenn/octave/statistics-bootstrap-2.8.8/private
total 112
-rw-r--r--  1 andrewcpenn  staff   688 Dec 16 15:39 BC.m
-rw-r--r--  1 andrewcpenn  staff  1310 Dec 16 15:39 BCa.m
-rw-r--r--  1 andrewcpenn  staff   518 Dec 16 15:39 autocorr.m
-rw-r--r--  1 andrewcpenn  staff  5913 Dec 16 15:39 boot1.m
-rw-r--r--  1 andrewcpenn  staff   743 Dec 16 15:39 bootstud.m
-rw-r--r--  1 andrewcpenn  staff  1204 Dec 16 15:39 clustmean.m
-rw-r--r--  1 andrewcpenn  staff   749 Dec 16 15:39 empcdf.m
-rw-r--r--  1 andrewcpenn  staff   751 Dec 16 15:39 isparallel.m
-rw-r--r--  1 andrewcpenn  staff  3339 Dec 16 15:39 jack.m
-rw-r--r--  1 andrewcpenn  staff   303 Dec 16 15:39 nanfun.m
-rw-r--r--  1 andrewcpenn  staff   454 Dec 16 15:39 seed2state.m
-rw-r--r--  1 andrewcpenn  staff  1134 Dec 16 15:39 sse_calc.m
-rw-r--r--  1 andrewcpenn  staff   879 Dec 16 15:39 unitmeans.m

So I’m a bit confused why bootci cannot see functions in the private folder (when normally it doesn’t have this issue) (Just to confirm though, running help on functions in helper or param folders does indicate that they are accessible by the user so that is working)

Strange. It works for me.

I had to additionally load the statistics package. (You might consider adding that to your dependencies so it loads automatically.) But after that, I get:

>> pkg load statistics-bootstrap
>> bootci(10000,@smoothmedian,randn(10,1))
error: An error occurred while trying to evaluate bootfun with the input data
error: called from
    ibootci at line 754 column 7
    bootci at line 291 column 21
>> pkg load statistics
>> bootci(10000,@smoothmedian,randn(10,1))
ans =

  -0.6165
   0.5092

I’m testing with Octave 6.4.0 on Windows 10.
Which version of Octave do you use?

OT: I had to remove the try-catch-block around the failing lines to get an idea why the error occurred. Why do you use the try-catch-block if you throw an error anyway?

At 4:49 GMT this afternoon I committed changes that moved all the functions from the private folder to the helper folder (which I do include in PKG_ADD). If you tested out the installation after that time then that’s why it worked for you. I’ll just stick to keeping all the functions in the helper folder which I add to the octave load path. BTW I noticed the following posts that sound like they are referring to a similar issue to what I had. Reportedly the bug was fixed and I’m using Octave 6.4 on Mac OSX 10.15 (installed by homebrew)
https://lists.gnu.org/archive/html/octave-maintainers/2020-04/msg00072.html
https://savannah.gnu.org/bugs/?54658

Regarding the statistics package dependency. The only reason it required that statistics package was a single call to the function nanmedian. Seems excessive to depend on a package for one function call in one function so I committed changes to smoothmedian.m that includes an if statement. If the nanmedian function doesn’t exist, it’ll just use the median instead.

The installation seems to work smooth now even without the statistics package :+1:

>> pkg install "https://github.com/gnu-octave/statistics-bootstrap/archive/refs/heads/master.zip"
>> pkg load statistics-bootstrap
>> bootci(10000,@smoothmedian,randn(10,1))
ans =

  -0.3201
   0.9676
1 Like

I think I’ve more or less done what I needed and fixed some backwards compatibility issues. I’ll run a couple more tests this weekend… Is there anything you want me to do before I proceed with the following:

4. Publish your package

What is the use of your package, if only you know about it?

You have several options to gain attention for your package:

1 Like

Please add your package :slightly_smiling_face:

Thanks @siko1056 and @mmuetzel for all you help making iboot the now statistics-bootstrap package in Octave (GNU Octave - Packages). One question though, how hard would it be to have it listed at https://octave.sourceforge.io/ for convenient installation with pkg install -forge. I notice that octave forge packages are on sourceforge. I’m happy to also put statistics-bootstrap package on source forge… I know it is also possible to make sourceforge automatically include new releases from a GitHub repo… but not sure how this all joins up so that packages can be installed with the command pkg install -forge. I’m just conscious that peple searching for octave packages might get the impression that all available octave packages should be listed on on the octave forge site.

You are welcome :slightly_smiling_face: :+1:

Regarding Octave Forge, please read Octave Forge / Package Releases / #452 bioinfo-0.2.2 release. If you can spare some time, you are welcome to become Octave Forge project leader. I am happy to provide you any information and admin rights necessary :wink: