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

Rename custom_attributes to custom_properties for Nodes #1145

Merged
merged 4 commits into from
Dec 17, 2024
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
5 changes: 5 additions & 0 deletions docs/whatsnew/v0-6-0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ API changes
effectively the same) had double weight before. Also, if the
initial storage level is defined, the costs just offset the
objective value without changing anything else.
* Rename custom_attributes to custom_properties for all Nodes.
Setting the oemof.network.Node.custom_properties
using an argument called "custom_attributes" was rather confusing.
Additionally, the class Bus already called the argument
"custom_properties".
* The parameters `GenericStorage.nominal_storage_capacity` and
`Flow.nominal_value` are now both called `nominal_capacity`.

Expand Down
11 changes: 5 additions & 6 deletions src/oemof/solph/components/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,20 @@ def __init__(
inputs=None,
outputs=None,
conversion_factors=None,
custom_attributes=None,
custom_properties=None,
):
if inputs is None:
inputs = {}
if outputs is None:
outputs = {}

if custom_attributes is None:
custom_attributes = {}
if custom_properties is None:
custom_properties = {}

super().__init__(
label=label,
inputs=inputs,
outputs=outputs,
custom_properties=custom_attributes,
custom_properties=custom_properties,
)
if not inputs:
warn_if_missing_attribute(self, "inputs")
Expand Down Expand Up @@ -153,7 +152,7 @@ def __init__(
inputs=inputs,
outputs=outputs,
conversion_factors=conversion_factors,
custom_attributes=custom_attributes,
custom_properties=custom_attributes,
)
warn(
"solph.components.Transformer has been renamed to"
Expand Down
4 changes: 2 additions & 2 deletions src/oemof/solph/components/_extraction_turbine_chp.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ def __init__(
inputs=None,
outputs=None,
conversion_factors=None,
custom_attributes=None,
custom_properties=None,
):
super().__init__(
label=label,
inputs=inputs,
outputs=outputs,
conversion_factors=conversion_factors,
custom_attributes=custom_attributes,
custom_properties=custom_properties,
)
self.conversion_factor_full_condensation = {
k: sequence(v)
Expand Down
8 changes: 4 additions & 4 deletions src/oemof/solph/components/_generic_chp.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ def __init__(
beta,
back_pressure,
label=None,
custom_attributes=None,
custom_properties=None,
):
if custom_attributes is None:
custom_attributes = {}
super().__init__(label, custom_properties=custom_attributes)
if custom_properties is None:
custom_properties = {}
super().__init__(label, custom_properties=custom_properties)

self.fuel_input = fuel_input
self.electrical_output = electrical_output
Expand Down
10 changes: 5 additions & 5 deletions src/oemof/solph/components/_offset_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@ def __init__(
conversion_factors=None,
normed_offsets=None,
coefficients=None,
custom_attributes=None,
custom_properties=None,
):
if custom_attributes is None:
custom_attributes = {}
if custom_properties is None:
custom_properties = {}

super().__init__(
inputs=inputs,
outputs=outputs,
label=label,
custom_properties=custom_attributes,
custom_properties=custom_properties,
)

# this part is used for the transition phase from the old
Expand Down Expand Up @@ -393,7 +393,7 @@ def __init__(
inputs=inputs,
outputs=outputs,
coefficients=coefficients,
custom_attributes=custom_attributes,
custom_properties=custom_attributes,
)
warn(
"solph.components.OffsetTransformer has been renamed to"
Expand Down
8 changes: 4 additions & 4 deletions src/oemof/solph/components/_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class Sink(Node):

"""

def __init__(self, label=None, *, inputs, custom_attributes=None):
def __init__(self, label=None, *, inputs, custom_properties=None):
if inputs is None:
inputs = {}
if custom_attributes is None:
custom_attributes = {}
if custom_properties is None:
custom_properties = {}

super().__init__(
label=label, inputs=inputs, custom_properties=custom_attributes
label=label, inputs=inputs, custom_properties=custom_properties
)

def constraint_group(self):
Expand Down
8 changes: 4 additions & 4 deletions src/oemof/solph/components/experimental/_sink_dsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ def __init__(
shift_eligibility=True,
fixed_costs=0,
investment=None,
custom_attributes=None,
custom_properties=None,
):
if custom_attributes is None:
custom_attributes = {}
if custom_properties is None:
custom_properties = {}
super().__init__(
label=label, inputs=inputs, custom_attributes=custom_attributes
label=label, inputs=inputs, custom_properties=custom_properties
)

self.capacity_up = sequence(capacity_up)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_components/test_offset_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_custom_properties():
outputs={bus2: solph.Flow()},
conversion_factors={bus2: 2},
normed_offsets={bus2: -0.5},
custom_attributes={"foo": "bar"},
custom_properties={"foo": "bar"},
)

assert oc.custom_properties["foo"] == "bar"
Expand Down
Loading