def _check_fill_value(fill_value, ndtype):
ndtype = np.dtype(ndtype)<EOL>fields = ndtype.fields<EOL>if fill_value is None:<EOL><INDENT>if fields:<EOL><INDENT>descr = ndtype.descr<EOL>fill_value = np.array(_recursive_set_default_fill_value(descr),<EOL>dtype=ndtype,)<EOL><DEDENT>else:<EOL><INDENT>fill_value = default_fill_value(ndtype)<EOL><DEDENT><DEDENT>elif fields:<EOL><INDENT>fdtype = [(_[<NUM_LIT:0>], _[<NUM_LIT:1>]) for _ in ndtype.descr]<EOL>if isinstance(fill_value, (ndarray, np.void)):<EOL><INDENT>try:<EOL><INDENT>fill_value = np.array(fill_value, copy=False, dtype=fdtype)<EOL><DEDENT>except ValueError:<EOL><INDENT>err_msg = "<STR_LIT>"<EOL>raise ValueError(err_msg % (fill_value, fdtype))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>descr = ndtype.descr<EOL>fill_value = np.asarray(fill_value, dtype=object)<EOL>fill_value = np.array(_recursive_set_fill_value(fill_value, descr),<EOL>dtype=ndtype)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(fill_value, basestring) and (ndtype.char not in '<STR_LIT>'):<EOL><INDENT>err_msg = "<STR_LIT>"<EOL>raise TypeError(err_msg % ndtype)<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>fill_value = np.array(fill_value, copy=False, dtype=ndtype)<EOL><DEDENT>except OverflowError:<EOL><INDENT>err_msg = "<STR_LIT>"<EOL>raise TypeError(err_msg % (fill_value, ndtype))<EOL><DEDENT><DEDENT><DEDENT>return np.array(fill_value)<EOL>
Private function validating the given `fill_value` for the given dtype.

If fill_value is None, it is set to the default corresponding to the dtype
if this latter is standard (no fields). If the datatype is flexible (named
fields), fill_value is set to a tuple whose elements are the default fill
values corresponding to each field.

If fill_value is not None, its value is forced to the given dtype.