[SciPy-dev] scipy.spatial 'output' args

Damian Eads eads at soe.ucsc.edu
Sat Feb 21 20:59:27 EST 2009


Hi David,

On Fri, Feb 20, 2009 at 1:21 AM, David Warde-Farley <dwf at cs.toronto.edu> wrote:
> Howdy,
>
> This is mostly a question for Damian (sorry, I seem to be bugging you
> on a lot of fronts!). I'm wondering if there's a principled reason why
> the pdist/squareform/etc. functions don't allow you to specify an
> output array.
>
> It seems hard to justify not having a way of avoiding repeated memory
> allocations if you're doing this more than once (as points change, for
> example -- if you're curious I'm implementing a 2-D embedding
> algorithm and the objective function relies on a lot of distances
> being recomputed).

There is no reason why I did not provide an 'out' parameter for
preallocated memory in these functions. This is probably just a
MATLABism oversight. I'd encourage you to add this feature. If you do,
please make sure to do the following:

    * the array holds the right number of values,
    * its C contiguous (the C functions don't do any special striding),
    * the data type of the out array is 'f',

Please provide regression tests, making sure the exception is thrown
in these appropriate cases. See 'test_distance.py' for the nose tests.

Thanks so much for agreeing to add this feature.

Damian

> My guess is this is a MATLABism and that this was just an oversight.
> Is there a reason I shouldn't go about trying to add it? Would other
> people find this useful?
>
> David
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>



-- 
-----------------------------------------------------
Damian Eads                             Ph.D. Student
Jack Baskin School of Engineering, UCSC        E2-489
1156 High Street                 Machine Learning Lab
Santa Cruz, CA 95064    http://www.soe.ucsc.edu/~eads



More information about the SciPy-Dev mailing list