Skip to content

Commit a718ce4

Browse files
authored
test: use np.nan for numpy >= 2.0.0 (#270)
* fix: use np.nan for numpy >= 2.0.0 * merge unittest-prerelease.yml into unittest.yml * add unit-prerelease to cover's dependencies * fix coverage file upload
1 parent 7da79d9 commit a718ce4

File tree

4 files changed

+37
-34
lines changed

4 files changed

+37
-34
lines changed

.github/workflows/unittest-prerelease.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/unittest.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,38 @@ jobs:
3131
name: coverage-artifact-${{ matrix.python }}
3232
path: .coverage-${{ matrix.python }}
3333

34+
unit-prerelease:
35+
runs-on: ubuntu-latest
36+
strategy:
37+
matrix:
38+
python: ['3.12']
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
- name: Setup Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: ${{ matrix.python }}
46+
- name: Install nox
47+
run: |
48+
python -m pip install --upgrade setuptools pip wheel
49+
python -m pip install nox
50+
- name: Run unit tests
51+
env:
52+
COVERAGE_FILE: .coverage-prerelease-${{ matrix.python }}
53+
run: |
54+
nox -s unit_prerelease
55+
- name: Upload coverage results
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: coverage-artifact-prerelease-${{ matrix.python }}
59+
path: .coverage-prerelease-${{ matrix.python }}
60+
3461
cover:
3562
runs-on: ubuntu-latest
3663
needs:
3764
- unit
65+
- unit-prerelease
3866
steps:
3967
- name: Checkout
4068
uses: actions/checkout@v4

owlbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"pandas": "https://pandas.pydata.org/pandas-docs/stable/"
3535
},
3636
)
37-
s.move(templated_files, excludes=["docs/multiprocessing.rst", "README.rst"])
37+
s.move(templated_files, excludes=["docs/multiprocessing.rst", "README.rst", ".github/workflows/unittest.yml"])
3838

3939
# ----------------------------------------------------------------------------
4040
# Fixup files

tests/unit/test_dtypes.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def test__validate_scalar_invalid(dtype):
314314
(False, None),
315315
(True, None),
316316
(True, pd.NaT if pd else None),
317-
(True, np.NaN if pd else None),
317+
(True, "np.nan" if pd else None),
318318
(True, 42),
319319
],
320320
)
@@ -328,6 +328,13 @@ def test_take(dtype, allow_fill, fill_value):
328328
if dtype == "dbdate"
329329
else datetime.time(0, 42, 42, 424242)
330330
)
331+
elif fill_value == "np.nan":
332+
expected_fill = pd.NaT
333+
try:
334+
fill_value = np.NaN
335+
except AttributeError:
336+
# `np.NaN` was removed in NumPy 2.0 release. Use `np.nan` instead
337+
fill_value = np.nan
331338
else:
332339
expected_fill = pd.NaT
333340
b = a.take([1, -1, 3], allow_fill=True, fill_value=fill_value)

0 commit comments

Comments
 (0)