Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #1274 Prevent crash of 0 simulated values in log scale #1275

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 lower or equal to 0."
)
},

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

# Add simulated values to plot
plotObject <- tlf::addLine(
x = simulatedTime,
y = simulatedValues,
caption = prettyCaption(paste(outputMapping$Caption, "Simulated Data"), plotObject),
linetype = tlfLinetype(outputMapping$LineStyle),
color = outputMapping$Color,
size = outputMapping$Size,
plotObject = plotObject
)

# If issues with log scale due to all zeros or negative values
# Warn and do not plot the data
logScaleIssue <- all(simulatedValues <= 0, isIncluded(axesProperties$y$scale, "log"))
if(logScaleIssue){
warning(messages$warningLogScaleIssue(outputMapping$Output), call. = FALSE)
}

if(!logScaleIssue){
# Add simulated values to plot
plotObject <- tlf::addLine(
x = simulatedTime,
y = simulatedValues,
caption = prettyCaption(paste(outputMapping$Caption, "Simulated Data"), plotObject),
linetype = tlfLinetype(outputMapping$LineStyle),
color = outputMapping$Color,
size = outputMapping$Size,
plotObject = plotObject
)
}

# Loop on each observed dataset in OutputMappings
for (observedDataSet in outputMapping$ObservedData) {
# Get data and meta data of observed results
Expand Down
Loading