diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4cdfa74..81dd1aa9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,17 +23,23 @@ jobs: python-version: 3.9 - uses: pre-commit/action@v3.0.0 build: - name: ${{ matrix.os }} Python ${{ matrix.python-version }} + name: ${{ matrix.os }} Python ${{ matrix.python-version }} numpy-nightly=${{ matrix.numpy-nightly }} runs-on: ${{ matrix.os }} strategy: matrix: os: ["ubuntu-latest"] python-version: ["3.9", "3.10", "3.11", "3.12"] + numpy-nightly: [false] include: + - os: ubuntu-latest + python-version: "3.12" + numpy-nightly: true - os: macOS-11 python-version: "3.11" + numpy-nightly: false - os: windows-2019 python-version: "3.11" + numpy-nightly: false steps: - uses: actions/checkout@v3 @@ -43,10 +49,20 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies with numpy nightly + if: ${{ matrix.numpy-nightly == true }} + run: | + python -m pip install --upgrade pip + python -m pip install -U --pre numpy \ + -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple + python -c "import numpy; print(f'{numpy.__version__=}')" + python -m pip install setuptools + python -m pip install .[dev] --no-build-isolation - name: Install dependencies + if: ${{ matrix.numpy-nightly == false }} run: | python -m pip install --upgrade pip - pip install .[dev] + python -m pip install .[dev] - name: Run tests run: | pytest -n auto diff --git a/ml_dtypes/tests/custom_float_test.py b/ml_dtypes/tests/custom_float_test.py index d71ae8b1..6ca15b21 100644 --- a/ml_dtypes/tests/custom_float_test.py +++ b/ml_dtypes/tests/custom_float_test.py @@ -37,6 +37,14 @@ float8_e5m2fnuz = ml_dtypes.float8_e5m2fnuz +try: + # numpy >= 2.0 + ComplexWarning = np.exceptions.ComplexWarning +except AttributeError: + # numpy < 2.0 + ComplexWarning = np.ComplexWarning + + @contextlib.contextmanager def ignore_warning(**kw): with warnings.catch_warnings(): @@ -703,7 +711,7 @@ def testCasts(self, float_type): self.assertTrue(np.all(x == z)) self.assertEqual(dtype, z.dtype) - @ignore_warning(category=np.ComplexWarning) + @ignore_warning(category=ComplexWarning) def testConformNumpyComplex(self, float_type): for dtype in [np.complex64, np.complex128, np.clongdouble]: x = np.array([1.5, 2.5 + 2.0j, 3.5], dtype=dtype) diff --git a/pytest.ini b/pytest.ini index 9e90ef7c..2842b4cf 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,4 @@ [pytest] filterwarnings = error + ignore:numpy.core._multiarray_umat.*:DeprecationWarning