mwaskom/seaborn — pull request #129 by mwaskom (2014-03-07 19:17:15+00:00)
Title: WIP: Use joblib to cache computationally intensive parts of plotting functions

This is a proof of concept using `regplot`. The basic idea is that a lot of the plotting functions do a significant amount of computation to fit the model used in the plot. But, often, a user is going to want to iterate over the plot to tweak the aesthetics, etc.

To make this easier, plotting functions that are compute-intensive will have an optional argument called `mem` that takes a `joblib.Memory` instance. Internally, the function will cache the compute-intensive methods. Basically, you'd get something like:

``` python
In [1]: mem = Memory(".", verbose=2)
In [2]: sns.regplot(x, y, mem=mem)

[Memory] Calling seaborn.linearmodels._RegressionPlotter.fit_fast...
fit_fast(array([-0.042867, ..., -1.340816]), array([ 0.886475, ..., 0.291993]), array([-4., ..., 4.]))
_________________________________________________________fit_fast - 0.3s, 0.0min

In [3]: sns.regplot(x, y, color="salmon", mem=mem)

[Memory] 14.1s, 0.2min: Loading seaborn.linearmodels._RegressionPlotter.fit_fast...
```

Currently tests fail as this requires a bit of change to the `regplot` fitting functions (moving the data access from `self` attributes inside the methods to method arguments, and I haven't updated the tests to reflect that).

Ideas on this are very appreciated.