Skip to content

Commit

Permalink
Merge branch 'dev' into revision/rename-nominal_value
Browse files Browse the repository at this point in the history
  • Loading branch information
p-snft committed Nov 26, 2024
2 parents 444b685 + 53acba7 commit b2c0cff
Show file tree
Hide file tree
Showing 30 changed files with 243 additions and 105 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: "CodeQL"

on:
push:
branches: [ "dev", "master" ]
branches:
- dev
- master
- 'release/**'
pull_request:
branches: [ "dev" ]
schedule:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- dev
- 'release/**'
pull_request:

jobs:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ name: packaging
on:
# Make sure packaging process is not broken
push:
branches: [master, dev]
branches:
- master
- dev
- 'release/**'
pull_request:
# Make a package for release
release:
Expand Down Expand Up @@ -31,7 +34,7 @@ jobs:
run: python -m build .
- name: Run twine check
run: twine check dist/*
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: tox-gh-actions-dist
path: dist
3 changes: 2 additions & 1 deletion .github/workflows/tox_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
branches:
- master
- dev
- 'release/**'
pull_request:

workflow_dispatch:
Expand Down Expand Up @@ -38,7 +39,7 @@ jobs:
python-version: "${{ env.default_python || '3.9' }}"

- name: Pip cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.toxenv }}-${{ hashFiles('tox.ini', 'setup.py') }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tox_pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- master
- dev
- 'release/**'
pull_request:

workflow_dispatch:
Expand Down
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ There are several solvers that can work with oemof, both open source and commerc
Two open source solvers are widely used (CBC and GLPK), but oemof suggests CBC (Coin-or branch and cut).
It may be useful to compare results of different solvers to see which performs best.
Other commercial solvers, like Gurobi or Cplex, are also options.
Have a look at the `pyomo docs <https://pyomo.readthedocs.io/en/stable/solving_pyomo_models.html#supported-solvers>`_ to learn about which solvers are supported.
Have a look at the `pyomo docs <https://pyomo.readthedocs.io/en/stable/api/pyomo.solvers.plugins.solvers.html>`_
to learn about which solvers are supported.

Check the solver installation by executing the test_installation example below (see section Installation Test).

Expand All @@ -188,7 +189,7 @@ Check the solver installation by executing the test_installation example (see th

Please follow the installation instructions on the respective homepages for details.

CBC-solver: https://projects.coin-or.org/Cbc
CBC-solver: https://github.com/coin-or/Cbc

GLPK-solver: http://arnab-deka.com/posts/2010/02/installing-glpk-on-a-mac/

Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ These are new features and improvements of note in each release


.. include:: whatsnew/v0-6-0.rst
.. include:: whatsnew/v0-5-6.rst
.. include:: whatsnew/v0-5-5.rst
.. include:: whatsnew/v0-5-4.rst
.. include:: whatsnew/v0-5-3.rst
.. include:: whatsnew/v0-5-2.rst
Expand Down
13 changes: 5 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ def setup(app):
r"https://requires.io/.*",
r"https://matrix.to/*",
r"https://forum.openmod-initiative.org/*",
] + (
[
r"https://github.com/oemof/oemof-solph/issues/*",
r"https://github.com/oemof/oemof-solph/pull/*",
]
if "TRAVIS" not in os.environ
else []
)
r"https://github.com/oemof/oemof-solph/issues/*",
r"https://github.com/oemof/oemof-solph/pull/*",
# Due to traffic limitation, the folowwing creates a 403 in CI pipeline:
"https://www.sciencedirect.com/science/article/abs/pii/S036054421500331X",
]
4 changes: 3 additions & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ a detailed and complete description of all oemof-solph modules.
How can I use solph?
--------------------

To use solph you have to install oemof.solph and at least one solver (see :ref:`installation_label`), which can be used together with pyomo (e.g. CBC, GLPK, Gurobi, Cplex). See the `pyomo installation guide <https://pyomo.readthedocs.io/en/stable/solving_pyomo_models.html#supported-solvers>`_ for all supported solvers.
To use solph you have to install oemof.solph and at least one solver (see :ref:`installation_label`),
which can be used together with `pyomo <https://pyomo.readthedocs.io/en/stable/getting_started/installation.html>`_
(e.g. CBC, GLPK, Gurobi, Cplex).
You can test it by executing one of the existing examples (see :ref:`examples_label`).
Be aware that the examples require the CBC solver but you can change the solver name in the example files to your
solver.
Expand Down
3 changes: 1 addition & 2 deletions docs/whatsnew/v0-3-2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ New components
Documentation
####################

* Revision of the `outputlib documentation
<https://oemof-solph.readthedocs.io/en/v0.3.2/oemof_outputlib.html>`_.
* Revision of the outputlib documentation.

Other changes
####################
Expand Down
12 changes: 12 additions & 0 deletions docs/whatsnew/v0-5-5.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
v0.5.5 (August 29th, 2024)
--------------------------

Bug fixes
#########

* Fix iterating over _FakeSequence objects

Contributors
############

* Patrik Schönfeldt
17 changes: 17 additions & 0 deletions docs/whatsnew/v0-5-6.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
v0.5.6
------

Bug fixes
#########

* Update required Pyomo version to allow working with numpy >= 2.0.0.

Known issues
############

* Indexing of Storage with capacity investment is off by one.

Contributors
############

* Patrik Schönfeldt
2 changes: 0 additions & 2 deletions docs/whatsnew/v0-6-0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ Other changes
Known issues
############

* Incompatible to numpy >= 2.0.0. This is because of Pyomo, but we have to
enforce a lower version in our package.

Contributors
############
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ requires-python = ">=3.8"
dependencies = [
"blinker",
"dill",
"numpy < 2.0.0",
"pandas >= 2.0.0",
"pyomo >= 6.6.0, < 7.0",
"numpy >= 2.0.0",
"pandas >= 2.2.0",
"pyomo >= 6.8.0",
"networkx",
"oemof.tools >= 0.4.3",
"oemof.network >= 0.5.0",
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.6.0a2"
__version__ = "0.6.0a3"

from . import buses
from . import components
Expand Down
49 changes: 43 additions & 6 deletions src/oemof/solph/_plumbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
SPDX-License-Identifier: MIT
"""

import warnings
from collections import abc
from itertools import repeat

Expand All @@ -19,8 +19,8 @@

def sequence(iterable_or_scalar):
"""Checks if an object is iterable (except string) or scalar and returns
the original sequence if object is an iterable and an 'emulated'
sequence object of class _Sequence if object is a scalar or string.
the an numpy array of the sequence if object is an iterable or an
'emulated' sequence object of class _FakeSequence if object is a scalar.
Parameters
----------
Expand All @@ -30,15 +30,15 @@ def sequence(iterable_or_scalar):
--------
>>> y = sequence([1,2,3,4,5,6,7,8,9,10,11])
>>> y[0]
1
np.int64(1)
>>> y[10]
11
np.int64(11)
>>> import pandas as pd
>>> s1 = sequence(pd.Series([1,5,9]))
>>> s1[2]
9
np.int64(9)
>>> x = sequence(10)
>>> x[0]
Expand All @@ -56,6 +56,43 @@ def sequence(iterable_or_scalar):
return _FakeSequence(value=iterable_or_scalar)


def valid_sequence(sequence, length: int) -> bool:
"""Checks if an object is a numpy array of at least the given length
or an 'emulated' sequence object of class _FakeSequence.
If unset, the latter is set to the required lenght.
"""
if sequence[0] is None:
return False

if isinstance(sequence, _FakeSequence):
if sequence.size is None:
sequence.size = length

if sequence.size == length:
return True
else:
return False

if isinstance(sequence, np.ndarray):
if sequence.size == length:
return True
# --- BEGIN: To be removed for versions >= v0.6 ---
elif sequence.size > length:
warnings.warn(
"Sequence longer than needed"
f" ({sequence.size} items instead of {length})."
" This will be trated as an error in the future.",
FutureWarning,
)
return True
# --- END ---
else:
raise ValueError(f"Lentgh of {sequence} should be {length}.")

return False


class _FakeSequence:
"""Emulates a list whose length is not known in advance.
Expand Down
6 changes: 3 additions & 3 deletions src/oemof/solph/components/_extraction_turbine_chp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from pyomo.environ import BuildAction
from pyomo.environ import Constraint

from oemof.solph._plumbing import sequence as solph_sequence
from oemof.solph.components._converter import Converter
from oemof.solph._plumbing import sequence
from oemof.solph.components import Converter


class ExtractionTurbineCHP(Converter):
Expand Down Expand Up @@ -87,7 +87,7 @@ def __init__(
custom_attributes=custom_attributes,
)
self.conversion_factor_full_condensation = {
k: solph_sequence(v)
k: sequence(v)
for k, v in conversion_factor_full_condensation.items()
}

Expand Down
Loading

0 comments on commit b2c0cff

Please sign in to comment.