[SciPy-dev] Idle (?) speculation about ndarray [was draft: NumPy User Guide introduction]
josef.pktd at gmail.com
josef.pktd at gmail.com
Fri Aug 21 11:32:07 EDT 2009
On Fri, Aug 21, 2009 at 11:19 AM, Gael
Varoquaux<gael.varoquaux at normalesup.org> wrote:
> On Fri, Aug 21, 2009 at 11:07:12AM -0400, josef.pktd at gmail.com wrote:
>> Methods are useful for being overwritten by subclasses. And the last
>> time I checked method calls were a bit faster than functions.
>
> Fernando and I had a look recently, and as far as we could tell, all the
> functions tried to call the methods, if any, sometimes after doing a bit
> more magic.
>
> Gaël
depends on how you define "all the functions"
there was a discussion a while ago about np.dot
>>> a = np.ma.masked_invalid([1,2,3,np.nan,np.inf,5])
>>> a
masked_array(data = [1.0 2.0 3.0 -- -- 5.0],
mask = [False False False True True False],
fill_value = 1e+020)
>>> np.dot(a,a)
Traceback (most recent call last):
File "<pyshell#54>", line 1, in <module>
np.dot(a,a)
File "C:\Programs\Python25\Lib\site-packages\numpy\ma\core.py", line
2447, in __array_finalize__
self._mask.shape = self.shape
ValueError: total size of new array must be unchanged
>>> np.ma.dot(a,a)
masked_array(data = 39.0,
mask = False,
fill_value = 1e+020)
>>> np.source(np.dot)
Not available for this object.
More information about the SciPy-Dev
mailing list