[SciPy-user] sparse version of stats.pearsonr ?

Nathan Bell wnbell@gmail....
Mon Mar 9 22:29:57 CDT 2009


On Mon, Mar 9, 2009 at 9:09 PM, Pauli Virtanen <pav@iki.fi> wrote:
>
> Sparse probably uses an integer accumulator for these functions, whereas
> normal numpy arrays use a float accumulator.
>
> Probably a bug: http://projects.scipy.org/scipy/ticket/884
>

Yep, this is something we'll address in SciPy 0.8:
   http://projects.scipy.org/scipy/ticket/658


As a work around, you could do
>>> B * ones((B.shape[1],1), dtype='float64')
and scipy.sparse will upcast B's data array accordingly.  This is
somewhat more efficient than
>>> B.astype('float64').sum(axis=0)

-- 
Nathan Bell wnbell@gmail.com
http://graphics.cs.uiuc.edu/~wnbell/


More information about the SciPy-user mailing list