#NEWLINE# def _check_fun( fun , d , * args , **kwargs ) : #NEWLINE# #INDENT# want_shape = d . shape #NEWLINE# d = fun ( d , * args , ** kwargs ) #NEWLINE# if ( not isinstance ( d , np . ndarray ) ) : #NEWLINE# #INDENT# raise TypeError ( 'Return value must be an ndarray' ) #NEWLINE# #UNINDENT# if ( d . shape != want_shape ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Return data must have shape %s not %s' % ( want_shape , d . shape ) ) ) #NEWLINE# #UNINDENT# return d