def compare_derivatives(more_reliable, less_reliable, eps=1e-6): from __builtin__ import max scale = max(1, ext.max(ext.abs(more_reliable))) if (not (more_reliable/scale).all_approx_equal( # fast other=less_reliable/scale, tolerance=eps)): from libtbx.test_utils import approx_equal assert approx_equal( # slow but helpful output more_reliable/scale, less_reliable/scale, eps=eps)