Skip to content

Commit

Permalink
Merge pull request #1089 from oemof/pandas-warnings-fixes
Browse files Browse the repository at this point in the history
Pandas warnings fixes
  • Loading branch information
p-snft authored Jul 31, 2024
2 parents 1fc19db + 6e02ae4 commit c2d44e4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
17 changes: 14 additions & 3 deletions src/oemof/solph/_plumbing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions src/oemof/solph/components/_offset_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion src/oemof/solph/components/_sink.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/oemof/solph/components/_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2d44e4

Please sign in to comment.