You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To address @timhoffm's other comment ("Does it still make sense to keep Affine2D._mtx as a numpy array if we only do element-wise operations?"): I'm quite convinced the whole transform stack would be faster if the transformation matrix was not a numpy array (because 3x3 is a size where the numpy's overhead is generally bigger than the gains from vectorization), but changing everything at once (even better would be to move things to C, but using plain C structs (or equivalently C++ objects) to store the coefficients) would be quite a big PR. So I'm doing the easy parts first :-)
I also noted that there exist several packages that do affine transforms already. I have not attempted any conversions, and they may not be any better, but might be useful as inspiration.
There are some pure Python packages:
affine - Matrices for affine transformations on the plane
Since pybind11 has native support for Eigen, I've put together a branch https://github.com/QuLogic/matplotlib/tree/eigen-transform that attempts to use it. There are a few minor issues that need to be fixed, but it passes most tests now.
However, I've noticed that there is a cast to a NumPy array in the path extension here:
Also, taking a quick look at Agg's trans_affine, it looks to be fairly similar to Eigen. It may be just as easy to implement that way, and not require the addition of Eigen.
Activity
QuLogic commentedon Jan 11, 2022
I also noted that there exist several packages that do affine transforms already. I have not attempted any conversions, and they may not be any better, but might be useful as inspiration.
There are some pure Python packages:
affine- Matrices for affine transformations on the planematrix-47- General matrix mathSome compiled options:
affine-transform- Parallel affine transforms using C++17 and OpenMPPyrr- 3D mathematical functions using NumPy (might be similar to ours though)cython-blis- Fast matrix-multiplication as a self-contained Python library (not affine specific)eigency- Cython interface to Eigen libraryAnd some non-Python things that would need wrappers:
cglm- OpenGL Mathematics (glm) for C (not affine specific, but does 2D and 3D math)math- Vector and matrix math in C++17trans_affinestructQuLogic commentedon Dec 20, 2023
Since pybind11 has native support for Eigen, I've put together a branch https://github.com/QuLogic/matplotlib/tree/eigen-transform that attempts to use it. There are a few minor issues that need to be fixed, but it passes most tests now.
However, I've noticed that there is a cast to a NumPy array in the path extension here:
matplotlib/src/py_converters.cpp
Lines 320 to 323 in 8f296db
which means we miss out on avoiding NumPy right now. This will be made easier once #27087 is complete.
I've not run any benchmarks yet, but at least this points out the pain points with doing this change (and we got #27511 out of it.)
QuLogic commentedon Dec 20, 2023
Also, taking a quick look at Agg's
trans_affine, it looks to be fairly similar to Eigen. It may be just as easy to implement that way, and not require the addition of Eigen.