class_docstr: Class for writing mat5 files 
docstr: Write variables in `mdict` to stream
  
  Parameters
  ----------
  mdict : mapping
     mapping with method ``items`` returns name, contents pairs where
     ``name`` which will appear in the matlab workspace in file load, and
     ``contents`` is something writeable to a matlab file, such as a NumPy
     array.
  write_header : {None, True, False}, optional
     If True, then write the matlab file header before writing the
     variables. If None (the default) then write the file header
     if we are at position 0 in the stream. By setting False
     here, and setting the stream position to the end of the file,
     you can append variables to a matlab file
docstr_tok: ["Write","variables","in","`","mdict","`","to","stream","Parameters","--","--","--","--","--","mdict",":","mapping","mapping","with","method","``","items","``","returns","name",",","contents","pairs","where","``","name","``","which","will","appear","in","the","matlab","workspace","in","file","load",",","and","``","contents","``","is","something","writeable","to","a","matlab","file",",","such","as","a","NumPy","array",".","write_header",":","{","None",",","True",",","False","}",",","optional","If","True",",","then","write","the","matlab","file","header","before","writing","the","variables",".","If","None","(","the","default",")","then","write","the","file","header","if","we","are","at","position","0","in","the","stream",".","By","setting","False","here",",","and","setting","the","stream","position","to","the","end","of","the","file",",","you","can","append","variables","to","a","matlab","file"]
code: def put_variables(self, mdict, write_header=None):
      """Write variables in `mdict` to stream
  
      Parameters
      ----------
      mdict : mapping
         mapping with method ``items`` returns name, contents pairs where
         ``name`` which will appear in the matlab workspace in file load, and
         ``contents`` is something writeable to a matlab file, such as a NumPy
         array.
      write_header : {None, True, False}, optional
         If True, then write the matlab file header before writing the
         variables. If None (the default) then write the file header
         if we are at position 0 in the stream. By setting False
         here, and setting the stream position to the end of the file,
         you can append variables to a matlab file
      """
      # write header if requested, or None and start of file
      if write_header is None:
          write_header = self.file_stream.tell() == 0
      if write_header:
          self.write_file_header()
      self._matrix_writer = VarWriter5(self)
      for name, var in mdict.items():
          if name[0] == "_":
              continue
          is_global = name in self.global_vars
          if self.do_compression:
              stream = BytesIO()
              self._matrix_writer.file_stream = stream
              self._matrix_writer.write_top(
                  var, name.encode("latin1"), is_global
              )
              out_str = zlib.compress(stream.getvalue())
              tag = np.empty((), NDT_TAG_FULL)
              tag["mdtype"] = miCOMPRESSED
              tag["byte_count"] = len(out_str)
              self.file_stream.write(tag.tobytes())
              self.file_stream.write(out_str)
          else:  # not compressing
              self._matrix_writer.write_top(
                  var, name.encode("latin1"), is_global
              )
  
imports: import os
  import time
  import sys
  import zlib
  from io import BytesIO
  import warnings
  import numpy
  import scipy.sparse
  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, mat_struct
  from ._streams import ZlibInputStream
label_desc: Use image node_id 3 for calling the MatFile5Writer obj's underlying member method code with example usage: obj.put_variables(mdict, write_header) without return types