Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Deepcopy of TextPath fails #20943

New issue

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

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

Already on GitHub? Sign in to your account

Closed
deep-jkl opened this issue Aug 29, 2021 · 0 comments · Fixed by #21280
Closed

[Bug]: Deepcopy of TextPath fails #20943

deep-jkl opened this issue Aug 29, 2021 · 0 comments · Fixed by #21280
Milestone

Comments

@deep-jkl
Copy link
Contributor

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

@deep-jkl deep-jkl mentioned this issue Sep 28, 2021
9 tasks
@QuLogic QuLogic added this to the v3.6.0 milestone Oct 7, 2021
@QuLogic QuLogic changed the title [Bug]: Deepcopy of TextPath failes [Bug]: Deepcopy of TextPath fails Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants