oemof.solph.plumbing

Helpers to fit scalar values into sequences.

oemof.solph._plumbing.sequence(iterable_or_scalar)[source]

Checks if an object is iterable (except string) or scalar and returns 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:

iterable_or_scalar (iterable or None or int or float)

Examples

>>> 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]
10
>>> x[10]
10
oemof.solph._plumbing.valid_sequence(sequence, length: int) bool[source]

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.