Skip to content

Add unary operator support for profiles#88

Merged
JulStraus merged 2 commits intosintefore:mainfrom
Zetison:enhance/profile_unary_operations
Feb 6, 2026
Merged

Add unary operator support for profiles#88
JulStraus merged 2 commits intosintefore:mainfrom
Zetison:enhance/profile_unary_operations

Conversation

@Zetison
Copy link
Contributor

@Zetison Zetison commented Feb 5, 2026

This PR provides unary operator support (for + and -) for profiles.

This basic functionality is convenient for example if one wants to model a market node in EMX as done here. One is then enabled to write

power = ResourceCarrier("Power", 0.0)
prices = [[10, 60, 15, 62], [9, 59, 14, 61]]
price_profile = StrategicProfile([OperationalProfile(p) for p in prices])
market_sale = RefSink(
    "market_sale", 
    FixedProfile(0), 
    Dict(
        :surplus => -price_profile,
        :deficit => price_profile
    ),
    Dict(power => 1), 
)

which simplifies code and abstracts away a call to the profile constructor compared to

power = ResourceCarrier("Power", 0.0)
prices = [[10, 60, 15, 62], [9, 59, 14, 61]]
market_sale = RefSink(
    "market_sale", 
    FixedProfile(0), 
    Dict(
        :surplus => StrategicProfile([OperationalProfile(-p) for p in prices])
        :deficit => StrategicProfile([OperationalProfile(p) for p in prices])
    ),
    Dict(power => 1),  
)

@JulStraus JulStraus requested a review from trulsf February 6, 2026 07:10
@codecov-commenter
Copy link

codecov-commenter commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/profiles.jl 84.93% <100.00%> (+5.88%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JulStraus
Copy link
Collaborator

I am not opposed to it. Formatting should be however done.

@JulStraus JulStraus self-requested a review February 6, 2026 07:23
Copy link
Member

@trulsf trulsf left a comment

Choose a reason for hiding this comment

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

Looks good to me

@JulStraus JulStraus merged commit 0d75602 into sintefore:main Feb 6, 2026
6 checks passed
@Zetison Zetison deleted the enhance/profile_unary_operations branch February 6, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants