-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the dtype of geometry data #612
Conversation
For me this is ok, but @simoneliuzzo may have a word on this |
Dear @lfarv and @swhite2401, I am using get_geometry in these days. For example I use it as:
and
would this pull request change these commands? In case it would be an API change, thus it would have to be scheduled and documented for the next MAJOR release. |
What changes is the data type. I take your example (with my data…) With the current release:1st example:
You get an array with one component, instead of a floating point number !
Here you get a record (x, y, angle), but each item is itself an array with one component. Now the same examples with the bug corrected:
Now you get a floating point number, that's how it should be. Well, technically, it is in fact a so-called scalar array (an array with 0 dimensions!) , but it behaves exactly like a Second example
The record now contains three floating point numbers. ConsequencesIt depends what you are doing with these numbers. In python, an array with one component is totally different from a scalar number. That's why correcting the bug makes all the following processing much easier. But if on your side you applied some tricks to extract the scalars from the array, it may change. The consequences depend upon what you do later. For instance, multiplication or addition of an array with a scalar still gives an array (as in Matlab), so maybe you did not even notice the bug and worked with these arrays without noticing. In which case the correction will be transparent. Or not… |
Dear @lfarv, I use the code in a matching script, and it works. This is why I do not see the need to change it. |
Dear @lfarv, I did the test and it works the same. So ok for me. |
That was my hope, but it could not be guaranteed. |
The data type of geometry data (output of
Lattice.get_geometry
) is incorrect:geodata.x
has shape (n, 1) instead of (n,)geodata[0].x
is a (1,) array instead of a scalarThis PR fixes that, but has consequences on existing code making use of this data.
In most cases, the present output needs a
squeeze()
, which would still work though now useless. In other cases code will breakKeeping
get_geometry
unchanged is of course possible, at the cost of unnecessary complexity of user code…Please advise !
Note for @simoneliuzzo : this appeared when trying to implement a GeometryObservable