Also Exception is too general (ValueError sounds better regarding the error message, although I am not sure the problem is necessarily related to any parameter misspecification).