From 32f9857fc85ddc8d95b712aef890bf303cde7c9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Patrik=20Sch=C3=B6nfeldt?= <patrik@salacia.snft.de>
Date: Mon, 26 Aug 2024 21:09:14 +0200
Subject: [PATCH] Warn about sequences that are too long

---
 src/oemof/solph/_plumbing.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/oemof/solph/_plumbing.py b/src/oemof/solph/_plumbing.py
index f4fec8d15..10e9f423d 100644
--- a/src/oemof/solph/_plumbing.py
+++ b/src/oemof/solph/_plumbing.py
@@ -10,7 +10,7 @@
 SPDX-License-Identifier: MIT
 
 """
-
+import warnings
 from collections import abc
 from itertools import repeat
 
@@ -69,10 +69,20 @@ def valid_sequence(sequence, length: int) -> bool:
         sequence.size = length
         return True
     if isinstance(sequence, np.ndarray):
-        if sequence.size >= length:
+        if sequence.size == length:
+            return True
+        # --- BEGIN: To be removed for versions >= v0.6 ---
+        elif sequence.size > length:
+            warnings.warn(
+                "Sequence longer than needed"
+                f" ({sequence.size} items instead of {length})."
+                " This will be trated as an error in the future.",
+                FutureWarning,
+            )
             return True
+        # --- END ---
         else:
-            raise ValueError(f"Lentgh of {sequence} should be {length}")
+            raise ValueError(f"Lentgh of {sequence} should be {length}.")
 
     return False