Skip to content

Commit

Permalink
Skip shortcut for primitive functions (TIL no body() or formals()!)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Sep 17, 2024
1 parent 269119d commit e9d7e99
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/transformed.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ Ops.dist_transformed <- function(e1, e2) {

monotonic_increasing <- function(f, support) {
# Shortcut for identity function (used widely in ggdist)
if(identical(body(f), as.name(names(formals(f))))) return(TRUE)
if(!is.primitive(f) && identical(body(f), as.name(names(formals(f))))) {
return(TRUE)
}

# Currently assumes (without checking, #9) monotonicity of f over the domain
x <- f(field(support, "lim")[[1]])
Expand Down

0 comments on commit e9d7e99

Please sign in to comment.