xrange no longer exists in python 3, and since it is a small number of
iterations there is a limited performance impact under python 2 by
using range instead.
Add check to ensure linearisation exception does not occur under python
3, due to exception in attempting to use a non existing function.
Change-Id: I3e6165b8bce14a44459fc9419792784f64636f5e