Midterm II#
Revised
22 Apr 2023
Programming Environment#
Show code cell source
from fractions import Fraction
import numpy as np
import sympy as sp
from sympy import init_printing,latex,solve,symbols
from sympy.matrices import diag,eye,GramSchmidt,ones,Matrix,zeros
from sympy.solvers.inequalities import reduce_inequalities
x1,x2,x3,x4=symbols('x1 x2 x3 x4')
init_printing(use_latex=True)
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.style.use('ggplot');
plt.rcParams.update({'text.usetex' : True});
%matplotlib inline
from IPython.display import display, Math
from datetime import datetime as d
import locale as l
import platform as p
import sys as s
pad = 20
print(f"{'Executed'.upper():<{pad}}: {d.now()}")
print()
print(f"{'Platform' :<{pad}}: "
f"{p.mac_ver()[0]} | "
f"{p.system()} | "
f"{p.release()} | "
f"{p.machine()}")
print(f"{'' :<{pad}}: {l.getpreferredencoding()}")
print()
print(f"{'Python' :<{pad}}: {s.version}")
print(f"{'' :<{pad}}: {s.version_info}")
print(f"{'' :<{pad}}: {p.python_implementation()}")
print()
print(f"{'Matplotlib' :<{pad}}: {mpl.__version__}")
print(f"{'NumPy' :<{pad}}: {np .__version__}")
print(f"{'SymPy' :<{pad}}: {sp .__version__}")
def unitVector (vec : np.ndarray) -> np.ndarray:
return vec/np.sqrt((vec[0]**2+vec[1]**2))
EXECUTED : 2024-05-21 15:52:46.848447
Platform : 14.4.1 | Darwin | 23.4.0 | arm64
: UTF-8
Python : 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:34:54) [Clang 16.0.6 ]
: sys.version_info(major=3, minor=11, micro=9, releaselevel='final', serial=0)
: CPython
Matplotlib : 3.8.4
NumPy : 1.26.4
SymPy : 1.12
Production Scenario#
Product A [x1]
$60.00 sale price
1 hr machining
5 lb material
900 unit demand per week
Product B [x2]
$90.00 sale price
2 hr machining
4 lb material
700 unit demand per week
supply per week
1000 hr machining
3200 lb material
extra
$28.00/hr machining [p1]
$4.00/lb material [p2]
initial cost D
$40,800.00 = $28 .00/hr x 1000 hr + $4 .00/lb x 3200 lb
LP#
\( \begin{aligned} \max z(\mathbf{x})&=60x_1+90x_2-40800 \\ g_1(\mathbf{x})&=x_1+2x_2\le1000=b_1 &&\text{machining constraint} \\ g_2(\mathbf{x})&=5x_1+4x_2\le3200=b_2 &&\text{material constraint} \\ g_3(\mathbf{x})&=x_1\le900=b_3 &&\text{Product A demand constaint} \\ g_4(\mathbf{x})&=x_2\le700=b_4 &&\text{Product B demand constraint} \\ \mathbf{x}&\ge\mathbf{0} &&\text{no negative production} \end{aligned} \)
LP A B
max z = 60x1 + 90x2 - 40800
g1 = 1x1 + 2x2 <= 1000 = b1 machining constraint
g2 = 5x1 + 4x2 <= 3200 = b2 material constraint
g3 = 1x1 + 0x2 <= 900 = b3 Product A demand constraint
g4 = 0x1 + 1x2 <= 700 = b4 Product B demand constraint
x >= 0 no negative production
Gradients and directions#
\( \begin{aligned} \nabla z&=\langle60,90\rangle \\ \nabla g_1&=\langle1,2\rangle &&\langle60,90\rangle\cdot\langle2,-1\rangle &&\gt0 &&\implies\langle2,-1\rangle \\ \nabla g_2&=\langle5,4\rangle &&\langle60,90\rangle\cdot\langle4,-5\rangle &&\lt0 &&\implies\langle-4,5\rangle \\ \nabla g_3&=\langle1,0\rangle &&\langle60,90\rangle\cdot\langle0,-1\rangle &&\lt0 &&\implies\langle0,1\rangle \\ \nabla g_4&=\langle0,1\rangle &&\langle60,90\rangle\cdot\langle1,0\rangle &&\gt0 &&\implies\langle1,0\rangle \end{aligned} \)
delz = <60,90>
delg1 = < 1, 2>
delg2 = < 5, 4>
delg3 = < 1, 0>
delg4 = < 0, 1>
<60,90><2,-1> >0 => < 2,-1> g1
<60,90><4,-5> <0 => <-4, 5> g2
<60,90><0,-1> <0 => < 0, 1> g3
<60,90><1, 0> >0 => < 1, 0> g4
d =40800
b1= 1000
b2= 3200
b3= 900
b4= 700
z =60*x1+90*x2- d
g1= 1*x1+ 2*x2-b1
g2= 5*x1+ 4*x2-b2
g3= 1*x1+ 0*x2-b3
g4= 0*x1+ 1*x2-b4
# GRADIENTS & DIRECTIONS
delz =np.array([60,90])
delg1=np.array([ 1, 2]); dg1=np.array([ 2,-1])
delg2=np.array([ 5, 4]); dg2=np.array([-4, 5])
delg3=np.array([ 1, 0]); dg3=np.array([ 0, 1])
delg4=np.array([ 0, 1]); dg4=np.array([ 1, 0])
# UNIT DIRECTION VECTORS
udg1=dg1/np.sqrt(dg1[0]**2+dg1[1]**2)
udg2=dg2/np.sqrt(dg2[0]**2+dg2[1]**2)
udg3=dg3/np.sqrt(dg3[0]**2+dg3[1]**2)
udg4=dg4/np.sqrt(dg4[0]**2+dg4[1]**2)
print(f"{delz.dot(dg1):>3}")
print(f"{delz.dot(dg2):>3}")
print(f"{delz.dot(dg3):>3}")
print(f"{delz.dot(dg4):>3}")
# LINES & INTERSECTIONS
display(
'LINES',
'g1',solve(g1,x2,dict=True)[0],
'g2',solve(g2,x2,dict=True)[0],
#'g3',solve(g3,x2,dict=True)[0],
'g4',solve(g4,x2,dict=True)[0],
)
display(
reduce_inequalities(g1<=0,[x2]),
reduce_inequalities(g2<=0,[x2]),
reduce_inequalities(g3<=0,[x2]),
reduce_inequalities(g4<=0,[x2]),
)
display(
'INTERSECTIONS',
'g1=g2', solve([g1,g2], [x1,x2],dict=True)[0],
'g1=g3', solve([g1,g3], [x1,x2],dict=True)[0],
'g1=g4', solve([g1,g4], [x1,x2],dict=True)[0],
'g2=g3', solve([g2,g3], [x1,x2],dict=True)[0],
'g2=g4', solve([g2,g4], [x1,x2],dict=True)[0],
'g3=g4', solve([g3,g4], [x1,x2],dict=True)[0],
'g1[ 0,x2]',solve([g1,x1 ],[x1,x2],dict=True)[0],
'g2[x1, 0]',solve([g2,x2 ],[x1,x2],dict=True)[0],
'g2[ 0,x2]',solve([g2,x1 ],[x1,x2],dict=True)[0],
'g3[x1, 0]',solve([g3,x2 ],[x1,x2],dict=True)[0],
'g4[ 0,x2]',solve([g4,x1 ],[x1,x2],dict=True)[0],
)
30
210
90
60
'LINES'
'g1'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g2'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g4'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'INTERSECTIONS'
'g1=g2'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g1=g3'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g1=g4'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g2=g3'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g2=g4'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g3=g4'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g1[ 0,x2]'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g2[x1, 0]'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g2[ 0,x2]'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g3[x1, 0]'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
'g4[ 0,x2]'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
Dual LP#
\( \boxed{ \text{LP}= \begin{aligned} \max z(\mathbf{x})&=\mathbf{cx}+d \\ \mathbf{Ax}&\le\mathbf{b} \\ \mathbf{x}&\ge\mathbf{0} \end{aligned} \overset{\text{dual to}}{\iff} \begin{aligned} \min w(\mathbf{y})&=\mathbf{yb}+d \\ \mathbf{yA}&\ge\mathbf{c} \\ \mathbf{y}&\ge\mathbf{0} \end{aligned} =\text{LP}^* } \)
\( \text{LP}= \begin{aligned} \max z(\mathbf{x})&=60x_1+90x_2-40800 \\ g_1(\mathbf{x})&=x_1+2x_2\le1000=b_1 \\ g_2(\mathbf{x})&=5x_1+4x_2\le3200=b_2 \\ g_3(\mathbf{x})&=x_1\le900=b_3 \\ g_4(\mathbf{x})&=x_2\le700=b_4 \\ \mathbf{x}&\ge\mathbf{0} \end{aligned} \overset{\text{dual to}}{\iff} \begin{aligned} \min w(\mathbf{y})&=1000y_1+3200y_2+900y_3+700y_4-40800 \\ h_1(\mathbf{y})&= y_1+ 5y_2+ y_3 \ge60=c_1\\ h_2(\mathbf{y})&= 2y_1+ 4y_2+ y_4 \ge90=c_2\\ \mathbf{y}&\ge\mathbf{0} \end{aligned} =\text{LP}^* \)
Simplex Algorithm#
Show code cell source
def pivot (iStar,jStar,tab):
nRows =tab.shape[0]-1
nCols =tab.shape[1]-1
newTab=tab[:,:]
newTab[0,jStar] =tab[iStar,nCols]
newTab[iStar,nCols]=tab[0,jStar]
newTab[iStar,0] =-tab[nRows,jStar]
newTab[nRows,jStar]=-tab[iStar,0]
for i in range(1,nRows):
for j in range(1,nCols):
if i==iStar and j==jStar:
newTab[i,j]=1/tab[iStar,jStar]
elif i==iStar and j!=jStar:
newTab[i,j]=-tab[i,j]/tab[iStar,jStar]
elif i!=iStar and j==jStar:
newTab[i,j]= tab[i,j]/tab[iStar,jStar]
elif i!=iStar and j!=jStar:
newTab[i,j]= tab[i,j]-tab[iStar,j]*tab[i,jStar]/tab[iStar,jStar]
return newTab
p1 =28
p2 = 4
db1=0
db2=0
db3=0
db4=0
rA = Matrix([
[ 'c', 'x1', 'x2', 1, 'r'],
['y1', -1, -2,b1+db1,'s1'],
['y2', -5, -4,b2+db2,'s2'],
['y3', -1, 0,b3+db3,'s3'],
['y4', 0, -1,b4+db4,'s4'],
[ -1, -60, -90, d,'-z'],
[ 'c','-v1', '-v2', 'w', 'r'],
])
rB = pivot(2,1,rA)
rC = pivot(1,2,rB)
cA = Matrix([
[ 'c', 'y1', 'y2', 'y3', 'y4', 1, 'r'],
['x1', 1, 5, 1, 0, -60,'v1'],
['x2', 2, 4, 0, 1, -90,'v2'],
[ -1,b1+db1,b2+db2,b3+db3,b4+db4, -d, 'w'],
[ 'c', '-s1', '-s2', '-s3', '-s4','-z', 'r'],
])
cB = pivot(2,1,cA)
cC = pivot(1,2,cB)
display(
'ROW',
Math(fr'rA = {latex(rA)}\,\,\,\,\,x_1=x_2=0'),
Math(fr'rB = {latex(rB)}\,\,\,\,\,x_2=s_2=0'),
Math(fr'rC = {latex(rC)}\,\,\,\,\,s_1=s_2=0'),
'COLUMN',
Math(fr'cA = {latex(cA)}\,\,\,\,\,x_1=x_2=0'),
Math(fr'cB = {latex(cB)}\,\,\,\,\,x_1=s_1=0'),
Math(fr'cC = {latex(cC)}\,\,\,\,\,s_1=s_2=0'),
)
'ROW'
'COLUMN'
xStar = (400,300)
zStar = z.subs([(x1,xStar[0]),(x2,xStar[1])])
yStar = (35,5,0,0)
print(f"xStar = {xStar}")
print(f"zStar = ${int(zStar):,.2f} = wStar")
print(f"yStar = {yStar}")
xStar = (400, 300)
zStar = $10,200.00 = wStar
yStar = (35, 5, 0, 0)
Graphical#
Show code cell source
s =1000
x =np.linspace(0,s,10001)
# LINES
y1=-(1/2)*x+500
y2=-(5/4)*x+800
#y3
y4= ( 0)*x+700
fig=plt.figure(dpi=200);
ax =plt.subplot();
ax.set_aspect(1);
# LINES
ax.plot (x,y1,label='g1=b1',linewidth=0.5,color='blue');
ax.plot (x,y2,label='g2=b2',linewidth=0.5,color='yellow');
ax.axvline( 900,label='g3=b3',linewidth=0.5,color='green');
ax.plot (x,y4,label='g4=b4',linewidth=0.5,color='red');
# delz
ax.arrow(200,200,*unitVector( delz)*75,color='black', width=0.01,head_width=10,length_includes_head=True);
# FEASIBLE SIDES <=
ax.arrow(200,200,*unitVector(-delg1)*75,color='blue', width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg2)*75,color='yellow',width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg3)*75,color='green', width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg4)*75,color='red', width=0.01,head_width=10,length_includes_head=True);
# DIRECTIONS
ax.arrow( 0,500,*udg1*75,width=5,head_width=20,length_includes_head=True,color='blue');
ax.arrow(640, 0,*udg2*75,width=5,head_width=20,length_includes_head=True,color='yellow');
ax.arrow(900, 0,*udg3*75,width=5,head_width=20,length_includes_head=True,color='green');
ax.arrow( 0,700,*udg4*75,width=5,head_width=20,length_includes_head=True,color='red');
fx,fy=np.meshgrid(x,x)
plt.imshow(
(
(fy<=-(1/2)*fx+500)
& (fy<=-(5/4)*fx+800)
& (fy<= ( 0)*fx+700)
).astype(int),
extent=(fx.min(),fx.max(),fy.min(),fy.max()),
origin='lower',
cmap ='Greys',
alpha =0.3,
);
ax.set_xlim(0,s);
ax.set_ylim(0,s);
ax.legend();
# xStar
ax.scatter(400,300,s=1e2,color='purple');
sol=(
r'\begin{eqnarray*}'
r'x^*&=&(400,300)'
r'\\'
r'z^*&=&10200=w^*'
r'\\'
r'y^*&=&(35,5,0,0)'
r'\end{eqnarray*}'
)
ax.text(400,600,sol,fontsize=10);
# SIMPLEX
dx,dy=20,20
ax.annotate( '$A$',( 0+dx, 0+dy));
ax.annotate('$rB$',(640+dx, 0+dy));
ax.annotate('$cB$',( 0+dx,500+dy));
ax.annotate( '$C$',(400+dx,300+dy));
Error in callback <function _draw_all_if_interactive at 0x136de8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
195 def _draw_all_if_interactive() -> None:
196 if matplotlib.is_interactive():
--> 197 draw_all()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
130 for manager in cls.get_all_fig_managers():
131 if force or manager.canvas.figure.stale:
--> 132 manager.canvas.draw_idle()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
1891 if not self._is_idle_drawing:
1892 with self._idle_draw_cntx():
-> 1893 self.draw(*args, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
3067 if artists_rasterized:
3068 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
3071 renderer, self, artists, self.figure.suppressComposite)
3073 renderer.close_group('axes')
3074 self.stale = False
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
1385 renderer.open_group(__name__, gid=self.get_gid())
1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1390 for tick in ticks_to_draw:
1391 tick.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
951 raise RuntimeError(
952 "Cannot get window extent of text w/o renderer. You likely "
953 "want to call 'figure.draw_without_rendering()' first.")
955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956 bbox, info, descent = self._get_layout(self._renderer)
957 x, y = self.get_unitless_position()
958 x, y = self.get_transform().transform((x, y))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
149 from matplotlib.backend_bases import FigureCanvasBase
150 FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
153 data = bytes_io.getvalue()
154 if fmt == 'svg':
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2161 # we do this instead of `self.figure.draw_without_rendering`
2162 # so that we can inject the orientation
2163 with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164 self.figure.draw(renderer)
2165 if bbox_inches:
2166 if bbox_inches == "tight":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
3067 if artists_rasterized:
3068 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
3071 renderer, self, artists, self.figure.suppressComposite)
3073 renderer.close_group('axes')
3074 self.stale = False
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
1385 renderer.open_group(__name__, gid=self.get_gid())
1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1390 for tick in ticks_to_draw:
1391 tick.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
951 raise RuntimeError(
952 "Cannot get window extent of text w/o renderer. You likely "
953 "want to call 'figure.draw_without_rendering()' first.")
955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956 bbox, info, descent = self._get_layout(self._renderer)
957 x, y = self.get_unitless_position()
958 x, y = self.get_transform().transform((x, y))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 1280x960 with 1 Axes>
Should the company buy more material?#
print(f"xStar = {xStar}")
print(f"zStar = ${int(zStar):,.2f} = wStar")
print(f"yStar = {yStar}")
xStar = (400, 300)
zStar = $10,200.00 = wStar
yStar = (35, 5, 0, 0)
ROI1=(yStar[0]-p1)/p1
ROI2=(yStar[1]-p2)/p2
db2 =g2.subs([(x1,900),(x2,50)])
dzStar=(yStar[1]-p2)*db2
r2cost=p2*db2
display(
ROI1,
ROI2,
db2,
dzStar,
zStar+dzStar,
r2cost,
)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
Show code cell source
def pivot (iStar,jStar,tab):
nRows =tab.shape[0]-1
nCols =tab.shape[1]-1
newTab=tab[:,:]
newTab[0,jStar] =tab[iStar,nCols]
newTab[iStar,nCols]=tab[0,jStar]
newTab[iStar,0] =-tab[nRows,jStar]
newTab[nRows,jStar]=-tab[iStar,0]
for i in range(1,nRows):
for j in range(1,nCols):
if i==iStar and j==jStar:
newTab[i,j]=1/tab[iStar,jStar]
elif i==iStar and j!=jStar:
newTab[i,j]=-tab[i,j]/tab[iStar,jStar]
elif i!=iStar and j==jStar:
newTab[i,j]= tab[i,j]/tab[iStar,jStar]
elif i!=iStar and j!=jStar:
newTab[i,j]= tab[i,j]-tab[iStar,j]*tab[i,jStar]/tab[iStar,jStar]
return newTab
p1 =28
p2 = 4
rA = Matrix([
[ 'c', 'x1', 'x2', 1, 'r'],
['y1', -1, -2, b1+db1,'s1'],
['y2', -5, -4, b2+db2,'s2'],
['y3', -1, 0, b3+db3,'s3'],
['y4', 0, -1, b4+db4,'s4'],
[ -1, -60, -90,d+r2cost,'-z'],
[ 'c','-v1', '-v2', 'w', 'r'],
])
rB = pivot(2,1,rA)
rC = pivot(1,2,rB)
rD = pivot(3,1,rC)
cA = Matrix([
[ 'c', 'y1', 'y2', 'y3', 'y4', 1, 'r'],
['x1', 1, 5, 1, 0, -60,'v1'],
['x2', 2, 4, 0, 1, -90,'v2'],
[ -1,b1+db1,b2+db2,b3+db3,b4+db4,-(d+r2cost), 'w'],
[ 'c', '-s1', '-s2', '-s3', '-s4', '-z', 'r'],
])
cB = pivot(2,1,cA)
cC = pivot(1,2,cB)
cD = pivot(1,3,cC)
display(
'ROW',
Math(fr'db = ({db1},{db2},{db3},{db4})\,\,\,rA = {latex(rA)}\,\,\,\,\,x_1=x_2=0'),
Math(fr'db = ({db1},{db2},{db3},{db4})\,\,\,rB = {latex(rB)}\,\,\,\,\,x_2=s_2=0'),
Math(fr'db = ({db1},{db2},{db3},{db4})\,\,\,rC = {latex(rC)}\,\,\,\,\,s_1=s_2=0'),
Math(fr'db = ({db1},{db2},{db3},{db4})\,\,\,rD = {latex(rD)}\,\,\,\,\,s_1=s_3=0'),
'COLUMN',
Math(fr'db = ({db1},{db2},{db3},{db4})\,\,\,cA = {latex(cA)}\,\,\,\,\,x_1=x_2=0'),
Math(fr'db = ({db1},{db2},{db3},{db4})\,\,\,cB = {latex(cB)}\,\,\,\,\,x_1=s_1=0'),
Math(fr'db = ({db1},{db2},{db3},{db4})\,\,\,cC = {latex(cC)}\,\,\,\,\,s_1=s_2=0'),
Math(fr'db = ({db1},{db2},{db3},{db4})\,\,\,cD = {latex(cD)}\,\,\,\,\,s_1=s_3=0'),
)
'ROW'
'COLUMN'
xStar1 = (900,50)
zStar1 = z.subs([(x1,xStar1[0]),(x2,xStar1[1])])
ycStar1 = (35,5, 0,0)
ydStar1 = (45,0,15,0)
print(f"xStar = {xStar1}")
print(f"zStar = ${int(zStar1):,.2f} = wStar")
print(f"yStar = {ycStar1}")
print(f"yStar = {ydStar1}")
xStar = (900, 50)
zStar = $17,700.00 = wStar
yStar = (35, 5, 0, 0)
yStar = (45, 0, 15, 0)
Show code cell source
s =1000
x =np.linspace(0,s,10001)
# LINES
y1=-(1/2)*x+500
y2=-(5/4)*x+800
#y3
y4= ( 0)*x+700
fig=plt.figure(dpi=300,figsize=(12,16));
ax =plt.subplot(131);
ax.set_aspect(1);
# LINES
ax.plot (x,y1,label='g1=b1',linewidth=0.5,color='blue');
ax.plot (x,y2,label='g2=b2',linewidth=0.5,color='yellow');
ax.axvline( 900,label='g3=b3',linewidth=0.5,color='green');
ax.plot (x,y4,label='g4=b4',linewidth=0.5,color='red');
# delz
ax.arrow(200,200,*unitVector( delz)*75,color='black', width=0.01,head_width=10,length_includes_head=True);
# FEASIBLE SIDES <=
ax.arrow(200,200,*unitVector(-delg1)*75,color='blue', width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg2)*75,color='yellow',width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg3)*75,color='green', width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg4)*75,color='red', width=0.01,head_width=10,length_includes_head=True);
# DIRECTIONS
ax.arrow( 0,500,*udg1*75,width=5,head_width=20,length_includes_head=True,color='blue');
ax.arrow(640, 0,*udg2*75,width=5,head_width=20,length_includes_head=True,color='yellow');
ax.arrow(900, 0,*udg3*75,width=5,head_width=20,length_includes_head=True,color='green');
ax.arrow( 0,700,*udg4*75,width=5,head_width=20,length_includes_head=True,color='red');
fx,fy=np.meshgrid(x,x)
plt.imshow(
(
(fy<=-(1/2)*fx+500)
& (fy<=-(5/4)*fx+800)
& (fy<= ( 0)*fx+700)
).astype(int),
extent=(fx.min(),fx.max(),fy.min(),fy.max()),
origin='lower',
cmap ='Greys',
alpha =0.3,
);
ax.set_xlim(0,s);
ax.set_ylim(0,s);
#ax.legend();
# xStar
ax.scatter(400,300,s=1e2,color='purple');
xStar=(
r'\begin{eqnarray*}'
r'x^*&=&(400,300)'
r'\\'
r'z^*&=&10200=w^*'
r'\\'
r'y^*&=&(35,5,0,0)'
r'\end{eqnarray*}'
)
ax.text(400,600,xStar,fontsize=5);
# SIMPLEX
dx,dy=20,20
ax.annotate( '$A$',( 0+dx, 0+dy));
ax.annotate('$rB$',(640+dx, 0+dy));
ax.annotate('$cB$',( 0+dx,500+dy));
ax.annotate( '$C$',(400+dx,300+dy));
##########
ax2 =plt.subplot(132);
ax2.set_aspect(1);
# LINES
ax2.plot (x,y1,label='g1=b1',linewidth=0.5,color='blue');
ax2.plot (x,y2,label='g2=b2',linewidth=0.5,color='yellow',linestyle='--');
ax2.plot (x,-(5/4)*(x-900)+50,label='g2=b2',linewidth=0.5,color='yellow');
ax2.axvline( 900,label='g3=b3',linewidth=0.5,color='green');
ax2.plot (x,y4,label='g4=b4',linewidth=0.5,color='red');
# delz
ax2.arrow(200,200,*unitVector( delz)*75,color='black', width=0.01,head_width=10,length_includes_head=True);
# FEASIBLE SIDES <=
ax2.arrow(200,200,*unitVector(-delg1)*75,color='blue', width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg2)*75,color='yellow',width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg3)*75,color='green', width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg4)*75,color='red', width=0.01,head_width=10,length_includes_head=True);
# DIRECTIONS
ax2.arrow( 0,500,*udg1*75,width=5,head_width=20,length_includes_head=True,color='blue');
ax2.arrow(640, 0,*udg2*75,width=5,head_width=20,length_includes_head=True,color='yellow');
ax2.arrow(900, 0,*udg3*75,width=5,head_width=20,length_includes_head=True,color='green');
ax2.arrow( 0,700,*udg4*75,width=5,head_width=20,length_includes_head=True,color='red');
fx,fy=np.meshgrid(x,x)
plt.imshow(
(
(fy<=-(1/2)* fx+500)
& (fy<=-(5/4)*(fx-900)+50)
& (fx<=900)
& (fy<= ( 0)* fx+700)
).astype(int),
extent=(fx.min(),fx.max(),fy.min(),fy.max()),
origin='lower',
cmap ='Greys',
alpha =0.3,
);
ax2.set_xlim(0,s);
ax2.set_ylim(0,s);
#ax.legend();
# xStar
ax2.scatter(900, 50,s=1e2,color='purple');
xStar=(
r'\begin{eqnarray*}'
r'x^*&=&(900, 50)'
r'\\'
r'z^*&=&11700=w^*'
r'\\'
r'yc^*&=&(35,5,0,0)'
r'\\'
r'yd^*&=&(45,0,15,0)'
r'\end{eqnarray*}'
)
ax2.text(400,600,xStar,fontsize=5);
# SIMPLEX
dx,dy=20,20
ax2.annotate( '$A$',( 0+dx, 0+dy));
ax2.annotate('$rB$',(640+dx, 0+dy));
ax2.annotate('$cB$',( 0+dx,500+dy));
ax2.annotate( '$C$',(400+dx,300+dy));
Error in callback <function _draw_all_if_interactive at 0x136de8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
195 def _draw_all_if_interactive() -> None:
196 if matplotlib.is_interactive():
--> 197 draw_all()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
130 for manager in cls.get_all_fig_managers():
131 if force or manager.canvas.figure.stale:
--> 132 manager.canvas.draw_idle()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
1891 if not self._is_idle_drawing:
1892 with self._idle_draw_cntx():
-> 1893 self.draw(*args, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
3067 if artists_rasterized:
3068 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
3071 renderer, self, artists, self.figure.suppressComposite)
3073 renderer.close_group('axes')
3074 self.stale = False
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
1385 renderer.open_group(__name__, gid=self.get_gid())
1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1390 for tick in ticks_to_draw:
1391 tick.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
951 raise RuntimeError(
952 "Cannot get window extent of text w/o renderer. You likely "
953 "want to call 'figure.draw_without_rendering()' first.")
955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956 bbox, info, descent = self._get_layout(self._renderer)
957 x, y = self.get_unitless_position()
958 x, y = self.get_transform().transform((x, y))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
149 from matplotlib.backend_bases import FigureCanvasBase
150 FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
153 data = bytes_io.getvalue()
154 if fmt == 'svg':
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2161 # we do this instead of `self.figure.draw_without_rendering`
2162 # so that we can inject the orientation
2163 with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164 self.figure.draw(renderer)
2165 if bbox_inches:
2166 if bbox_inches == "tight":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
3067 if artists_rasterized:
3068 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
3071 renderer, self, artists, self.figure.suppressComposite)
3073 renderer.close_group('axes')
3074 self.stale = False
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
1385 renderer.open_group(__name__, gid=self.get_gid())
1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1390 for tick in ticks_to_draw:
1391 tick.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
951 raise RuntimeError(
952 "Cannot get window extent of text w/o renderer. You likely "
953 "want to call 'figure.draw_without_rendering()' first.")
955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956 bbox, info, descent = self._get_layout(self._renderer)
957 x, y = self.get_unitless_position()
958 x, y = self.get_transform().transform((x, y))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 3600x4800 with 2 Axes>
Show code cell source
s =1000
x =np.linspace(0,s,10001)
# LINES
y1=-(1/2)*x+500
y2=-(5/4)*x+800
#y3
y4= ( 0)*x+700
fig=plt.figure(figsize=(16,16));
##########
ax =plt.subplot(221);
ax.set_aspect(1);
# LINES
ax.plot (x,y1,label='g1=b1',linewidth=0.5,color='blue');
ax.plot (x,y2,label='g2=b2',linewidth=0.5,color='yellow');
ax.axvline( 900,label='g3=b3',linewidth=0.5,color='green');
ax.plot (x,y4,label='g4=b4',linewidth=0.5,color='red');
# delz
ax.arrow(200,200,*unitVector( delz)*75,color='black', width=0.01,head_width=10,length_includes_head=True);
# FEASIBLE SIDES <=
ax.arrow(200,200,*unitVector(-delg1)*75,color='blue', width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg2)*75,color='yellow',width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg3)*75,color='green', width=0.01,head_width=10,length_includes_head=True);
ax.arrow(200,200,*unitVector(-delg4)*75,color='red', width=0.01,head_width=10,length_includes_head=True);
# DIRECTIONS
ax.arrow( 0,500,*udg1*75,width=5,head_width=20,length_includes_head=True,color='blue');
ax.arrow(640, 0,*udg2*75,width=5,head_width=20,length_includes_head=True,color='yellow');
ax.arrow(900, 0,*udg3*75,width=5,head_width=20,length_includes_head=True,color='green');
ax.arrow( 0,700,*udg4*75,width=5,head_width=20,length_includes_head=True,color='red');
fx,fy=np.meshgrid(x,x)
plt.imshow(
(
(fy<=-(1/2)*fx+500)
& (fy<=-(5/4)*fx+800)
& (fy<= ( 0)*fx+700)
).astype(int),
extent=(fx.min(),fx.max(),fy.min(),fy.max()),
origin='lower',
cmap ='Greys',
alpha =0.3,
);
ax.set_xlim(0,s);
ax.set_ylim(0,s);
#ax.legend();
# xStar
ax.scatter(400,300,s=1e2,color='purple');
xStar=(
r'\begin{eqnarray*}'
r'x^*&=&(400,300)'
r'\\'
r'z^*&=&10200=w^*'
r'\\'
r'y^*&=&(35,5,0,0)'
r'\end{eqnarray*}'
)
ax.text(400,600,xStar,fontsize=5);
# SIMPLEX
dx,dy=20,20
ax.annotate( '$A$',( 0+dx, 0+dy));
ax.annotate('$rB$',(640+dx, 0+dy));
ax.annotate('$cB$',( 0+dx,500+dy));
ax.annotate( '$C$',(400+dx,300+dy));
##########
ax2 =plt.subplot(222);
ax2.set_aspect(1);
# LINES
ax2.plot (x,y1,label='g1=b1',linewidth=0.5,color='blue');
ax2.plot (x,y2,label='g2=b2',linewidth=0.5,color='yellow',linestyle='--');
ax2.plot (x,-(5/4)*(x-900)+50,label='g2=b2',linewidth=0.5,color='yellow');
ax2.axvline( 900,label='g3=b3',linewidth=0.5,color='green');
ax2.plot (x,y4,label='g4=b4',linewidth=0.5,color='red');
# delz
ax2.arrow(200,200,*unitVector( delz)*75,color='black', width=0.01,head_width=10,length_includes_head=True);
# FEASIBLE SIDES <=
ax2.arrow(200,200,*unitVector(-delg1)*75,color='blue', width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg2)*75,color='yellow',width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg3)*75,color='green', width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg4)*75,color='red', width=0.01,head_width=10,length_includes_head=True);
# DIRECTIONS
ax2.arrow( 0,500,*udg1*75,width=5,head_width=20,length_includes_head=True,color='blue');
ax2.arrow(640, 0,*udg2*75,width=5,head_width=20,length_includes_head=True,color='yellow');
ax2.arrow(900, 0,*udg3*75,width=5,head_width=20,length_includes_head=True,color='green');
ax2.arrow( 0,700,*udg4*75,width=5,head_width=20,length_includes_head=True,color='red');
fx,fy=np.meshgrid(x,x)
plt.imshow(
(
(fy<=-(1/2)* fx+500)
& (fy<=-(5/4)*(fx-900)+50)
& (fx<=900)
& (fy<= ( 0)* fx+700)
).astype(int),
extent=(fx.min(),fx.max(),fy.min(),fy.max()),
origin='lower',
cmap ='Greys',
alpha =0.3,
);
ax2.set_xlim(0,s);
ax2.set_ylim(0,s);
#ax.legend();
# xStar
ax2.scatter(900, 50,s=1e2,color='purple');
xStar=(
r'\begin{eqnarray*}'
r'x^*&=&(900, 50)'
r'\\'
r'z^*&=&11700=w^*'
r'\\'
r'yc^*&=&(35,5,0,0)'
r'\\'
r'yd^*&=&(45,0,15,0)'
r'\end{eqnarray*}'
)
ax2.text(400,600,xStar,fontsize=5);
# SIMPLEX
dx,dy=20,20
ax2.annotate( '$A$',( 0+dx, 0+dy));
ax2.annotate('$rB$',(640+dx, 0+dy));
ax2.annotate('$cB$',( 0+dx,500+dy));
ax2.annotate( '$C$',(400+dx,300+dy));
##########
ax2 =plt.subplot(223);
ax2.set_aspect(1);
# LINES
ax2.plot (x,y1,label='g1=b1',linewidth=0.8,color='blue',linestyle=(0,(5,10)));
ax2.plot (x,-(1/2)*(x-380)+700,label='g1=b1',linewidth=0.8,color='blue');
ax2.plot (x,y2,label='g2=b2',linewidth=0.8,color='yellow',linestyle=(0,(5,10)));
ax2.plot (x,-(5/4)*(x-900)+50,label='g2=b2',linewidth=0.8,color='yellow');
ax2.axvline( 900,label='g3=b3',linewidth=0.5,color='green');
ax2.plot (x,y4,label='g4=b4',linewidth=0.5,color='red');
# delz
ax2.arrow(200,200,*unitVector( delz)*75,color='black', width=0.01,head_width=10,length_includes_head=True);
# FEASIBLE SIDES <=
ax2.arrow(200,200,*unitVector(-delg1)*75,color='blue', width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg2)*75,color='yellow',width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg3)*75,color='green', width=0.01,head_width=10,length_includes_head=True);
ax2.arrow(200,200,*unitVector(-delg4)*75,color='red', width=0.01,head_width=10,length_includes_head=True);
# DIRECTIONS
ax2.arrow( 0,500,*udg1*75,width=5,head_width=20,length_includes_head=True,color='blue');
ax2.arrow(640, 0,*udg2*75,width=5,head_width=20,length_includes_head=True,color='yellow');
ax2.arrow(900, 0,*udg3*75,width=5,head_width=20,length_includes_head=True,color='green');
ax2.arrow( 0,700,*udg4*75,width=5,head_width=20,length_includes_head=True,color='red');
fx,fy=np.meshgrid(x,x)
plt.imshow(
(
(fy<=-(1/2)*(fx-380)+700)
& (fy<=-(5/4)*(fx-900)+50)
& (fx<=900)
& (fy<= ( 0)* fx+700)
).astype(int),
extent=(fx.min(),fx.max(),fy.min(),fy.max()),
origin='lower',
cmap ='Greys',
alpha =0.3,
);
ax2.set_xlim(0,s);
ax2.set_ylim(0,s);
#ax.legend();
# xStar
ax2.scatter(380,700,s=1e2,color='purple');
xStar=(
r'\begin{eqnarray*}'
r'x^*&=&(900, 50)'
r'\\'
r'z^*&=&11700=w^*'
r'\\'
r'yc^*&=&(35,5,0,0)'
r'\\'
r'yd^*&=&(45,0,15,0)'
r'\end{eqnarray*}'
)
ax2.text(400,600,xStar,fontsize=5);
# SIMPLEX
dx,dy=20,20
ax2.annotate( '$A$',( 0+dx, 0+dy));
ax2.annotate('$rB$',(640+dx, 0+dy));
ax2.annotate('$cB$',( 0+dx,500+dy));
ax2.annotate( '$C$',(400+dx,300+dy));
Error in callback <function _draw_all_if_interactive at 0x136de8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
195 def _draw_all_if_interactive() -> None:
196 if matplotlib.is_interactive():
--> 197 draw_all()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
130 for manager in cls.get_all_fig_managers():
131 if force or manager.canvas.figure.stale:
--> 132 manager.canvas.draw_idle()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
1891 if not self._is_idle_drawing:
1892 with self._idle_draw_cntx():
-> 1893 self.draw(*args, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
3067 if artists_rasterized:
3068 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
3071 renderer, self, artists, self.figure.suppressComposite)
3073 renderer.close_group('axes')
3074 self.stale = False
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
1385 renderer.open_group(__name__, gid=self.get_gid())
1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1390 for tick in ticks_to_draw:
1391 tick.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
951 raise RuntimeError(
952 "Cannot get window extent of text w/o renderer. You likely "
953 "want to call 'figure.draw_without_rendering()' first.")
955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956 bbox, info, descent = self._get_layout(self._renderer)
957 x, y = self.get_unitless_position()
958 x, y = self.get_transform().transform((x, y))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
149 from matplotlib.backend_bases import FigureCanvasBase
150 FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
153 data = bytes_io.getvalue()
154 if fmt == 'svg':
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2161 # we do this instead of `self.figure.draw_without_rendering`
2162 # so that we can inject the orientation
2163 with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164 self.figure.draw(renderer)
2165 if bbox_inches:
2166 if bbox_inches == "tight":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
3067 if artists_rasterized:
3068 _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
3071 renderer, self, artists, self.figure.suppressComposite)
3073 renderer.close_group('axes')
3074 self.stale = False
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
1385 renderer.open_group(__name__, gid=self.get_gid())
1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
1390 for tick in ticks_to_draw:
1391 tick.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
1313 if renderer is None:
1314 renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
1316 for tick in ticks if tick.label1.get_visible()],
1317 [tick.label2.get_window_extent(renderer)
1318 for tick in ticks if tick.label2.get_visible()])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
951 raise RuntimeError(
952 "Cannot get window extent of text w/o renderer. You likely "
953 "want to call 'figure.draw_without_rendering()' first.")
955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956 bbox, info, descent = self._get_layout(self._renderer)
957 x, y = self.get_unitless_position()
958 x, y = self.get_transform().transform((x, y))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 1600x1600 with 3 Axes>
y2p=-(5/4)*(x1-900)+50
g2p= (5/4)*x1+x2-1175
g1max=-(1/2)*(x1-380)+700
display(
y2p,
solve([g2p,g4])
)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
341 pass
342 else:
--> 343 return printer(obj)
344 # Finally look for special method names
345 method = get_real_method(obj, self.print_method)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'
g1max
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
177 try:
--> 178 return _preview_wrapper(s)
179 except RuntimeError as e:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
88 try:
---> 89 preview(o, output='png', viewer='BytesIO', euler=euler,
90 outputbuffer=exprbuffer, extra_preamble=extra_preamble,
91 dvioptions=dvioptions, fontsize=fontsize)
92 except Exception as e:
93 # IPython swallows exceptions
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
307 if not shutil.which('latex'):
--> 308 raise RuntimeError("latex program is not installed")
310 try:
RuntimeError: latex program is not installed
During handling of the above exception, another exception occurred:
PermissionError Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
345 method = get_real_method(obj, self.print_method)
346 if method is not None:
--> 347 return method()
348 return None
349 else:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
182 if latex_mode != 'inline':
183 s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
116 try:
117 try:
--> 118 return latex_to_png(o, color=forecolor, scale=scale)
119 except TypeError: # Old IPython version without color and scale
120 return latex_to_png(o)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
103 else:
104 raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
106 if encode and bin_data:
107 bin_data = encodebytes(bin_data)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
133 fig.text(0, depth / height, s, fontproperties=prop, color=color)
134 backend_agg.FigureCanvasAgg(fig)
--> 135 fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
136 return buffer.getvalue()
137 except (ValueError, RuntimeError, ParseFatalException):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
3388 for ax in self.axes:
3389 _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
2189 try:
2190 # _get_renderer may change the figure dpi (as vector formats
2191 # force the figure dpi to 72), so we need to set it again here.
2192 with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193 result = print_method(
2194 filename,
2195 facecolor=facecolor,
2196 edgecolor=edgecolor,
2197 orientation=orientation,
2198 bbox_inches_restore=_bbox_inches_restore,
2199 **kwargs)
2200 finally:
2201 if bbox_inches and restore_bbox:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
2039 optional_kws = { # Passed by print_figure for other renderers.
2040 "dpi", "facecolor", "edgecolor", "orientation",
2041 "bbox_inches_restore"}
2042 skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043 print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
2044 *args, **{k: v for k, v in kwargs.items() if k not in skip}))
2045 else: # Let third-parties do as they see fit.
2046 print_method = meth
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
451 """
452 Write the figure to a PNG file.
453
(...)
495 *metadata*, including the default 'Software' key.
496 """
--> 497 self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
441 """
442 Draw the canvas, then save it using `.image.imsave` (to which
443 *pil_kwargs* and *metadata* are forwarded).
444 """
--> 445 FigureCanvasAgg.draw(self)
446 mpl.image.imsave(
447 filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
448 dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
385 # Acquire a lock on the shared font cache.
386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
387 else nullcontext()):
--> 388 self.figure.draw(self.renderer)
389 # A GUI class may be need to update a window using this draw, so
390 # don't forget to call the superclass.
391 super().draw()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
93 @wraps(draw)
94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95 result = draw(artist, renderer, *args, **kwargs)
96 if renderer._rasterizing:
97 renderer.stop_rasterizing()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
3151 # ValueError can occur when resizing a window.
3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
3155 renderer, self, artists, self.suppressComposite)
3157 for sfig in self.subfigs:
3158 sfig.draw(renderer)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
130 if not_composite or not has_images:
131 for a in artists:
--> 132 a.draw(renderer)
133 else:
134 # Composite any adjacent images together
135 image_group = []
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
69 if artist.get_agg_filter() is not None:
70 renderer.start_filter()
---> 72 return draw(artist, renderer)
73 finally:
74 if artist.get_agg_filter() is not None:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
745 renderer.open_group('text', self.get_gid())
747 with self._cm_set(text=self._get_wrapped_text()):
--> 748 bbox, info, descent = self._get_layout(renderer)
749 trans = self.get_transform()
751 # don't use self.get_position here, which refers to text
752 # position in Text:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
370 ys = []
372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
374 renderer, "lp", self._fontproperties,
375 ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
376 min_dy = (lp_h - lp_d) * self._linespacing
378 for i, line in enumerate(lines):
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
67 # Cached based on a copy of fontprop so that later in-place mutations of
68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
70 weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
73 @functools.lru_cache(4096)
74 def _get_text_metrics_with_cache_impl(
75 renderer_ref, text, fontprop, ismath, dpi):
76 # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77 return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
211 _api.check_in_list(["TeX", True, False], ismath=ismath)
212 if ismath == "TeX":
--> 213 return super().get_text_width_height_descent(s, prop, ismath)
215 if ismath:
216 ox, oy, width, height, descent, font_image = \
217 self.mathtext_parser.parse(s, self.dpi, prop)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
648 fontsize = prop.get_size_in_points()
650 if ismath == 'TeX':
651 # todo: handle properties
--> 652 return self.get_texmanager().get_text_width_height_descent(
653 s, fontsize, renderer=self)
655 dpi = self.points_to_pixels(72)
656 if ismath:
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366 page, = dvi
367 # A total height (including the descent) needs to be returned.
368 return page.width, page.height + page.descent, page.descent
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
280 def __iter__(self):
281 """
282 Iterate through the pages of the file.
283
(...)
294 integers.
295 """
--> 296 while self._read():
297 yield self._output()
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
373 while True:
374 byte = self.file.read(1)[0]
--> 375 self._dtable[byte](self, byte)
376 name = self._dtable[byte].__name__
377 if name == "_push":
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
225 if state is not None and self.state != state:
226 raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
525 def _fnt_def(self, k, c, s, d, a, l):
--> 526 self._fnt_def_real(k, c, s, d, a, l)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
529 n = self.file.read(a + l)
530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
533 raise ValueError('tfm checksum mismatch: %s' % n)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
1114 @lru_cache
1115 def _fontfile(cls, suffix, texname):
-> 1116 return cls(find_tex_file(texname + suffix))
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
1079 filename = filename.decode('utf-8', errors='replace')
1081 try:
-> 1082 lk = _LuatexKpsewhich()
1083 except FileNotFoundError:
1084 lk = None # Fallback to directly calling kpsewhich, as below.
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
1034 @lru_cache # A singleton.
1035 def __new__(cls):
1036 self = object.__new__(cls)
-> 1037 self._proc = self._new_proc()
1038 return self
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
1040 def _new_proc(self):
-> 1041 return subprocess.Popen(
1042 ["luatex", "--luaonly",
1043 str(cbook._get_data_path("kpsewhich.lua"))],
1044 stdin=subprocess.PIPE, stdout=subprocess.PIPE)
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
1022 if self.text_mode:
1023 self.stderr = io.TextIOWrapper(self.stderr,
1024 encoding=encoding, errors=errors)
-> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
1027 pass_fds, cwd, env,
1028 startupinfo, creationflags, shell,
1029 p2cread, p2cwrite,
1030 c2pread, c2pwrite,
1031 errread, errwrite,
1032 restore_signals,
1033 gid, gids, uid, umask,
1034 start_new_session, process_group)
1035 except:
1036 # Cleanup if the child failed starting.
1037 for f in filter(None, (self.stdin, self.stdout, self.stderr)):
File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
1953 err_msg = os.strerror(errno_num)
1954 if err_filename is not None:
-> 1955 raise child_exception_type(errno_num, err_msg, err_filename)
1956 else:
1957 raise child_exception_type(errno_num, err_msg)
PermissionError: [Errno 13] Permission denied: 'luatex'