this looks like it's checking that all the inputs are correct, so I think this and following `AssertionError`s should probably be `ValueError` instead.