From a6985b54c716b43b17e794adea07620ae553e599 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 18 Oct 2024 10:18:12 +0200 Subject: [PATCH 1/3] remove `clip` --- pyclesperanto/_interroperability.py | 26 +++++++++++++------------- tests/test_clip.py | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pyclesperanto/_interroperability.py b/pyclesperanto/_interroperability.py index 570c1ab0..5e812206 100644 --- a/pyclesperanto/_interroperability.py +++ b/pyclesperanto/_interroperability.py @@ -86,19 +86,19 @@ 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): diff --git a/tests/test_clip.py b/tests/test_clip.py index 6b05ee09..37f1c333 100644 --- a/tests/test_clip.py +++ b/tests/test_clip.py @@ -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) @@ -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) @@ -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) From aa6466b777733b7330156b493893eedee0940a71 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 18 Oct 2024 10:24:07 +0200 Subject: [PATCH 2/3] removed `power` --- pyclesperanto/_interroperability.py | 28 +++++++------- tests/test_operability.py | 59 ----------------------------- tests/test_power.py | 2 +- 3 files changed, 15 insertions(+), 74 deletions(-) delete mode 100644 tests/test_operability.py diff --git a/pyclesperanto/_interroperability.py b/pyclesperanto/_interroperability.py index 5e812206..b6228884 100644 --- a/pyclesperanto/_interroperability.py +++ b/pyclesperanto/_interroperability.py @@ -128,23 +128,23 @@ def cbrt(x, out=None): 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) +# 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 +# # test if x2 is a scalar +# if np.isscalar(x2): +# from ._tier1 import power - return power(input_image=x1, scalar=x2, output_image=out, device=x1.device) - else: - from ._tier1 import power_images +# 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 - ) +# x2 = asarray(x2) +# return power_images( +# input_image0=x1, input_image1=x2, output_image=out, device=x1.device +# ) def fabs(x, out=None): diff --git a/tests/test_operability.py b/tests/test_operability.py deleted file mode 100644 index c7e16c77..00000000 --- a/tests/test_operability.py +++ /dev/null @@ -1,59 +0,0 @@ -import numpy as np - -import pyclesperanto as cle - - -def test_mod(): - a = np.array([1, 2, 3, 4, 5]).astype(float) - b = np.array([2, 2, 2, 2, 2]).astype(float) - c = cle.mod(a, b) - - res = cle.pull(c) - - assert (res == np.array([1, 0, 1, 0, 1])).all() - - -def test_sqrt(): - a = np.array([1, 9, 25]).astype(float) - c = cle.sqrt(a) - - res = cle.pull(c) - - assert (res == np.array([1, 3, 5])).all() - - -def test_cbrt(): - a = np.array([1, 27, 125]).astype(float) - c = cle.cbrt(a) - - res = cle.pull(c) - - assert (res == np.array([1, 3, 5])).all() - - -def test_fabs(): - a = np.array([-1, -2, -3, -4, -5]).astype(float) - c = cle.fabs(a) - - res = cle.pull(c) - - assert (res == np.array([1, 2, 3, 4, 5])).all() - - -def test_power_scalar(): - a = np.array([1, 2, 3, 4, 5]).astype(float) - c = cle.power(a, 3) - - res = cle.pull(c) - - assert (res == np.array([1, 8, 27, 64, 125])).all() - - -def test_power_images(): - a = np.array([1, 2, 3, 4, 5]).astype(float) - b = np.array([3, 3, 3, 3, 3]).astype(float) - - c = cle.power(a, b) - res = cle.pull(c) - - assert (res == np.array([1, 8, 27, 64, 125])).all() diff --git a/tests/test_power.py b/tests/test_power.py index 04223f7c..3c14b8d8 100644 --- a/tests/test_power.py +++ b/tests/test_power.py @@ -30,7 +30,7 @@ def test_power(): ) ) - result = cle.power(test1, 3) + result = cle.power(test1, scalar=3) print(result) From f391cc58f98c4e3d4c0832d1a18fda5d433f1b53 Mon Sep 17 00:00:00 2001 From: Stephane Rigaud Date: Fri, 18 Oct 2024 10:25:33 +0200 Subject: [PATCH 3/3] removed all numpy function --- pyclesperanto/_interroperability.py | 54 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/pyclesperanto/_interroperability.py b/pyclesperanto/_interroperability.py index b6228884..4f83c4d7 100644 --- a/pyclesperanto/_interroperability.py +++ b/pyclesperanto/_interroperability.py @@ -101,31 +101,31 @@ def set_wait_for_kernel_finish(wait: bool = True): # ) -def mod(x1, x2, out=None): - from ._tier1 import modulo_images +# 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) +# 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 +# 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) +# 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 +# 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) +# 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): @@ -147,13 +147,13 @@ def cbrt(x, out=None): # ) -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)