Skip to content

Commit

Permalink
Merge pull request #277 from clEsperanto/prototype-compatibility
Browse files Browse the repository at this point in the history
Prototype compatibility
  • Loading branch information
StRigaud authored Oct 18, 2024
2 parents 6277e64 + f62e401 commit 7dd4cfd
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pyclesperanto/_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __add__(x1, x2):
else:
from ._tier1 import add_images_weighted

return add_images_weighted(x1, x2, factor0=1, factor1=1)
return add_images_weighted(x1, x2, factor1=1, factor2=1)


def __iadd__(x1, x2):
Expand All @@ -150,7 +150,7 @@ def __iadd__(x1, x2):
else:
from ._tier1 import add_images_weighted

add_images_weighted(temp, x2, output_image=x1, factor0=1, factor1=1)
add_images_weighted(temp, x2, output_image=x1, factor1=1, factor2=1)
return x1


Expand All @@ -163,7 +163,7 @@ def __sub__(x1, x2):
else:
from ._tier1 import add_images_weighted

return add_images_weighted(x1, x2, factor0=1, factor1=-1)
return add_images_weighted(x1, x2, factor1=1, factor2=-1)


def __div__(x1, x2):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_add_images_weighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_add_images_weighted_named_parameters():
input2 = np.asarray([4, 5, 6])

reference = np.asarray([9, 12, 15])
output = cle.add_images_weighted(input1, input2, None, factor0=1, factor1=2)
output = cle.add_images_weighted(input1, input2, None, factor1=1, factor2=2)
result = cle.pull(output)

print(result)
Expand All @@ -49,7 +49,7 @@ def test_add_images_weighted_wrong_parameter_order():
input2 = np.asarray([4, 5, 6])

reference = np.asarray([9, 12, 15])
output = cle.add_images_weighted(input1, input2, factor0=1, factor1=2)
output = cle.add_images_weighted(input1, input2, factor1=1, factor2=2)
result = cle.pull(output)

print(result)
Expand All @@ -62,7 +62,7 @@ def test_add_images_weighted_parameters_wrong_order_and_missing():
input2 = np.asarray([4, 5, 6])

reference = np.asarray([9, 12, 15])
output = cle.add_images_weighted(input1, input2, factor1=2, factor0=1)
output = cle.add_images_weighted(input1, input2, factor2=2, factor1=1)
result = cle.pull(output)

print(result)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_erode_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_erode_labels_2d_1():

for r in range(5):
print("r", r)
gpu_reference = cle.minimum(gpu_input, radius_x=r, radius_y=r)
gpu_reference = cle.minimum_filter(gpu_input, radius_x=r, radius_y=r)
gpu_output = cle.erode_labels(gpu_input, radius=r, relabel=False)

print(gpu_output)
Expand Down
14 changes: 10 additions & 4 deletions tests/test_histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ def test_histogram():

ref_histogram = [1, 2, 3, 4, 2]

my_histogram = cle.histogram(test, nbins=5, min=1, max=5)
my_histogram = cle.histogram(
test, num_bins=5, minimum_intensity=1, maximum_intensity=5
)

print(my_histogram)

Expand All @@ -23,7 +25,9 @@ def test_histogram_3d():

ref_histogram = [1, 2, 3, 4, 2]

my_histogram = cle.histogram(test, nbins=5, min=1, max=5)
my_histogram = cle.histogram(
test, num_bins=5, minimum_intensity=1, maximum_intensity=5
)

print(my_histogram)

Expand All @@ -36,7 +40,9 @@ def test_histogram_3d_2():

ref_histogram = [1, 2, 3, 4, 2]

my_histogram = cle.histogram(test, nbins=5, min=1, max=5)
my_histogram = cle.histogram(
test, num_bins=5, minimum_intensity=1, maximum_intensity=5
)

print(my_histogram)

Expand All @@ -51,6 +57,6 @@ def test_histogram_3d_2():
# hist, bc = exposure.histogram(image.ravel(), 256, source_range="image")
# print(hist)
# gpu_image = cle.push(image.astype(int))
# gpu_hist = cle.histogram(gpu_image, nbins=256, min=0, max=gpu_image.max())
# gpu_hist = cle.histogram(gpu_image, num_bins=256, minimum_intensity=0, maximum_intensity=gpu_image.max())
# print(cle.pull(gpu_hist))
# assert np.allclose(hist, cle.pull(gpu_hist))
2 changes: 1 addition & 1 deletion tests/test_maximum_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_maximum_box():
)

result = cle.create(test1)
cle.maximum(test1, result, 1, 1, 0)
cle.maximum_filter(test1, result, 1, 1, 0)

a = cle.pull(result)
b = cle.pull(reference)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_maximum_sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_maximum_sphere_1():
test = cle.push(np.asarray([[1, 1, 1], [1, 2, 1], [1, 1, 1]]))

test2 = cle.create(test)
cle.maximum(test, test2, 1, 1, 1, "sphere")
cle.maximum_filter(test, test2, 1, 1, 1, "sphere")

a = cle.pull(test2)
assert np.min(a) == 1
Expand All @@ -28,7 +28,7 @@ def test_maximum_sphere_1():
def test_maximum_sphere_2():
gpu_a = cle.push(np.asarray([[1, 1, 1], [1, 2, 1], [1, 1, 1]]))
gpu_b = cle.create(gpu_a)
cle.maximum(gpu_a, gpu_b, 1, 1, 1, "sphere")
cle.maximum_filter(gpu_a, gpu_b, 1, 1, 1, "sphere")

a = cle.pull(gpu_b)
assert np.min(a) == 1
Expand Down
2 changes: 1 addition & 1 deletion tests/test_minimum_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_minimum_box():
)

result = cle.create(test1)
cle.minimum(test1, result, 1, 1, 0)
cle.minimum_filter(test1, result, 1, 1, 0)

a = cle.pull(result)
b = cle.pull(reference)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_statistics_of_labelled_pixels.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_statistics_of_labelled_pixels():
)
)

result = cle.statistics_of_labelled_pixels(labels, intensities)
result = cle.statistics_of_labelled_pixels(intensities, labels)

print(result)

Expand Down

0 comments on commit 7dd4cfd

Please sign in to comment.