A lot depends on what you mean by 'punishing yourself'.
Ghandi starved himself to draw attention to a cause. He had a particular political goal in mind and starving himself was a stunt to get people to notice. Some people are willing to die for a cause, and that is not unreasonable, if the actions truly do advance the cause.
Self-deprivation as a means of training to become better at some skill is also quite reasonable as long, again, as it actually does help in the training.
On the other hand, whipping yourself in privacy as punishment for some imagined sin is just insanity. It has no redeeming effect that offsets the badness involved.
Ghandi starved himself to draw attention to a cause. He had a particular political goal in mind and starving himself was a stunt to get people to notice. Some people are willing to die for a cause, and that is not unreasonable, if the actions truly do advance the cause.
Self-deprivation as a means of training to become better at some skill is also quite reasonable as long, again, as it actually does help in the training.
On the other hand, whipping yourself in privacy as punishment for some imagined sin is just insanity. It has no redeeming effect that offsets the badness involved.