From d34576cbfc3b8e8a586a5c9f5d80027b85a93482 Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Mon, 25 Sep 2023 12:07:47 -0400 Subject: [PATCH 1/3] Fix `np.float_` and `np.complex_` references --- deepdiff/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deepdiff/helper.py b/deepdiff/helper.py index cec24f38..6b7f0a11 100644 --- a/deepdiff/helper.py +++ b/deepdiff/helper.py @@ -64,11 +64,11 @@ class pydantic_base_model_type: np_uintp = np.uintp np_float32 = np.float32 np_float64 = np.float64 - np_float_ = np.float_ + np_float_ = np.double # np.float_ is an alias for np.double and is being removed by NumPy 2.0 np_floating = np.floating np_complex64 = np.complex64 np_complex128 = np.complex128 - np_complex_ = np.complex_ + np_complex_ = np.cdouble # np.complex_ is an alias for np.cdouble and is being removed by NumPy 2.0 np_complexfloating = np.complexfloating numpy_numbers = ( From b1e7d9dddbe4488b50928654d7e4cc9d43bdb46f Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Mon, 25 Sep 2023 12:14:45 -0400 Subject: [PATCH 2/3] Fix deprecation warning from numpy 2.0 --- deepdiff/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepdiff/helper.py b/deepdiff/helper.py index 6b7f0a11..29efe0bd 100644 --- a/deepdiff/helper.py +++ b/deepdiff/helper.py @@ -655,7 +655,7 @@ def diff_numpy_array(A, B): By Divakar https://stackoverflow.com/a/52417967/1497443 """ - return A[~np.in1d(A, B)] + return A[~np.isin(A, B)] PYTHON_TYPE_TO_NUMPY_TYPE = { From c9232d2ba03f43531d3c48436b971db777754e82 Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Mon, 25 Sep 2023 15:17:55 -0400 Subject: [PATCH 3/3] Update tests to run with numpy 2.0 where appropriate. --- .github/workflows/main.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 27223735..b17d2542 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -14,6 +14,13 @@ jobs: matrix: python-version: [3.7, 3.8, 3.9, "3.10", "3.11"] architecture: ["x64"] + include: + - python-version: 3.9 + numpy-version: "2.0.dev" + - python-version: 3.10 + numpy-version: "2.0.dev" + - python-version: 3.11 + numpy-version: "2.0.dev" steps: - uses: actions/checkout@v2 - name: Setup Python ${{ matrix.python-version }} on ${{ matrix.architecture }} @@ -37,6 +44,9 @@ jobs: - name: Install dependencies if: matrix.python-version != 3.7 run: pip install -r requirements-dev.txt + - name: Install Numpy Dev + if: ${{ matrix.numpy-version }} + run: pip install -I --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple "numpy>=0.0.dev0" - name: Lint with flake8 if: matrix.python-version == 3.11 run: |