Mon 23 May 2016 09:24:44 AM UTC, comment #3:
numpy.sort does not work on a Coords array, because it uses the sort() method of a numpy.ndarray and we have overloaded the sort() method in Coords.
The reason for overloading the sort() is that you normally do not want to sort coordinate x of point i with respect to coordinate z of point j. Thus we implemented a sort() method that sorts points, but leaves the order of the coordinates unchanged.
In your case, you want to sort the coordinates of a single point,
which seems useful because it is not really a point, but distances. To fix this, different level solutions are possible, and I would like some discussion about how to proceed.
1. Rename our Coords.sort method to e.g. sortPoints: this would restore the default sort.
+: Easy to do, solves everything.
-: Compatibility. Need to check existing code and add a warning to users.
2. Add the numpy arguments for sort to Coords.sort, and allow calling the original depending on proper arg values.
+: No change for user.
-: Not sure if it will work and solve everything. New tricky cases might evolve. It might hide problems with Coords/ndarray confusion which are now exposed.
3. Let the Coords.sizes() method return a numpy.ndarray instead of a Coords.
+: Easy to do.
-: Does not solve everything (users still can not do a numpy.sort on a Coords); some functionality is lost (sizes().x, sizes().xz, ...)
4. Let the user convert the Coords to a numpy.ndarray before sorting: sort(asarray(sizes()).
+: Nothing changes
-: Least user friendly.
I tend to implement solution 1. It would retain full numpy sort possibilities on a Coords (and who knows where that might become handy).
If anyone has other arguments to count in, please let me know.
|