Skip to content

Commit

Permalink
updating pyedt import in tests too
Browse files Browse the repository at this point in the history
  • Loading branch information
jgostick committed Jun 5, 2024
1 parent 8f61591 commit faebe5e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 19 deletions.
7 changes: 5 additions & 2 deletions test/integration/test_inverse_Bo_study.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import numpy as np
import porespy as ps
import pyedt
import matplotlib.pyplot as plt
import pandas as pd
try:
from pyedt import edt
except ModuleNotFoundError:
from edt import edt


def test_inverse_Bo_study():
Expand All @@ -19,7 +22,7 @@ def test_inverse_Bo_study():
inlets[0, ...] = True
outlets = np.zeros_like(im, dtype=bool)
outlets[-1, ...] = True
dt = np.sqrt(pyedt.edt(im))
dt = np.sqrt(edt(im))
a = np.median(dt[dt > 0])*vx*2

sim1 = {}
Expand Down
9 changes: 7 additions & 2 deletions test/unit/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import pytest
import numpy as np
import pyedt
import porespy as ps
import scipy.ndimage as spim
from skimage.morphology import disk, ball, skeletonize_3d
from skimage.util import random_noise
from scipy.stats import norm
try:
from pyedt import edt
except ModuleNotFoundError:
from edt import edt


ps.settings.tqdm['disable'] = True


Expand All @@ -15,7 +20,7 @@ def setup_class(self):
self.im = ps.generators.blobs(shape=[100, 100, 100], blobiness=2)
# Ensure that im was generated as expeccted
assert ps.metrics.porosity(self.im) == 0.499829
self.im_dt = np.sqrt(pyedt.edt(self.im))
self.im_dt = np.sqrt(edt(self.im))

def test_im_in_not_im_out(self):
im = self.im[:, :, 50]
Expand Down
9 changes: 7 additions & 2 deletions test/unit/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
import numpy as np
import porespy as ps
from skimage import io
import pyedt
from pathlib import Path
import scipy.ndimage as spim
from skimage.morphology import ball
from numpy.testing import assert_allclose
try:
from pyedt import edt
except ModuleNotFoundError:
from edt import edt


ps.settings.tqdm['disable'] = True


Expand Down Expand Up @@ -79,7 +84,7 @@ def test_rev(self):
assert (np.mean(rev.porosity) - 0.5)**2 < 0.05

def test_radial_density(self):
dt = np.sqrt(pyedt.edt(self.blobs))
dt = np.sqrt(edt(self.blobs))
den = ps.metrics.radial_density_distribution(dt)
assert den.cdf.max() == 1

Expand Down
13 changes: 9 additions & 4 deletions test/unit/test_parallel_filters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import numpy as np
import pyedt
import porespy as ps
import scipy.ndimage as spim
from skimage.morphology import skeletonize_3d
try:
from pyedt import edt
except ModuleNotFoundError:
from edt import edt


ps.settings.loglevel = "CRITICAL"
ps.settings.tqdm['disable'] = True

Expand All @@ -13,18 +18,18 @@ def setup_class(self):
self.im = ps.generators.blobs(shape=[100, 100, 100], blobiness=2)
# Ensure that im was generated as expeccted
assert ps.metrics.porosity(self.im) == 0.499829
self.im_dt = np.sqrt(pyedt.edt(self.im))
self.im_dt = np.sqrt(edt(self.im))

def test_find_peaks_2D(self):
im = ps.generators.blobs(shape=[200, 200], blobiness=2)
dt = np.sqrt(pyedt.edt(im))
dt = np.sqrt(edt(im))
mx_serial = ps.filters.find_peaks(dt=dt)
mx_parallel_1 = ps.filters.find_peaks(dt=dt, divs=2)
assert np.all(mx_serial == mx_parallel_1)

