bugpyFormex - Bugs: bug #45354, principalSizes return Coords type...

 
 

bug #45354: principalSizes return Coords type instead of numpy array

Submitter:  francesco <francio>
Submitted:  Fri 19 Jun 2015 09:26:40 AM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Functionality error Status:  In Progress
Privacy:  Public Assigned to:  bverheg
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

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.


Benedict Verhegghe <bverheg>
Group administrator
Fri 19 Jun 2015 11:11:20 AM UTC, comment #2: 

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)

francesco <francio>
Group Member
Fri 19 Jun 2015 10:47:53 AM UTC, comment #1: 

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?


Benedict Verhegghe <bverheg>
Group administrator
Fri 19 Jun 2015 09:26:40 AM UTC, original submission:  

We should change this, not sure at which level it occurs.

francesco <francio>
Group Member

 

(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

 

Carbon-Copy List
  • -email is unavailable- added by bverheg (Posted a comment)
  • -email is unavailable- added by francio (Submitted the item)
  •  

    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.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-05-23 bverheg Item GroupNone Functionality error
        StatusNone In Progress
        Assigned toNone bverheg
    2015-06-19 francio CategoryNone Core

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code