nimble-dev / nimble

The base NIMBLE package for R
http://R-nimble.org
BSD 3-Clause "New" or "Revised" License
156 stars 23 forks source link

registerDistributions type-checking allows default value for x arg #1346

Closed danielturek closed 9 months ago

danielturek commented 11 months ago

Modified the type-checking in registerDistributions, to allow a default value for the x argument of user-defined distributions. For example, the following is now ok:

ddist <- nimbleFunction(
    run = function(x = double(default = 0), log = integer(default = 1)) {
        returnType(double())
        return(0)
    }
)

This should never affect model calculations, but does result in a user-defined density function (in the R environment) which has a default value for the x argument.

danielturek commented 11 months ago

Fixes #1345

danielturek commented 11 months ago

@paciorek @perrydv I think this is a pretty reasonable change, and I'm ok with this getting merged, pending any thoughts from either of you.

paciorek commented 9 months ago

Closing this without merging given discussion in issue #1345