Skip to content

Commit

Permalink
Merge pull request #604 from oemof/release/v0.3.1
Browse files Browse the repository at this point in the history
Release/v0.3.1
  • Loading branch information
uvchik authored Jun 11, 2019
2 parents 19656ba + cf34877 commit 1429cb5
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 41 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.3.0"
__version__ = "0.3.1"

1 change: 1 addition & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ These are new features and improvements of note in each release
:local:
:backlinks: top

.. include:: whatsnew/v0-3-1.rst
.. include:: whatsnew/v0-3-0.rst
.. include:: whatsnew/v0-2-3.rst
.. include:: whatsnew/v0-2-2.rst
Expand Down
47 changes: 9 additions & 38 deletions doc/whatsnew/v0-3-1.rst
Original file line number Diff line number Diff line change
@@ -1,48 +1,19 @@
v0.3.1 (September ??, 2019)
v0.3.1 (June 11, 2019)
++++++++++++++++++++++++++


API changes
###########

* something

New features
############

* something

New components
##############

* something

Documentation
#############

* something

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

* something

Bug fixes
#########

* something

Testing
#######

* something

Other changes
#############

* something
* The API of the GenericStorage changed. Due to the open structure of solph
the old parameters are still accepted. Therefore users may not notice that
the default value is used instead of the given value after an update from
v0.2.x to v0.3.x. With this version an error is raised. We work on a
structure to avoid such problems in the future.

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

* something
* Patrik Schönfeldt
* Stephan Günther
* Uwe Krien
2 changes: 1 addition & 1 deletion oemof/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)

__version__ = '0.3.0'
__version__ = '0.3.1'
27 changes: 27 additions & 0 deletions oemof/solph/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@ def __init__(self, *args,
if self._invest_group is True:
self._check_invest_attributes()

# Check for old parameter names. This is a temporary fix and should
# be removed once a general solution is found.
# TODO: https://github.com/oemof/oemof/issues/560
renamed_parameters = [
('nominal_capacity', 'nominal_storage_capacity'),
('initial_capacity', 'initial_storage_level'),
('capacity_loss', 'loss_rate'),
('capacity_min', 'min_storage_level'),
('capacity_max', 'max_storage_level')]
messages = [
"`{0}` to `{1}`".format(old_name, new_name)
for old_name, new_name in renamed_parameters
if old_name in kwargs
]
if messages:
message = (
"The following attributes have been renamed from v0.2 to v0.3:"
"\n\n {}\n\n"
"You are using the old names as parameters, thus setting "
"deprecated\n"
"attributes, which is not what you might have intended.\n"
"Use the new names, or, if you know what you're doing, set "
"these\n"
"attributes explicitly after construction instead."
)
raise AttributeError(message.format("\n ".join(messages)))

def _set_flows(self):
for flow in self.inputs.values():
if (self.invest_relation_input_capacity is not None and
Expand Down
30 changes: 30 additions & 0 deletions tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,36 @@ def test_generic_storage_3():
inflow_conversion_factor=1, outflow_conversion_factor=0.8)


def test_generic_storage_with_old_parameters():
deprecated = {
'nominal_capacity': 45,
'initial_capacity': 0,
'capacity_loss': 0,
'capacity_min': 0,
'capacity_max': 0,
}
# Make sure an `AttributeError` is raised if we supply all deprecated
# parameters.
with tools.assert_raises(AttributeError) as caught:
solph.components.GenericStorage(
label='`GenericStorage` with all deprecated parameters',
**deprecated
)
for parameter in deprecated:
# Make sure every parameter used is mentioned in the exception's
# message.
assert parameter in str(caught.exception)
# Make sure an `AttributeError` is raised for each deprecated parameter.
tools.assert_raises(
AttributeError,
solph.components.GenericStorage,
**{
"label": "`GenericStorage` with `{}`".format(parameter),
parameter: deprecated[parameter],
}
)


# ********* OffsetTransformer *********

def test_offsettransformer_wrong_flow_type():
Expand Down
1 change: 0 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
def test_timeincrement_with_valid_timeindex():
datetimeindex = pd.date_range('1/1/2012', periods=1, freq='H')
es = solph.EnergySystem(timeindex=datetimeindex)
print(es.timeindex.freq)
m = solph.models.BaseModel(es)
eq_(m.timeincrement[0], 1)
eq_(es.timeindex.freq.nanos / 3.6e12, 1)
Expand Down

0 comments on commit 1429cb5

Please sign in to comment.