def write(self, data, **keys):
slow = keys.get('<STR_LIT>', False)<EOL>isrec = False<EOL>if isinstance(data, (list, dict)):<EOL><INDENT>if isinstance(data, list):<EOL><INDENT>data_list = data<EOL>columns_all = keys.get('<STR_LIT>', None)<EOL>if columns_all is None:<EOL><INDENT>columns_all = keys.get('<STR_LIT>', None)<EOL>if columns_all is None:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>columns_all = list(data.keys())<EOL>data_list = [data[n] for n in columns_all]<EOL><DEDENT>colnums_all = [self._extract_colnum(c) for c in columns_all]<EOL>names = [self.get_colname(c) for c in colnums_all]<EOL>isobj = numpy.zeros(len(data_list), dtype=numpy.bool)<EOL>for i in xrange(len(data_list)):<EOL><INDENT>isobj[i] = is_object(data_list[i])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if data.dtype.fields is None:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if data.shape is ():<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>isrec = True<EOL>names = data.dtype.names<EOL>isobj = fields_are_object(data)<EOL>data_list = []<EOL>colnums_all = []<EOL>for i, name in enumerate(names):<EOL><INDENT>colnum = self._extract_colnum(name)<EOL>data_list.append(data[name])<EOL>colnums_all.append(colnum)<EOL><DEDENT><DEDENT>if slow:<EOL><INDENT>for i, name in enumerate(names):<EOL><INDENT>if not isobj[i]:<EOL><INDENT>self.write_column(name, data_list[i], **keys)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>nonobj_colnums = []<EOL>nonobj_arrays = []<EOL>for i in xrange(len(data_list)):<EOL><INDENT>if not isobj[i]:<EOL><INDENT>nonobj_colnums.append(colnums_all[i])<EOL>if isrec:<EOL><INDENT>colref = array_to_native(data_list[i], inplace=False)<EOL><DEDENT>else:<EOL><INDENT>colref = array_to_native_c(data_list[i], inplace=False)<EOL><DEDENT>if IS_PY3 and colref.dtype.char == '<STR_LIT>':<EOL><INDENT>colref = colref.astype('<STR_LIT:S>', copy=False)<EOL><DEDENT>nonobj_arrays.append(colref)<EOL><DEDENT><DEDENT>for tcolnum, tdata in zip(nonobj_colnums, nonobj_arrays):<EOL><INDENT>self._verify_column_data(tcolnum, tdata)<EOL><DEDENT>if len(nonobj_arrays) > <NUM_LIT:0>:<EOL><INDENT>firstrow = keys.get('<STR_LIT>', <NUM_LIT:0>)<EOL>self._FITS.write_columns(<EOL>self._ext+<NUM_LIT:1>, nonobj_colnums, nonobj_arrays,<EOL>firstrow=firstrow+<NUM_LIT:1>, write_bitcols=self.write_bitcols)<EOL><DEDENT><DEDENT>for i, name in enumerate(names):<EOL><INDENT>if isobj[i]:<EOL><INDENT>self.write_var_column(name, data_list[i], **keys)<EOL><DEDENT><DEDENT>self._update_info()<EOL>
Write data into this HDU

parameters
----------
data: ndarray or list of ndarray
    A numerical python array.  Should be an ordinary array for image
    HDUs, should have fields for tables.  To write an ordinary array to
    a column in a table HDU, use write_column.  If data already exists
    in this HDU, it will be overwritten.  See the append(() method to
    append new rows to a table HDU.
firstrow: integer, optional
    At which row you should begin writing to tables.  Be sure you know
    what you are doing!  For appending see the append() method.
    Default 0.
columns: list, optional
    If data is a list of arrays, you must send columns as a list
    of names or column numbers

    You can also send names=
names: list, optional
    same as columns=