Skip to content

Commit

Permalink
Adapt scenario.add_par to raise instead of xpass
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Jan 9, 2024
1 parent 0eba0ac commit 4ff6ef3
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions ixmp/core/scenario.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import sys
from functools import partialmethod
from itertools import repeat, zip_longest
from numbers import Real
Expand Down Expand Up @@ -575,17 +574,9 @@ def add_par(
# Multiple values
values = value

if sys.version_info >= (3, 10):
try:
data = pd.DataFrame(
zip(keys, values, strict=True), columns=["key", "value"]
)
except ValueError as e:
raise ValueError("Length mismatch between keys and values") from e
else:
data = pd.DataFrame(zip(keys, values), columns=["key", "value"])
if data.isna().any(axis=None):
raise ValueError("Length mismatch between keys and values")
data = pd.DataFrame(zip_longest(keys, values), columns=["key", "value"])
if data.isna().any(axis=None):
raise ValueError("Length mismatch between keys and values")

# Column types
types = {
Expand Down

0 comments on commit 4ff6ef3

Please sign in to comment.