Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds external-data handlers to reload transition-size distributions and distribution values; makes two distribution-provider methods internal and adds ReloadDistributionValuesFromScenario; removes TransitionSizeDistribution ID and keyed collection behavior, updating constructors and collection usage accordingly. Changes
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
src/Statistics/STSimDistributionProvider.cs (2)
56-56: Access widening OK, but document preconditionsKeeping
FillDistributionValueCollectioninternal is fine if called only via the new reload API. Add XML doc noting the preconditionm_DistributionValues.Count == 0to prevent future misuse.
102-102: Map creation visibility change is acceptable; consider atomic publishInternal is fine. If concurrent access ever becomes a concern, build the map in a local variable and assign to
m_DistributionValueMaponce to avoid transient nulls.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/Runtime/STSimTransformer.ExtProc.cs(1 hunks)src/Statistics/STSimDistributionProvider.cs(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/Runtime/STSimTransformer.ExtProc.cs (3)
src/Shared/Strings.cs (1)
Strings(8-700)src/Runtime/STSimTransformer.Collections.cs (1)
FillTransitionSizeDistributionCollection(2232-2277)src/Statistics/STSimDistributionProvider.cs (2)
FillDistributionValueCollection(56-100)CreateDistributionValueMap(102-111)
src/Statistics/STSimDistributionProvider.cs (1)
src/Statistics/STSimDistributionValueMap.cs (2)
DistributionValueCollection(34-51)STSimDistributionValueMap(9-52)
alexembrey
left a comment
There was a problem hiding this comment.
As per our discussion looks good
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/Runtime/TransitionSizeDistribution.cs (1)
17-27: Constructor change looks good; add invariant checks and make MinimumSize initialisation explicitDropping the ID simplifies usage. Please also guard inputs and set
m_MinimumSizeexplicitly to avoid relying on default initialisation.public TransitionSizeDistribution( int? stratumId, int? iteration, int? timestep, int transitionGroupId, double maximumSize, double relativeAmount) { this.m_StratumId = stratumId; this.m_Iteration = iteration; this.m_Timestep = timestep; this.m_TransitionGroupId = transitionGroupId; - this.m_MaximumSize = maximumSize; - this.m_RelativeAmount = relativeAmount; + if (maximumSize <= 0) + { + throw new ArgumentOutOfRangeException(nameof(maximumSize), "Maximum size must be > 0."); + } + if (double.IsNaN(relativeAmount) || relativeAmount < 0) + { + throw new ArgumentOutOfRangeException(nameof(relativeAmount), "Relative amount must be ≥ 0."); + } + this.m_MinimumSize = 0.0; // explicit default + this.m_MaximumSize = maximumSize; + this.m_RelativeAmount = relativeAmount; }src/Runtime/STSimTransformer.Collections.cs (1)
2244-2275: Constructor call is correct; add defensive validation on row values before creating itemsPrevent bad data from propagating (negative/zero sizes or amounts) and fail fast with a clear message tied to the datasheet.
DataSheet ds = this.ResultScenario.GetDataSheet(Strings.DATASHEET_TRANSITION_SIZE_DISTRIBUTION_NAME); foreach (DataRow dr in ds.GetData().Rows) { int? StratumId = null; int? Iteration = null; int? Timestep = null; int TransitionGroupId = Convert.ToInt32(dr[Strings.DATASHEET_TRANSITION_GROUP_ID_COLUMN_NAME], CultureInfo.InvariantCulture); double MaximumSize = Convert.ToDouble(dr[Strings.DATASHEET_TRANSITION_SIZE_DISTRIBUTION_MAXIMUM_AREA_COLUMN_NAME], CultureInfo.InvariantCulture); double RelativeAmount = Convert.ToDouble(dr[Strings.DATASHEET_TRANSITION_SIZE_DISTRIBUTION_RELATIVE_AMOUNT_COLUMN_NAME], CultureInfo.InvariantCulture); + if (MaximumSize <= 0) + { + throw new ArgumentException(ds.DisplayName + " -> Maximum area must be > 0."); + } + if (double.IsNaN(RelativeAmount) || RelativeAmount < 0) + { + throw new ArgumentException(ds.DisplayName + " -> Relative amount must be ≥ 0."); + } if (dr[Strings.DATASHEET_STRATUM_ID_COLUMN_NAME] != DBNull.Value) { StratumId = Convert.ToInt32(dr[Strings.DATASHEET_STRATUM_ID_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Strings.DATASHEET_ITERATION_COLUMN_NAME] != DBNull.Value) { Iteration = Convert.ToInt32(dr[Strings.DATASHEET_ITERATION_COLUMN_NAME], CultureInfo.InvariantCulture); } if (dr[Strings.DATASHEET_TIMESTEP_COLUMN_NAME] != DBNull.Value) { Timestep = Convert.ToInt32(dr[Strings.DATASHEET_TIMESTEP_COLUMN_NAME], CultureInfo.InvariantCulture); } TransitionSizeDistribution tsd = new TransitionSizeDistribution( StratumId, Iteration, Timestep, TransitionGroupId, MaximumSize, RelativeAmount);
🧹 Nitpick comments (1)
src/Runtime/TransitionSizeDistribution.cs (1)
89-99: Validate Proportion on set to keep it within [0, 1]Avoid accidental invalid values leaking into later calculations.
public double Proportion { get { return this.m_Proportion; } set { - this.m_Proportion = value; + if (double.IsNaN(value) || value < 0.0 || value > 1.0) + { + throw new ArgumentOutOfRangeException(nameof(value), "Proportion must be between 0 and 1."); + } + this.m_Proportion = value; } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
src/Runtime/STSimTransformer.Collections.cs(1 hunks)src/Runtime/STSimTransformer.ExtProc.cs(1 hunks)src/Runtime/TransitionSizeDistribution.cs(1 hunks)src/Runtime/TransitionSizeDistributionCollection.cs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/Runtime/STSimTransformer.ExtProc.cs
🧰 Additional context used
🧬 Code graph analysis (1)
src/Runtime/TransitionSizeDistributionCollection.cs (1)
src/Runtime/TransitionSizeDistribution.cs (2)
TransitionSizeDistribution(6-100)TransitionSizeDistribution(17-27)
🔇 Additional comments (2)
src/Runtime/TransitionSizeDistributionCollection.cs (1)
8-10: Verified removal of keyed Collection is safe
No lingeringGetKeyForItemor keyed semantics forTransitionSizeDistribution;TransitionSizeDistributionMapand its usages provide efficient ID-based lookups.src/Runtime/STSimTransformer.Collections.cs (1)
2233-2246: No clearing needed: collection is fresh on init and explicitly cleared in ext-proc. In the default spatial initializationm_TransitionSizeDistributionsis newly constructed and only filled once, so the debug assert always holds. InSTSimTransformer.ExtProcthe code callsm_TransitionSizeDistributions.Clear()before each refill and rebuilds the map.
Adds stsim_DistributionValue and stsim_TransitionSizeDistribution
Summary by CodeRabbit
New Features
Refactor