diff --git a/src/oemof/solph/_plumbing.py b/src/oemof/solph/_plumbing.py index 806cf9507..bf18dbdae 100644 --- a/src/oemof/solph/_plumbing.py +++ b/src/oemof/solph/_plumbing.py @@ -15,6 +15,8 @@ from collections import abc from itertools import repeat +import numpy as np + def sequence(iterable_or_scalar): """Tests if an object is iterable (except string) or scalar and returns @@ -27,8 +29,17 @@ def sequence(iterable_or_scalar): Examples -------- - >>> sequence([1,2]) - [1, 2] + >>> y = sequence([1,2,3,4,5,6,7,8,9,10,11]) + >>> y[0] + 1 + + >>> y[10] + 11 + + >>> import pandas as pd + >>> s1 = sequence(pd.Series([1,5,9])) + >>> s1[2] + 9 >>> x = sequence(10) >>> x[0] @@ -43,7 +54,7 @@ def sequence(iterable_or_scalar): if isinstance(iterable_or_scalar, abc.Iterable) and not isinstance( iterable_or_scalar, str ): - return iterable_or_scalar + return np.array(iterable_or_scalar) else: return _Sequence(default=iterable_or_scalar) diff --git a/src/oemof/solph/components/_offset_converter.py b/src/oemof/solph/components/_offset_converter.py index c8f742df3..d5a09bcba 100644 --- a/src/oemof/solph/components/_offset_converter.py +++ b/src/oemof/solph/components/_offset_converter.py @@ -304,12 +304,12 @@ def normed_offset_and_conversion_factors_from_coefficients( c0, c1 = slope_offset_from_nonconvex_output( flow.max[i], flow.min[i], eta_at_max, eta_at_min ) - slope += [c0] - offset += [c1] + slope.append(c0) + offset.append(c1) if max_len == 1: - slope = sequence(slope[0]) - offset = sequence(offset[0]) + slope = slope[0] + offset = offset[0] conversion_factors = {input_bus: slope} normed_offsets = {input_bus: offset} diff --git a/src/oemof/solph/components/_sink.py b/src/oemof/solph/components/_sink.py index 1e2676792..7644871fd 100644 --- a/src/oemof/solph/components/_sink.py +++ b/src/oemof/solph/components/_sink.py @@ -21,7 +21,7 @@ class Sink(Node): Parameters ---------- - label : str + label : str or tuple String holding the label of the Sink object. The label of each object must be unique. inputs: dict diff --git a/src/oemof/solph/components/_source.py b/src/oemof/solph/components/_source.py index fa81fdb65..d775d16d8 100644 --- a/src/oemof/solph/components/_source.py +++ b/src/oemof/solph/components/_source.py @@ -21,7 +21,7 @@ class Source(Node): Parameters ---------- - label : str + label : str or tuple String holding the label of the Source object. The label of each object must be unique. outputs: dict