-
Notifications
You must be signed in to change notification settings - Fork 307
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
[Feature Request] More powerful power
like numpy.power
#1392
Comments
I think this falls under the "too many methods" problem, but other maintainers may have a different opinion. You might already know, but what you request can be coded like this
|
Indeed. Adding more methods would be convenient when people want to port some Python code to Rust. I opened this issue while trying to port some Python code and found out I needed to use iterators. However, this would also make implementation and maintenance more complex and may confuse users. I genuinely think more discussion should be taken. |
(just accidentally found this issue) From a user's perspective there's already a lot of methods for If this functionality were added via generics it could be nice to have, but I guess generics would be very hard to implement. And personally I find @nilgoyette solution sufficient. Iterators are a staple feature of Rust and are used everywhere. That solution is a little bit verbose but also idiomatic. So I would say, Rust doesn't have to be like Python I guess... |
I'm gonna agree with @nilgoyette that this gets close to muddying the waters of the API for a function that could be implemented as a one-liner. At some point (when With two maintainer votes for closing and the OP's thumbs-up on the alternative implementation, I'm going to close. Maintainers, please re-open if you think that's a mistake. |
#1042 has added element-wise power methods
powi
andpowf
. But they only accept one parameter.In NumPy,
numpy.power
receives two arrays,x1
andx2
. The latter could be a number or an array and performs power with different exponents.An example from: https://numpy.org/doc/stable/reference/generated/numpy.power.html#numpy.power
Though we may archive this using an iterator, a more powerful function might fill the gap for users coming from NumPy.
The text was updated successfully, but these errors were encountered: