Skip to content

Commit

Permalink
test: use np.nan for numpy >= 2.0.0 (#270)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Linchin authored Apr 15, 2024
1 parent 7da79d9 commit a718ce4
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 34 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/unittest-prerelease.yml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,38 @@ jobs:
name: coverage-artifact-${{ matrix.python }}
path: .coverage-${{ matrix.python }}

unit-prerelease:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.12']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install nox
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install nox
- name: Run unit tests
env:
COVERAGE_FILE: .coverage-prerelease-${{ matrix.python }}
run: |
nox -s unit_prerelease
- name: Upload coverage results
uses: actions/upload-artifact@v4
with:
name: coverage-artifact-prerelease-${{ matrix.python }}
path: .coverage-prerelease-${{ matrix.python }}

cover:
runs-on: ubuntu-latest
needs:
- unit
- unit-prerelease
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"pandas": "https://pandas.pydata.org/pandas-docs/stable/"
},
)
s.move(templated_files, excludes=["docs/multiprocessing.rst", "README.rst"])
s.move(templated_files, excludes=["docs/multiprocessing.rst", "README.rst", ".github/workflows/unittest.yml"])

# ----------------------------------------------------------------------------
# Fixup files
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def test__validate_scalar_invalid(dtype):
(False, None),
(True, None),
(True, pd.NaT if pd else None),
(True, np.NaN if pd else None),
(True, "np.nan" if pd else None),
(True, 42),
],
)
Expand All @@ -328,6 +328,13 @@ def test_take(dtype, allow_fill, fill_value):
if dtype == "dbdate"
else datetime.time(0, 42, 42, 424242)
)
elif fill_value == "np.nan":
expected_fill = pd.NaT
try:
fill_value = np.NaN
except AttributeError:
# `np.NaN` was removed in NumPy 2.0 release. Use `np.nan` instead
fill_value = np.nan
else:
expected_fill = pd.NaT
b = a.take([1, -1, 3], allow_fill=True, fill_value=fill_value)
Expand Down

0 comments on commit a718ce4

Please sign in to comment.