Multivariate Pattern Analysis in Python

# mvpa2.algorithms.group_clusterthr.dok_matrix

class `mvpa2.algorithms.group_clusterthr.``dok_matrix`(arg1, shape=None, dtype=None, copy=False)

  Dictionary Of Keys based sparse matrix.

  This is an efficient structure for constructing sparse matrices incrementally.

  This can be instantiated in several ways:
    dok_matrix(D)
      with a dense matrix, D
    dok_matrix(S)
      with a sparse matrix, S
    dok_matrix((M,N), [dtype])
      create the matrix with initial shape (M,N) dtype is optional, defaulting to dtype=’d’

  Notes

  Sparse matrices can be used in arithmetic operations: they support addition, subtraction, multiplication, division, and matrix power.

  Allows for efficient O(1) access of individual elements. Duplicates are not allowed. Can be efficiently converted to a coo_matrix once constructed.

  Examples

      >>> import numpy as np
      >>> from scipy.sparse import dok_matrix
      >>> S = dok_matrix((5, 5), dtype=np.float32)
      >>> for i in range(5):
      ...     for j in range(5):
      ...         S[i, j] = i + j    # Update element

  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

  Methods

  `clear`(() -> None. Remove all items from D.) |
  `fromkeys`(...) | v defaults to None.
  `has_key`((k) -> True if D has a key k, else False) |
  `items`(() -> list of D’s (key, value) pairs, ...) |
  `iteritems`(() -> an iterator over the (key, ...) |
  `iterkeys`(() -> an iterator over the keys of D) |
  `itervalues`(...) |
  `keys`(() -> list of D’s keys) |
  `pop`((k[,d]) -> v, ...) | If key is not found, d is returned if given, otherwise KeyError is raised
  `popitem`(() -> (k, v), ...) | 2-tuple; but raise KeyError if D is empty.
  `setdefault`((k[,d]) -> D.get(k,d), ...) |
  `update`(([E, ...) | If E present and has a .keys() method, does: for k in E: D[k] = E[k]
  `values`(() -> list of D’s values) |
  `viewitems`(...) |
  `viewkeys`(...) |
  `viewvalues`(...) |

  `conjtransp`()

    Return the conjugate transpose

  `copy`()
  `get`(key, default=0.0)

    This overrides the dict.get method, providing type checking but otherwise equivalent functionality.

  `getcol`(j)

    Returns a copy of column j of the matrix as a (m x 1) DOK matrix.

  `getnnz`()
  `getrow`(i)

    Returns a copy of row i of the matrix as a (1 x n) DOK matrix.

  `nnz`
  `resize`(shape)

    Resize the matrix in-place to dimensions given by ‘shape’.

    Any non-zero elements that lie outside the new shape are removed.

  `tocoo`()

    Return a copy of this matrix in COOrdinate format

  `tocsc`()

    Return a copy of this matrix in Compressed Sparse Column format

  `tocsr`()

    Return a copy of this matrix in Compressed Sparse Row format

  `todok`(copy=False)
  `transpose`()

    Return the transpose