summarylogtreecommitdiffstats
path: root/sagemath-matplotlib-3.3.patch
blob: 9256443ea7eadab0eff8bf182e6861ca8fbb6cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
diff --git a/build/pkgs/matplotlib/patches/fix-path-of-degenerate-polygon.patch b/build/pkgs/matplotlib/patches/fix-path-of-degenerate-polygon.patch
new file mode 100644
index 00000000..bedd4a4
--- /dev/null
+++ b/build/pkgs/matplotlib/patches/fix-path-of-degenerate-polygon.patch
@@ -0,0 +1,67 @@
+From 07847dd27dd16296999161a616ea27445c5a49db Mon Sep 17 00:00:00 2001
+From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
+Date: Tue, 21 Jul 2020 20:11:50 -0400
+Subject: [PATCH] Backport PR #17982: BF: for degenerate polygons, add
+ CLOSEPOLY vertex
+
+---
+ lib/matplotlib/patches.py            | 18 ++++++++++++++++--
+ lib/matplotlib/tests/test_patches.py |  7 +++++++
+ 2 files changed, 23 insertions(+), 2 deletions(-)
+
+diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py
+index 5811cba39ad..fdd06f004f7 100644
+--- a/lib/matplotlib/patches.py
++++ b/lib/matplotlib/patches.py
+@@ -1063,13 +1063,27 @@ def set_xy(self, xy):
+         ----------
+         xy : (N, 2) array-like
+             The coordinates of the vertices.
++
++        Notes
++        -----
++        Unlike `~.path.Path`, we do not ignore the last input vertex. If the
++        polygon is meant to be closed, and the last point of the polygon is not
++        equal to the first, we assume that the user has not explicitly passed a
++        ``CLOSEPOLY`` vertex, and add it ourselves.
+         """
+         xy = np.asarray(xy)
++        nverts, _ = xy.shape
+         if self._closed:
+-            if len(xy) and (xy[0] != xy[-1]).any():
++            # if the first and last vertex are the "same", then we assume that
++            # the user explicitly passed the CLOSEPOLY vertex. Otherwise, we
++            # have to append one since the last vertex will be "ignored" by
++            # Path
++            if nverts == 1 or nverts > 1 and (xy[0] != xy[-1]).any():
+                 xy = np.concatenate([xy, [xy[0]]])
+         else:
+-            if len(xy) > 2 and (xy[0] == xy[-1]).all():
++            # if we aren't closed, and the last vertex matches the first, then
++            # we assume we have an unecessary CLOSEPOLY vertex and remove it
++            if nverts > 2 and (xy[0] == xy[-1]).all():
+                 xy = xy[:-1]
+         self._path = Path(xy, closed=self._closed)
+         self.stale = True
+diff --git a/lib/matplotlib/tests/test_patches.py b/lib/matplotlib/tests/test_patches.py
+index 475300b7c2d..3b9d1e0adb3 100644
+--- a/lib/matplotlib/tests/test_patches.py
++++ b/lib/matplotlib/tests/test_patches.py
+@@ -7,6 +7,7 @@
+ 
+ from matplotlib.patches import Polygon, Rectangle, FancyArrowPatch
+ from matplotlib.testing.decorators import image_comparison, check_figures_equal
++from matplotlib.transforms import Bbox
+ import matplotlib.pyplot as plt
+ from matplotlib import (
+     collections as mcollections, colors as mcolors, patches as mpatches,
+@@ -556,3 +557,9 @@ def test_rotated_arcs():
+         ax.axvline(0, color="k")
+         ax.set_axis_off()
+         ax.set_aspect("equal")
++
++
++def test_degenerate_polygon():
++    point = [0, 0]
++    correct_extents = Bbox([point, point]).extents
++    assert np.all(Polygon([point]).get_extents().extents == correct_extents)
diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
index d422cab..39129f0 100644
--- a/src/sage/plot/graphics.py
+++ b/src/sage/plot/graphics.py
@@ -1404,15 +1404,15 @@ class Graphics(WithEqualityById, SageObject):
         if scale == 'linear':
             basex = basey = 10
         elif scale == 'loglog':
-            subplot.set_xscale('log', basex=basex)
-            subplot.set_yscale('log', basey=basey)
+            subplot.set_xscale('log', base=basex)
+            subplot.set_yscale('log', base=basey)
             xscale = yscale = 'log'
         elif scale == 'semilogx':
-            subplot.set_xscale('log', basex=basex)
+            subplot.set_xscale('log', base=basex)
             basey = 10
             xscale = 'log'
         elif scale == 'semilogy':
-            subplot.set_yscale('log', basey=basey)
+            subplot.set_yscale('log', base=basey)
             basex = 10
             yscale = 'log'
 
@@ -2349,17 +2349,17 @@ class Graphics(WithEqualityById, SageObject):
             sage: subplot = Figure().add_subplot(111)
             sage: p._objects[0]._render_on_subplot(subplot)
             sage: p._matplotlib_tick_formatter(subplot, **d)
-            (<matplotlib.axes._subplots.AxesSubplot object at ...>,
+            (<AxesSubplot:>,
             <matplotlib.ticker.MaxNLocator object at ...>,
             <matplotlib.ticker.MaxNLocator object at ...>,
-            <matplotlib.ticker.OldScalarFormatter object at ...>,
-            <matplotlib.ticker.OldScalarFormatter object at ...>)
+            <matplotlib.ticker.ScalarFormatter object at ...>,
+            <matplotlib.ticker.ScalarFormatter object at ...>)
         """
         # This function is created to refactor some code that is repeated
         # in the matplotlib function
         from matplotlib.ticker import (FixedLocator, Locator,
                 LogFormatterMathtext, LogLocator, MaxNLocator,
-                MultipleLocator, NullLocator, OldScalarFormatter)
+                MultipleLocator, NullLocator, ScalarFormatter)
 
         x_locator, y_locator = ticks
         #---------------------- Location of x-ticks ---------------------#
