def array2tabledef(data, table_type='<STR_LIT>', write_bitcols=False):
is_ascii = (table_type == '<STR_LIT:ascii>')<EOL>if data.dtype.fields is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>names = []<EOL>names_nocase = {}<EOL>formats = []<EOL>dims = []<EOL>descr = data.dtype.descr<EOL>for d in descr:<EOL><INDENT>npy_dtype = d[<NUM_LIT:1>][<NUM_LIT:1>:]<EOL>if is_ascii:<EOL><INDENT>if npy_dtype in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % npy_dtype)<EOL><DEDENT>if npy_dtype in ['<STR_LIT>']:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % npy_dtype)<EOL><DEDENT><DEDENT>if npy_dtype[<NUM_LIT:0>] == '<STR_LIT:O>':<EOL><INDENT>name = d[<NUM_LIT:0>]<EOL>form, dim = npy_obj2fits(data, name)<EOL><DEDENT>elif npy_dtype[<NUM_LIT:0>] == "<STR_LIT>":<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>name, form, dim = _npy2fits(<EOL>d, table_type=table_type, write_bitcols=write_bitcols)<EOL><DEDENT>if name == '<STR_LIT>':<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>"""<STR_LIT>"""<EOL>name_nocase = name.upper()<EOL>if name_nocase in names_nocase:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % name_nocase)<EOL><DEDENT>names.append(name)<EOL>names_nocase[name_nocase] = name_nocase<EOL>formats.append(form)<EOL>dims.append(dim)<EOL><DEDENT>return names, formats, dims<EOL>
Similar to descr2tabledef but if there are object columns a type
and max length will be extracted and used for the tabledef