def _read_array_header(fp, version):
<EOL>import struct<EOL>if version == (<NUM_LIT:1>, <NUM_LIT:0>):<EOL><INDENT>hlength_str = _read_bytes(fp, <NUM_LIT:2>, "<STR_LIT>")<EOL>header_length = struct.unpack('<STR_LIT>', hlength_str)[<NUM_LIT:0>]<EOL>header = _read_bytes(fp, header_length, "<STR_LIT>")<EOL><DEDENT>elif version == (<NUM_LIT:2>, <NUM_LIT:0>):<EOL><INDENT>hlength_str = _read_bytes(fp, <NUM_LIT:4>, "<STR_LIT>")<EOL>header_length = struct.unpack('<STR_LIT>', hlength_str)[<NUM_LIT:0>]<EOL>header = _read_bytes(fp, header_length, "<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % version)<EOL><DEDENT>header = _filter_header(header)<EOL>try:<EOL><INDENT>d = safe_eval(header)<EOL><DEDENT>except SyntaxError as e:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg % (header, e))<EOL><DEDENT>if not isinstance(d, dict):<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg % d)<EOL><DEDENT>keys = sorted(d.keys())<EOL>if keys != ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg % (keys,))<EOL><DEDENT>if (not isinstance(d['<STR_LIT>'], tuple) or<EOL>not numpy.all([isinstance(x, (int, long)) for x in d['<STR_LIT>']])):<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg % (d['<STR_LIT>'],))<EOL><DEDENT>if not isinstance(d['<STR_LIT>'], bool):<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg % (d['<STR_LIT>'],))<EOL><DEDENT>try:<EOL><INDENT>dtype = numpy.dtype(d['<STR_LIT>'])<EOL><DEDENT>except TypeError as e:<EOL><INDENT>msg = "<STR_LIT>"<EOL>raise ValueError(msg % (d['<STR_LIT>'],))<EOL><DEDENT>return d['<STR_LIT>'], d['<STR_LIT>'], dtype<EOL>
see read_array_header_1_0