def add_index(self, values, name=None):
if len(values) != len(set(values)):<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>d = self.indices<EOL>if len(values) != len(self) and len(values) and d:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>' % (len(values), len(self)))<EOL><DEDENT>if name is None:<EOL><INDENT>name = '<STR_LIT>' + str(len(d)+<NUM_LIT:1>)<EOL>name = get_unique_name(name, d)<EOL><DEDENT>else:<EOL><INDENT>MI_check_index_name(name)<EOL>if name in d:<EOL><INDENT>raise ValueError('<STR_LIT>' % (name,))<EOL><DEDENT><DEDENT>if len(d) == <NUM_LIT:0>:<EOL><INDENT>items = [(v,) for v in values]<EOL><DEDENT>else:<EOL><INDENT>items = [i+(v,) for i, v in zip(self.items(), values)]<EOL><DEDENT>names = force_list(d.keys()) + [name]<EOL>self.clear(True)<EOL>_MI_init(self, items, names)<EOL>
add an index of ``name`` with the list of ``values``