Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ If upgrading from v2.x, see the [v3.0.0 release notes](https://github.com/flixOp

### ✨ Added

- Added proper deprecation tests

### 💥 Breaking Changes

### ♻️ Changed
Expand All @@ -67,6 +69,8 @@ If upgrading from v2.x, see the [v3.0.0 release notes](https://github.com/flixOp

### 🐛 Fixed

- Fixed Deprecation warnings to specify the version of removal.

### 🔒 Security

### 📦 Dependencies
Expand Down
7 changes: 4 additions & 3 deletions flixopt/calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from . import io as fx_io
from .aggregation import Aggregation, AggregationModel, AggregationParameters
from .components import Storage
from .config import CONFIG
from .config import CONFIG, DEPRECATION_REMOVAL_VERSION
from .core import DataConverter, TimeSeriesData, drop_constant_arrays
from .features import InvestmentModel
from .flow_system import FlowSystem
Expand Down Expand Up @@ -79,7 +79,7 @@ def __init__(
warnings.warn(
"The 'active_timesteps' parameter is deprecated and will be removed in a future version. "
'Use flow_system.sel(time=timesteps) or flow_system.isel(time=indices) before passing '
'the FlowSystem to the Calculation instead.',
f'the FlowSystem to the Calculation instead. Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -162,7 +162,8 @@ def summary(self):
@property
def active_timesteps(self) -> pd.DatetimeIndex:
warnings.warn(
'active_timesteps is deprecated. Use flow_system.sel(time=...) or flow_system.isel(time=...) instead.',
f'active_timesteps is deprecated. Use flow_system.sel(time=...) or flow_system.isel(time=...) instead. '
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand Down
52 changes: 35 additions & 17 deletions flixopt/effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy as np
import xarray as xr

from .config import DEPRECATION_REMOVAL_VERSION
from .core import PlausibilityError
from .features import ShareAllocationModel
from .structure import Element, ElementContainer, ElementModel, FlowSystemModel, Submodel, register_class_for_io
Expand Down Expand Up @@ -252,7 +253,8 @@ def __init__(
def minimum_operation(self):
"""DEPRECATED: Use 'minimum_temporal' property instead."""
warnings.warn(
"Property 'minimum_operation' is deprecated. Use 'minimum_temporal' instead.",
f"Property 'minimum_operation' is deprecated. Use 'minimum_temporal' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -262,7 +264,8 @@ def minimum_operation(self):
def minimum_operation(self, value):
"""DEPRECATED: Use 'minimum_temporal' property instead."""
warnings.warn(
"Property 'minimum_operation' is deprecated. Use 'minimum_temporal' instead.",
f"Property 'minimum_operation' is deprecated. Use 'minimum_temporal' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -272,7 +275,8 @@ def minimum_operation(self, value):
def maximum_operation(self):
"""DEPRECATED: Use 'maximum_temporal' property instead."""
warnings.warn(
"Property 'maximum_operation' is deprecated. Use 'maximum_temporal' instead.",
f"Property 'maximum_operation' is deprecated. Use 'maximum_temporal' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -282,7 +286,8 @@ def maximum_operation(self):
def maximum_operation(self, value):
"""DEPRECATED: Use 'maximum_temporal' property instead."""
warnings.warn(
"Property 'maximum_operation' is deprecated. Use 'maximum_temporal' instead.",
f"Property 'maximum_operation' is deprecated. Use 'maximum_temporal' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -292,7 +297,8 @@ def maximum_operation(self, value):
def minimum_invest(self):
"""DEPRECATED: Use 'minimum_periodic' property instead."""
warnings.warn(
"Property 'minimum_invest' is deprecated. Use 'minimum_periodic' instead.",
f"Property 'minimum_invest' is deprecated. Use 'minimum_periodic' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -302,7 +308,8 @@ def minimum_invest(self):
def minimum_invest(self, value):
"""DEPRECATED: Use 'minimum_periodic' property instead."""
warnings.warn(
"Property 'minimum_invest' is deprecated. Use 'minimum_periodic' instead.",
f"Property 'minimum_invest' is deprecated. Use 'minimum_periodic' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -312,7 +319,8 @@ def minimum_invest(self, value):
def maximum_invest(self):
"""DEPRECATED: Use 'maximum_periodic' property instead."""
warnings.warn(
"Property 'maximum_invest' is deprecated. Use 'maximum_periodic' instead.",
f"Property 'maximum_invest' is deprecated. Use 'maximum_periodic' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -322,7 +330,8 @@ def maximum_invest(self):
def maximum_invest(self, value):
"""DEPRECATED: Use 'maximum_periodic' property instead."""
warnings.warn(
"Property 'maximum_invest' is deprecated. Use 'maximum_periodic' instead.",
f"Property 'maximum_invest' is deprecated. Use 'maximum_periodic' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -332,7 +341,8 @@ def maximum_invest(self, value):
def minimum_operation_per_hour(self):
"""DEPRECATED: Use 'minimum_per_hour' property instead."""
warnings.warn(
"Property 'minimum_operation_per_hour' is deprecated. Use 'minimum_per_hour' instead.",
f"Property 'minimum_operation_per_hour' is deprecated. Use 'minimum_per_hour' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -342,7 +352,8 @@ def minimum_operation_per_hour(self):
def minimum_operation_per_hour(self, value):
"""DEPRECATED: Use 'minimum_per_hour' property instead."""
warnings.warn(
"Property 'minimum_operation_per_hour' is deprecated. Use 'minimum_per_hour' instead.",
f"Property 'minimum_operation_per_hour' is deprecated. Use 'minimum_per_hour' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -352,7 +363,8 @@ def minimum_operation_per_hour(self, value):
def maximum_operation_per_hour(self):
"""DEPRECATED: Use 'maximum_per_hour' property instead."""
warnings.warn(
"Property 'maximum_operation_per_hour' is deprecated. Use 'maximum_per_hour' instead.",
f"Property 'maximum_operation_per_hour' is deprecated. Use 'maximum_per_hour' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -362,7 +374,8 @@ def maximum_operation_per_hour(self):
def maximum_operation_per_hour(self, value):
"""DEPRECATED: Use 'maximum_per_hour' property instead."""
warnings.warn(
"Property 'maximum_operation_per_hour' is deprecated. Use 'maximum_per_hour' instead.",
f"Property 'maximum_operation_per_hour' is deprecated. Use 'maximum_per_hour' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -372,7 +385,8 @@ def maximum_operation_per_hour(self, value):
def minimum_total_per_period(self):
"""DEPRECATED: Use 'minimum_total' property instead."""
warnings.warn(
"Property 'minimum_total_per_period' is deprecated. Use 'minimum_total' instead.",
f"Property 'minimum_total_per_period' is deprecated. Use 'minimum_total' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -382,7 +396,8 @@ def minimum_total_per_period(self):
def minimum_total_per_period(self, value):
"""DEPRECATED: Use 'minimum_total' property instead."""
warnings.warn(
"Property 'minimum_total_per_period' is deprecated. Use 'minimum_total' instead.",
f"Property 'minimum_total_per_period' is deprecated. Use 'minimum_total' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -392,7 +407,8 @@ def minimum_total_per_period(self, value):
def maximum_total_per_period(self):
"""DEPRECATED: Use 'maximum_total' property instead."""
warnings.warn(
"Property 'maximum_total_per_period' is deprecated. Use 'maximum_total' instead.",
f"Property 'maximum_total_per_period' is deprecated. Use 'maximum_total' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -402,7 +418,8 @@ def maximum_total_per_period(self):
def maximum_total_per_period(self, value):
"""DEPRECATED: Use 'maximum_total' property instead."""
warnings.warn(
"Property 'maximum_total_per_period' is deprecated. Use 'maximum_total' instead.",
f"Property 'maximum_total_per_period' is deprecated. Use 'maximum_total' instead. "
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -617,7 +634,8 @@ def get_effect_label(eff: Effect | str) -> str:
if isinstance(eff, Effect):
warnings.warn(
f'The use of effect objects when specifying EffectValues is deprecated. '
f'Use the label of the effect instead. Used effect: {eff.label_full}',
f'Use the label of the effect instead. Used effect: {eff.label_full}. '
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
UserWarning,
stacklevel=2,
)
Expand Down
3 changes: 2 additions & 1 deletion flixopt/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ def __init__(
self.bus = bus.label_full
warnings.warn(
f'Bus {bus.label} is passed as a Bus object to {self.label}. This is deprecated and will be removed '
f'in the future. Add the Bus to the FlowSystem instead and pass its label to the Flow.',
f'in the future. Add the Bus to the FlowSystem instead and pass its label to the Flow. '
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
UserWarning,
stacklevel=1,
)
Expand Down
13 changes: 8 additions & 5 deletions flixopt/flow_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import xarray as xr

from . import io as fx_io
from .config import CONFIG
from .config import CONFIG, DEPRECATION_REMOVAL_VERSION
from .core import (
ConversionError,
DataConverter,
Expand Down Expand Up @@ -995,7 +995,8 @@ def _connect_network(self):
warnings.warn(
f'The Bus {flow._bus_object.label_full} was added to the FlowSystem from {flow.label_full}.'
f'This is deprecated and will be removed in the future. '
f'Please pass the Bus.label to the Flow and the Bus to the FlowSystem instead.',
f'Please pass the Bus.label to the Flow and the Bus to the FlowSystem instead. '
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=1,
)
Expand Down Expand Up @@ -1109,7 +1110,7 @@ def all_elements(self) -> dict[str, Element]:
"The 'all_elements' property is deprecated. Use dict-like interface instead: "
"flow_system['element'], 'element' in flow_system, flow_system.keys(), "
'flow_system.values(), or flow_system.items(). '
'This property will be removed in v4.0.0.',
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand Down Expand Up @@ -1165,7 +1166,8 @@ def scenario_weights(self, value: Numeric_S | None) -> None:
@property
def weights(self) -> Numeric_S | None:
warnings.warn(
'FlowSystem.weights is deprecated. Use FlowSystem.scenario_weights instead.',
f'FlowSystem.weights is deprecated. Use FlowSystem.scenario_weights instead. '
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand All @@ -1180,7 +1182,8 @@ def weights(self, value: Numeric_S) -> None:
value: Scenario weights to set
"""
warnings.warn(
'Setting FlowSystem.weights is deprecated. Set FlowSystem.scenario_weights instead.',
f'Setting FlowSystem.weights is deprecated. Set FlowSystem.scenario_weights instead. '
f'Will be removed in v{DEPRECATION_REMOVAL_VERSION}.',
DeprecationWarning,
stacklevel=2,
)
Expand Down
Loading