Skip to content

Commit d28feeb

Browse files
committed
Update deps
Includes changes to support Pandas 3.0 (xcals now explicitly defines Timestamp resolutions following change to pandas inference ruiles). Also corrects license specification in pyproject.toml to 'Apache-2.0'.
1 parent 9e81641 commit d28feeb

File tree

9 files changed

+243
-142
lines changed

9 files changed

+243
-142
lines changed

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Run benchmark
2323
run: uv run -- pytest etc/bench.py --benchmark-json output.json
2424
- name: Download previous benchmark data
25-
uses: actions/cache@v5.0.1
25+
uses: actions/cache@v5.0.3
2626
with:
2727
path: ./cache
2828
key: ${{ runner.os }}-benchmark

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
os: [ubuntu-latest, windows-latest, macos-latest]
27-
python-version: ["3.10", "3.13"]
27+
python-version: ["3.10", "3.14"]
2828

2929
steps:
3030
- uses: actions/checkout@v6
@@ -53,8 +53,8 @@ jobs:
5353
- name: Set up minimum environment and run tests
5454
shell: bash
5555
run: |
56-
if [ "${{ matrix.python-version }}" == "3.13" ]; then
57-
GROUP="test_py13"
56+
if [ "${{ matrix.python-version }}" == "3.14" ]; then
57+
GROUP="test_py14"
5858
else
5959
GROUP="test_min"
6060
fi

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.10
1+
>=3.10

