Skip to content

Commit

Permalink
add datetime with utc offset test
Browse files Browse the repository at this point in the history
  • Loading branch information
wgifford committed Aug 29, 2024
1 parent ceea4e0 commit 4a7439f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/toolkit/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""Tests basic dataset functions"""

from datetime import datetime, timedelta
from datetime import datetime, timedelta, timezone

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -317,3 +317,30 @@ def my_collate(batch):
b = next(iter(dl))

assert len(b["target_values"].shape) == 1


def test_datetime_handling(ts_data):
df = ts_data.copy()
df["time_date_utc_offset"] = pd.date_range(start="2022-10-01 10:00:00 +01:00", periods=10, freq="h")

ds = ForecastDFDataset(
df,
timestamp_column="time_date_utc_offset",
id_columns=["id"],
target_columns=["val"],
context_length=3,
prediction_length=2,
)

assert ds[0]["timestamp"].tz == timezone(timedelta(hours=1))

ds = ForecastDFDataset(
df,
timestamp_column="time_date",
id_columns=["id"],
target_columns=["val"],
context_length=3,
prediction_length=2,
)

assert ds[0]["timestamp"].tz is None

0 comments on commit 4a7439f

Please sign in to comment.