summarylogtreecommitdiffstats
path: root/sagemath-matplotlib2.patch
blob: e773d82d8049e1d0f3f6da59301af9cd2c875792 (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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
diff --git a/src/sage/all.py b/src/sage/all.py
index 300f519..19bc8ec 100644
--- a/src/sage/all.py
+++ b/src/sage/all.py
@@ -313,8 +313,6 @@ warnings.filters.remove(('ignore', None, DeprecationWarning, None, 0))
 # Ignore all deprecations from IPython etc.
 warnings.filterwarnings('ignore',
     module='.*(IPython|ipykernel|jupyter_client|jupyter_core|nbformat|notebook|ipywidgets|storemagic)')
-# Ignore warnings due to matplotlib-1.5 together with numpy-1.13
-warnings.filterwarnings('ignore', module='matplotlib[.]contour|numpy[.]ma[.]core')
 # However, be sure to keep OUR deprecation warnings
 warnings.filterwarnings('default',
     '[\s\S]*See http://trac.sagemath.org/[0-9]* for details.')
diff --git a/src/sage/plot/arrow.py b/src/sage/plot/arrow.py
index 98d6224..fbce029 100644
--- a/src/sage/plot/arrow.py
+++ b/src/sage/plot/arrow.py
@@ -147,8 +147,8 @@ class CurveArrow(GraphicPrimitive):
         bpath = Path(self.vertices, self.codes)
         p = FancyArrowPatch(path=bpath,
                             lw=width, arrowstyle='%s,head_width=%s,head_length=%s' % (style, head_width, head_length),
-                            fc=color, ec=color)
-        p.set_linestyle(get_matplotlib_linestyle(options['linestyle'], return_type='long'))
+                            fc=color, ec=color, 
+                            linestyle=get_matplotlib_linestyle(options['linestyle'], return_type='long'))
         p.set_zorder(options['zorder'])
         p.set_label(options['legend_label'])
         subplot.add_patch(p)
@@ -336,7 +336,7 @@ class Arrow(GraphicPrimitive):
         this into account. See :trac:`12836`::
 
             sage: fig = Graphics().matplotlib()
-            sage: sp = fig.add_subplot(1,1,1)
+            sage: sp = fig.add_subplot(1,1,1, label='axis1')
             sage: a = arrow((0,0), (1,1))
             sage: b = arrow((0,0), (1,1), width=20)
             sage: p1 = a[0]._render_on_subplot(sp)
@@ -358,7 +358,7 @@ class Arrow(GraphicPrimitive):
             sage: a.save(filename=filename)
             sage: with open(filename, 'r') as f:
             ....:     contents = f.read().replace('\n', ' ')
-            sage: two_stroke_pattern = r'setdash.*stroke.*stroke.*setdash'
+            sage: two_stroke_pattern = r'setdash.*setdash.*stroke.*stroke.*setdash'
             sage: import re
             sage: two_stroke_re = re.compile(two_stroke_pattern)
             sage: two_stroke_re.search(contents) is None
@@ -383,8 +383,8 @@ class Arrow(GraphicPrimitive):
                             lw=width,
                             arrowstyle='%s,head_width=%s,head_length=%s' % (style, head_width, head_length),
                             shrinkA=arrowshorten_end, shrinkB=arrowshorten_end,
-                            fc=color, ec=color)
-        p.set_linestyle(get_matplotlib_linestyle(options['linestyle'], return_type='long'))
+                            fc=color, ec=color,
+                            linestyle=get_matplotlib_linestyle(options['linestyle'], return_type='long'))
         p.set_zorder(options['zorder'])
         p.set_label(options['legend_label'])
 
@@ -437,7 +437,7 @@ class Arrow(GraphicPrimitive):
                             pe1.draw_path(renderer, gc, tpath, affine, rgbFace)
 
             pe1 = ConditionalStroke(CheckNthSubPath(p, 0), [pe.Stroke()])
-            pe2 = ConditionalStroke(CheckNthSubPath(p, 1), [pe.Stroke(linestyle="solid")])
+            pe2 = ConditionalStroke(CheckNthSubPath(p, 1), [pe.Stroke(dashes={'dash_offset': 0, 'dash_list': None})])
             p.set_path_effects([pe1, pe2])
 
         subplot.add_patch(p)
