X Tutup
Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/matplotlib/backends/backend_pgf.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,19 @@ class LatexManagerFactory(object):
def get_latex_manager():
texcommand = get_texcommand()
latex_header = LatexManager._build_latex_header()
prev = LatexManagerFactory.previous_instance

# check if the previous instance of LatexManager can be reused
if prev and prev.latex_header == latex_header and prev.texcommand == texcommand:
if rcParams.get("pgf.debug", False):
print("reusing LatexManager")
return prev
else:
if rcParams.get("pgf.debug", False):
print("creating LatexManager")
new_inst = LatexManager()
LatexManagerFactory.previous_instance = new_inst
return new_inst
if LatexManagerFactory.previous_instance:
prev = LatexManagerFactory.previous_instance()

# check if the previous instance of LatexManager can be reused
if prev and prev.latex_header == latex_header and prev.texcommand == texcommand:
if rcParams.get("pgf.debug", False):
print("reusing LatexManager")
return prev
if rcParams.get("pgf.debug", False):
print("creating LatexManager")
new_inst = LatexManager()
LatexManagerFactory.previous_instance = weakref.ref(new_inst)
return new_inst

class WeakSet(object):
# TODO: Poor man's weakref.WeakSet.
Expand Down
X Tutup