Skip to content

Commit 3993f56

Browse files
committed
CI: add a build against numpy nightly
1 parent 6f7b695 commit 3993f56

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,23 @@ jobs:
2323
python-version: 3.9
2424
- uses: pre-commit/[email protected]
2525
build:
26-
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
26+
name: ${{ matrix.os }} Python ${{ matrix.python-version }} numpy-nightly=${{ matrix.numpy-nightly }}
2727
runs-on: ${{ matrix.os }}
2828
strategy:
2929
matrix:
3030
os: ["ubuntu-latest"]
3131
python-version: ["3.9", "3.10", "3.11", "3.12"]
32+
numpy-nightly: [false]
3233
include:
34+
- os: ubuntu-latest
35+
python-version: "3.12"
36+
numpy-nightly: true
3337
- os: macOS-11
3438
python-version: "3.11"
39+
numpy-nightly: false
3540
- os: windows-2019
3641
python-version: "3.11"
42+
numpy-nightly: false
3743

3844
steps:
3945
- uses: actions/checkout@v3
@@ -43,10 +49,20 @@ jobs:
4349
uses: actions/setup-python@v4
4450
with:
4551
python-version: ${{ matrix.python-version }}
52+
- name: Install dependencies with numpy nightly
53+
if: ${{ matrix.numpy-nightly == true }}
54+
run: |
55+
python -m pip install --upgrade pip
56+
python -m pip install -U --pre numpy \
57+
-i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
58+
python -c "import numpy; print(f'{numpy.__version__=}')"
59+
python -m pip install setuptools wheel
60+
python -m pip install .[dev] --no-build-isolation
4661
- name: Install dependencies
62+
if: ${{ matrix.numpy-nightly == false }}
4763
run: |
4864
python -m pip install --upgrade pip
49-
pip install .[dev]
65+
python -m pip install .[dev]
5066
- name: Run tests
5167
run: |
5268
pytest -n auto

ml_dtypes/tests/custom_float_test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
float8_e5m2fnuz = ml_dtypes.float8_e5m2fnuz
3838

3939

40+
try:
41+
# numpy >= 2.0
42+
ComplexWarning = np.exceptions.ComplexWarning
43+
except AttributeError:
44+
# numpy < 2.0
45+
ComplexWarning = np.ComplexWarning
46+
47+
4048
@contextlib.contextmanager
4149
def ignore_warning(**kw):
4250
with warnings.catch_warnings():
@@ -703,7 +711,7 @@ def testCasts(self, float_type):
703711
self.assertTrue(np.all(x == z))
704712
self.assertEqual(dtype, z.dtype)
705713

706-
@ignore_warning(category=np.ComplexWarning)
714+
@ignore_warning(category=ComplexWarning)
707715
def testConformNumpyComplex(self, float_type):
708716
for dtype in [np.complex64, np.complex128, np.clongdouble]:
709717
x = np.array([1.5, 2.5 + 2.0j, 3.5], dtype=dtype)

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[pytest]
22
filterwarnings =
33
error
4+
ignore:numpy.core._multiarray_umat.*:DeprecationWarning

0 commit comments

Comments
 (0)