diff --git a/src/sage/plot/contour_plot.py b/src/sage/plot/contour_plot.py
index 76077e3..efc1f2b 100644
--- a/src/sage/plot/contour_plot.py
+++ b/src/sage/plot/contour_plot.py
@@ -178,12 +178,10 @@ class ContourPlot(GraphicPrimitive):
         if fill:
             if contours is None:
                 CSF = subplot.contourf(self.xy_data_array, cmap=cmap,
-                                       extent=(x0, x1, y0, y1),
-                                       label=options['legend_label'])
+                                       extent=(x0, x1, y0, y1))
             else:
                 CSF = subplot.contourf(self.xy_data_array, contours, cmap=cmap,
-                                       extent=(x0, x1, y0, y1), extend='both',
-                                       label=options['legend_label'])
+                                       extent=(x0, x1, y0, y1), extend='both')
 
         linewidths = options.get('linewidths', None)
         if isinstance(linewidths, (int, Integer)):
@@ -200,13 +198,11 @@ class ContourPlot(GraphicPrimitive):
         if contours is None:
             CS = subplot.contour(self.xy_data_array, cmap=cmap,
                                  extent=(x0, x1, y0, y1),
-                                 linewidths=linewidths, linestyles=linestyles,
-                                 label=options['legend_label'])
+                                 linewidths=linewidths, linestyles=linestyles)
         else:
             CS = subplot.contour(self.xy_data_array, contours, cmap=cmap,
                                  extent=(x0, x1, y0, y1),
-                                 linewidths=linewidths, linestyles=linestyles,
-                                 label=options['legend_label'])
+                                 linewidths=linewidths, linestyles=linestyles)
         if options.get('labels', False):
             label_options = options['label_options']
             label_options['fontsize'] = int(label_options['fontsize'])
diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
index aa82eda..03a0f3a 100644
--- a/src/sage/plot/plot.py
+++ b/src/sage/plot/plot.py
@@ -478,7 +478,7 @@ We test that ``imshow`` works as well, verifying that
 
 ::
 
-    sage: plt.imshow([[(0,0,0)]])
+    sage: plt.imshow([[(0.0,0.0,0.0)]])
     <matplotlib.image.AxesImage object at ...>
     sage: plt.savefig(os.path.join(SAGE_TMP, 'foo.png'))
 
@@ -2908,11 +2908,14 @@ def list_plot(data, plotjoined=False, **kwargs):
         If ``plotjoined`` is ``False`` then the axis that is in log scale
         must have all points strictly positive. For instance, the following
         plot will show no points in the figure since the points in the
-        horizontal axis starts from `(0,1)`.
+        horizontal axis starts from `(0,1)`. Further, matplotlib will display
+        a user warning.
 
         ::
 
             sage: list_plot(yl, scale='loglog')         # both axes are log
+            doctest:warning
+            ...
             Graphics object consisting of 1 graphics primitive
 
         Instead this will work. We drop the point `(0,1)`.::
@@ -3288,12 +3291,15 @@ def list_plot_semilogy(data, plotjoined=False, **kwds):
 
         If ``plotjoined`` is ``False`` then the vertical axis must have all
         points strictly positive. Otherwise the plot will come up empty.
-        For instance the following plot contains a point at `(1,0)`.
+        For instance the following plot contains a point at `(1,0)`. Further, 
+        matplotlib will display a user warning.
 
         ::
 
             sage: xl = [2**k for k in range(12)]; yl = range(len(xl))
             sage: list_plot_semilogy(list(zip(xl,yl))) # plot empty due to (1,0)
+            doctest:warning
+            ...
             Graphics object consisting of 1 graphics primitive
 
         We remove `(1,0)` to fix this.::
diff --git a/src/sage/plot/plot3d/list_plot3d.py b/src/sage/plot/plot3d/list_plot3d.py
index c9f22dd..be87ff2 100644
--- a/src/sage/plot/plot3d/list_plot3d.py
+++ b/src/sage/plot/plot3d/list_plot3d.py
@@ -29,21 +29,20 @@ def list_plot3d(v, interpolation_type='default', texture="automatic", point_list
 
     OPTIONAL KEYWORDS:
 
-    - ``interpolation_type`` - 'linear', 'nn' (natural neighbor), 'spline'
+    - ``interpolation_type`` - 'linear', 'clough' (CloughTocher2D), 'spline'
 
       'linear' will perform linear interpolation
 
-      The option 'nn' An interpolation method for multivariate data in a 
-      Delaunay triangulation. The value for an interpolation point is 
-      estimated using weighted values of the closest surrounding points in 
-      the triangulation. These points, the natural neighbors, are the ones 
-      the interpolation point would connect to if inserted into the 
-      triangulation.
+      The option 'clough' will interpolate by using a piecewise cubic interpolating
+      Bezier polynomial on each triangle, using a Clough-Tocher scheme.
+      The interpolant is guaranteed to be continuously differentiable.
+      The gradients of the interpolant are chosen so that the curvature of the
+      interpolating surface is approximatively minimized.
 
       The option 'spline' interpolates using a bivariate B-spline.
 
       When v is a matrix the default is to use linear interpolation, when
-      v is a list of points the default is nearest neighbor.
+      v is a list of points the default is 'clough'.
 
     - ``degree`` - an integer between 1 and 5, controls the degree of spline
       used for spline interpolation. For data that is highly oscillatory
@@ -320,18 +319,18 @@ def list_plot3d_tuples(v, interpolation_type, texture, **kwds):
 
     OPTIONAL KEYWORDS:
 
-    - ``interpolation_type`` - 'linear', 'nn' (natural neighbor), 'spline'
+    - ``interpolation_type`` - 'linear', 'clough' (CloughTocher2D), 'spline'
 
       'linear' will perform linear interpolation
 
-      The option 'nn' will interpolate by using natural neighbors. The 
-      value for an interpolation point is estimated using weighted values 
-      of the closest surrounding points in the triangulation.
+      The option 'clough' will interpolate by using a piecewise cubic interpolating
+      Bezier polynomial on each triangle, using a Clough-Tocher scheme.
+      The interpolant is guaranteed to be continuously differentiable.
 
       The option 'spline' interpolates using a bivariate B-spline.
 
       When v is a matrix the default is to use linear interpolation, when
-      v is a list of points the default is nearest neighbor.
+      v is a list of points the default is 'clough'.
 
     - ``degree`` - an integer between 1 and 5, controls the degree of spline
       used for spline interpolation. For data that is highly oscillatory
@@ -373,7 +372,7 @@ def list_plot3d_tuples(v, interpolation_type, texture, **kwds):
         sage: list_plot3d([(1, 2, 3), (0, 1, 3), (2, 1, 4), (1, 0, -2)], texture='yellow', num_points=50)
         Graphics3d Object
     """
-    from matplotlib import tri, delaunay
+    from matplotlib import tri
     import numpy
     import scipy
     from random import random
@@ -439,19 +438,15 @@ def list_plot3d_tuples(v, interpolation_type, texture, **kwds):
         G._set_extra_kwds(kwds)
         return G
 
-    if interpolation_type == 'nn'  or interpolation_type =='default':
+    if interpolation_type == 'clough'  or interpolation_type =='default':
 
-        T=delaunay.Triangulation(x,y)
-        f=T.nn_interpolator(z)
-        f.default_value=0.0
-        j=numpy.complex(0,1)
-        vals=f[ymin:ymax:j*num_points,xmin:xmax:j*num_points]
+        points=[[x[i],y[i]] for i in range(len(x))]
+        j = numpy.complex(0, 1)
+        f = interpolate.CloughTocher2DInterpolator(points,z)
         from .parametric_surface import ParametricSurface
-        def g(x,y):
-            i=round( (x-xmin)/(xmax-xmin)*(num_points-1) )
-            j=round( (y-ymin)/(ymax-ymin)*(num_points-1) )
-            z=vals[int(j),int(i)]
-            return (x,y,z)
+        def g(x, y):
+            z = f([x, y])
+            return (x, y, z)
         G = ParametricSurface(g, (list(numpy.r_[xmin:xmax:num_points*j]), list(numpy.r_[ymin:ymax:num_points*j])), texture=texture, **kwds)
         G._set_extra_kwds(kwds)
         return G
diff --git a/src/sage/probability/probability_distribution.pyx b/src/sage/probability/probability_distribution.pyx
index 3ce4642..f66cd89 100644
--- a/src/sage/probability/probability_distribution.pyx
+++ b/src/sage/probability/probability_distribution.pyx
@@ -118,7 +118,7 @@ cdef class ProbabilityDistribution:
             sage: P = [0.3, 0.4, 0.3]
             sage: X = GeneralDiscreteDistribution(P)
             sage: h, b = X.generate_histogram_data(bins = 10)
-            sage: h
+            sage: h  # rel tol 1e-08
             [1.6299999999999999,
              0.0,
              0.0,