Skip to content

Commit

Permalink
style: Sort imports throughout the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-sadeghi committed Aug 9, 2024
1 parent d772175 commit 2f45048
Show file tree
Hide file tree
Showing 58 changed files with 266 additions and 186 deletions.
11 changes: 7 additions & 4 deletions src/porespy/beta/_drainage2.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import numpy as np
from edt import edt
from numba import njit, prange
from porespy.filters import trim_disconnected_blobs, pc_to_satn

from porespy import settings
from porespy.tools import get_tqdm, Results
from porespy.filters import pc_to_satn, trim_disconnected_blobs
from porespy.tools import Results, get_tqdm

tqdm = get_tqdm()


Expand Down Expand Up @@ -180,11 +182,12 @@ def _insert_disks_npoints_nradii_1value_parallel(


if __name__ == "__main__":
import numpy as np
import porespy as ps
import matplotlib.pyplot as plt
import numpy as np
from edt import edt

import porespy as ps

# %%
im = ps.generators.blobs(shape=[200, 200, 200], porosity=0.7, blobiness=1.5, seed=0)
inlets = np.zeros_like(im)
Expand Down
15 changes: 9 additions & 6 deletions src/porespy/beta/_gdd.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import time
from porespy import simulations, settings
from porespy.tools import Results

import dask
import dask.delayed
import edt
import numpy as np
import openpnm as op
from pandas import DataFrame
import dask.delayed
import dask
import edt

from porespy import settings, simulations
from porespy.tools import Results

__all__ = ['tortuosity_gdd', 'chunks_to_dataframe']
settings.loglevel = 50
Expand Down Expand Up @@ -345,8 +347,9 @@ def chunks_to_dataframe(im, scale_factor=3, use_dask=True):


if __name__ =="__main__":
import porespy as ps
import numpy as np

import porespy as ps
np.random.seed(1)
im = ps.generators.blobs(shape=[100, 100, 100], porosity=0.7)
res = ps.simulations.tortuosity_gdd(im=im, scale_factor=3, use_dask=True)
Expand Down
2 changes: 1 addition & 1 deletion src/porespy/beta/_generators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from scipy.signal import convolve
from porespy.tools import ps_rect

from porespy.tools import ps_rect

__all__ = [
"local_diff",
Expand Down
5 changes: 3 additions & 2 deletions src/porespy/beta/_poly_cylinders.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import numpy as np

from porespy import settings
from porespy.tools import get_tqdm


tqdm = get_tqdm()


Expand Down Expand Up @@ -145,8 +145,9 @@ def polydisperse_cylinders(


if __name__ == "__main__":
import scipy.stats as spst
import matplotlib.pyplot as plt
import scipy.stats as spst

import porespy as ps

params = (5.65832732e+00, 1.54364793e-05, 7.37705832e+00)
Expand Down
2 changes: 1 addition & 1 deletion src/porespy/dns/_funcs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from deprecated import deprecated
from porespy.simulations import tortuosity_fd as _tortuosity

from porespy.simulations import tortuosity_fd as _tortuosity

__all__ = [
'tortuosity',
Expand Down
1 change: 0 additions & 1 deletion src/porespy/filters/_fftmorphology.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import numpy as np
from scipy.signal import fftconvolve


__all__ = [
"fftmorphology",
]
Expand Down
28 changes: 19 additions & 9 deletions src/porespy/filters/_funcs.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import inspect as insp
import logging
import operator as op
from typing import Literal

import dask
import numpy as np
import operator as op
import scipy.ndimage as spim
from deprecated import deprecated
from skimage.morphology import reconstruction
from skimage.morphology import ball, cube, diamond, disk, octahedron, reconstruction, square
from skimage.segmentation import clear_border
from skimage.morphology import ball, disk, square, cube, diamond, octahedron
from porespy.tools import _check_for_singleton_axes
from porespy.tools import get_border, subdivide, recombine, make_contiguous
from porespy.tools import unpad, extract_subsection
from porespy.tools import ps_disk, ps_ball, ps_round

from porespy import settings
from porespy.tools import get_tqdm
from typing import Literal
from porespy.tools import (
_check_for_singleton_axes,
extract_subsection,
get_border,
get_tqdm,
make_contiguous,
ps_ball,
ps_disk,
ps_round,
recombine,
subdivide,
unpad,
)

try:
from pyedt import edt
except ModuleNotFoundError:
Expand Down
7 changes: 4 additions & 3 deletions src/porespy/filters/_nlmeans.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import dask
import numpy as np
from skimage.restoration.non_local_means import denoise_nl_means
from skimage.exposure import match_histograms, rescale_intensity
from skimage.restoration import estimate_sigma
from skimage.exposure import rescale_intensity, match_histograms
import dask
from skimage.restoration.non_local_means import denoise_nl_means

dask.config.set(scheduler="threads")
# from dask.diagnostics import ProgressBar

Expand Down
2 changes: 1 addition & 1 deletion src/porespy/filters/_size_seq_satn.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from porespy.tools import make_contiguous
from scipy.stats import rankdata

from porespy.tools import make_contiguous

__all__ = [
'size_to_seq',
Expand Down
23 changes: 15 additions & 8 deletions src/porespy/filters/_snows.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import dask.array as da
import inspect as insp
import logging

import dask.array as da
import numpy as np
from numba import njit, prange
import scipy.ndimage as spim
import scipy.spatial as sptl
from numba import njit, prange
from skimage.morphology import cube, square
from skimage.segmentation import watershed
from skimage.morphology import square, cube
from porespy.tools import _check_for_singleton_axes
from porespy.tools import extend_slice, ps_rect, ps_round
from porespy.tools import Results
from porespy.tools import get_tqdm
from porespy.filters import chunked_func

from porespy import settings
from porespy.filters import chunked_func
from porespy.tools import (
Results,
_check_for_singleton_axes,
extend_slice,
get_tqdm,
ps_rect,
ps_round,
)

try:
from pyedt import edt
except ModuleNotFoundError:
Expand Down
2 changes: 1 addition & 1 deletion src/porespy/filters/imagej/_funcs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import numpy as np

import numpy as np

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/porespy/generators/_borders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from typing import Literal

import numpy as np

__all__ = ['faces', 'borders']

Expand Down
5 changes: 3 additions & 2 deletions src/porespy/generators/_fractals.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging

import numpy as np
import scipy.ndimage as spim
from porespy.tools import get_tqdm
from porespy import settings

from porespy import settings
from porespy.tools import get_tqdm

tqdm = get_tqdm()
logger = logging.getLogger(__name__)
Expand Down
28 changes: 15 additions & 13 deletions src/porespy/generators/_imgen.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import inspect as insp
import logging
from typing import List, Literal

import numpy as np
import inspect as insp
from numba import njit
import scipy.spatial as sptl
import numpy.typing as npt
import scipy.ndimage as spim
import scipy.spatial as sptl
import scipy.stats as spst
from porespy import metrics
from porespy import settings
from typing import List, Literal
from numba import njit

from porespy import metrics, settings
from porespy.filters import chunked_func
from porespy.tools import (
_insert_disk_at_points,
_insert_disk_at_points_parallel,
all_to_uniform,
ps_ball,
ps_disk,
get_border,
extract_subsection,
insert_sphere,
get_border,
get_tqdm,
_insert_disk_at_points,
_insert_disk_at_points_parallel,
insert_sphere,
ps_ball,
ps_disk,
)
import numpy.typing as npt

try:
from pyedt import edt
except ModuleNotFoundError:
Expand Down
6 changes: 4 additions & 2 deletions src/porespy/generators/_noise.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Literal

import numpy as np
from porespy.tools import all_to_uniform
import psutil
from typing import Literal

from porespy.tools import all_to_uniform


def fractal_noise(
Expand Down
18 changes: 11 additions & 7 deletions src/porespy/generators/_pseudo_packings.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import logging
from typing import List, Literal

import numpy as np
import scipy.ndimage as spim
import numpy.typing as npt
import scipy.ndimage as spim
from numba import njit
from typing import Literal, List
from skimage.morphology import disk, ball
from skimage.morphology import ball, disk

from porespy.filters import trim_disconnected_blobs
from porespy.tools import (
_insert_disk_at_point,
get_border,
get_tqdm,
ps_round,
get_border,
unpad,
_insert_disk_at_point,
)
from porespy.filters import trim_disconnected_blobs

try:
from pyedt import edt
except ModuleNotFoundError:
Expand Down Expand Up @@ -453,9 +456,10 @@ def _do_packing(im, mask, q, r, value, clearance, smooth, maxiter):


if __name__ == "__main__":
import porespy as ps
import matplotlib.pyplot as plt
import scipy.ndimage as spim

import porespy as ps
shape = [200, 200]


Expand Down
3 changes: 2 additions & 1 deletion src/porespy/generators/_spheres_from_coords.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging

import numpy as np
from porespy.tools import _insert_disks_at_points, find_bbox

from porespy.tools import _insert_disks_at_points, find_bbox

__all__ = [
'spheres_from_coords',
Expand Down
3 changes: 3 additions & 0 deletions src/porespy/io/_funcs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import os
import subprocess

import numpy as np
import scipy.ndimage as nd
import skimage.measure as ms
from skimage.morphology import ball

from porespy.filters import reduce_peaks
from porespy.networks import generate_voxel_image
from porespy.tools import sanitize_filename

try:
from pyedt import edt
except ModuleNotFoundError:
Expand Down
12 changes: 5 additions & 7 deletions src/porespy/metrics/_funcs.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import logging

import numpy as np
import scipy.ndimage as spim
import scipy.spatial as sptl
from scipy import fft as sp_ft
from skimage.measure import regionprops
from deprecated import deprecated
from porespy.tools import extend_slice
from porespy.tools import _check_for_singleton_axes
from porespy.tools import Results
from porespy import settings
from porespy.tools import get_tqdm
from numba import njit
from scipy import fft as sp_ft
from skimage.measure import regionprops

from porespy import settings
from porespy.tools import Results, _check_for_singleton_axes, extend_slice, get_tqdm

__all__ = [
"boxcount",
Expand Down
15 changes: 10 additions & 5 deletions src/porespy/metrics/_meshtools.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import logging

import numpy as np
import scipy.ndimage as spim
from porespy.tools import extend_slice, ps_round
from porespy.tools import _check_for_singleton_axes, Results
from porespy.tools import mesh_region
from skimage import measure
from porespy.tools import get_tqdm
from porespy import settings

from porespy import settings
from porespy.tools import (
Results,
_check_for_singleton_axes,
extend_slice,
get_tqdm,
mesh_region,
ps_round,
)

__all__ = [
"mesh_surface_area",
Expand Down
Loading

0 comments on commit 2f45048

Please sign in to comment.