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,8 +188,14 @@ def _find_closest_date(
""" """
if delta.days < 0 and date < min(data.data): if delta.days < 0 and date < min(data.data):
if if_not_found == "nan":
return float("NaN"), float("NaN")
else:
raise DateOutOfRangeError(date, "min") raise DateOutOfRangeError(date, "min")
if delta.days > 0 and date > max(data.data): if delta.days > 0 and date > max(data.data):
if if_not_found == "nan":
return float("NaN"), float("NaN")
else:
raise DateOutOfRangeError(date, "max") raise DateOutOfRangeError(date, "max")
row: tuple = data.get(date, None) row: tuple = data.get(date, None)