@@ -2415,7 +2415,7 @@ class Graphics(WithEqualityById, SageObject):
             if scale[0] == 'log':
                 x_formatter = LogFormatterMathtext(base=base[0])
             else:
-                x_formatter = OldScalarFormatter()
+                x_formatter = ScalarFormatter()
         elif x_formatter in SR:
             x_const = x_formatter
             x_formatter = FuncFormatter(lambda n,pos:
@@ -2440,7 +2440,7 @@ class Graphics(WithEqualityById, SageObject):
             if scale[1] == 'log':
                 y_formatter = LogFormatterMathtext(base=base[1])
             else:
-                y_formatter = OldScalarFormatter()
+                y_formatter = ScalarFormatter()
         elif y_formatter in SR:
             y_const = y_formatter
             y_formatter = FuncFormatter(lambda n,pos:
diff --git a/src/sage/plot/multigraphics.py b/src/sage/plot/multigraphics.py
index 184a97c..8a87d1b 100644
--- a/src/sage/plot/multigraphics.py
+++ b/src/sage/plot/multigraphics.py
@@ -1295,15 +1295,15 @@ class GraphicsArray(MultiGraphics):
             sage: g2 = circle((0,1), 1.)
             sage: G = graphics_array([g1, g2])
             sage: G.position(0)  # tol 1.0e-13
-            (0.023437500000000003,
+            (0.025045451349937315,
              0.03415488992713045,
-             0.4627803348994754,
+             0.4489880779745068,
              0.9345951100728696)
             sage: G.position(1)  # tol 1.0e-13
-            (0.5136230468749999,
-             0.19293222169724827,
-             0.46278033489947534,
-             0.617040446532634)
+            (0.5170637412999687,
+             0.20212705964722733,
+             0.4489880779745068,
+             0.5986507706326758)
 
         """
         if not self._positions: