Closed merrygoat closed 4 years ago
I'm not completely against this but it will be a lot of work to move over to an external library and probably need restructuring of a lot of the project.
I generally only use the quaternion objects for calculations including a few orientations, where the inefficiency of python doesn't really matter. Any calculations including all the orientations in a grain or map, for example, have been manually vectorised using arrays containing the components of all the quaternions (see Quat.calcSymEqvs or ebsd.Map.findBoundaries) and I don't think you'll see much of a performance improvement over those (but I'm happy to be proved wrong).
OK - i'll have a more detailed look after file writers.
This is way too much work to move over. Now I look carefully there is loads of logic in the Quat class. Silly Peter.
One of the current performance bottlenecks in DefDAP is the implementation of quaternions. The Quaternion object is written in pure Python and not vectorised.
Would you consider adding an external dependency for quaternions? This one looks mature and seems to have all of the required features: https://github.com/moble/quaternion. They are vectorised in numpy arrays with ufuncs and have the core in C so are quite fast. Installation is just with pip (not all releases have binary wheels so use
pip install numpy-quaternion --only-binary :all:
to avoid having to compile).If you are interested, I would first mock some quick benchmarks to see if they would be an improvement. Then if they are, I would look to finish making tests for all of the functions of the current Quaternion object and then write the same tests for the library method. Once we are happy that they are doing the same thing it would be possible to move across.