def __process_equalities(self, equalities, momentequalities):
monomial_sets = []<EOL>n_rows = <NUM_LIT:0><EOL>le = <NUM_LIT:0><EOL>if equalities is not None:<EOL><INDENT>for equality in equalities:<EOL><INDENT>le += <NUM_LIT:1><EOL>if equality.is_Relational:<EOL><INDENT>equality = convert_relational(equality)<EOL><DEDENT>eq_order = ncdegree(equality)<EOL>if eq_order > <NUM_LIT:2> * self.level:<EOL><INDENT>raise Exception("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>% eq_order)<EOL><DEDENT>localization_order = (<NUM_LIT:2> * self.level - eq_order)//<NUM_LIT:2><EOL>index = find_variable_set(self.variables, equality)<EOL>localizing_monomials =pick_monomials_up_to_degree(self.monomial_sets[index],<EOL>localization_order)<EOL>if len(localizing_monomials) == <NUM_LIT:0>:<EOL><INDENT>localizing_monomials = [S.One]<EOL><DEDENT>localizing_monomials = unique(localizing_monomials)<EOL>monomial_sets.append(localizing_monomials)<EOL>n_rows += len(localizing_monomials) *(len(localizing_monomials) + <NUM_LIT:1>) // <NUM_LIT:2><EOL><DEDENT><DEDENT>if momentequalities is not None:<EOL><INDENT>for _ in momentequalities:<EOL><INDENT>le += <NUM_LIT:1><EOL>monomial_sets.append([S.One])<EOL>n_rows += <NUM_LIT:1><EOL><DEDENT><DEDENT>A = np.zeros((n_rows, self.n_vars + <NUM_LIT:1>), dtype=self.F.dtype)<EOL>n_rows = <NUM_LIT:0><EOL>if self._parallel:<EOL><INDENT>pool = Pool()<EOL><DEDENT>for i, equality in enumerate(flatten([equalities, momentequalities])):<EOL><INDENT>func = partial(moment_of_entry, monomials=monomial_sets[i],<EOL>ineq=equality, substitutions=self.substitutions)<EOL>lm = len(monomial_sets[i])<EOL>if self._parallel and lm > <NUM_LIT:1>:<EOL><INDENT>chunksize = max(int(np.sqrt(lm*lm/<NUM_LIT:2>) /<EOL>cpu_count()), <NUM_LIT:1>)<EOL>iter_ = pool.map(func, ([row, column] for row in range(lm)<EOL>for column in range(row, lm)),<EOL>chunksize)<EOL><DEDENT>else:<EOL><INDENT>iter_ = imap(func, ([row, column] for row in range(lm)<EOL>for column in range(row, lm)))<EOL><DEDENT>for row, column, polynomial in iter_:<EOL><INDENT>if isinstance(polynomial, str):<EOL><INDENT>self.__parse_expression(equality, -<NUM_LIT:1>, A[n_rows])<EOL><DEDENT>else:<EOL><INDENT>A[n_rows] = self._get_facvar(polynomial)<EOL><DEDENT>n_rows += <NUM_LIT:1><EOL>if self.verbose > <NUM_LIT:0>:<EOL><INDENT>sys.stdout.write("<STR_LIT>" %<EOL>(i+<NUM_LIT:1>, le))<EOL>sys.stdout.flush()<EOL><DEDENT><DEDENT><DEDENT>if self._parallel:<EOL><INDENT>pool.close()<EOL>pool.join()<EOL><DEDENT>if self.verbose > <NUM_LIT:0>:<EOL><INDENT>sys.stdout.write("<STR_LIT:\n>")<EOL><DEDENT>return A<EOL>
Generate localizing matrices

        Arguments:
        equalities -- list of equality constraints
        equalities -- list of moment equality constraints