Skip to content

Commit 3249f18

Browse files
authored
Fix: Correct mismatched datetime resolution with pd.date_range (#243)
* replace pandas date_range with polars datetime_range for compatible default dt resolution * udpate changelog * Revert "udpate changelog" This reverts commit 267d272. * Revert "replace pandas date_range with polars datetime_range for compatible default dt resolution" This reverts commit 9a05dba. * udpate changelog * replace pandas date_range with polars datetime_range for compatible default dt resolution * update changelog * bump version
1 parent de7a8c5 commit 3249f18

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## v0.13.4 - 14 July 2026
4+
5+
- Replaces the use of `pandas.date_range` with `polars.datetime_range` in
6+
`tests/unit/test_environment.py` to account for Pandas updated default time resolution of us to ns.
7+
38
## v0.13.3. - 8 April 2026
49

510
- Enable Pandas v3.

tests/unit/test_environment.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pathlib import Path
77

88
import numpy as np
9-
import pandas as pd
109
import polars as pl
1110
import pytest
1211
import numpy.testing as npt
@@ -372,11 +371,12 @@ def test_weather_forecast():
372371

373372
# Test for the next 5 hours, but at the top of the hour
374373
# Starts with hour 0, and ends with the 5th hour following
375-
correct_index = pl.from_pandas(
376-
pd.date_range(
377-
"1/1/2002 00:00:00", "1/1/2002 04:00:00", freq="1h", name="datetime"
378-
)
379-
)
374+
correct_index = pl.datetime_range(
375+
datetime.datetime(2002, 1, 1),
376+
datetime.datetime(2002, 1, 1, 4),
377+
interval="1h",
378+
eager=True,
379+
).alias("datetime")
380380
correct_hour = np.array([0, 1, 2, 3, 4], dtype=float)
381381
correct_wind = np.array(
382382
[11.75561096, 10.41321252, 8.959270788, 9.10014808, 9.945059601]
@@ -395,11 +395,12 @@ def test_weather_forecast():
395395
# Test for 5 hours at an uneven start time increment
396396
# Starts at hour 1, and ends with the 5th hour following
397397
env.run(until=0.1)
398-
correct_index = pl.from_pandas(
399-
pd.date_range(
400-
"1/1/2002 00:00:00", "1/1/2002 05:00:00", freq="1h", name="datetime"
401-
)
402-
)
398+
correct_index = pl.datetime_range(
399+
datetime.datetime(2002, 1, 1),
400+
datetime.datetime(2002, 1, 1, 5),
401+
interval="1h",
402+
eager=True,
403+
).alias("datetime")
403404
correct_hour = np.arange(6, dtype=float)
404405
correct_wind = np.array(
405406
[11.75561096, 10.41321252, 8.959270788, 9.10014808, 9.945059601, 11.50807971]
@@ -418,11 +419,12 @@ def test_weather_forecast():
418419
# Test for 5.5 hours at an uneven start time increment
419420
# Starts at hour 1, and ends at the 7th hour following
420421
env.run(until=1.2)
421-
correct_index = pl.from_pandas(
422-
pd.date_range(
423-
"1/1/2002 01:00:00", "1/1/2002 07:00:00", freq="1h", name="datetime"
424-
)
425-
)
422+
correct_index = pl.datetime_range(
423+
datetime.datetime(2002, 1, 1, 1),
424+
datetime.datetime(2002, 1, 1, 7),
425+
interval="1h",
426+
eager=True,
427+
).alias("datetime")
426428
correct_hour = np.arange(1, 8, dtype=float)
427429
correct_wind = np.array(
428430
[

wombat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from wombat.core.library import create_library_structure, load_yaml
55

66

7-
__version__ = "0.13.3"
7+
__version__ = "0.13.4"

0 commit comments

Comments
 (0)