import pandas as pd
from spotforecast2_safe.preprocessing.data_transform import date_to_index_position
# Integer input returns itself unchanged
idx = pd.date_range("2020-01-01", periods=10, freq="h")
result = date_to_index_position(idx, 5)
print(result)
assert result == 5
# String date → prediction steps from the last date in the index
# idx[-1] == "2020-01-01 09:00", so 3 steps to reach "2020-01-01 12:00"
steps = date_to_index_position(idx, "2020-01-01 12:00", method="prediction")
print(steps)
assert steps == 3
# String date → validation position (1-based count from start)
pos = date_to_index_position(idx, "2020-01-01 03:00", method="validation")
print(pos)
assert pos == 45
3
4