class_docstr: Generic matlab matrix writing class 
class_docstr_tok: ["Generic","matlab","matrix","writing","class"]
code: def _write_items(self, arr):
      # write fieldnames
      fieldnames = [f[0] for f in arr.dtype.descr]
      length = max([len(fieldname) for fieldname in fieldnames]) + 1
      max_length = (self.long_field_names and 64) or 32
      if length > max_length:
          raise ValueError(
              "Field names are restricted to %d characters"
              % (max_length - 1)
          )
      self.write_element(np.array([length], dtype="i4"))
      self.write_element(
          np.array(fieldnames, dtype="S%d" % (length)), mdtype=miINT8
      )
      A = np.atleast_2d(arr).flatten("F")
      for el in A:
          for f in fieldnames:
              self.write(el[f])
  
imports: from __future__ import division, print_function, absolute_import
  import os
  import time
  import sys
  import zlib
  from io import BytesIO
  import warnings
  import numpy
  from numpy.compat import asbytes, asstr
  import scipy.sparse
  from scipy._lib.six import string_types
  from .byteordercodes import native_code, swapped_code
  from .miobase import MatFileReader, docfiller, matdims, read_dtype, arr_to_chars, arr_dtype_number, MatWriteError, MatReadError, MatReadWarning
  from .mio5_utils import VarReader5
  from .mio5_params import MatlabObject, MatlabFunction, MDTYPES, NP_TO_MTYPES, NP_TO_MXTYPES, miCOMPRESSED, miMATRIX, miINT8, miUTF8, miUINT32, mxCELL_CLASS, mxSTRUCT_CLASS, mxOBJECT_CLASS, mxCHAR_CLASS, mxSPARSE_CLASS, mxDOUBLE_CLASS, mclass_info
  from .streams import ZlibInputStream
label_desc: Use image node_id 17 for calling the VarWriter5 obj's underlying member method code with example usage: obj._write_items(arr) without return types