Skip to content

Commit 88d0cb9

Browse files
committed
opf: Fix get_shadows for no branches
1 parent 564826d commit 88d0cb9

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pypsa/opf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,8 @@ def set_from_series(df, series):
11671167
df.loc[snapshots] = series.unstack(0).reindex(columns=df.columns)
11681168

11691169
def get_shadows(constraint, multiind=True):
1170+
if len(constraint) == 0: return pd.Series()
1171+
11701172
index = list(constraint.keys())
11711173
if multiind:
11721174
index = pd.MultiIndex.from_tuples(index)

test/test_unit_commitment.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,8 @@ def test_minimum_down_time():
134134
expected_dispatch = np.array([[3000,0,0,8000],[0,800,3000,0]],dtype=float).T
135135

136136
np.testing.assert_array_almost_equal(nu.generators_t.p.values,expected_dispatch)
137+
138+
if __name__ == "__main__":
139+
test_minimum_down_time()
140+
test_minimum_up_time()
141+
test_part_load()

0 commit comments

Comments
 (0)