Skip to content

Commit e243f55

Browse files
authored
Fix Python Bindings for Numpy 2 (#100)
* Update CI to Python 3.8–3.12 * Only run clang-format-check on relevant push * Update pybind11 * Replace .A with .toarray()
1 parent 3af9200 commit e243f55

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

.github/workflows/clang-format-check.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: clang-format Check
22
on:
33
push:
4+
paths:
5+
- '.github/workflows/clang-format-check.yml'
6+
- '.clang-format'
7+
- 'src/**'
8+
- 'tests/src/**'
9+
- 'python/src/**'
410
pull_request:
511
paths:
612
- '.github/workflows/clang-format-check.yml'

.github/workflows/python.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
os: [ubuntu-latest, macos-latest, windows-latest]
26-
python-version: ["3.10"]
26+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
2727
include:
2828
- os: ubuntu-latest
2929
name: Linux
@@ -65,8 +65,7 @@ jobs:
6565
uses: actions/[email protected]
6666
with:
6767
path: ${{ env.CACHE_PATH }}
68-
key: ${{ runner.os }}-Python-cache
69-
restore-keys: ${{ runner.os }}-Release-cache
68+
key: ${{ runner.os }}-Python${{ matrix.python-version }}-cache
7069

7170
- name: Prepare Ccache
7271
run: |

cmake/recipes/pybind11.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
2626
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
2727

2828
include(CPM)
29-
CPMAddPackage("gh:pybind/pybind11@2.11.1")
29+
CPMAddPackage("gh:pybind/pybind11@2.13.1")

python/tests/find_ipctk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
repo_root / "build" / "debug" / "python",
1212
]
1313
for path in possible_paths:
14-
if path.exists():
14+
if path.exists() and len(list(path.glob("ipctk.*"))) > 0:
1515
sys.path.append(str(path))
1616
break
1717
else:
1818
raise ImportError("Could not find the ipctk module")
19+
print(f"Using found ipctk module at {path}")
1920
import ipctk # Try again

python/tests/test_ipc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def check_ipc_derivatives(broad_phase_method, use_convergent_formulation, mesh_n
3030
assert np.linalg.norm(grad_b) > 1e-8
3131
assert np.allclose(grad_b, fgrad_b)
3232

33-
hess_b = B.hessian(collisions, mesh, vertices).A
33+
hess_b = B.hessian(collisions, mesh, vertices).toarray()
3434
fhess_b = utils.finite_jacobian(
3535
vertices.flatten(), lambda x: B.gradient(collisions, mesh, x.reshape(vertices.shape)))
3636

0 commit comments

Comments
 (0)