def nonzero(matrix, row):
    """
    usage:
     >>> from scipy.sparse import csr_matrix
     >>> m = csr_matrix([[1, 0, 2], [3, 0, 0]])
     >>> print nonzero(m, 0)
     set([0, 2])
     >>> print nonzero(m, 1)
     set([0])
    """
    return set(matrix[row].indices)