ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 11 Apr 2021 10:24:59 +0200Possible problem in bezier_path.pyhttps://ask.sagemath.org/question/56608/possible-problem-in-bezier_pathpy/ It seems that the path that is stored by BezierPath is not correct.
Let
p2d = [[(3.0,0.0),(3.0,0.13),(2.94,0.25),(2.8,0.35)],
[(2.7,0.44),(2.6,0.5),(2.5,0.5)],
[(2.36,0.5),(2.24,0.44),(2.14,0.35)],
[(2.05,0.25),(2.0,0.13),(2.0,6.1e-17)]]
then
bezier_path(p2d)[0].path
is different than the given path p2d. There are several consequences to this, for example, the stored path cannot be fed again to bezier_path, so this won't work (results in weird errors):
bezier_path(bezier_path(p2d)[0].path)
and also affects the plot3d method of the class.
The issue seems to stem from line 64 of bezier_path.py:
vertices = self.path[0]
Since the list of vertices changes size after the line so does self.path. I believe the line should be
vertices = deepcopy(self.path[0])Sun, 11 Apr 2021 02:07:59 +0200https://ask.sagemath.org/question/56608/possible-problem-in-bezier_pathpy/Answer by vdelecroix for <p>It seems that the path that is stored by BezierPath is not correct.</p>
<p>Let </p>
<pre><code>p2d = [[(3.0,0.0),(3.0,0.13),(2.94,0.25),(2.8,0.35)],
[(2.7,0.44),(2.6,0.5),(2.5,0.5)],
[(2.36,0.5),(2.24,0.44),(2.14,0.35)],
[(2.05,0.25),(2.0,0.13),(2.0,6.1e-17)]]
</code></pre>
<p>then </p>
<pre><code>bezier_path(p2d)[0].path
</code></pre>
<p>is different than the given path p2d. There are several consequences to this, for example, the stored path cannot be fed again to bezier_path, so this won't work (results in weird errors): </p>
<pre><code>bezier_path(bezier_path(p2d)[0].path)
</code></pre>
<p>and also affects the plot3d method of the class.</p>
<p>The issue seems to stem from line 64 of bezier_path.py:</p>
<pre><code>vertices = self.path[0]
</code></pre>
<p>Since the list of vertices changes size after the line so does self.path. I believe the line should be </p>
<pre><code>vertices = deepcopy(self.path[0])
</code></pre>
https://ask.sagemath.org/question/56608/possible-problem-in-bezier_pathpy/?answer=56611#post-id-56611hmmm I wonder who wrote that extremly buggy and untested code! You were exactly right `vertices = self.path[0]` was the line to blame. Thanks for your report and the precise analysis of the bug!
I opened the ticket [#31646](https://trac.sagemath.org/ticket/31646) in which I provide a more general cleaning of the `BezierPath` constructor.Sun, 11 Apr 2021 10:24:59 +0200https://ask.sagemath.org/question/56608/possible-problem-in-bezier_pathpy/?answer=56611#post-id-56611