Skip to content

Commit

Permalink
Merge pull request #2262 from pmenczel/result-opt-no-feedback
Browse files Browse the repository at this point in the history
Make sure result objects don't store references to corresponding solver objects
  • Loading branch information
pmenczel committed Nov 14, 2023
2 parents 454b615 + 250692b commit 4ce8829
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/changes/2262.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed result objects storing a reference to the solver through options._feedback.
8 changes: 6 additions & 2 deletions qutip/solver/result.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
""" Class for solve function results"""
import numpy as np
from ..core import Qobj, QobjEvo, expect, isket, ket2dm, qzero, qzero_like
from ..core import Qobj, QobjEvo, expect, isket, ket2dm, qzero_like

__all__ = ["Result", "MultiTrajResult", "McResult", "NmmcResult",
"McTrajectoryResult", "McResultImprovedSampling"]
Expand Down Expand Up @@ -79,7 +79,11 @@ def __init__(self, options, *, solver=None, stats=None):
self._state_processors = []
self._state_processors_require_copy = False

self.options = options
# make sure not to store a reference to the solver
options_copy = options.copy()
if hasattr(options_copy, '_feedback'):
options_copy._feedback = None
self.options = options_copy

def _e_ops_to_dict(self, e_ops):
""" Convert the supplied e_ops to a dictionary of Eop instances. """
Expand Down

0 comments on commit 4ce8829

Please sign in to comment.