There are several ways to count number of 1's in your CSR matrix, but the quickest way is to use __getattr__
>>> X.toarray()
array([[0, 1, 0, 0, 1],
[1, 0, 0, 0, 0],
[0, 0, 1, 1, 1],
[1, 0, 0, 1, 0],
[0, 0, 0, 0, 1],
[0, 1, 1, 1, 0],
[1, 0, 0, 0, 0]], dtype=int8)
>>> print(X.__getattr__)
<bound method spmatrix.__getattr__ of <7x5 sparse matrix of type '<class 'numpy.int8'>'
with 13 stored elements in Compressed Sparse Row format>>