Replaced assert with exception, issue #5090
Replaced assert with exception, issue #5090

If this function is for public use, then raising an exception makes
better sense than assert.

kaushik94/sympy,kaushik94/sympy,kaushik94/sympy