class_docstr: A sparse matrix in COOrdinate format.
  
  Also known as the 'ijv' or 'triplet' format.
  
  This can be instantiated in several ways:
      coo_matrix(D)
          with a dense matrix D
  
      coo_matrix(S)
          with another sparse matrix S (equivalent to S.tocoo())
  
      coo_matrix((M, N), [dtype])
          to construct an empty matrix with shape (M, N)
          dtype is optional, defaulting to dtype='d'.
  
      coo_matrix((data, (i, j)), [shape=(M, N)])
          to construct from three arrays:
              1. data[:]   the entries of the matrix, in any order
              2. i[:]      the row indices of the matrix entries
              3. j[:]      the column indices of the matrix entries
  
          Where ``A[i[k], j[k]] = data[k]``.  When shape is not
          specified, it is inferred from the index arrays
  
  Attributes
  ----------
  dtype : dtype
      Data type of the matrix
  shape : 2-tuple
      Shape of the matrix
  ndim : int
      Number of dimensions (this is always 2)
  nnz
      Number of nonzero elements
  data
      COO format data array of the matrix
  row
      COO format row index array of the matrix
  col
      COO format column index array of the matrix
  
  Notes
  -----
  
  Sparse matrices can be used in arithmetic operations: they support
  addition, subtraction, multiplication, division, and matrix power.
  
  Advantages of the COO format
      - facilitates fast conversion among sparse formats
      - permits duplicate entries (see example)
      - very fast conversion to and from CSR/CSC formats
  
  Disadvantages of the COO format
      - does not directly support:
          + arithmetic operations
          + slicing
  
  Intended Usage
      - COO is a fast format for constructing sparse matrices
      - Once a matrix has been constructed, convert to CSR or
        CSC format for fast arithmetic and matrix vector operations
      - By default when converting to CSR or CSC format, duplicate (i,j)
        entries will be summed together.  This facilitates efficient
        construction of finite element matrices and the like. (see example)
  
  Examples
  --------
  
  >>> # Constructing an empty matrix
  >>> from scipy.sparse import coo_matrix
  >>> coo_matrix((3, 4), dtype=np.int8).toarray()
  array([[0, 0, 0, 0],
         [0, 0, 0, 0],
         [0, 0, 0, 0]], dtype=int8)
  
  >>> # Constructing a matrix using ijv format
  >>> row  = np.array([0, 3, 1, 0])
  >>> col  = np.array([0, 3, 1, 2])
  >>> data = np.array([4, 5, 7, 9])
  >>> coo_matrix((data, (row, col)), shape=(4, 4)).toarray()
  array([[4, 0, 9, 0],
         [0, 7, 0, 0],
         [0, 0, 0, 0],
         [0, 0, 0, 5]])
  
  >>> # Constructing a matrix with duplicate indices
  >>> row  = np.array([0, 0, 1, 3, 1, 0, 0])
  >>> col  = np.array([0, 2, 1, 3, 1, 0, 0])
  >>> data = np.array([1, 1, 1, 1, 1, 1, 1])
  >>> coo = coo_matrix((data, (row, col)), shape=(4, 4))
  >>> # Duplicate indices are maintained until implicitly or explicitly summed
  >>> np.max(coo.data)
  1
  >>> coo.toarray()
  array([[3, 0, 1, 0],
         [0, 2, 0, 0],
         [0, 0, 0, 0],
         [0, 0, 0, 1]])
