Skip to content

Commit

Permalink
numpy -> np
Browse files Browse the repository at this point in the history
  • Loading branch information
keurfonluu committed Aug 13, 2022
1 parent 2da6586 commit fa69d40
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions test/test_eikonal2d.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from copy import deepcopy

import numpy
import numpy as np
import pytest
from helpers import allclose, eik2d

Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions test/test_eikonal3d.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from copy import deepcopy

import numpy
import numpy as np
import pytest
from helpers import allclose, eik3d

Expand All @@ -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],
Expand All @@ -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),
),
),
)
Expand Down
4 changes: 2 additions & 2 deletions test/test_gradient2d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import numpy
import numpy as np
import pytest
from helpers import allclose, eik2d

Expand All @@ -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]],
Expand Down
4 changes: 2 additions & 2 deletions test/test_gradient3d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import numpy
import numpy as np
import pytest
from helpers import allclose, eik3d

Expand All @@ -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],
Expand Down
14 changes: 7 additions & 7 deletions test/test_meshio.py
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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

Expand All @@ -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
)
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test/test_traveltime2d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import numpy
import numpy as np
import pytest
from helpers import allclose, eik2d

Expand All @@ -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],
Expand Down
4 changes: 2 additions & 2 deletions test/test_traveltime3d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import numpy
import numpy as np
import pytest
from helpers import allclose, eik3d

Expand All @@ -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],
Expand Down

0 comments on commit fa69d40

Please sign in to comment.