Skip to content

Commit 72404a8

Browse files
authored
Fix meteonorm tests for older pandas versions (#2553)
* allow ValueError for older pandas versions * add explanatory comment
1 parent 4d21d99 commit 72404a8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pvlib/iotools/meteonorm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,19 +532,21 @@ def _get_meteonorm(
532532

533533
# Check for None type in case of TMY request
534534
# Check for DateParseError in case of relative times, e.g., '+3hours'
535+
# TODO: remove ValueError when our minimum pandas version is high enough
536+
# to make it unnecessary (2.0?)
535537
if (start is not None) & (start != 'now'):
536538
try:
537539
start = pd.Timestamp(start)
538540
start = start.tz_localize("UTC") if start.tzinfo is None else start
539541
start = start.strftime("%Y-%m-%dT%H:%M:%SZ")
540-
except DateParseError:
542+
except (ValueError, DateParseError):
541543
pass
542544
if (end is not None) & (end != 'now'):
543545
try:
544546
end = pd.Timestamp(end)
545547
end = end.tz_localize("UTC") if end.tzinfo is None else end
546548
end = end.strftime("%Y-%m-%dT%H:%M:%SZ")
547-
except DateParseError:
549+
except (ValueError, DateParseError):
548550
pass
549551

550552
params = {

0 commit comments

Comments
 (0)