Skip to content

Commit 01eeab1

Browse files
committed
Rework new messages with verbosity system.
1 parent 63b86ce commit 01eeab1

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

packages/nimble/R/parameterTransform.R

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,27 @@ parameterTransform <- nimbleFunction(
171171
if(length(all.vars(lowerBdExpr)) > 0) stop('Node ', node, ' appears to have a non-constant lower bound, which cannot be used in parameterTransform.')
172172
if(length(all.vars(upperBdExpr)) > 0) stop('Node ', node, ' appears to have a non-constant upper bound, which cannot be used in parameterTransform.')
173173
} else { ## some other distribution with finite support
174-
message(' [Warning] `parameterTransform` system cannot process the ', dist, ' distribution of node ', node, '.\n The upper and lower bounds of the ', dist, ' distribution must be constant.\n If you\'re uncertain about this, please get in touch with the NIMBLE development team.')
174+
messageIfVerbose(' [Warning] `parameterTransform` system cannot process the `', dist, '`\n',
175+
' distribution for node `', node, '. The upper and lower bounds\n',
176+
' of `', dist, '` must be constant.\n')
175177
}
176178
transformType[i] <- 5L
177179
transformData[i,DATA1] <- bounds[1] ## formerly lowerBound
178180
transformData[i,DATA2] <- bounds[2] - bounds[1] ## formerly range
179181
next }
180-
stop(paste0('`parameterTransform` system doesn\'t have a transformation for the bounds of node: ', node, ', which are (', bounds[1], ', ', bounds[2], ')'))
182+
stop('`parameterTransform` system doesn\'t have a transformation for the bounds of node: ', node, ', which are (', bounds[1], ', ', bounds[2], ')')
181183
} else { ## multivariate
182184
if(dist %in% c('dmnorm', 'dmvt', 'dcar_normal', 'dcar_proper') || ## 6: multivariate {normal, t, CAR},
183185
isUserDefined(dist)) ## all multivariate user-defined distributions,
184186
{ ## and non-scalar determ nodes when allowDeterm is TRUE
185187
if(isUserDefined(dist) && getNimbleOption('parameterTransformWarnUserDists'))
186-
message(' [Warning] `parameterTransform` system detected multivariate user-defined distribution ', dist, '. No transformation will be applied to any dimension of \'x\' values of ', dist, '. If some values of \'x\' are not valid in ', dist, ', you may encounter errors. This warning can be disabled using nimbleOptions(parameterTransformWarnUserDists = FALSE)')
188+
messageIfVerbose(
189+
' [Warning] `parameterTransform` system detected multivariate user-defined\n',
190+
' distribution `', dist, '`. No transformation will be applied\n',
191+
' to any dimension of the `x` values of `', dist, '`.\n'
192+
' If some values of `x` are not valid, you may encounter errors.\n'
193+
' This warning can be disabled using\n',
194+
' `nimbleOptions(parameterTransformWarnUserDists = FALSE)`.')
187195
transformType[i] <- 6L
188196
d <- length(model$expandNodeNames(node, returnScalarComponents = TRUE))
189197
transformData[i,NIND2] <- transformData[i,NIND1] + d - 1
@@ -215,7 +223,7 @@ parameterTransform <- nimbleFunction(
215223
transformData[i,DATA1] <- d
216224
transformData[i,DATA2] <- p
217225
next }
218-
stop(paste0('parameterTransform doesn\'t handle \'', dist, '\' distributions.'), call. = FALSE)
226+
stop('parameterTransform doesn\'t handle \'', dist, '\' distributions.', call. = FALSE)
219227
}
220228
}
221229
if(nNodes == 0) {

0 commit comments

Comments
 (0)