exchange_calendars/exchange_calendar.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,12 @@ def __init__(
369369

370370
break_starts = None if self._break_starts is None else self._break_starts
371371
break_ends = None if self._break_ends is None else self._break_ends
372+
# NOTE can lose the if line when min supported version of pandas bumps to
373+
# 2.0 (`as_unit`` introduced in pandas 2.0). Indeed could then remove the whole
374+
# if clause and amend index parameter below to take `_all_days.as_unit("ns")`.
375+
# NB pre v3.0 pandas infers resolution here as "ns", not so in v3.
376+
if pd.__version__ >= "3.0.0":
377+
_all_days = _all_days.as_unit("ns")
372378
self.schedule = pd.DataFrame(
373379
index=_all_days,
374380
data=collections.OrderedDict(
@@ -389,8 +395,15 @@ def __init__(
389395

390396
_check_breaks_match(self.break_starts_nanos, self.break_ends_nanos)
391397

392-
self._late_opens = _special_opens.index
393-
self._early_closes = _special_closes.index
398+
# NOTE If / when min pandas bumps to 2.0 can reduce all the following to just
399+
# the content of the if clause. (`as_unit`` introduced in pandas 2.0).
400+
# NB pre v3.0 pandas infers resolution here as "ns", not so in v3.
401+
if pd.__version__ >= "3.0.0":
402+
self._late_opens = _special_opens.index.as_unit("ns")
403+
self._early_closes = _special_closes.index.as_unit("ns")
404+
else:
405+
self._late_opens = _special_opens.index
406+
self._early_closes = _special_closes.index
394407

395408
# --------------- Calendar definition methods/properties --------------
396409
# Methods and properties in this section should be overriden or

exchange_calendars/utils/pandas_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def indexes_union(indexes: list[pd.Index]) -> pd.Index:
144144
DatetimeIndex(['2021-05-01 12:20:00', '2021-05-01 13:20:00',
145145
'2021-05-02 17:10:00', '2021-05-02 17:32:00',
146146
'2021-05-03 00:00:00', '2021-05-04 00:00:00'],
147-
dtype='datetime64[ns]', freq=None)
147+
dtype='datetime64[us]', freq=None)
148148
"""
149149
index = indexes[0]
150150
for indx in indexes[1:]:

pyproject.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ authors = [
1010
{name = "Gerry Manoim"}
1111
]
1212
readme = "README.md"
13-
license = "APSL-2.0"
13+
license = "Apache-2.0"
1414
keywords = ["finance", "security", "calendar", "exchange"]
1515
requires-python = ">=3.10, <4"
1616
classifiers = [
@@ -21,6 +21,7 @@ classifiers = [
2121
"Programming Language :: Python :: 3.11",
2222
"Programming Language :: Python :: 3.12",
2323
"Programming Language :: Python :: 3.13",
24+
"Programming Language :: Python :: 3.14",
2425
"Intended Audience :: Science/Research",
2526
"Topic :: Scientific/Engineering",
2627
"Topic :: Scientific/Engineering :: Mathematics",
@@ -48,13 +49,13 @@ test_min = [
4849
{include-group = "test"},
4950
"numpy==1.26.4",
5051
]
51-
# Separate group required for test jobs running on python 3.13.
52-
# Should be able to remove this provision once numpy and pandas officially support python 3.13, allowing uv to resolve accordingly
53-
test_py13 = [
52+
# Separate group required for test jobs running on python >= 3.14.
53+
# Might be able to remove this provision if/when bump min pandas to 2.0 and numpy to 2.0
54+
test_py14 = [
5455
{include-group = "test"},
55-
"numpy>=2.1; python_version<'3.13'",
56-
"numpy>=2.3.3; python_version>='3.13'",
57-
"pandas>=2.3; python_version>='3.13'",
56+
"numpy>=2.1; python_version<'3.14'",
57+
"numpy>=2.3.2; python_version>='3.14'",
58+
"pandas>=2.3.3; python_version>='3.14'",
5859
]
5960

6061
dev = [
@@ -77,7 +78,7 @@ trusted-publishing = "always"
7778
conflicts = [
7879
[
7980
{ group = "test_min" },
80-
{ group = "test_py13" },
81+
{ group = "test_py14" },
8182
],
8283
]
8384

@@ -111,7 +112,7 @@ testpaths = [
111112
# Settings for tools previously used by project
112113
[tool.black]
113114
line-length = 88
114-
target-version = ["py310", "py311", "py312", "py313"]
115+
target-version = ["py310", "py311", "py312", "py313", "py314"]
115116

116117
[tool.flake8]
117118
max-line-length = 88

requirements.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ numpy==2.2.6 ; python_full_version < '3.11'
66
# via
77
# exchange-calendars
88
# pandas
9-
numpy==2.4.1 ; python_full_version >= '3.11'
9+
numpy==2.4.2 ; python_full_version >= '3.11'
1010
# via
1111
# exchange-calendars
1212
# pandas
13-
pandas==2.3.3
13+
pandas==2.3.3 ; python_full_version < '3.11'
14+
# via exchange-calendars
15+
pandas==3.0.0 ; python_full_version >= '3.11'
1416
# via exchange-calendars
1517
pyluach==2.3.0
1618
# via exchange-calendars
1719
python-dateutil==2.9.0.post0
1820
# via pandas
19-
pytz==2025.2
21+
pytz==2025.2 ; python_full_version < '3.11'
2022
# via pandas
2123
six==1.17.0
2224
# via python-dateutil

tests/test_exchange_calendar.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,19 @@ def get_csv(name: str) -> pd.DataFrame:
183183
)
184184
if df.index.tz is not None:
185185
df.index = df.index.tz_convert(None)
186+
# NOTE When min supported version of pandas bumps to 2.0 will be able to lose the
187+
# if pd.__version__ >= "3.0.0" lines and just conver to as_unit in all cases
188+
# (`as_unit`` introduced in pandas 2.0).
189+
# NB pre v3.0 pandas infers resolution here as "ns", not so in v3.
186190
for col in df:
191+
if pd.__version__ >= "3.0.0":
192+
df[col] = df[col].dt.as_unit("ns")
187193
if df[col].dt.tz is None:
188194
df[col] = df[col].dt.tz_localize(UTC)
189195
else:
190196
df[col] = df[col].dt.tz_convert(UTC)
197+
if pd.__version__ >= "3.0.0":
198+
df.index = df.index.as_unit("ns")
191199
return df
192200

193201

0 commit comments

Comments
 (0)