From fa69d40a4bfcecffc8a56d1f8ca838d015a04ea4 Mon Sep 17 00:00:00 2001 From: Keurfon Luu Date: Sat, 13 Aug 2022 09:57:05 +0200 Subject: [PATCH] numpy -> np --- test/test_eikonal2d.py | 6 +++--- test/test_eikonal3d.py | 6 +++--- test/test_gradient2d.py | 4 ++-- test/test_gradient3d.py | 4 ++-- test/test_meshio.py | 14 +++++++------- test/test_traveltime2d.py | 4 ++-- test/test_traveltime3d.py | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/test_eikonal2d.py b/test/test_eikonal2d.py index 6c93ca8..33ff12d 100644 --- a/test/test_eikonal2d.py +++ b/test/test_eikonal2d.py @@ -1,6 +1,6 @@ from copy import deepcopy -import numpy +import numpy as np import pytest from helpers import allclose, eik2d @@ -25,8 +25,8 @@ def test_solve(sources, tref): "points, vref", ( ([0.0, 0.0], 1.0), - ([-1.0, -1.0], numpy.nan), - ([[0.0, 0.0], [15.0, 0.0], [15.0, 15.0], [0.0, 15.0]], numpy.ones(4)), + ([-1.0, -1.0], np.nan), + ([[0.0, 0.0], [15.0, 0.0], [15.0, 15.0], [0.0, 15.0]], np.ones(4)), ), ) def test_call(points, vref): diff --git a/test/test_eikonal3d.py b/test/test_eikonal3d.py index 672098a..8557654 100644 --- a/test/test_eikonal3d.py +++ b/test/test_eikonal3d.py @@ -1,6 +1,6 @@ from copy import deepcopy -import numpy +import numpy as np import pytest from helpers import allclose, eik3d @@ -25,7 +25,7 @@ def test_solve(sources, tref): "points, vref", ( ([0.0, 0.0, 0.0], 1.0), - ([-1.0, -1.0, -1.0], numpy.nan), + ([-1.0, -1.0, -1.0], np.nan), ( [ [0.0, 0.0, 0.0], @@ -37,7 +37,7 @@ def test_solve(sources, tref): [15.0, 15.0, 15.0], [0.0, 15.0, 15.0], ], - numpy.ones(8), + np.ones(8), ), ), ) diff --git a/test/test_gradient2d.py b/test/test_gradient2d.py index 29f03b5..77cb75d 100644 --- a/test/test_gradient2d.py +++ b/test/test_gradient2d.py @@ -1,4 +1,4 @@ -import numpy +import numpy as np import pytest from helpers import allclose, eik2d @@ -8,7 +8,7 @@ ( ([0.0, 0.0], [0.0, 0.0], 0.0, 0.0), ([3.5, 3.5], [0.0, 0.0], -0.70710678, -0.70710678), - ([0.0, 0.0], [-1.0, -1.0], numpy.nan, numpy.nan), + ([0.0, 0.0], [-1.0, -1.0], np.nan, np.nan), ( [0.0, 0.0], [[0.0, 0.0], [15.0, 0.0], [15.0, 15.0], [0.0, 15.0]], diff --git a/test/test_gradient3d.py b/test/test_gradient3d.py index ab87079..7a02ffd 100644 --- a/test/test_gradient3d.py +++ b/test/test_gradient3d.py @@ -1,4 +1,4 @@ -import numpy +import numpy as np import pytest from helpers import allclose, eik3d @@ -7,7 +7,7 @@ "points, gzref, gxref, gyref", ( ([0.0, 0.0, 0.0], 0.0, 0.0, 0.0), - ([-1.0, -1.0, -1.0], numpy.nan, numpy.nan, numpy.nan), + ([-1.0, -1.0, -1.0], np.nan, np.nan, np.nan), ( [ [0.0, 0.0, 0.0], diff --git a/test/test_meshio.py b/test/test_meshio.py index 665126d..d912177 100644 --- a/test/test_meshio.py +++ b/test/test_meshio.py @@ -1,11 +1,11 @@ -import numpy +import numpy as np from fteikpy import Eikonal2D, Eikonal3D, grid_to_meshio, ray_to_meshio def test_meshio_2d(): nz, nx = 8, 10 - eik = Eikonal2D(numpy.ones((nz, nx)), (1.0, 1.0)) + eik = Eikonal2D(np.ones((nz, nx)), (1.0, 1.0)) tt = eik.solve((float(nz // 2), float(nx // 2)), return_gradient=True) ray = tt.raytrace((0.0, 0.0), honor_grid=True) @@ -17,11 +17,11 @@ def test_meshio_2d(): assert sum(len(cell) for cell in mesh.cells) == nz * nx assert mesh.point_data["Traveltime"][npts // 2] == 0.0 - assert numpy.allclose(mesh.point_data["Traveltime"].sum(), 378.23469225) + assert np.allclose(mesh.point_data["Traveltime"].sum(), 378.23469225) for grad in mesh.point_data["Gradient"].T: assert grad[npts // 2] == 0.0 - assert numpy.allclose(grad.sum(), 0.0) + assert np.allclose(grad.sum(), 0.0) assert mesh.cell_data["Velocity"][0].sum() == nz * nx @@ -32,7 +32,7 @@ def test_meshio_2d(): def test_meshio_3d(): nz, nx, ny = 8, 10, 12 - eik = Eikonal3D(numpy.ones((nz, nx, ny)), (1.0, 1.0, 1.0)) + eik = Eikonal3D(np.ones((nz, nx, ny)), (1.0, 1.0, 1.0)) tt = eik.solve( (float(nz // 2), float(nx // 2), float(ny // 2)), return_gradient=True ) @@ -46,11 +46,11 @@ def test_meshio_3d(): assert sum(len(cell) for cell in mesh.cells) == nz * nx * ny assert mesh.point_data["Traveltime"][npts // 2] == 0.0 - assert numpy.allclose(mesh.point_data["Traveltime"].sum(), 6909.90160991) + assert np.allclose(mesh.point_data["Traveltime"].sum(), 6909.90160991) for grad in mesh.point_data["Gradient"].T: assert grad[npts // 2] == 0.0 - assert numpy.allclose(grad.sum(), 0.0) + assert np.allclose(grad.sum(), 0.0) assert mesh.cell_data["Velocity"][0].sum() == nz * nx * ny diff --git a/test/test_traveltime2d.py b/test/test_traveltime2d.py index 90ce539..1416947 100644 --- a/test/test_traveltime2d.py +++ b/test/test_traveltime2d.py @@ -1,4 +1,4 @@ -import numpy +import numpy as np import pytest from helpers import allclose, eik2d @@ -9,7 +9,7 @@ ([0.0, 0.0], 0.0), ([0.5, 0.5], 0.70710678), ([1.5, 1.5], 2.12132034), - ([-1.0, -1.0], numpy.nan), + ([-1.0, -1.0], np.nan), ( [[0.0, 0.0], [15.0, 0.0], [15.0, 15.0], [0.0, 15.0]], [0.0, 15.0, 21.21320343, 15.0], diff --git a/test/test_traveltime3d.py b/test/test_traveltime3d.py index 1ce48ba..02c8ff1 100644 --- a/test/test_traveltime3d.py +++ b/test/test_traveltime3d.py @@ -1,4 +1,4 @@ -import numpy +import numpy as np import pytest from helpers import allclose, eik3d @@ -9,7 +9,7 @@ ([0.0, 0.0, 0.0], 0.0), ([0.5, 0.5, 0.5], 0.86602540), ([1.5, 1.5, 1.5], 2.60631816), - ([-1.0, -1.0, -1.0], numpy.nan), + ([-1.0, -1.0, -1.0], np.nan), ( [ [0.0, 0.0, 0.0],