Stuckness shouldn't be avoided. It's the psychic predecessor of all real understanding. An egoless acceptance of stuckness is a key to an understanding of Quality, in mechanical work as in other endeavors. It's this understanding of Quality as revealed by stuckness which so often makes self-taught mechanics so superior to institute-trained men who have learned how to handle everything except a new situation. - Robert Pirsig, Zen and the Art of Motorcycle Maintenance
Thursday, April 5, 2012
Copy one sparse matrix into another in Python
Copying Xf into features. In this case, Xf is a scipy.sparse.csr_matrix and features is a dok_matrix.
nz_indices = Xf.nonzero() for ix, jx in zip(nz_indices, nz_indices): features[ix, jx] = Xf[ix, jx]
1. When I checked, the assignment of a 0 to an element of a dok_matrix resulted in a crash. So 0 assignments have to be avoided.