Adding numpy count_nonzero & minor template fix

Have i missed something?
No the point is to avoid a branching. And this behaviour is fully determined by the standard