From 0ef5213fe6222d3bcc237a15e0eb3c8aa5abbcaa Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 27 Sep 2023 00:06:09 +0200 Subject: [PATCH] `find_transformation` incorrectly detects power transformations (#813) * `find_transformation` incorrectly detects power transformations Fixes #812 * add test * version * add more tests, found exception * fix - * add test * comment * add test --- DESCRIPTION | 2 +- R/find_terms.R | 4 ++- R/find_transformation.R | 2 +- R/get_transformation.R | 13 ++++++--- tests/testthat/test-find_terms.R | 11 +++++++ tests/testthat/test-find_transformation.R | 35 +++++++++++++++++++++++ 6 files changed, 60 insertions(+), 7 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5b6bd6e1a..dceb5f902 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: insight Title: Easy Access to Model Information for Various Model Objects -Version: 0.19.5.3 +Version: 0.19.5.4 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/R/find_terms.R b/R/find_terms.R index eb3fcddb8..d6a11f1e1 100644 --- a/R/find_terms.R +++ b/R/find_terms.R @@ -188,8 +188,10 @@ find_terms.mipo <- function(x, flatten = FALSE, ...) { # protect "-1" f$conditional <- gsub("(-1|- 1)(?![^(]*\\))", "#1", f$conditional, perl = TRUE) + # This regular expression matches any of the characters *, +, :, |, -, or /, + # unless they are preceded by a ^ and followed by a closing parenthesis ). f <- lapply(f, function(.x) { - pattern <- "[*+:|\\-\\/](?![^(]*\\))" # was: "[\\*\\+:\\-\\|/](?![^(]*\\))" + pattern <- "(?