class_docstr_tok: ["A","sparse","matrix","in","COOrdinate","format",".","Also","known","as","the","'ijv","'","or","'triplet","'","format",".","This","can","be","instantiated","in","several","ways",":","coo_matrix","(","D",")","with","a","dense","matrix","D","coo_matrix","(","S",")","with","another","sparse","matrix","S","(","equivalent","to","S.tocoo","(",")",")","coo_matrix","(","(","M",",","N",")",",","[","dtype","]",")","to","construct","an","empty","matrix","with","shape","(","M",",","N",")","dtype","is","optional",",","defaulting","to","dtype=","'d","'",".","coo_matrix","(","(","data",",","(","i",",","j",")",")",",","[","shape=","(","M",",","N",")","]",")","to","construct","from","three","arrays",":","1.","data","[",":","]","the","entries","of","the","matrix",",","in","any","order","2.","i","[",":","]","the","row","indices","of","the","matrix","entries","3.","j","[",":","]","the","column","indices","of","the","matrix","entries","Where","``","A","[","i","[","k","]",",","j","[","k","]","]","=","data","[","k","]","``",".","When","shape","is","not","specified",",","it","is","inferred","from","the","index","arrays","Attributes","--","--","--","--","--","dtype",":","dtype","Data","type","of","the","matrix","shape",":","2-tuple","Shape","of","the","matrix","ndim",":","int","Number","of","dimensions","(","this","is","always","2",")","nnz","Number","of","nonzero","elements","data","COO","format","data","array","of","the","matrix","row","COO","format","row","index","array","of","the","matrix","col","COO","format","column","index","array","of","the","matrix","Notes","--","--","-","Sparse","matrices","can","be","used","in","arithmetic","operations",":","they","support","addition",",","subtraction",",","multiplication",",","division",",","and","matrix","power",".","Advantages","of","the","COO","format","-","facilitates","fast","conversion","among","sparse","formats","-","permits","duplicate","entries","(","see","example",")","-","very","fast","conversion","to","and","from","CSR\/CSC","formats","Disadvantages","of","the","COO","format","-","does","not","directly","support",":","+","arithmetic","operations","+","slicing","Intended","Usage","-","COO","is","a","fast","format","for","constructing","sparse","matrices","-","Once","a","matrix","has","been","constructed",",","convert","to","CSR","or","CSC","format","for","fast","arithmetic","and","matrix","vector","operations","-","By","default","when","converting","to","CSR","or","CSC","format",",","duplicate","(","i",",","j",")","entries","will","be","summed","together",".","This","facilitates","efficient","construction","of","finite","element","matrices","and","the","like",".","(","see","example",")","Examples","--","--","--","--",">",">",">","#","Constructing","an","empty","matrix",">",">",">","from","scipy.sparse","import","coo_matrix",">",">",">","coo_matrix","(","(","3",",","4",")",",","dtype=np.int8",")",".toarray","(",")","array","(","[","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]","]",",","dtype=int8",")",">",">",">","#","Constructing","a","matrix","using","ijv","format",">",">",">","row","=","np.array","(","[","0",",","3",",","1",",","0","]",")",">",">",">","col","=","np.array","(","[","0",",","3",",","1",",","2","]",")",">",">",">","data","=","np.array","(","[","4",",","5",",","7",",","9","]",")",">",">",">","coo_matrix","(","(","data",",","(","row",",","col",")",")",",","shape=","(","4",",","4",")",")",".toarray","(",")","array","(","[","[","4",",","0",",","9",",","0","]",",","[","0",",","7",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","5","]","]",")",">",">",">","#","Constructing","a","matrix","with","duplicate","indices",">",">",">","row","=","np.array","(","[","0",",","0",",","1",",","3",",","1",",","0",",","0","]",")",">",">",">","col","=","np.array","(","[","0",",","2",",","1",",","3",",","1",",","0",",","0","]",")",">",">",">","data","=","np.array","(","[","1",",","1",",","1",",","1",",","1",",","1",",","1","]",")",">",">",">","coo","=","coo_matrix","(","(","data",",","(","row",",","col",")",")",",","shape=","(","4",",","4",")",")",">",">",">","#","Duplicate","indices","are","maintained","until","implicitly","or","explicitly","summed",">",">",">","np.max","(","coo.data",")","1",">",">",">","coo.toarray","(",")","array","(","[","[","3",",","0",",","1",",","0","]",",","[","0",",","2",",","0",",","0","]",",","[","0",",","0",",","0",",","0","]",",","[","0",",","0",",","0",",","1","]","]",")"]
docstr: Returns a matrix with the same sparsity structure as self,
  but with different data.  By default the index arrays
  (i.e. .row and .col) are copied.
docstr_tok: ["Returns","a","matrix","with","the","same","sparsity","structure","as","self",",","but","with","different","data",".","By","default","the","index","arrays","(","i.e",".",".row","and",".col",")","are","copied","."]
code: def _with_data(self, data, copy=True):
      """Returns a matrix with the same sparsity structure as self,
      but with different data.  By default the index arrays
      (i.e. .row and .col) are copied.
      """
      if copy:
          return coo_matrix(
              (data, (self.row.copy(), self.col.copy())),
              shape=self.shape,
              dtype=data.dtype,
          )
      else:
          return coo_matrix(
              (data, (self.row, self.col)),
              shape=self.shape,
              dtype=data.dtype,
          )
  
imports: from __future__ import division, print_function, absolute_import
  from warnings import warn
  import numpy
  from scipy._lib.six import zip
  from ._sparsetools import coo_tocsr, coo_todense, coo_matvec
  from .base import isspmatrix, SparseEfficiencyWarning, spmatrix
  from .data import _data_matrix, _minmax_mixin
  from .sputils import upcast, upcast_char, to_native, isshape, getdtype, get_index_dtype, downcast_intp_index, check_shape, check_reshape_kwargs, matrix
label_desc: Use image node_id 15 for calling the coo_matrix obj's underlying member method code with example usage: obj._with_data(data, copy) and returns: coo_matrix, coo_matrix