From 9e632ccf9344671c227325eeb8161ba8abe92fc9 Mon Sep 17 00:00:00 2001 From: mitchelloharawild Date: Tue, 17 Sep 2024 11:00:30 +1000 Subject: [PATCH] Skip monotonic transformation check if function is identity --- R/transformed.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/transformed.R b/R/transformed.R index 66d42649..79ad3092 100755 --- a/R/transformed.R +++ b/R/transformed.R @@ -159,6 +159,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) + # Currently assumes (without checking, #9) monotonicity of f over the domain x <- f(field(support, "lim")[[1]]) x[[2L]] > x[[1L]]