def _verify_integrity(self, codes=None, levels=None):
<EOL>codes = codes or self.codes<EOL>levels = levels or self.levels<EOL>if len(levels) != len(codes):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>codes_length = len(self.codes[<NUM_LIT:0>])<EOL>for i, (level, level_codes) in enumerate(zip(levels, codes)):<EOL><INDENT>if len(level_codes) != codes_length:<EOL><INDENT>raise ValueError("<STR_LIT>" %<EOL>([len(code_) for code_ in codes]))<EOL><DEDENT>if len(level_codes) and level_codes.max() >= len(level):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (i, level_codes.max(),<EOL>len(level)))<EOL><DEDENT>if not level.is_unique:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>".format(<EOL>values=[value for value in level],<EOL>level=i))<EOL><DEDENT><DEDENT>
Parameters
----------
codes : optional list
    Codes to check for validity. Defaults to current codes.
levels : optional list
    Levels to check for validity. Defaults to current levels.

Raises
------
ValueError
    If length of levels and codes don't match, if the codes for any
    level would exceed level bounds, or there are any duplicate levels.