Discussion:
Package precedence?
roland65
2018-11-12 10:26:15 UTC
Permalink
Hi,

some of the functions implemented in different packages can have the same
name. For example, nan and statistics packages have the same functions
std(), median(), corrcoef(), etc. that should do the same things but are
implemented in different ways.

In my .octaverc, I load these packages:

load nan
load statistics

However, whatever the order of these lines, the functions selected by Octave
are always those of the nan package (because of the alphabetical order?).

Is there a way to tell Octave to get first the functions from the statistics
package?

Thanks,
RB




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Mike Miller
2018-11-12 17:40:41 UTC
Permalink
Post by roland65
some of the functions implemented in different packages can have the same
name. For example, nan and statistics packages have the same functions
std(), median(), corrcoef(), etc.
These specific functions are actually part of Octave's core library, not
the Octave Forge statistics package. Are these the particular functions
you are asking about?
Post by roland65
load nan
load statistics
However, whatever the order of these lines, the functions selected by Octave
are always those of the nan package (because of the alphabetical order?).
Yes, functions that are provided by a loadable package will override
functions that are in Octave's core library.
Post by roland65
Is there a way to tell Octave to get first the functions from the statistics
package?
Packages that are loaded last will override earlier packages. If you
look at a function that is actually provided by the statistics package,
for example 'normpdf', you should see the results you wanted.

There is no simple way to load a package such that its functions do not
override Octave's core library functions. You can try manipulating the
load path directly, or consider not loading the nan package when you
don't want to use it.
--
mike
roland65
2018-11-14 14:01:26 UTC
Permalink
OK, you're right, the point is that these functions std() median(),
corrcoef(), etc. belong to Octave's core and are overloaded by the nan
package.

I wrongly thought that these functions belonged to the statistics package!

Thanks for your clear explanations...




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Loading...