Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings #1033

Merged
merged 15 commits into from
Dec 22, 2023
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.5.2dev2
current_version = 0.5.2.dev2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.9

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tox_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v2

- name: Set up Python ${{ env.default_python || '3.9' }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "${{ env.default_python || '3.9' }}"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tox_pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install cbc
run: sudo apt install coinor-cbc
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ graft tests

include .bumpversion.cfg
include .coveragerc
include .cookiecutterrc
include .editorconfig

include AUTHORS.rst
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.2dev2"
__version__ = "0.5.2.dev2"
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setup(app):
year = "2014-2023"
author = "oemof-developer-group"
copyright = "{0}, {1}".format(year, author)
version = release = "0.5.2dev2"
version = release = "0.5.2.dev2"

pygments_style = "trac"
templates_path = ["."]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ exclude = '''
'''

[build-system]
requires = ["setuptools<60.0", "wheel"]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ python_files =
tests.py
addopts =
-ra
--strict
--strict-markers
--ignore=docs/conf.py
--ignore=setup.py
--ignore=ci
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def read(*names, **kwargs):

setup(
name="oemof.solph",
version="0.5.2dev2",
version="0.5.2.dev2",
license="MIT",
description=(
"A model generator for energy system modelling and optimisation."
Expand Down
2 changes: 1 addition & 1 deletion src/oemof/solph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.5.2dev2"
__version__ = "0.5.2.dev2"

from . import buses
from . import components
Expand Down
7 changes: 5 additions & 2 deletions src/oemof/solph/constraints/equate_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ def equate_variables(model, var1, var2, factor1=1, name=None):

>>> import pandas as pd
>>> from oemof import solph
>>> date_time_index = pd.date_range('1/1/2012', periods=5, freq='H')
>>> energysystem = solph.EnergySystem(timeindex=date_time_index)
>>> date_time_index = pd.date_range('1/1/2012', periods=6, freq='H')
>>> energysystem = solph.EnergySystem(
... timeindex=date_time_index,
... infer_last_interval=False,
... )
>>> bel1 = solph.buses.Bus(label='electricity1')
>>> bel2 = solph.buses.Bus(label='electricity2')
>>> energysystem.add(bel1, bel2)
Expand Down
7 changes: 5 additions & 2 deletions src/oemof/solph/constraints/integral_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ def generic_integral_limit(om, keyword, flows=None, limit=None):
--------
>>> import pandas as pd
>>> from oemof import solph
>>> date_time_index = pd.date_range('1/1/2012', periods=5, freq='H')
>>> energysystem = solph.EnergySystem(timeindex=date_time_index)
>>> date_time_index = pd.date_range('1/1/2012', periods=6, freq='H')
>>> energysystem = solph.EnergySystem(
... timeindex=date_time_index,
... infer_last_interval=False,
... )
>>> bel = solph.buses.Bus(label='electricityBus')
>>> flow1 = solph.flows.Flow(
... nominal_value=100,
Expand Down
7 changes: 5 additions & 2 deletions src/oemof/solph/constraints/investment_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ def additional_investment_flow_limit(model, keyword, limit=None):
--------
>>> import pandas as pd
>>> from oemof import solph
>>> date_time_index = pd.date_range('1/1/2020', periods=5, freq='H')
>>> es = solph.EnergySystem(timeindex=date_time_index)
>>> date_time_index = pd.date_range('1/1/2020', periods=6, freq='H')
>>> es = solph.EnergySystem(
... timeindex=date_time_index,
... infer_last_interval=False,
... )
>>> bus = solph.buses.Bus(label='bus_1')
>>> sink = solph.components.Sink(label="sink", inputs={bus:
... solph.flows.Flow(nominal_value=10, fix=[10, 20, 30, 40, 50])})
Expand Down
7 changes: 5 additions & 2 deletions src/oemof/solph/constraints/shared_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ def shared_limit(

>>> import pandas as pd
>>> from oemof import solph
>>> date_time_index = pd.date_range('1/1/2012', periods=5, freq='H')
>>> energysystem = solph.EnergySystem(timeindex=date_time_index)
>>> date_time_index = pd.date_range('1/1/2012', periods=6, freq='H')
>>> energysystem = solph.EnergySystem(
... timeindex=date_time_index,
... infer_last_interval=False,
... )
>>> b1 = solph.buses.Bus(label="Party1Bus")
>>> b2 = solph.buses.Bus(label="Party2Bus")
>>> storage1 = solph.components.GenericStorage(
Expand Down
8 changes: 5 additions & 3 deletions tests/constraint_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def setup_class(cls):

def setup_method(self):
self.energysystem = solph.EnergySystem(
groupings=solph.GROUPINGS, timeindex=self.date_time_index
groupings=solph.GROUPINGS,
timeindex=self.date_time_index,
infer_last_interval=True,
)

def get_om(self):
Expand Down Expand Up @@ -1862,8 +1864,8 @@ def test_integral_limit_error_no_multi_period(self):
om, keyword="space"
)

def test_summed_min_max_source(self):
"""Constraints test summed_min and summed_max attribute of flow"""
def test_full_load_time_min_max_source(self):
"""Constraints test full_load_time_min and _max attribute of flow"""

bel = solph.buses.Bus(label="electricityBus")

Expand Down
55 changes: 36 additions & 19 deletions tests/multi_period_constraint_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@
logging.disable(logging.INFO)


# Warnings about the fature being experimental:
@pytest.mark.filterwarnings(
"ignore:Ensure that your timeindex and timeincrement are"
" consistent.:UserWarning"
)
@pytest.mark.filterwarnings(
"ignore:CAUTION! You specified the 'periods' attribute:UserWarning"
)
# Warnings about default parameters beaing used:
@pytest.mark.filterwarnings(
"ignore:You did not specify an interest rate.:UserWarning"
)
@pytest.mark.filterwarnings(
"ignore:By default, a discount_rate of 0.02 is used for a multi-period"
" model.:UserWarning"
)
class TestsMultiPeriodConstraint:
@classmethod
def setup_class(cls):
Expand Down Expand Up @@ -160,7 +176,7 @@ def test_linear_converter_invest_remaining_value(self):
outputs={
bel: solph.flows.Flow(
variable_costs=50,
investment=solph.Investment(
nominal_value=solph.Investment(
existing=50,
maximum=1000,
overall_maximum=10000,
Expand Down Expand Up @@ -266,7 +282,8 @@ def test_nominal_value_to_zero(self):
self.compare_lp_files("nominal_value_to_zero_multi_period.lp")

def test_fixed_source_invest_sink(self):
"""Constraints test for fixed source + invest sink w. `summed_max`"""
"""Constraints test for fixed source + invest sink w.
`full_load_time_max`"""
bel = solph.buses.Bus(label="electricityBus")

source = solph.components.Source(
Expand All @@ -282,7 +299,7 @@ def test_fixed_source_invest_sink(self):
label="excess",
inputs={
bel: solph.flows.Flow(
summed_max=2.3,
full_load_time_max=2.3,
variable_costs=25,
max=0.8,
nominal_value=solph.Investment(
Expand Down Expand Up @@ -407,7 +424,6 @@ def test_storage_invest_1_remaining_value(self):
label="storage1",
inputs={bel: solph.flows.Flow(variable_costs=56)},
outputs={bel: solph.flows.Flow(variable_costs=24)},
nominal_storage_capacity=None,
loss_rate=0.13,
max_storage_level=0.9,
min_storage_level=0.1,
Expand All @@ -417,7 +433,7 @@ def test_storage_invest_1_remaining_value(self):
lifetime_outflow=20,
inflow_conversion_factor=0.97,
outflow_conversion_factor=0.86,
investment=solph.Investment(
nominal_storage_capacity=solph.Investment(
ep_costs=[145, 130, 115],
maximum=234,
lifetime=20,
Expand Down Expand Up @@ -1930,7 +1946,6 @@ def test_nonconvex_investment_storage_without_offset_remaining_value(self):
label="storage_non_convex",
inputs={bel: solph.flows.Flow(variable_costs=56)},
outputs={bel: solph.flows.Flow(variable_costs=24)},
nominal_storage_capacity=None,
loss_rate=0.13,
max_storage_level=0.9,
min_storage_level=0.1,
Expand All @@ -1940,7 +1955,7 @@ def test_nonconvex_investment_storage_without_offset_remaining_value(self):
outflow_conversion_factor=0.86,
lifetime_inflow=20,
lifetime_outflow=20,
investment=solph.Investment(
nominal_storage_capacity=solph.Investment(
ep_costs=141,
maximum=244,
minimum=12,
Expand Down Expand Up @@ -1996,7 +2011,6 @@ def test_nonconvex_investment_storage_with_offset_remaining_value(self):
label="storage_non_convex",
inputs={bel: solph.flows.Flow(variable_costs=56)},
outputs={bel: solph.flows.Flow(variable_costs=24)},
nominal_storage_capacity=None,
loss_rate=0.13,
max_storage_level=0.9,
min_storage_level=0.1,
Expand All @@ -2006,7 +2020,7 @@ def test_nonconvex_investment_storage_with_offset_remaining_value(self):
outflow_conversion_factor=0.86,
lifetime_inflow=20,
lifetime_outflow=20,
investment=solph.Investment(
nominal_storage_capacity=solph.Investment(
ep_costs=145,
minimum=19,
offset=5,
Expand Down Expand Up @@ -2072,7 +2086,7 @@ def test_nonconvex_invest_sink_without_offset(self):
label="sink_nonconvex_invest",
inputs={
bel: solph.flows.Flow(
summed_max=2.3,
full_load_time_max=2.3,
variable_costs=25,
max=0.8,
nominal_value=solph.Investment(
Expand All @@ -2096,10 +2110,10 @@ def test_nonconvex_invest_sink_without_offset_remaining_value(self):
label="sink_nonconvex_invest",
inputs={
bel: solph.flows.Flow(
summed_max=2.3,
full_load_time_max=2.3,
variable_costs=25,
max=0.8,
investment=solph.Investment(
nominal_value=solph.Investment(
ep_costs=500,
minimum=15,
nonconvex=True,
Expand All @@ -2124,7 +2138,7 @@ def test_nonconvex_invest_source_with_offset(self):
label="source_nonconvex_invest",
outputs={
bel: solph.flows.Flow(
summed_max=2.3,
full_load_time_max=2.3,
variable_costs=25,
max=0.8,
nominal_value=solph.Investment(
Expand All @@ -2149,10 +2163,10 @@ def test_nonconvex_invest_source_with_offset_remaining_value(self):
label="source_nonconvex_invest",
outputs={
bel: solph.flows.Flow(
summed_max=2.3,
full_load_time_max=2.3,
variable_costs=25,
max=0.8,
investment=solph.Investment(
nominal_value=solph.Investment(
ep_costs=500,
minimum=15,
maximum=20,
Expand All @@ -2178,7 +2192,7 @@ def test_nonconvex_invest_source_with_offset_no_minimum(self):
label="source_nonconvex_invest",
outputs={
bel: solph.flows.Flow(
summed_max=2.3,
full_load_time_max=2.3,
variable_costs=25,
max=0.8,
nominal_value=solph.Investment(
Expand All @@ -2197,15 +2211,15 @@ def test_nonconvex_invest_source_with_offset_no_minimum(self):
)

def test_summed_min_max_source(self):
"""Test sink with summed_min and summed_max attribute"""
"""Test sink with full_load_time_min and _max attribute"""
bel = solph.buses.Bus(label="electricityBus")

sink = solph.components.Sink(
label="excess",
inputs={
bel: solph.flows.Flow(
summed_min=3,
summed_max=100,
full_load_time_min=3,
full_load_time_max=100,
variable_costs=25,
max=0.8,
nominal_value=10,
Expand Down Expand Up @@ -2249,6 +2263,9 @@ def test_flow_reaching_lifetime_initial_age(self):
self.energysystem.add(bel, sink)
self.compare_lp_files("flow_reaching_lifetime_initial_age.lp")

@pytest.mark.filterwarnings(
"ignore:Be aware that the fixed costs attribute is only:UserWarning"
)
def test_fixed_costs(self):
"""Test fixed_cost attribute for different kinds of flows"""
bel = solph.buses.Bus(label="electricityBus")
Expand Down
11 changes: 11 additions & 0 deletions tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ def test_generic_storage_with_convex_invest_offset():
)


def test_generic_storage_invest_warning():
with pytest.warns(FutureWarning):
bel = Bus()
components.GenericStorage(
label="storage7",
inputs={bel: Flow()},
outputs={bel: Flow()},
investment=Investment(),
)


def test_generic_storage_with_invest_and_fixed_losses_absolute():
"""
Storage with fixed losses in the investment mode but no minimum or existing
Expand Down
Loading
Loading