dfm/george — pull request #20 by jbernhard (2014-10-10 16:41:11+00:00)
Title: Speeding up repeated predictions

As discussed in #19.

I am not sure what you want to do for a unit test. This is an implementation detail, so by design, it does not affect any actual behavior (other than speed).

I thought about literally timing `predict()` -- once without the cache and then again with the cache -- and asserting that the second time must be sufficiently smaller than the first. There are at least two problems with that: one, this optimization is only significant for relatively large numbers of samples, and we don't want to slow down the tests too much; two, we have no idea exactly how the timings will behave on an arbitrary machine.

[Mock](http://www.voidspace.org.uk/python/mock) is another possibility.

For now, I simply test that calling `predict()` twice for the same observations produces the same results, and when the observations change it doesn't mistakenly re-use the old cached `alpha`. I guess this is better than nothing but it's not really a stringent test.