python-quantities-developers team mailing list archive
-
python-quantities-developers team
-
Mailing list archive
-
Message #00015
Re: Quantity/numpy member functions vs. static counterparts
Additionally:
In [10]: x
Out[10]: [ 1. 2. 3. 4.]*Btu
In [11]: math.e ** x #this works correctly
ValueError: exponent is not dimensionless
In [12]: numpy.exp(x) # but this does not
Out[12]: [ 2.71828183 7.3890561 20.08553692 54.59815003]*Btu
On Tue, Jan 6, 2009 at 1:32 AM, John Salvatier <jsalvati@xxxxxxxxxxxxxxxx>wrote:
> I have noticed that while many members functions work as we would like them
> to work after I overload them, the static member functions in the numpy
> namespace are unaffected. For example:
>
> for the sum function
> In [13]: y
> Out[13]:
> [[ 1. 3. 4. 5.]
> [ 1. 2. 3. 6.]]*inch
>
> In [14]: y.sum()
> Out[14]: 25.0*inch
>
> In [15]: numpy.sum(y) # this actually throws an error
> ... error stuff...
>
> for the ravel function
> In [19]: y
> Out[19]:
> [[ 1. 3. 4. 5.]
> [ 1. 2. 3. 6.]]*inch
>
> In [20]: y.ravel()
> Out[20]: [ 1. 3. 4. 5. 1. 2. 3. 6.]*inch
>
> In [21]: numpy.ravel(y)
> Out[21]: array([ 1., 3., 4., 5., 1., 2., 3., 6.])
>
> I am not sure what --if anything-- we want to do about this, and I am not
> sure there is a whole lot we *can* do.
> Thoughts?
>
Follow ups
References