Comment #2 on issue 1991 by smichr: Don't use assert in the library code
http://code.google.com/p/sympy/issues/detail?id=1991

Sometimes the assert is there because that is an assumption at that point in the code that you want the reader to be made aware of. They are like road signs that help keep you oriented...not that you couldn't look at a map and figure out where you were, but in the limited amount of lines to a screen (and finite "where am I" memory) they also provide a nanny-ish role. e.g. in the ode module there is a portion where perhaps you think that there should only be one solution and you act on that belief. I would just like to put "assert len(sol) == 1" and proceed with confidence. I maybe can't (in my limited imagination) think of a case where there would be more solutions but if, for some reason there are I want someone to make the code len(sol) > 1 compliant. "Today" I don't want to have to think up imaginative names for errors that probably won't exist. I am happy enough to know that I alerted someone -- like a zone of red on a tachometer -- that there is a pending problem.

I once looked at some personal code of Tim Peters and it was *loaded* with assertions. He writes some pretty slick stuff. I asked what that was for and he taught me about the assertion.

I'm not saying there isn't a place for a good error message. I am just saying that sometimes it isn't a user error as much as a logical error that the assertion protects against.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to sympy-iss...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy-issues+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to