class_docstr: Store a corpus in `Matrix Market format <https://math.nist.gov/MatrixMarket/formats.html>`_,
  using :class:`~gensim.corpora.mmcorpus.MmCorpus`.
  
  Notes
  -----
  The output is written one document at a time, not the whole matrix at once (unlike e.g. `scipy.io.mmread`).
  This allows you to write corpora which are larger than the available RAM.
  
  The output file is created in a single pass through the input corpus, so that the input can be
  a once-only stream (generator).
  
  To achieve this, a fake MM header is written first, corpus statistics are collected
  during the pass (shape of the matrix, number of non-zeroes), followed by a seek back to the beginning of the file,
  rewriting the fake header with the final values.
class_docstr_tok: ["Store","a","corpus","in","`","Matrix","Market","format","<","https",":","\/\/math.nist.gov\/MatrixMarket\/formats.html",">","`","_",",","using",":","class",":","`","~gensim.corpora.mmcorpus.MmCorpus","`",".","Notes","--","--","-","The","output","is","written","one","document","at","a","time",",","not","the","whole","matrix","at","once","(","unlike","e.g",".","`","scipy.io.mmread","`",")",".","This","allows","you","to","write","corpora","which","are","larger","than","the","available","RAM",".","The","output","file","is","created","in","a","single","pass","through","the","input","corpus",",","so","that","the","input","can","be","a","once-only","stream","(","generator",")",".","To","achieve","this",",","a","fake","MM","header","is","written","first",",","corpus","statistics","are","collected","during","the","pass","(","shape","of","the","matrix",",","number","of","non-zeroes",")",",","followed","by","a","seek","back","to","the","beginning","of","the","file",",","rewriting","the","fake","header","with","the","final","values","."]
docstr: Write a single sparse vector to the file.
  
  Parameters
  ----------
  docno : int
      Number of document.
  vector : list of (int, number)
      Document in BoW format.
  
  Returns
  -------
  (int, int)
      Max word index in vector and len of vector. If vector is empty, return (-1, 0).
docstr_tok: ["Write","a","single","sparse","vector","to","the","file",".","Parameters","--","--","--","--","--","docno",":","int","Number","of","document",".","vector",":","list","of","(","int",",","number",")","Document","in","BoW","format",".","Returns","--","--","--","-","(","int",",","int",")","Max","word","index","in","vector","and","len","of","vector",".","If","vector","is","empty",",","return","(","-1",",","0",")","."]
code: def write_vector(self, docno, vector):
      """Write a single sparse vector to the file.
  
      Parameters
      ----------
      docno : int
          Number of document.
      vector : list of (int, number)
          Document in BoW format.
  
      Returns
      -------
      (int, int)
          Max word index in vector and len of vector. If vector is empty, return (-1, 0).
  
      """
      assert (
          self.headers_written
      ), "must write Matrix Market file headers before writing data!"
      assert (
          self.last_docno < docno
      ), "documents %i and %i not in sequential order!" % (
          self.last_docno,
          docno,
      )
      vector = sorted(
          (i, w) for i, w in vector if abs(w) > 1e-12
      )  # ignore near-zero entries
      for termid, weight in vector:  # write term ids in sorted order
          # +1 because MM format starts counting from 1
          self.fout.write(
              utils.to_utf8(
                  "%i %i %s\n" % (docno + 1, termid + 1, weight)
              )
          )
      self.last_docno = docno
      return (vector[-1][0], len(vector)) if vector else (-1, 0)
  
imports: from __future__ import with_statement
  import logging
  import math
  from gensim import utils
  import numpy
  import scipy.sparse
  from scipy.stats import entropy
  from scipy.linalg import get_blas_funcs, triu
  from scipy.linalg.lapack import get_lapack_funcs
  from scipy.special import psi
label_desc: Use image node_id 4 for calling the MmWriter obj's underlying member method code with example usage: obj.write_vector(docno, vector) and returns: unknown