Skip to content

Commit

Permalink
fixing imports
Browse files Browse the repository at this point in the history
  • Loading branch information
dkazanc committed May 1, 2024
1 parent 29affed commit eb5da60
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 34 deletions.
13 changes: 6 additions & 7 deletions httomolibgpu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from httomolibgpu.misc.corr import *
from httomolibgpu.misc.morph import *
from httomolibgpu.misc.rescale import *
from httomolibgpu.prep.alignment import *

# from httomolibgpu.prep.normalize import *
# from httomolibgpu.prep.phase import paganin_filter_savu, paganin_filter_tomopy
from httomolibgpu.misc.corr import median_filter, remove_outlier
from httomolibgpu.misc.morph import sino_360_to_180, data_resampler
from httomolibgpu.misc.rescale import rescale_to_int
from httomolibgpu.prep.alignment import distortion_correction_proj_discorpy
from httomolibgpu.prep.normalize import normalize
from httomolibgpu.prep.phase import paganin_filter_savu, paganin_filter_tomopy
# from httomolibgpu.prep.stripe import (
# remove_stripe_based_sorting,
# remove_stripe_ti,
Expand Down
13 changes: 7 additions & 6 deletions httomolibgpu/misc/corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,30 @@
# ---------------------------------------------------------------------------
""" Module for data correction """

import numpy as xp

import numpy as np
cupy_run = False
try:
import cupy as xp
from cupy import mean

try:
xp.cuda.Device(0).compute_capability
cupy_run = True

except xp.cuda.runtime.CUDARuntimeError:
print("CuPy library is a major dependency for HTTomolibgpu, please install")
import numpy as np
import numpy as xp
except ImportError:
import numpy as np
import numpy as xp

try:
from cucim.skimage.filters import median
from cucim.skimage.morphology import disk
except ImportError:
print(
"Cucim library of Rapidsai is a required dependency for some modules, please install"
"Cucim library of Rapidsai is a required dependency for median_filter and remove_outlier modules, please install"
)
from skimage.filters import median
from skimage.morphology import disk

from numpy import float32
import nvtx
Expand Down
18 changes: 11 additions & 7 deletions httomolibgpu/misc/morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@
# ---------------------------------------------------------------------------
"""Module for data type morphing functions"""

import numpy as xp
import numpy as np

cupy_run = False
try:
import cupy as xp

try:
xp.cuda.Device(0).compute_capability

cupy_run = True
except xp.cuda.runtime.CUDARuntimeError:
print("CuPy library is a major dependency for HTTomolibgpu, please install")
import numpy as np
import numpy as xp
except ImportError:
import numpy as np
import numpy as xp

if cupy_run:
from cupyx.scipy.interpolate import interpn
else:
from scipy.interpolate import interpn

import nvtx
from typing import Literal

Expand Down Expand Up @@ -123,8 +128,7 @@ def data_resampler(
Returns:
cp.ndarray: Up/Down-scaled 3D cupy array
"""
from cupyx.scipy.interpolate import interpn
"""

if data.ndim != 3:
raise ValueError("only 3D data is supported")
Expand Down
29 changes: 24 additions & 5 deletions httomolibgpu/misc/rescale.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
import numpy as xp
import numpy as np
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Copyright 2023 Diamond Light Source Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ---------------------------------------------------------------------------
# Created By : Tomography Team at DLS <scientificsoftware@diamond.ac.uk>
# Created Date: 1 March 2024
# ---------------------------------------------------------------------------

import numpy as np
try:
import cupy as xp

try:
xp.cuda.Device(0).compute_capability

except xp.cuda.runtime.CUDARuntimeError:
print("CuPy library is a major dependency for HTTomolibgpu, please install")
import numpy as np
import numpy as xp
except ImportError:
import numpy as np
import numpy as xp

import nvtx
from typing import Literal, Optional, Tuple, Union

Expand Down
7 changes: 2 additions & 5 deletions httomolibgpu/prep/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,19 @@
# ---------------------------------------------------------------------------
"""Modules for data correction"""

import numpy as xp
import numpy as np

cupy_run = False
try:
import cupy as xp
from cupy import mean

try:
xp.cuda.Device(0).compute_capability
cupy_run = True
except xp.cuda.runtime.CUDARuntimeError:
print("CuPy library is a major dependency for HTTomolibgpu, please install")
import numpy as np
import numpy as xp
except ImportError:
import numpy as np
import numpy as xp

from typing import Dict, List
import nvtx
Expand Down
7 changes: 3 additions & 4 deletions httomolibgpu/prep/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
# ---------------------------------------------------------------------------
"""Modules for raw projection data normalization"""

import numpy as xp
import numpy as np

import numpy as np
try:
import cupy as xp
from cupy import mean
Expand All @@ -31,9 +30,9 @@
xp.cuda.Device(0).compute_capability
except xp.cuda.runtime.CUDARuntimeError:
print("CuPy library is a major dependency for HTTomolibgpu, please install")
import numpy as np
import numpy as xp
except ImportError:
import numpy as np
import numpy as xp

import nvtx
from numpy import float32
Expand Down

0 comments on commit eb5da60

Please sign in to comment.