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

Skip to content

Commit 5b1d671

Browse files
authored
Merge pull request #7544 from anntzer/cleanup
Cleanups
2 parents 2ce3b61 + 7722070 commit 5b1d671

54 files changed

Lines changed: 5320 additions & 5580 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/api/api_changes/code_removal.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ The ``GraphicsContextBase.set_graylevel``, ``FigureCanvasBase.onHilite`` and
1919
``mpl_toolkits.axes_grid1.mpl_axes.Axes.toggle_axisline`` methods have been
2020
removed.
2121

22+
The ``ArtistInspector.findobj`` method, which was never working due to the lack
23+
of a ``get_children`` method, has been removed.
24+
2225

2326
`Axes.set_aspect("normal")`
2427
---------------------------

examples/api/custom_projection_example.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def __init__(self, round_to=1.0):
4343
self._round_to = round_to
4444

4545
def __call__(self, x, pos=None):
46-
degrees = (x / np.pi) * 180.0
47-
degrees = np.round(degrees / self._round_to) * self._round_to
46+
degrees = np.round(np.rad2deg(x) / self._round_to) * self._round_to
4847
if rcParams['text.usetex'] and not rcParams['text.latex.unicode']:
4948
return r"$%0.0f^\circ$" % degrees
5049
else:
@@ -278,8 +277,7 @@ def format_coord(self, lon, lat):
278277
279278
In this case, we want them to be displayed in degrees N/S/E/W.
280279
"""
281-
lon = lon * (180.0 / np.pi)
282-
lat = lat * (180.0 / np.pi)
280+
lon, lat = np.rad2deg([lon, lat])
283281
if lat >= 0.0:
284282
ns = 'N'
285283
else:
@@ -330,7 +328,7 @@ def set_longitude_grid_ends(self, degrees):
330328
class -- it provides an interface to something that has no
331329
analogy in the base Axes class.
332330
"""
333-
self._longitude_cap = degrees * (np.pi / 180.0)
331+
self._longitude_cap = np.deg2rad(degrees)
334332
self._xaxis_pretransform \
335333
.clear() \
336334
.scale(1.0, self._longitude_cap * 2.0) \

examples/mplot3d/pathpatch3d_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs):
4949
text3d(ax, (4, -2, 0), "X-axis", zdir="z", size=.5, usetex=False,
5050
ec="none", fc="k")
5151
text3d(ax, (12, 4, 0), "Y-axis", zdir="z", size=.5, usetex=False,
52-
angle=.5*3.14159, ec="none", fc="k")
52+
angle=np.pi / 2, ec="none", fc="k")
5353
text3d(ax, (12, 10, 4), "Z-axis", zdir="y", size=.5, usetex=False,
54-
angle=.5*3.14159, ec="none", fc="k")
54+
angle=np.pi / 2, ec="none", fc="k")
5555

