def _calculate_block_structure(self, inequalities, equalities,<EOL>momentinequalities, momentequalities,<EOL>extramomentmatrix, removeequalities,<EOL>block_struct=None):
if block_struct is None:<EOL><INDENT>if self.verbose > <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT>self.block_struct = []<EOL>if self.parameters is not None:<EOL><INDENT>self.block_struct += [<NUM_LIT:1> for _ in self.parameters]<EOL><DEDENT>for monomials in self.monomial_sets:<EOL><INDENT>if len(monomials) > <NUM_LIT:0> and isinstance(monomials[<NUM_LIT:0>], list):<EOL><INDENT>self.block_struct.append(len(monomials[<NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>self.block_struct.append(len(monomials))<EOL><DEDENT><DEDENT>if extramomentmatrix is not None:<EOL><INDENT>for _ in extramomentmatrix:<EOL><INDENT>for monomials in self.monomial_sets:<EOL><INDENT>if len(monomials) > <NUM_LIT:0> andisinstance(monomials[<NUM_LIT:0>], list):<EOL><INDENT>self.block_struct.append(len(monomials[<NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>self.block_struct.append(len(monomials))<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>self.block_struct = block_struct<EOL><DEDENT>degree_warning = False<EOL>if inequalities is not None:<EOL><INDENT>self._n_inequalities = len(inequalities)<EOL>n_tmp_inequalities = len(inequalities)<EOL><DEDENT>else:<EOL><INDENT>self._n_inequalities = <NUM_LIT:0><EOL>n_tmp_inequalities = <NUM_LIT:0><EOL><DEDENT>constraints = flatten([inequalities])<EOL>if momentinequalities is not None:<EOL><INDENT>self._n_inequalities += len(momentinequalities)<EOL>constraints += momentinequalities<EOL><DEDENT>if not removeequalities:<EOL><INDENT>constraints += flatten([equalities])<EOL><DEDENT>monomial_sets = []<EOL>for k, constraint in enumerate(constraints):<EOL><INDENT>if k < n_tmp_inequalities or k >= self._n_inequalities:<EOL><INDENT>if isinstance(constraint, str):<EOL><INDENT>ineq_order = <NUM_LIT:2> * self.level<EOL><DEDENT>else:<EOL><INDENT>if constraint.is_Relational:<EOL><INDENT>constraint = convert_relational(constraint)<EOL><DEDENT>ineq_order = ncdegree(constraint)<EOL>if iscomplex(constraint):<EOL><INDENT>self.complex_matrix = True<EOL><DEDENT><DEDENT>if ineq_order > <NUM_LIT:2> * self.level:<EOL><INDENT>degree_warning = True<EOL><DEDENT>localization_order = (<NUM_LIT:2>*self.level - ineq_order)//<NUM_LIT:2><EOL>if self.level == -<NUM_LIT:1>:<EOL><INDENT>localization_order = <NUM_LIT:0><EOL><DEDENT>if self.localizing_monomial_sets is not None andself.localizing_monomial_sets[k] is not None:<EOL><INDENT>localizing_monomials = self.localizing_monomial_sets[k]<EOL><DEDENT>else:<EOL><INDENT>index = find_variable_set(self.variables, constraint)<EOL>localizing_monomials =pick_monomials_up_to_degree(self.monomial_sets[index],<EOL>localization_order)<EOL><DEDENT>ln = len(localizing_monomials)<EOL>if ln == <NUM_LIT:0>:<EOL><INDENT>localizing_monomials = [S.One]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>localizing_monomials = [S.One]<EOL>ln = <NUM_LIT:1><EOL><DEDENT>localizing_monomials = unique(localizing_monomials)<EOL>monomial_sets.append(localizing_monomials)<EOL>if k < self._n_inequalities:<EOL><INDENT>self.block_struct.append(ln)<EOL><DEDENT>else:<EOL><INDENT>monomial_sets += [None for _ in range(ln*(ln+<NUM_LIT:1>)//<NUM_LIT:2>-<NUM_LIT:1>)]<EOL>monomial_sets.append(localizing_monomials)<EOL>monomial_sets += [None for _ in range(ln*(ln+<NUM_LIT:1>)//<NUM_LIT:2>-<NUM_LIT:1>)]<EOL>self.block_struct += [<NUM_LIT:1> for _ in range(ln*(ln+<NUM_LIT:1>))]<EOL><DEDENT><DEDENT>if degree_warning and self.verbose > <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (ineq_order), file=sys.stderr)<EOL><DEDENT>if momentequalities is not None:<EOL><INDENT>for moment_eq in momentequalities:<EOL><INDENT>self._moment_equalities.append(moment_eq)<EOL>if not removeequalities:<EOL><INDENT>monomial_sets += [[S.One], [S.One]]<EOL>self.block_struct += [<NUM_LIT:1>, <NUM_LIT:1>]<EOL><DEDENT><DEDENT><DEDENT>self.localizing_monomial_sets = monomial_sets<EOL>
Calculates the block_struct array for the output file.