Add a New Comment (Rich Markup)
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.
The problem is that the sort does not seem to work on Coords array. My numpy version is (1.9.1) a= sort(Coords([0,0,0])) Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/numpy/core/fromnumeric.py", line 791, in sort a.sort(axis, kind, order) TypeError: sort() takes at most 2 arguments (4 given)
Now that would be something easy to fix, even for a junior member ;) So please do not leave everything for me to fix. A wild guess: bbox() returns two points, in a Coords, sizes() takes the difference between the two. On the other hand, I am not sure that we have to fix this. While not technically the coordinates of a point, sizes() can be considered a vector from one point to another. We used Coords in many cases as a class to store 3D vectors. SO as far as I am concerned, I would allow Coords to be used for anything that has 3 components (it is the only restriction built into the class). The fact that it is a Coords also provides opportunities. Does it create problems?
We should change this, not sure at which level it occurs.
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
No files currently attached
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Only logged-in users can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 4 latest changes.
Copyright © 2023 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.11