def projection(self, variables):
<EOL>variables = set(variables)<EOL>if not variables.issubset(self.variables):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>idxs = [i for i, v in enumerate(self.variables) if v in variables]<EOL>configurations = frozenset(tuple(config[i] for i in idxs) for config in self.configurations)<EOL>variables = tuple(self.variables[i] for i in idxs)<EOL>return self.from_configurations(configurations, variables, self.vartype)<EOL>
Create a new constraint that is the projection onto a subset of the variables.

        Args:
            variables (iterable):
                Subset of the constraint's variables.

        Returns:
            :obj:`.Constraint`: A new constraint over a subset of the variables.

        Examples:

            >>> import dwavebinarycsp
            ...
            >>> const = dwavebinarycsp.Constraint.from_configurations([(0, 0), (0, 1)],
            ...                                                       ['a', 'b'],
            ...                                                       dwavebinarycsp.BINARY)
            >>> proj = const.projection(['a'])
            >>> proj.variables
            ['a']
            >>> proj.configurations
            {(0,)}