From 94ca096afea33ccf0f4be6774137259f4417505e Mon Sep 17 00:00:00 2001 From: TimWeaving Date: Thu, 7 Mar 2024 18:54:49 +0000 Subject: [PATCH] Bugfix when setting noncon strategy to solved --- symmer/projection/contextual_subspace.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/symmer/projection/contextual_subspace.py b/symmer/projection/contextual_subspace.py index 30ea3a06..9453240e 100644 --- a/symmer/projection/contextual_subspace.py +++ b/symmer/projection/contextual_subspace.py @@ -65,15 +65,10 @@ def __init__(self, self.noncontextual_operator = NoncontextualOp.from_hamiltonian( operator, strategy=noncontextual_strategy ) - # solve noncon problem - self._noncontextual_update() - noncontextual_strategy = 'solved' else: self.noncontextual_operator = noncontextual_operator - - ## case for StabilizeFirst when need to solve noncon problem - if not noncontextual_strategy == 'solved': - self._noncontextual_update() + self.unitary_partitioning_method = unitary_partitioning_method + self._noncontextual_update() def manual_stabilizers(self, S: Union[List[str], IndependentOp]) -> None: """ @@ -150,10 +145,13 @@ def _noncontextual_update(self): self.contextual_operator = self.operator - self.noncontextual_operator if self.contextual_operator.n_terms == 0: raise ValueError('The Hamiltonian is noncontextual, the contextual subspace is empty.') - self.noncontextual_operator.solve( - strategy=self.noncontextual_solver, - ref_state=self.ref_state - ) + if self.nc_strategy != "solved": + self.noncontextual_operator.solve( + strategy=self.noncontextual_solver, + ref_state=self.ref_state + ) + else: + self.noncontextual_operator.update_clique_representative_operator() self.n_cliques = self.noncontextual_operator.n_cliques def _aux_operator_preserving_stabilizer_search(self,