Bug summary
The problem is that deepcopy of TextPath calls deepcopy of Path. In turn Path utilizes super().init for creating a new
instance. However, Path.init and TextPath.init are completely different.
Code for reproduction
from matplotlib.textpath import TextPath
TextPath((0, 0), ".").deepcopy()
Actual outcome
AttributeError Traceback (most recent call last)
c:\figures.py in <module>
----> 1 TextPath((0, 0), ".").deepcopy()
~\.site-packages\matplotlib\path.py in __deepcopy__(self, memo)
284 return self.__class__(
285 self.vertices.copy(), codes,
--> 286 _interpolation_steps=self._interpolation_steps)
287
288 deepcopy = __deepcopy__
~\.site-packages\matplotlib\textpath.py in __init__(self, xy, s, size, prop, _interpolation_steps, usetex)
394
395 self._cached_vertices = None
--> 396 s, ismath = Text(usetex=usetex)._preprocess_math(s)
397 self._vertices, self._codes = text_to_path.get_text_path(
398 prop, s, ismath=ismath)
~\.site-packages\matplotlib\text.py in _preprocess_math(self, s)
1186 return s, True
1187 else:
-> 1188 return s.replace(r"\$", "$"), False
1189
1190 def set_fontproperties(self, fp):
AttributeError: 'list' object has no attribute 'replace'
Expected outcome
A new instance of TextPath.
Operating system
Windows 10
Matplotlib Version
3.3.4
Matplotlib Backend
module://ipykernel.pylab.backend_inline
Python version
Python 3.6.6
Jupyter version
No response
Other libraries
No response
Installation
pip
Conda channel
No response
Bug summary
The problem is that deepcopy of TextPath calls deepcopy of Path. In turn Path utilizes super().init for creating a new
instance. However, Path.init and TextPath.init are completely different.
Code for reproduction
Actual outcome
Expected outcome
A new instance of TextPath.
Operating system
Windows 10
Matplotlib Version
3.3.4
Matplotlib Backend
module://ipykernel.pylab.backend_inline
Python version
Python 3.6.6
Jupyter version
No response
Other libraries
No response
Installation
pip
Conda channel
No response