twolodzko / extraDistr

Additional univariate and multivariate distributions
51 stars 11 forks source link

change to consistency with base R functions regarding log.p, log and … #5

Closed mnel closed 7 years ago

mnel commented 7 years ago

Currently the documentation (and practice) for distribution functions in base R (eg dnorm / rpois) "Only the first elements of the logical arguments are used"

This means the following works in base R

dnorm(1, log = c(TRUE, FALSE))
# [1] -1.418939

This pull request will stop extraDistr returning errors such as

extraDistr::pgev(1, log.p = c(TRUE, FALSE))
#Error in cpp_pgev(q, mu, sigma, xi, lower.tail, log.p) : 
 #  expecting a single value

In some situations, when using base R functions directly, no errors are given, and the functions return using the first value

extraDistr::pdnorm(1, log = c(TRUE, FALSE))
# [1] -0.02301291
codecov[bot] commented 7 years ago

Codecov Report

Merging #5 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master       #5   +/-   ##
=======================================
  Coverage   92.37%   92.37%           
=======================================
  Files         116      116           
  Lines        6096     6096           
=======================================
  Hits         5631     5631           
  Misses        465      465
Impacted Files Coverage Δ
R/zero-inflated-negative-binomial-distribution.R 100% <100%> (ø) :arrow_up:
R/discrete-uniform-distribution.R 100% <100%> (ø) :arrow_up:
R/gpd-distribution.R 100% <100%> (ø) :arrow_up:
R/beta-prime-distribution.R 100% <100%> (ø) :arrow_up:
R/multivariate-hypergeometric-distribution.R 100% <100%> (ø) :arrow_up:
R/discrete-weibull-distribution.R 100% <100%> (ø) :arrow_up:
R/discrete-gamma-distribution.R 62.5% <100%> (ø) :arrow_up:
R/half-t-distribution.R 100% <100%> (ø) :arrow_up:
R/bivariate-normal-distribution.R 45.45% <100%> (ø) :arrow_up:
R/laplace-distribution.R 100% <100%> (ø) :arrow_up:
... and 42 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update c36c44f...b00afeb. Read the comment docs.

twolodzko commented 7 years ago

Thanks @mnel. How would you prefer me to document your contribution in the package description file?