def test_find_peaks_3D(self):
im = ps.generators.blobs(shape=[100, 100, 100], blobiness=2)
dt = np.sqrt(pyedt.edt(im))
dt = np.sqrt(edt(im))
mx_serial = ps.filters.find_peaks(dt=dt)
mx_parallel_1 = ps.filters.find_peaks(dt=dt, divs=2)
assert np.all(mx_serial == mx_parallel_1)
Expand Down
10 changes: 7 additions & 3 deletions test/unit/test_simulations.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import pytest
import numpy as np
import pyedt
import porespy as ps
import scipy.ndimage as spim
from skimage.morphology import disk, ball, skeletonize_3d
from skimage.util import random_noise
from scipy.stats import norm
try:
from pyedt import edt
except ModuleNotFoundError:
from edt import edt


ps.settings.tqdm['disable'] = True

Expand All @@ -17,12 +21,12 @@ def setup_class(self):
self.im = ps.generators.blobs(shape=[100, 100, 100], blobiness=2)
# Ensure that im was generated as expeccted
assert ps.metrics.porosity(self.im) == 0.499829
self.im_dt = np.sqrt(pyedt.edt(self.im))
self.im_dt = np.sqrt(edt(self.im))

def test_drainage_with_gravity(self):
np.random.seed(2)
im = ps.generators.blobs(shape=[100, 100], porosity=0.7)
dt = np.sqrt(pyedt.edt(im))
dt = np.sqrt(edt(im))
pc = -2*0.072*np.cos(np.deg2rad(180))/dt
np.testing.assert_approx_equal(pc[im].max(), 0.144)
drn = ps.simulations.drainage(pc=pc, im=im, voxel_size=1e-5, g=9.81)
Expand Down
9 changes: 7 additions & 2 deletions test/unit/test_simulations_ibip.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
import porespy as ps
import scipy.ndimage as spim
from skimage.morphology import square
import pyedt
try:
from pyedt import edt
except ModuleNotFoundError:
from edt import edt


ps.settings.tqdm['disable'] = True


Expand Down Expand Up @@ -102,7 +107,7 @@ def test_size_to_satn(self):

def test_compare_size_and_seq_to_satn(self):
im = ps.generators.blobs(shape=[250, 250])
dt = np.sqrt(pyedt.edt(im))
dt = np.sqrt(edt(im))
sizes = np.arange(int(dt.max())+1, 0, -1)
mio = ps.filters.porosimetry(im, sizes=sizes)
mio_satn = ps.filters.size_to_satn(size=mio, im=im)
Expand Down
11 changes: 8 additions & 3 deletions test/unit/test_snow2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import scipy.ndimage as spim
import porespy as ps
import openpnm as op
import pyedt
try:
from pyedt import edt
except ModuleNotFoundError:
from edt import edt


ws = op.Workspace()
ws.settings['loglevel'] = 50
ps.settings.tqdm['disable'] = True
Expand Down Expand Up @@ -195,7 +200,7 @@ def test_trim_saddle_points(self):
im = ps.generators.blobs(shape=[400, 400],
blobiness=[2, 1],
porosity=0.6)
dt = np.sqrt(pyedt.edt(im))
dt = np.sqrt(edt(im))
peaks1 = ps.filters.find_peaks(dt=dt, r_max=4)
peaks2 = ps.filters.trim_saddle_points(peaks=peaks1, dt=dt)
assert (peaks1 > 0).sum() > (peaks2 > 0).sum()
Expand All @@ -206,7 +211,7 @@ def test_trim_saddle_points_legacy(self):
im = ps.generators.blobs(shape=[400, 400],
blobiness=[2, 1],
porosity=0.6)
dt = np.sqrt(pyedt.edt(im))
dt = np.sqrt(edt(im))
peaks1 = ps.filters.find_peaks(dt=dt, r_max=4)
peaks2 = ps.filters.trim_saddle_points_legacy(peaks=peaks1, dt=dt)
assert (peaks1 > 0).sum() > (peaks2 > 0).sum()
Expand Down
7 changes: 6 additions & 1 deletion test/unit/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import scipy.ndimage as spim
import matplotlib.pyplot as plt
import pytest
import pyedt
try:
from pyedt import edt
except ModuleNotFoundError:
from edt import edt


ps.settings.tqdm['disable'] = True


Expand Down

0 comments on commit faebe5e

Please sign in to comment.