[SciPy-dev] [Numpy-discussion] Proposal: scipy.spatial
Wed Oct 1 11:53:01 CDT 2008
Anne Archibald wrote:
>> This is nice. How about a keyword argument "sort=True" that lets people
>> choose if they want the results sorted by distance or not? I have seen
>> cases where unsorted results are useful.
> That is a possibility. My current code produces results that are in a
> heap, so sorting can in principle be an O(n) activity. Since the
> number of results returned is rarely going to be large, I'm not sure
I thought this was a discussion on a good API for such an algorithm
(sorry if I misunderstood!). Given that context, if this is a general
purpose algorithm I'd rather not assume that the number of results is
typically going to be small.
> the gain in efficiency is worth the loss in determinism. And
If there is no need for sorting and there are a large number of nearest
neighbor queries (in my case there are O(N) nearest neighbor queries),
this quickly adds up to an unnecessary O(N) inefficiency that I'd like
> additional API complexity does have a cost - in an ideal world it
> should at the least double the number of unit tests. I think perhaps
> this should wait on a C implementation.
I don't see why the addition of a sort keyword will double your unit
tests. Another option would be to return unsorted results and have a
separate sort method if it makes testing easier.
Thanks for listening.
More information about the Scipy-dev