Skip to content

Add operational_type for identifying the operational time structure of a TimeStructurePeriod - #106

Merged
JulStraus merged 2 commits into
mainfrom
feat/oper_type
Oct 22, 2026
Merged

JulStraus merged 2 commits into
mainfrom
feat/oper_type

Conversation

@JulStraus

Copy link
Copy Markdown
Collaborator

Adds the exported function operational_type(ts::TimeStructurePeriod), which returns the type of the operational time structure held by a strategic period, representative period, or operational scenario. It complements has_opscenarios and has_repr_periods (#105).

  • Periods that hold a time structure directly (StrategicPeriod, StratNode, RepresentativePeriod, OperationalScenario, and the Single* wrappers) return the type of that structure.
  • Nested periods (e.g., StratReprPeriod, StratReprOpScenario) call the function on the period they contain, so they return the innermost operational structure.
  • Strategic scenarios are not supported (MethodError), as they include several operational time structures.

I did not include this method for any other subtype of TimeStructure as there is no benefit in that:

  • TimePeriod does not contain an operational time structure,
  • TimeStructInnerIter and TimeStructOuterIter may contain multiple operational structures.

Important

I do not return the instance, only the type. The reason for that is to avoid that people iterate over the operational time structure as that may lead to indexing problems. It hence still closes #81 as it is my opinion the better and safer approach.

@JulStraus
JulStraus requested review from hellemo and trulsf October 21, 2026 10:41
@JulStraus JulStraus added the enhancement New feature or request label Oct 21, 2026
@codecov-commenter

codecov-commenter commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/TimeStruct.jl 100.00% <ø> (ø)
src/calendar.jl 90.74% <100.00%> (+0.35%) ⬆️
src/op_scenarios/core_types.jl 96.22% <100.00%> (+0.14%) ⬆️
src/op_scenarios/opscenarios.jl 72.61% <100.00%> (+1.36%) ⬆️
src/op_scenarios/rep_periods.jl 61.81% <100.00%> (+0.70%) ⬆️
src/op_scenarios/strat_periods.jl 73.50% <100.00%> (+0.46%) ⬆️
src/op_scenarios/tree_periods.jl 78.94% <100.00%> (+0.56%) ⬆️
src/representative/core_types.jl 96.22% <100.00%> (+0.14%) ⬆️
src/representative/rep_periods.jl 87.83% <100.00%> (+0.88%) ⬆️
src/representative/strat_periods.jl 76.00% <100.00%> (+0.48%) ⬆️
... and 8 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/utils.jl Outdated

The method is implemented for [`AbstractStrategicPeriod`](@ref),
[`AbstractRepresentativePeriod`](@ref), and [`AbstractOperationalScenario`](@ref). For nested
periods (*e.g.*, a representative period of a strategic period), the type of the innermost

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be unclear what is meant by innermost here. E.g the innermost of the two, or the innermost operational time structure overall.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree. It is from Claude ;) I will improve on it.

@trulsf trulsf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. I agree with keeping this at the level of returning the type. Should be enough to cover dispatch needs.

@JulStraus

Copy link
Copy Markdown
Collaborator Author

I will merge once the CI ran through. From my end, we can then create a new release.

@JulStraus
JulStraus merged commit ba447a6 into main Oct 22, 2026
6 checks passed
@JulStraus
JulStraus deleted the feat/oper_type branch October 22, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extraction of the operational structures of a time structure

3 participants