8000 Merge remote-tracking branch 'matplotlib/v2.x' · matplotlib/matplotlib@a9c9012 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9c9012

Browse files
committed
Merge remote-tracking branch 'matplotlib/v2.x'
Conflicts: lib/matplotlib/backend_bases.py - keep draw_idle in backend_bases same source of conflict resolved in ac01d85
2 parents 6eeb109 + 099f0af commit a9c9012

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

doc/users/style_sheets.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ changes, you can write something like the following::
8585

8686

8787
.. _matplotlibrc: http://matplotlib.org/users/customizing.html
88-
.. _ggplot: http://had.co.nz/ggplot2/
89-
.. _R: http://www.r-project.org/
88+
.. _ggplot: http://ggplot2.org/
89+
.. _R: https://www.r-project.org/

lib/matplotlib/quiver.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,13 @@ def _angles_lengths(self, U, V, eps=1):
606606

607607
def _make_verts(self, U, V):
608608
uv = (U + V * 1j)
609-
if self.angles == 'xy' and self.scale_units == 'xy':
609+
str_angles = isinstance(self.angles, six.string_types)
610+
if str_angles and (self.angles == 'xy' and self.scale_units == 'xy'):
610611
# Here eps is 1 so that if we get U, V by diffing
611612
# the X, Y arrays, the vectors will connect the
612613
# points, regardless of the axis scaling (including log).
613614
angles, lengths = self._angles_lengths(U, V, eps=1)
614-
elif self.angles == 'xy' or self.scale_units == 'xy':
615+
elif str_angles and (self.angles == 'xy' or self.scale_units == 'xy'):
615616
# Calculate eps based on the extents of the plot
616617
# so that we don't end up with roundoff error from
617618
# adding a small number to a large.
@@ -644,9 +645,9 @@ def _make_verts(self, U, V):
644645
self.scale = scale * widthu_per_lenu
645646
length = a * (widthu_per_lenu / (self.scale * self.width))
646647
X, Y = self._h_arrows(length)
647-
if self.angles == 'xy':
648+
if str_angles and (self.angles == 'xy'):
648649
theta = angles
649-
elif self.angles == 'uv':
650+
elif str_angles and (self.angles == 'uv'):
650651
theta = np.angle(uv)
651652
else:
652653
# Make a copy to avoid changing the input array.

lib/matplotlib/tests/test_quiver.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import print_function
2-
import os
3-
import tempfile
2+
import warnings
43
import numpy as np
54
import sys
65
from matplotlib import pyplot as plt
@@ -45,6 +44,20 @@ def test_quiver_key_memory_leak():
4544
assert sys.getrefcount(qk) == 2
4645

4746

47+
@cleanup
48+
def test_no_warnings():
49+
fig, ax = plt.subplots()
50+
51+
X, Y = np.meshgrid(np.arange(15), np.arange(10))
52+
U = V = np.ones_like(X)
53+
54+
phi = (np.random.rand(15, 10) - .5) * 150
55+
with warnings.catch_warnings(record=True) as w:
56+
ax.quiver(X, Y, U, V, angles=phi)
57+
fig.canvas.draw()
58+
assert len(w) == 0
59+
60+
4861
@image_comparison(baseline_images=['quiver_animated_test_image'],
4962
extensions=['png'])
5063
def test_quiver_animate():

src/_contour.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ void QuadContourGenerator::append_contour_line_to_vertices(
396396
line(i, 0) = point->x;
397397
line(i, 1) = point->y;
398398
}
399-
if (PyList_Append(vertices_list, line.pyobj())) {
399+
if (PyList_Append(vertices_list, line.pyobj_steal())) {
400400
Py_XDECREF(vertices_list);
401401
throw "Unable to add contour line to vertices_list";
402402
}
@@ -470,8 +470,8 @@ void QuadContourGenerator::append_contour_to_vertices_and_codes(
470470
child.clear_parent(); // To indicate it can be deleted.
471471
}
472472

473-
if (PyList_Append(vertices_list, vertices.pyobj()) ||
474-
PyList_Append(codes_list, codes.pyobj())) {
473+
if (PyList_Append(vertices_list, vertices.pyobj_steal()) ||
474+
PyList_Append(codes_list, codes.pyobj_steal())) {
475475
Py_XDECREF(vertices_list);
476476
Py_XDECREF(codes_list);
477477
contour.delete_contour_lines();

src/numpy_cpp.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,19 @@ class array_view : public detail::array_view_accessors<array_view, T, ND>
525525
return (T *)m_data;
526526
}
527527

528+
// Return a new reference.
528529
PyObject *pyobj()
529530
{
530531
Py_XINCREF(m_arr);
531532
return (PyObject *)m_arr;
532533
}
533534

535+
// Steal a reference.
536+
PyObject *pyobj_steal()
537+
{
538+
return (PyObject *)m_arr;
539+
}
540+
534541
static int converter(PyObject *obj, void *arrp)
535542
{
536543
array_view<T, ND> *arr = (array_view<T, ND> *)arrp;

0 commit comments

Comments
 (0)
0