Fixes #2760 Add validation of Nan and Inf parameters at t=0#2761
Fixes #2760 Add validation of Nan and Inf parameters at t=0#2761rwmcintosh merged 6 commits intodevelopfrom
Conversation
📝 WalkthroughWalkthroughAdds validation and warnings for non-finite (NaN/Infinity) values at time zero, integrates checks into model creation and run flows, introduces WithValidationResult/CreationResult/RunValidationResult types, a SimulationQuantityValueWarningTask service, a user setting toggle, and unit tests. Changes
Sequence Diagram(s)sequenceDiagram
participant Consumer as Consumer (create/run)
participant MC as ModelConstructor
participant CR as CreationResult / RunValidationResult
participant SQV as SimulationQuantityValueWarningTask
participant M as IModel
Consumer->>MC: request create/run (model, builder)
MC->>CR: construct CreationResult / RunValidationResult
MC->>MC: finalizeModel(model, simulationBuilder, creationResult)
MC->>SQV: WarnForNonFiniteQuantities(model, creationResult)
SQV->>M: enumerate parameters & molecule amounts
SQV->>SQV: detect NaN / Infinity values
SQV->>CR: append ValidationMessage warnings
MC->>SQV: WarnForOptimizedLocalMoleculeParameters(optimizedParams, creationResult)
SQV->>CR: append parameter-specific warnings
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/OSPSuite.Assets/UIConstants.cs (1)
1589-1594:⚠️ Potential issue | 🟡 MinorAdd braces around the conditional.
This file uses the no-brace pattern here, but the guideline requires braces for conditionals.Suggested fix
- if (string.IsNullOrEmpty(containerType)) - return NameAlreadyExists(name); + if (string.IsNullOrEmpty(containerType)) + { + return NameAlreadyExists(name); + }As per coding guidelines, Always use braces for loops and conditionals.
🤖 Fix all issues with AI agents
In `@src/OSPSuite.Core/Domain/Services/SimulationQuantityValueWarningTask.cs`:
- Around line 44-67: Several if statements lack braces (violating style rules) —
add explicit braces to all conditional blocks in this file: wrap the bodies of
the if (!_userSettings.WarnForNonFiniteQuantities) checks found in
WarnForOptimizedLocalMoleculeParameters, WarnForNonFiniteQuantities, and
warnForNonFiniteQuantities with { ... }, and likewise add braces to the other
brace-free conditionals noted around the later block (the ones referenced by the
reviewer at the 92-96 region). Ensure each conditional uses braces even for
single-line returns or single statements to conform to the coding guideline.
In
`@tests/OSPSuite.Core.Tests/Services/SimulationQuantityValueWarningTaskSpecs.cs`:
- Around line 13-353: The tests repeat literal IDs and names for NaN quantities;
add constants in the base test class concern_for_SimulationQuantityWarningTask
(e.g., NAN_AMOUNT_ID, NAN_AMOUNT_NAME, NAN_PARAMETER_ID, NAN_PARAMETER_NAME,
DEFAULT_BUILDER_NAME) and replace all hard-coded strings used in
NewSimulationQuantity()/NewBuilder() and the setup (calls to WithId/WithName and
AddSimulationEntitySource) with those constants so all scenarios reuse the
shared identifiers.
tests/OSPSuite.Core.Tests/Services/SimulationQuantityValueWarningTaskSpecs.cs
Outdated
Show resolved
Hide resolved
src/OSPSuite.Core/Domain/Services/SimulationQuantityValueWarningTask.cs
Outdated
Show resolved
Hide resolved
src/OSPSuite.Core/Domain/Services/SimulationQuantityValueWarningTask.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/OSPSuite.Core/Domain/Services/SimulationQuantityValueWarningTask.cs`:
- Around line 44-50: The method WarnForOptimizedLocalMoleculeParameters
unconditionally adds warnings for every optimizedParameters entry; update it to
respect the SimulationBuilder's WarnForNonFiniteQuantities flag by checking
creationResult.SimulationBuilder.WarnForNonFiniteQuantities (null-safe) and
returning early when the flag is false so no ValidationResult/ValidationMessage
(created via Warning.RemovedParameterDueToNanAtTimeZero, ValidationResult,
builderAndBuildingBlockFor, etc.) are added; ensure you still use the same
builderAndBuildingBlockFor(...) logic when the flag is true.
Fixes #2760 Add validation of Nan and Inf parameters at t=0
Description
Introducing a new user setting and a task to create validation messages for simulation creation and for simulation runtime.
Type of change
Please mark relevant options with an
xin the brackets.How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Reviewer checklist
Mark everything that needs to be checked before merging the PR.
This change requires a documentation updateabove is selectedScreenshots (if appropriate):
Questions (if appropriate):
Summary by CodeRabbit
New Features
Tests