Implmented local _count_nonzero method to replace np.count_nonzero (for Numpy 1.5.1 compatibility)