From d8d6324f4c55f1161d59a11bb479053551ebf653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dieter=20Werthm=C3=BCller?= Date: Tue, 20 Feb 2024 15:23:04 +0100 Subject: [PATCH] Address Deprecation Warnings --- emg3d/meshes.py | 2 +- emg3d/solver.py | 2 +- tests/test_cli.py | 10 +++++----- tests/test_electrodes.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/emg3d/meshes.py b/emg3d/meshes.py index e5aed097..6b1c70fa 100644 --- a/emg3d/meshes.py +++ b/emg3d/meshes.py @@ -1030,7 +1030,7 @@ def _seasurface(edges, widths, center, seasurface, stretching, vector, limits): # No vector given (only one existing cell). if vector is None: - tdmin = fact*widths + tdmin = fact*widths.item() cedge = center + tdmin/2 alphmax = 1.1*stretching[0] # 10 % extra stretching. diff --git a/emg3d/solver.py b/emg3d/solver.py index d03d8ff1..172aecfe 100644 --- a/emg3d/solver.py +++ b/emg3d/solver.py @@ -758,7 +758,7 @@ def callback(x): # therefore throw an exception in `_terminate`, and catch it here. try: efield.field, i = getattr(ssl, var.sslsolver)( - A=A, b=sfield.field, x0=efield.field, tol=var.tol, + A=A, b=sfield.field, x0=efield.field, rtol=var.tol, maxiter=var.ssl_maxit, atol=1e-30, M=M, callback=callback) except _ConvergenceError: i = -1 # Mark it as error; returned field is all zero. diff --git a/tests/test_cli.py b/tests/test_cli.py index f0629d80..f1d958c3 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -35,7 +35,7 @@ def __exit__(self, *exc): def test_main(script_runner): # Test the installed version runs by -h. - ret = script_runner.run('emg3d', '-h') + ret = script_runner.run(['emg3d', '-h']) assert ret.success assert "Multigrid solver for 3D electromagnetic diffusion." in ret.stdout @@ -47,19 +47,19 @@ def test_main(script_runner): # Test emg3d/cli/_main_.py by calling the file - I. ret = script_runner.run( - 'python', join('emg3d', 'cli', 'main.py'), '--version') + ['python', join('emg3d', 'cli', 'main.py'), '--version']) assert ret.success assert "emg3d v" in ret.stdout # Test emg3d/cli/_main_.py by calling the file - II. ret = script_runner.run( - 'python', join('emg3d', 'cli', 'main.py'), '--report') + ['python', join('emg3d', 'cli', 'main.py'), '--report']) assert ret.success # Exclude time to avoid errors. assert emg3d.utils.Report().__repr__()[115:475] in ret.stdout # Test emg3d/cli/_main_.py by calling the file - III. - ret = script_runner.run('python', join('emg3d', 'cli', 'main.py'), '-d') + ret = script_runner.run(['python', join('emg3d', 'cli', 'main.py'), '-d']) assert not ret.success assert "* ERROR :: Config file not found: " in ret.stderr @@ -72,7 +72,7 @@ def test_main(script_runner): def test_main2(script_runner): # Test emg3d/__main__.py by calling the folder emg3d. - ret = script_runner.run('python', 'emg3d', '--report') + ret = script_runner.run(['python', 'emg3d', '--report']) assert ret.success # Exclude time to avoid errors. # Exclude empymod-version (after 475), because if run locally without diff --git a/tests/test_electrodes.py b/tests/test_electrodes.py index 45f64c8c..baa98ba3 100644 --- a/tests/test_electrodes.py +++ b/tests/test_electrodes.py @@ -595,7 +595,7 @@ def fwd(u): def adj(v): """What does `Simulation._get_rfield()`.""" # The strength in _get_rfield is conj(residual*weight), normalized - strength = complex(v/-smu0) + strength = complex(v.item()/-smu0) src = rec._adjoint_source(rec.coordinates, strength=strength) return src.get_field(mesh, frequency).field