Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for incorrect function signature in power() from issue #271: updated parameters and order. #272

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions pyclesperanto/_interroperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,22 @@ 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(input_image, output_image, exponent):
input_image = asarray(input_image)
if output_image:
output_image = asarray(output_image)

# test if x2 is a scalar
if np.isscalar(x2):
# test if exponent is a scalar
if np.isscalar(exponent):
from ._tier1 import power

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

x2 = asarray(x2)
exponent = asarray(exponent)
return power_images(
input_image0=x1, input_image1=x2, output_image=out, device=x1.device
input_image0=input_image, input_image1=exponent, output_image=output_image, device=input_image.device
Comment on lines +137 to +146
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic seems broken now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should not be in there anyway. Can we remove it @StRigaud ? I think if people wanted to call power_images, they should do it explicitly. It should not be called in case some parameters are set in a specific way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a mimic of the numpy power function, along with other numpy function in interoperability.

The question is "how far do we mimic numpy" ( we dont is a valid answer 😉 )

)


Expand Down
Loading