Perhaps integer power should raise an error on negative powers? That way people will at least be directed to use arr ** -1.0 instead of silently getting nonsense from arr ** -1. On 18 Feb 2014 06:57, "Robert Kern" <robert.k...@gmail.com> wrote:
> On Tue, Feb 18, 2014 at 11:44 AM, Sturla Molden <sturla.mol...@gmail.com> > wrote: > > Robert Kern <robert.k...@gmail.com> wrote: > > > >> We're talking about numpy.power(), not just ndarray.__pow__(). The > >> equivalence of the two is indeed an implementation detail, but I do > >> think that it is useful to maintain the equivalence. If we didn't, it > >> would be the only exception, to my knowledge. > > > > But in this case it makes sence. > > Every proposed special case we come up with "makes sense" in some way. > That doesn't mean that they are special enough to break the rules. In > my opinion, this is not special enough to break the rules. In your > opinion, it is. > > > math.pow(2,2) and 2**2 does not do the same. That is how Python behaves. > > Yes, because the functions in the math module are explicitly thin > wrappers around floating-point C library functions and don't have any > particular relationship to the special methods on int objects. numpy > does have largely 1:1 relationship between its ndarray operator > special methods and the ufuncs that implement them. I believe this is > a useful relationship for learning the API and predicting what a given > expression is going to do. > > -- > Robert Kern > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion