Разница между help func и help (func) в октаве - PullRequest
2 голосов
/ 22 декабря 2019

Функция help работает по-разному, когда используется как help func по сравнению с help(func).

Например, при выполнении help mvnrnd отображается желаемый вывод:

>> help mvnrnd
'mvnrnd' is a function from the file /home/student/octave/statistics-1.4.0/mvnrnd.m

 -- Function File: S = mvnrnd (MU, SIGMA)
 -- Function File: S = mvnrnd (MU, SIGMA, N)
 -- Function File: S = mvnrnd (..., TOL)
     Draw N random D-dimensional vectors from a multivariate Gaussian
     distribution with mean MU(NxD) and covariance matrix SIGMA(DxD).

     MU must be N-by-D (or 1-by-D if N is given) or a scalar.

     If the argument TOL is given the eigenvalues of SIGMA are checked
     for positivity against -100*tol.  The default value of tol is
     'eps*norm (Sigma, "fro")'.

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.

При выполнении help(mvnrnd) выдает ошибку:

>> help(mvnrnd)
error: 'Sigma' undefined near line 22 column 50
error: called from
    mvnrnd

Я думал help func и help(func), где то же самое, но кажется, что есть некоторые различия, которые я не смог найти при поиске в Интернете. Любые идеи?

Я также пытался создать свою собственную функцию, например:

function hello()
  % Whatsup
  print("hello")
end

И имеет такое же поведение. Выполнение help hello работает нормально, тогда как при выполнении help(hello) возникает ошибка. Как будто он пытается выполнить код внутри функции, потому что трассировка стека имеет ссылки на код функции и ее вызывающих функций. Это вывод:

>> help(hello)
warning: print.m: fig2dev binary is not available.
Some output formats are not available.
warning: called from
    __print_parse_opts__ at line 388 column 9
    print at line 316 column 8
    hello at line 3 column 3
error: print: no figure to print
error: called from
    print at line 341 column 5
    hello at line 3 column 3

PS: для доступа к mvnrnd необходимо загрузить пакет statistics:

pkg load statistics
...