From 36431cd0e462a98ebd4cef93049d944ba922bef1 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 29 Jul 2024 02:25:16 -0700 Subject: [PATCH] enable numpy 2.0 and recent scipy --- meanas/fdfd/bloch.py | 6 +++--- meanas/test/test_fdfd.py | 2 +- meanas/test/test_fdfd_pml.py | 2 +- pyproject.toml | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/meanas/fdfd/bloch.py b/meanas/fdfd/bloch.py index 2f4a002..2e1da30 100644 --- a/meanas/fdfd/bloch.py +++ b/meanas/fdfd/bloch.py @@ -155,7 +155,7 @@ def generate_kmn( All are given in the xyz basis (e.g. `|k|[0,0,0] = norm(G_matrix @ k0)`). """ k0 = numpy.array(k0) - G_matrix = numpy.array(G_matrix, copy=False) + G_matrix = numpy.asarray(G_matrix) Gi_grids = numpy.array(numpy.meshgrid(*(fftfreq(n, 1 / n) for n in shape[:3]), indexing='ij')) Gi = numpy.moveaxis(Gi_grids, 0, -1) @@ -538,7 +538,7 @@ def eigsolve( `(eigenvalues, eigenvectors)` where `eigenvalues[i]` corresponds to the vector `eigenvectors[i, :]` """ - k0 = numpy.array(k0, copy=False) + k0 = numpy.asarray(k0) h_size = 2 * epsilon[0].size @@ -566,7 +566,7 @@ def eigsolve( if y0 is None: Z = rng.random(y_shape) + 1j * rng.random(y_shape) else: - Z = numpy.array(y0, copy=False).T + Z = numpy.asarray(y0).T while True: Z *= num_modes / norm(Z) diff --git a/meanas/test/test_fdfd.py b/meanas/test/test_fdfd.py index 5df8e4f..5f2cf11 100644 --- a/meanas/test/test_fdfd.py +++ b/meanas/test/test_fdfd.py @@ -145,7 +145,7 @@ def sim( omega=omega, dxes=dxes, epsilon=eps_vec, - matrix_solver_opts={'atol': 1e-15, 'tol': 1e-11}, + matrix_solver_opts={'atol': 1e-15, 'rtol': 1e-11}, ) e = unvec(e_vec, shape[1:]) diff --git a/meanas/test/test_fdfd_pml.py b/meanas/test/test_fdfd_pml.py index a443ef8..832053d 100644 --- a/meanas/test/test_fdfd_pml.py +++ b/meanas/test/test_fdfd_pml.py @@ -162,7 +162,7 @@ def sim( omega=omega, dxes=dxes, epsilon=eps_vec, - matrix_solver_opts={'atol': 1e-15, 'tol': 1e-11}, + matrix_solver_opts={'atol': 1e-15, 'rtol': 1e-11}, ) e = unvec(e_vec, shape[1:]) diff --git a/pyproject.toml b/pyproject.toml index 741ae48..a6d31bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,8 +39,8 @@ include = [ ] dynamic = ["version"] dependencies = [ - "numpy~=1.26", - "scipy", + "numpy>=1.26", + "scipy~=1.14", ]