Skip to content

Commit 94a08c2

Browse files
committed
Replace pandas date_range API with DatetimeIndex in tests
Signed-off-by: Arham Chopra <arham.chopra@cubistsystematic.com>
1 parent 8ff82fd commit 94a08c2

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

csp/tests/adapters/test_parquet.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,13 @@ def graph():
205205
csp.run(graph, starttime=start_time)
206206
df = pandas.read_parquet(filename)
207207
expected_columns = {}
208-
# pandas 3.0+: need to explicitly force ns unit and UTC tz, no longer the default
208+
# Build the expected index explicitly rather than via pandas.date_range(...),
209+
# which segfaults under pandas 3.0.4 + numpy<2.5 (tslibs offset ABI mismatch).
210+
# This yields the same datetime64[ns, UTC] values.
209211
if timestamp_column_name:
210-
expected_columns[timestamp_column_name] = pandas.date_range(
211-
start=start_time + timedelta(seconds=1), periods=10, unit="ns", freq="1s", tz="UTC"
212-
)
212+
expected_columns[timestamp_column_name] = pandas.DatetimeIndex(
213+
[start_time + timedelta(seconds=i) for i in range(1, 11)]
214+
).as_unit("ns")
213215
expected_columns.update(
214216
{
215217
"x": list(range(1, 11)),
@@ -242,10 +244,12 @@ def graph():
242244

243245
expected_df = pandas.DataFrame.from_dict(
244246
{
245-
# pandas 3.0+: need to explicitly force ns unit and UTC tz, no longer the default
246-
"timestamp": pandas.date_range(
247-
start=start_time + timedelta(seconds=1), periods=10, unit="ns", freq="1s", tz="UTC"
248-
),
247+
# Build the expected index explicitly rather than via pandas.date_range(...),
248+
# which segfaults under pandas 3.0.4 + numpy<2.5 (tslibs offset ABI mismatch).
249+
# This yields the same datetime64[ns, UTC] values.
250+
"timestamp": pandas.DatetimeIndex(
251+
[start_time + timedelta(seconds=i) for i in range(1, 11)]
252+
).as_unit("ns"),
249253
"x": list(range(1, 11)),
250254
"y": list(map(float, range(0, 100, 10))),
251255
}

0 commit comments

Comments
 (0)