Change asserts to if...raise ValueError.