Can we use `mdtraj.utils.ensure_type` to simplify the input checking code here?