'Ensure has_canonical_format memoizes state for sum_duplicates'

def test_has_canonical_format(self):

    M = csr_matrix((np.array([2]), np.array([0]), np.array([0, 1])))
    assert_equal(True, M.has_canonical_format)
    indices = np.array([0, 0])
    data = np.array([1, 1])
    indptr = np.array([0, 2])
    M = csr_matrix((data, indices, indptr)).copy()
    assert_equal(False, M.has_canonical_format)
    M.sum_duplicates()
    assert_equal(True, M.has_canonical_format)
    assert_equal(1, len(M.indices))
    M = csr_matrix((data, indices, indptr)).copy()
    M.has_canonical_format = True
    assert_equal(True, M.has_canonical_format)
    assert_equal(2, len(M.indices))
    M.sum_duplicates()
    assert_equal(2, len(M.indices))
