Skip to content

Commit

Permalink
Merge pull request #274 from clEsperanto/remove-numpy-func
Browse files Browse the repository at this point in the history
remove numpy style function
  • Loading branch information
StRigaud authored Oct 18, 2024
2 parents 2f51de2 + f391cc5 commit 94e59db
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 117 deletions.
108 changes: 54 additions & 54 deletions pyclesperanto/_interroperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,74 +86,74 @@ def set_wait_for_kernel_finish(wait: bool = True):
wait_for_kernel_to_finish(wait)


def clip(a, a_min, a_max, out=None):
from ._tier2 import clip

a = asarray(a)
if out:
out = asarray(out)
return clip(
input_image=a,
output_image=out,
min_intensity=a_min,
max_intensity=a_max,
device=a.device,
)
# def clip(a, a_min, a_max, out=None):
# from ._tier2 import clip

# a = asarray(a)
# if out:
# out = asarray(out)
# return clip(
# input_image=a,
# output_image=out,
# min_intensity=a_min,
# max_intensity=a_max,
# device=a.device,
# )

def mod(x1, x2, out=None):
from ._tier1 import modulo_images

x1 = asarray(x1)
if out:
out = asarray(out)
return modulo_images(input_image0=x1, input_image1=x2, device=x1.device)
# def mod(x1, x2, out=None):
# from ._tier1 import modulo_images

# x1 = asarray(x1)
# if out:
# out = asarray(out)
# return modulo_images(input_image0=x1, input_image1=x2, device=x1.device)

def sqrt(x, out=None):
from ._tier1 import square_root

x = asarray(x)
if out:
out = asarray(out)
return square_root(input_image=x, output_image=out, device=x.device)
# def sqrt(x, out=None):
# from ._tier1 import square_root

# x = asarray(x)
# if out:
# out = asarray(out)
# return square_root(input_image=x, output_image=out, device=x.device)

def cbrt(x, out=None):
from ._tier1 import cubic_root

x = asarray(x)
if out:
out = asarray(out)
return cubic_root(input_image=x, output_image=out, device=x.device)
# def cbrt(x, out=None):
# from ._tier1 import cubic_root

# x = asarray(x)
# if out:
# out = asarray(out)
# return cubic_root(input_image=x, output_image=out, device=x.device)

def power(x1, x2, out=None):
x1 = asarray(x1)
if out:
out = asarray(out)

# test if x2 is a scalar
if np.isscalar(x2):
from ._tier1 import power
# def power(x1, x2, out=None):
# x1 = asarray(x1)
# if out:
# out = asarray(out)

return power(input_image=x1, scalar=x2, output_image=out, device=x1.device)
else:
from ._tier1 import power_images
# # test if x2 is a scalar
# if np.isscalar(x2):
# from ._tier1 import power

x2 = asarray(x2)
return power_images(
input_image0=x1, input_image1=x2, output_image=out, device=x1.device
)
# return power(input_image=x1, scalar=x2, output_image=out, device=x1.device)
# else:
# from ._tier1 import power_images

# x2 = asarray(x2)
# return power_images(
# input_image0=x1, input_image1=x2, output_image=out, device=x1.device
# )


def fabs(x, out=None):
from ._memory import create
from ._tier1 import absolute
# def fabs(x, out=None):
# from ._memory import create
# from ._tier1 import absolute

x = asarray(x)
if out:
out = asarray(out)
else:
out = create(x.shape, dtype=float, mtype=x.mtype, device=x.device)
return absolute(input_image=x, output_image=out, device=x.device)
# x = asarray(x)
# if out:
# out = asarray(out)
# else:
# out = create(x.shape, dtype=float, mtype=x.mtype, device=x.device)
# return absolute(input_image=x, output_image=out, device=x.device)
6 changes: 3 additions & 3 deletions tests/test_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_clip_min_max():
test = [[0, 1], [2, 3]]
reference = [[1, 1], [2, 2]]

result = cle.clip(test, a_min=1, a_max=2)
result = cle.clip(test, min_intensity=1, max_intensity=2)

assert np.array_equal(result, reference)

Expand All @@ -18,7 +18,7 @@ def test_clip_max():
test = [[0, 1], [2, 3]]
reference = [[0, 1], [2, 2]]

result = cle.clip(test, a_min=0, a_max=2)
result = cle.clip(test, min_intensity=0, max_intensity=2)

assert np.array_equal(result, reference)

Expand All @@ -27,6 +27,6 @@ def test_clip_min():
test = [[0, 1], [2, 3]]
reference = [[1, 1], [2, 3]]

result = cle.clip(test, a_min=1, a_max=3)
result = cle.clip(test, min_intensity=1, max_intensity=3)

assert np.array_equal(result, reference)
59 changes: 0 additions & 59 deletions tests/test_operability.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_power():
)
)

result = cle.power(test1, 3)
result = cle.power(test1, scalar=3)

print(result)

Expand Down

0 comments on commit 94e59db

Please sign in to comment.