Skip to content

Commit

Permalink
Merge pull request #183 from UCL-CCS/noncon_bugfix
Browse files Browse the repository at this point in the history
Bugfix when setting noncon strategy to solved
  • Loading branch information
TimWeaving authored Mar 7, 2024
2 parents 9a41e82 + 94ca096 commit 95843d6
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions symmer/projection/contextual_subspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 95843d6

Please sign in to comment.