matplotlib/matplotlib — pull request #723 by PhilipElson (2012-02-27 17:49:20+00:00)
Title: Caching the results of Transform.transform_path for non-affine transforms

This pull request supports the previously intended capability of caching non-affine transformations. It was discussed briefly on the devel mailing-list:

http://old.nabble.com/Caching-the-results-of-Transform.transform_path-for-non-affine-transforms-td33256890.html

An example of how to test this capability by hand was included on the thread:

```
import matplotlib.transforms

class SlowNonAffineTransform(matplotlib.transforms.Transform):
input_dims = 2
output_dims = 2
is_separable = False
has_inverse = True

def transform(self, points):
return matplotlib.transforms.IdentityTransform().transform(points)

def transform_path(self, path):
# pretends that it is doing something clever & time
# consuming, but really is just sleeping
import time
# take a long time to do something
time.sleep(3)
# return the original path
return matplotlib.transforms.IdentityTransform().transform_path(path)

if __name__ == '__main__':
import matplotlib.pyplot as plt

ax = plt.axes()
ax.plot([0, 10, 20], [1, 3, 2], transform=SlowNonAffineTransform() + ax.transData)
plt.show()
```