def checkgrad(self, target_param=None, verbose=False, step=<NUM_LIT>, tolerance=<NUM_LIT>, block_indices=None, plot=False):
try:<EOL><INDENT>import numdifftools as nd<EOL><DEDENT>except:<EOL><INDENT>raise ImportError("<STR_LIT>")<EOL><DEDENT>if target_param:<EOL><INDENT>raise NotImplementedError('<STR_LIT>')<EOL><DEDENT>current_index = <NUM_LIT:0><EOL>for name, shape in zip(self.names, self.shapes):<EOL><INDENT>current_size = numpy.prod(shape)<EOL>x = self.optimizer_array.copy()<EOL>x = x[current_index:current_index + current_size].reshape(shape)<EOL>analytic_hess = self._ddf(x)<EOL>if analytic_hess.shape[<NUM_LIT:1>] == <NUM_LIT:1>:<EOL><INDENT>analytic_hess = numpy.diagflat(analytic_hess)<EOL><DEDENT>numeric_hess_partial = nd.Jacobian(self._df, vectorized=False)<EOL>numeric_hess = numeric_hess_partial(x)<EOL>check_passed = self.checkgrad_block(analytic_hess, numeric_hess, verbose=verbose, step=step, tolerance=tolerance, block_indices=block_indices, plot=plot)<EOL>current_index += current_size<EOL><DEDENT>return check_passed<EOL>
Overwrite checkgrad method to check whole block instead of looping through

Shows diagnostics using matshow instead

:param verbose: If True, print a "full" checking of each parameter
:type verbose: bool
:param step: The size of the step around which to linearise the objective
:type step: float (default 1e-6)
:param tolerance: the tolerance allowed (see note)
:type tolerance: float (default 1e-3)

Note:-
   The gradient is considered correct if the ratio of the analytical
   and numerical gradients is within <tolerance> of unity.