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

Add sqrt and power functions to operate on pdarray #1725

Closed
milthorpe opened this issue Aug 29, 2022 · 4 comments · Fixed by #1726
Closed

Add sqrt and power functions to operate on pdarray #1725

milthorpe opened this issue Aug 29, 2022 · 4 comments · Fixed by #1726
Assignees
Labels
enhancement New feature or request

Comments

@milthorpe
Copy link

Square root and power operations are useful; this enhancement would add them as functions to the arkouda module alongside exp etc.

arkouda.sqrt would be a simple element-wise operation (like exp).
arkouda.power would have a similar interface to numpy.power, accepting as the second argument either a scalar value to which all elements of the first array are raised, or an array of powers to which corresponding elements of the first array are raised.

@milthorpe
Copy link
Author

Immediately closing this issue after discovering that Arkouda has already implemented the ** operator :-)
E.g. the following work just fine:

>>> ak.array([2,0,-1])**0.5
array([1.4142135623730951 0 nan])
>>> ak.array([10,5,2])**ak.array([2,3,4])
array([100 125 16])

@Ethan-DeBandi99
Copy link
Contributor

@milthorpe - I am reopening this. Since your first thought was to use .sqrt and .power I am going to create those functions that will essentially be aliases for the ** operator, but will at least exist.

@milthorpe
Copy link
Author

If it fits with the Arkouda design philosophy, sure! As a little more background - you have probably guessed this already - I am attempting a 'verbatim' translation of existing numpy code to use Arkouda, and for whatever reason sqrt and power seem to be the preferred numpy style.

@Ethan-DeBandi99
Copy link
Contributor

@milthorpe - if it is the preferred style by numpy, Arkouda should definitely include it. I already added the code. I already put up a PR for this so once the rest of the team reviews it will be merged and will be in the next release. Thanks for bringing this up!

stress-tess pushed a commit that referenced this issue Aug 30, 2022
* Added .power and .sqrt functions as aliases for ** and **0.5. Testing to ensure they return expected numpy results.

* Addressing review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants