MISC: replace 'assert' with actual ValueError

Addresses comment by @NelleV