5656
# Write a Latex formula on the z=0 'floor'
5757
text3d(ax, (1, 5, 0),

examples/pylab_examples/leftventricle_bulleye.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,20 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
5959

6060
# Create the bounds for the segments 1-12
6161
for i in range(6):
62-
theta_i = i*60*np.pi/180
62+
theta_i = np.deg2rad(i * 60)
6363
ax.plot([theta_i, theta_i], [r[1], 1], '-k', lw=linewidth)
6464

6565
# Create the bounds for the segmentss 13-16
6666
for i in range(4):
67-
theta_i = i*90*np.pi/180 - 45*np.pi/180
67+
theta_i = np.deg2rad(i * 90 - 45)
6868
ax.plot([theta_i, theta_i], [r[0], r[1]], '-k', lw=linewidth)
6969

7070
# Fill the segments 1-6
7171
r0 = r[2:4]
7272
r0 = np.repeat(r0[:, np.newaxis], 128, axis=1).T
7373
for i in range(6):
7474
# First segment start at 60 degrees
75-
theta0 = theta[i*128:i*128+128] + 60*np.pi/180
75+
theta0 = theta[i*128:i*128+128] + np.deg2rad(60)
7676
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
7777
z = np.ones((128, 2))*data[i]
7878
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
@@ -86,7 +86,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
8686
r0 = np.repeat(r0[:, np.newaxis], 128, axis=1).T
8787
for i in range(6):
8888
# First segment start at 60 degrees
89-
theta0 = theta[i*128:i*128+128] + 60*np.pi/180
89+
theta0 = theta[i*128:i*128+128] + np.deg2rad(60)
9090
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
9191
z = np.ones((128, 2))*data[i+6]
9292
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)
@@ -100,7 +100,7 @@ def bullseye_plot(ax, data, segBold=None, cmap=None, norm=None):
100100
r0 = np.repeat(r0[:, np.newaxis], 192, axis=1).T
101101
for i in range(4):
102102
# First segment start at 45 degrees
103-
theta0 = theta[i*192:i*192+192] + 45*np.pi/180
103+
theta0 = theta[i*192:i*192+192] + np.deg2rad(45)
104104
theta0 = np.repeat(theta0[:, np.newaxis], 2, axis=1)
105105
z = np.ones((192, 2))*data[i+12]
106106
ax.pcolormesh(theta0, r0, z, cmap=cmap, norm=norm)

examples/pylab_examples/tripcolor_demo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@
7272
[-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872],
7373
[-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933],
7474
[-0.077, 0.990], [-0.059, 0.993]])
75-
x = xy[:, 0]*180/3.14159
76-
y = xy[:, 1]*180/3.14159
75+
x, y = np.rad2deg(xy).T
7776

7877
triangles = np.asarray([
7978
[67, 66, 1], [65, 2, 66], [ 1, 66, 2], [64, 2, 65], [63, 3, 64],

examples/units/basic_units.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ def __init__(self, fn_name, obj):
6161

6262
def __call__(self, *args):
6363
ret = PassThroughProxy.__call__(self, *args)
64-
if (type(ret) == type(NotImplemented)):
65-
return NotImplemented
66-
return TaggedValue(ret, self.unit)
64+
return (NotImplemented if ret is NotImplemented
65+
else TaggedValue(ret, self.unit))
6766

6867

6968
class ConvertAllProxy(PassThroughProxy):
@@ -95,10 +94,10 @@ def __call__(self, *args):
9594
arg_units.append(None)
9695
converted_args = tuple(converted_args)
9796
ret = PassThroughProxy.__call__(self, *converted_args)
98-
if (type(ret) == type(NotImplemented)):
97+
if ret is NotImplemented:
9998
return NotImplemented
10099
ret_unit = unit_resolver(self.fn_name, arg_units)
101-
if (ret_unit == NotImplemented):
100+
if ret_unit is NotImplemented:
102101
return NotImplemented
103102
return TaggedValue(ret, ret_unit)
104103

@@ -216,7 +215,7 @@ def __mul__(self, rhs):
216215
value = rhs.get_value()
217216
unit = rhs.get_unit()
218217
unit = unit_resolver('__mul__', (self, unit))
219-
if (unit == NotImplemented):
218+
if unit is NotImplemented:
220219
return NotImplemented
221220
return TaggedValue(value, unit)
222221

examples/units/ellipse_with_units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
width, height = 1e-1*cm, 3e-1*cm
1313
angle = -30
1414

15-
theta = np.arange(0.0, 360.0, 1.0)*np.pi/180.0
15+
theta = np.deg2rad(np.arange(0.0, 360.0, 1.0))
1616
x = 0.5 * width * np.cos(theta)
1717
y = 0.5 * height * np.sin(theta)
1818

examples/user_interfaces/embedding_in_tk_canvas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def draw_figure(canvas, figure, loc=(0, 0)):
4242
canvas.pack()
4343

4444
# Generate some example data
45-
X = np.linspace(0, 2.0*3.14, 50)
45+
X = np.linspace(0, 2 * np.pi, 50)
4646
Y = np.sin(X)
4747

4848
# Create the figure we desire to add to an existing canvas

0 commit comments

Comments
 (0)