Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tokestermw
tokestermw / incremental_sparse_matrix.py
Last active March 20, 2019 12:49
Incrementally creating sparse matrices are memory-intensive (had some trouble when data size was large). this is an alternative using the array module. ref: http://maciejkula.github.io/2015/02/22/incremental-sparse-matrices/
import array
import numpy as np
import scipy.sparse as sp
class IncrementalCOOMatrix(object):
def __init__(self, shape, dtype):
if dtype is np.int32: