find closest date returns nan for min/max failure as well

This commit is contained in:
Gourav Kumar 2022-09-11 15:13:06 +05:30
parent 18b60bd608
commit 7b65f6ff3f

View File

@ -188,9 +188,15 @@ def _find_closest_date(
"""
if delta.days < 0 and date < min(data.data):
raise DateOutOfRangeError(date, "min")
if if_not_found == "nan":
return float("NaN"), float("NaN")
else:
raise DateOutOfRangeError(date, "min")
if delta.days > 0 and date > max(data.data):
raise DateOutOfRangeError(date, "max")
if if_not_found == "nan":
return float("NaN"), float("NaN")
else:
raise DateOutOfRangeError(date, "max")
row: tuple = data.get(date, None)
if row is not None: