The row[0] should be changed to `row[0] if row else 0` so this will work with the SparseMatrix.zeros(3) -- and a test should be added for the same.