From 6ccf4c119f12f732bb3e820df404a83b688e80f1 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 10:12:47 -0700 Subject: [PATCH 01/10] try testing numpy <2 and >=2 --- .github/workflows/tests.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8075b01..5d2cfad 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,13 +8,14 @@ on: jobs: tests: - name: Py${{ matrix.python-version }} ${{ matrix.os }} + name: Py${{ matrix.python-version }} ${{ matrix.os }} NumPy${{ matrix.numpy-version }} runs-on: ${{ matrix.os }} strategy: matrix: os: [macos-latest, windows-latest, ubuntu-22.04] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] + numpy-version: ['<2', '>=2'] steps: - uses: actions/checkout@v4.1.1 @@ -41,6 +42,10 @@ jobs: pip install --upgrade pip setuptools wheel pip install .[test] + - name: Install NumPy + run: | + pip install --force-reinstall "numpy${{ matrix.numpy-version }}" + - name: Tests run: | pip install cython From e68574404988bb68459bbbdaae92f564fc9c6a30 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 10:22:33 -0700 Subject: [PATCH 02/10] exclude old ubuntus --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5d2cfad..ade5acb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,6 +16,10 @@ jobs: os: [macos-latest, windows-latest, ubuntu-22.04] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] numpy-version: ['<2', '>=2'] + exclude: + - os: ubuntu-22.04 + python-version: '3.8' + numpy-version: '>=2' steps: - uses: actions/checkout@v4.1.1 From e2d4cec4d683ea95da3d6c542b15cc7d628a629d Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 10:33:57 -0700 Subject: [PATCH 03/10] why is the previous stopping all the tests from running? --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ade5acb..8b1d817 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-22.04] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - numpy-version: ['<2', '>=2'] + numpy-version: ['<2.0.0', '>=2.0.0'] exclude: - os: ubuntu-22.04 python-version: '3.8' From 3b5f3f83bffa410a7e78f690f1e4c03198f2c683 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 10:44:58 -0700 Subject: [PATCH 04/10] bah --- .github/workflows/tests.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8b1d817..5f5d780 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,10 +16,6 @@ jobs: os: [macos-latest, windows-latest, ubuntu-22.04] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] numpy-version: ['<2.0.0', '>=2.0.0'] - exclude: - - os: ubuntu-22.04 - python-version: '3.8' - numpy-version: '>=2' steps: - uses: actions/checkout@v4.1.1 From 0f3c6699d111fc55f3d126028e64c2d9f36099d3 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 11:00:36 -0700 Subject: [PATCH 05/10] drop 3.8 for now from tests --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5f5d780..c3bcb4d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,8 +14,8 @@ jobs: strategy: matrix: os: [macos-latest, windows-latest, ubuntu-22.04] - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] - numpy-version: ['<2.0.0', '>=2.0.0'] + python-version: ['3.9', '3.10', '3.11', '3.12'] + numpy-version: ['<2', '>=2'] steps: - uses: actions/checkout@v4.1.1 From 9152fe81aad3d7d93a8458df2a9a8c1b52cd264b Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 11:06:10 -0700 Subject: [PATCH 06/10] does this work? --- .github/workflows/tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c3bcb4d..3636e0d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,6 +16,9 @@ jobs: os: [macos-latest, windows-latest, ubuntu-22.04] python-version: ['3.9', '3.10', '3.11', '3.12'] numpy-version: ['<2', '>=2'] + include: + - python-version: '3.8' + numpy-version: '<2' steps: - uses: actions/checkout@v4.1.1 From dd94d305f220dc00828a0a0d7c592f79df902dfa Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 11:07:03 -0700 Subject: [PATCH 07/10] how about this? --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3636e0d..04cc2e8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,8 @@ jobs: python-version: ['3.9', '3.10', '3.11', '3.12'] numpy-version: ['<2', '>=2'] include: - - python-version: '3.8' + - os: macos-latest + python-version: '3.8' numpy-version: '<2' steps: From e9b3ff5f60d5c1b9b297899a8dca62481a634f1e Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 11:11:01 -0700 Subject: [PATCH 08/10] add back in all possible 3.8 tests --- .github/workflows/tests.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 04cc2e8..b8fddc2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,6 +20,12 @@ jobs: - os: macos-latest python-version: '3.8' numpy-version: '<2' + - os: windows-latest + python-version: '3.8' + numpy-version: '<2' + - os: ubuntu-22.04 + python-version: '3.8' + numpy-version: '<2' steps: - uses: actions/checkout@v4.1.1 From 696e7533adf524b8191c16708c17937b7b094a2b Mon Sep 17 00:00:00 2001 From: Jongbin Jung Date: Sat, 5 Oct 2024 10:43:40 -0700 Subject: [PATCH 09/10] Support `str`-like values for str_to_int (#408) * Add failing test * Explicitly convert to str before calling _cy.str_to_int --- src/h3/api/basic_int/__init__.py | 2 +- tests/test_apis/test_numpy_int.py | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/h3/api/basic_int/__init__.py b/src/h3/api/basic_int/__init__.py index 6035966..992fce7 100644 --- a/src/h3/api/basic_int/__init__.py +++ b/src/h3/api/basic_int/__init__.py @@ -53,7 +53,7 @@ def str_to_int(h): int Unsigned 64-bit integer """ - return _cy.str_to_int(h) + return _cy.str_to_int(str(h)) def int_to_str(x): diff --git a/tests/test_apis/test_numpy_int.py b/tests/test_apis/test_numpy_int.py index 2ffa43f..c341b55 100644 --- a/tests/test_apis/test_numpy_int.py +++ b/tests/test_apis/test_numpy_int.py @@ -5,7 +5,10 @@ from .. import util as u def test1(): - lat, lng = 37.7752702151959, -122.418307270836, + lat, lng = ( + 37.7752702151959, + -122.418307270836, + ) assert h3.latlng_to_cell(lat, lng, 9) == 617700169958293503 @@ -31,3 +34,19 @@ def test_compact_cells(): assert isinstance(cells, np.ndarray) assert h3.compact_cells(cells) == [h] + + +def test_numpy_str(): + expected = [ + 617700169957507071, + 617700169957769215, + 617700169958031359, + 617700169958293503, + 617700169961177087, + 617700169964847103, + 617700169965109247, + ] + cells = np.array([h3.int_to_str(h) for h in expected]) + got = [h3.str_to_int(c) for c in cells] + + assert expected == got From 92ddaeb813117b77a856c64c8dfffaa3fef731b7 Mon Sep 17 00:00:00 2001 From: AJ Friend Date: Sat, 5 Oct 2024 11:19:33 -0700 Subject: [PATCH 10/10] try it without --- src/h3/api/basic_int/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/h3/api/basic_int/__init__.py b/src/h3/api/basic_int/__init__.py index 992fce7..6035966 100644 --- a/src/h3/api/basic_int/__init__.py +++ b/src/h3/api/basic_int/__init__.py @@ -53,7 +53,7 @@ def str_to_int(h): int Unsigned 64-bit integer """ - return _cy.str_to_int(str(h)) + return _cy.str_to_int(h) def int_to_str(x):