From 66d908b548f40c10b284e82d5f5cb0d9a7ad301b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Wed, 12 Mar 2025 10:07:17 +0100 Subject: [PATCH] fix: Correct boolean conversion in DHT hook call --- bench/dolo/dolo_interp.R | 48 +++++++++---------- src/Chemistry/SurrogateModels/DHT_Wrapper.cpp | 2 +- .../SurrogateModels/InterpolationModule.cpp | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/bench/dolo/dolo_interp.R b/bench/dolo/dolo_interp.R index f48527d00..1dc6ae950 100644 --- a/bench/dolo/dolo_interp.R +++ b/bench/dolo/dolo_interp.R @@ -41,36 +41,36 @@ diffusion_setup <- list( ) check_sign_cal_dol_dht <- function(old, new) { - if ((old["Calcite"] == 0) != (new["Calcite"] == 0)) { - return(TRUE) - } - if ((old["Dolomite"] == 0) != (new["Dolomite"] == 0)) { - return(TRUE) - } + # if ((old["Calcite"] == 0) != (new["Calcite"] == 0)) { + # return(TRUE) + # } + # if ((old["Dolomite"] == 0) != (new["Dolomite"] == 0)) { + # return(TRUE) + # } return(FALSE) } -fuzz_input_dht_keys <- function(input) { - dht_species <- c( - "H" = 3, - "O" = 3, - "Charge" = 3, - "C(4)" = 6, - "Ca" = 6, - "Cl" = 3, - "Mg" = 5, - "Calcite" = 4, - "Dolomite" = 4 - ) - return(input[names(dht_species)]) -} +# fuzz_input_dht_keys <- function(input) { +# dht_species <- c( +# "H" = 3, +# "O" = 3, +# "Charge" = 3, +# "C" = 6, +# "Ca" = 6, +# "Cl" = 3, +# "Mg" = 5, +# "Calcite" = 4, +# "Dolomite" = 4 +# ) +# return(input[names(dht_species)]) +# } check_sign_cal_dol_interp <- function(to_interp, data_set) { dht_species <- c( "H" = 3, "O" = 3, "Charge" = 3, - "C(4)" = 6, + "C" = 6, "Ca" = 6, "Cl" = 3, "Mg" = 5, @@ -95,7 +95,7 @@ check_neg_cal_dol <- function(result) { # significant digits) pht_species <- c( - "C(4)" = 3, + "C" = 3, "Ca" = 3, "Mg" = 2, "Calcite" = 2, @@ -107,7 +107,7 @@ chemistry_setup <- list( "H" = 3, "O" = 3, "Charge" = 3, - "C(4)" = 6, + "C" = 6, "Ca" = 6, "Cl" = 3, "Mg" = 5, @@ -117,7 +117,7 @@ chemistry_setup <- list( pht_species = pht_species, hooks = list( dht_fill = check_sign_cal_dol_dht, - dht_fuzz = fuzz_input_dht_keys, + # dht_fuzz = fuzz_input_dht_keys, interp_pre = check_sign_cal_dol_interp, interp_post = check_neg_cal_dol ) diff --git a/src/Chemistry/SurrogateModels/DHT_Wrapper.cpp b/src/Chemistry/SurrogateModels/DHT_Wrapper.cpp index 3b836d4f4..83db27ff8 100644 --- a/src/Chemistry/SurrogateModels/DHT_Wrapper.cpp +++ b/src/Chemistry/SurrogateModels/DHT_Wrapper.cpp @@ -144,7 +144,7 @@ void DHT_Wrapper::fillDHT(const WorkPackage &work_package) { NamedVector old_values(output_names, work_package.input[i]); NamedVector new_values(output_names, work_package.output[i]); - if (hooks.dht_fill(old_values, new_values)) { + if (Rcpp::as(hooks.dht_fill(old_values, new_values))) { continue; } } diff --git a/src/Chemistry/SurrogateModels/InterpolationModule.cpp b/src/Chemistry/SurrogateModels/InterpolationModule.cpp index 0b6fbd1d8..db730d00d 100644 --- a/src/Chemistry/SurrogateModels/InterpolationModule.cpp +++ b/src/Chemistry/SurrogateModels/InterpolationModule.cpp @@ -145,7 +145,7 @@ void InterpolationModule::tryInterpolation(WorkPackage &work_package) { if (hooks.interp_post.isValid()) { NamedVector nv_result(this->out_names, work_package.output[wp_i]); - if (hooks.interp_post(nv_result)) { + if (Rcpp::as(hooks.interp_post(nv_result))) { interp_result.status[wp_i] = INSUFFICIENT_DATA; continue; }