Maybe just remove the or? If axis is not None, it might still be wrong, and it should be an error.