Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure result objects don't store references to corresponding solver objects #2262

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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