'Test the derivative of a model by fitting with an estimated and
analytical derivative.'

@pytest.mark.skipif(u'not    HAS_SCIPY')
def test_deriv_2D(self, model_class, test_parameters):

    x_lim = test_parameters[u'x_lim']
    y_lim = test_parameters[u'y_lim']
    if (model_class.fit_deriv is None):
        pytest.skip(u'Derivative    function    is    not    defined    for    model.')
    if issubclass(model_class, PolynomialBase):
        pytest.skip(u'Skip    testing    derivative    of    polynomials.')
    if (u'log_fit' in test_parameters):
        if test_parameters[u'log_fit']:
            x = np.logspace(x_lim[0], x_lim[1], self.N)
            y = np.logspace(y_lim[0], y_lim[1], self.M)
    else:
        x = np.linspace(x_lim[0], x_lim[1], self.N)
        y = np.linspace(y_lim[0], y_lim[1], self.M)
    (xv, yv) = np.meshgrid(x, y)
    try:
        model_with_deriv = create_model(model_class, test_parameters, use_constraints=False, parameter_key=u'deriv_initial')
        model_no_deriv = create_model(model_class, test_parameters, use_constraints=False, parameter_key=u'deriv_initial')
        model = create_model(model_class, test_parameters, use_constraints=False, parameter_key=u'deriv_initial')
    except KeyError:
        model_with_deriv = create_model(model_class, test_parameters, use_constraints=False)
        model_no_deriv = create_model(model_class, test_parameters, use_constraints=False)
        model = create_model(model_class, test_parameters, use_constraints=False)
    rsn = np.random.RandomState(1234567890)
    amplitude = test_parameters[u'parameters'][0]
    n = ((0.1 * amplitude) * (rsn.rand(self.M, self.N) - 0.5))
    data = (model(xv, yv) + n)
    fitter_with_deriv = fitting.LevMarLSQFitter()
    new_model_with_deriv = fitter_with_deriv(model_with_deriv, xv, yv, data)
    fitter_no_deriv = fitting.LevMarLSQFitter()
    new_model_no_deriv = fitter_no_deriv(model_no_deriv, xv, yv, data, estimate_jacobian=True)
    utils.assert_allclose(new_model_with_deriv.parameters, new_model_no_deriv.parameters, rtol=0.1)
