Skip to content

Commit

Permalink
Fixes #1274 Prevent crash of 0 simulated values in log scale
Browse files Browse the repository at this point in the history
Provides a warning for such a case
  • Loading branch information
pchelle committed Sep 6, 2024
1 parent 252a166 commit 4111752
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions R/messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ messages <- list(
paste0(highlight(unique(values)), collapse = "', '"), "'."
)
},
warningLogScaleIssue = function(output) {
paste0(
"Plot scale is logarithmic, however all values from simulated output '",
highlight(output), "' were 0."
)
},

#----- Info messages ----
runStarting = function(runName, subRun = NULL) {
if (is.null(subRun)) {
Expand Down
9 changes: 8 additions & 1 deletion R/qualification-comparison-time-profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,14 @@ addOutputToComparisonTimeProfile <- function(outputMapping, simulationDuration,
molWeight = molWeight
)
simulatedValues <- simulatedValues[selectedTimeValues]

logScaleIssue <- all(simulatedValues == 0, isIncluded(axesProperties$y$scale, "log"))
if(logScaleIssue){
warning(messages$warningLogScaleIssue(outputMapping$Output), call. = FALSE)
# Set the first value to 1 to avoid log scale issue
# Since this only affect one value, no line will plotted
simulatedValues[1] <- 1
}

# Add simulated values to plot
plotObject <- tlf::addLine(
x = simulatedTime,
Expand Down

0 comments on commit 4111752

Please sign in to comment.