Stopped iteration if dx values are all < 0
And to python interface
Hours later...
Oddly this fixes the error in derivative, but it should have no impact