Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f77243b

Browse filesBrowse files
authored
Merge pull request #10328 from anntzer/deg2rad
Use deg2rad/rad2deg where appropriate.
2 parents 86083dd + 13a3095 commit f77243b
Copy full SHA for f77243b

File tree

Expand file treeCollapse file tree

5 files changed

+15
-21
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+15
-21
lines changed

‎lib/matplotlib/projections/geo.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/geo.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def set_longitude_grid_ends(self, degrees):
203203
"""
204204
Set the latitude(s) at which to stop drawing the longitude grids.
205205
"""
206-
self._longitude_cap = degrees * (np.pi / 180.0)
206+
self._longitude_cap = np.deg2rad(degrees)
207207
self._xaxis_pretransform \
208208
.clear() \
209209
.scale(1.0, self._longitude_cap * 2.0) \

‎lib/matplotlib/projections/polar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/projections/polar.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,9 +1016,7 @@ def get_yaxis_text2_transform(self, pad):
10161016
return self._yaxis_text_transform + pad_shift, 'center', halign
10171017

10181018
def draw(self, *args, **kwargs):
1019-
thetamin, thetamax = self._realViewLim.intervalx
1020-
thetamin *= 180 / np.pi
1021-
thetamax *= 180 / np.pi
1019+
thetamin, thetamax = np.rad2deg(self._realViewLim.intervalx)
10221020
if thetamin > thetamax:
10231021
thetamin, thetamax = thetamax, thetamin
10241022
rmin, rmax = self._realViewLim.intervaly - self.get_rorigin()
@@ -1260,8 +1258,8 @@ def set_thetagrids(self, angles, labels=None, frac=None, fmt=None,
12601258

12611259
# Make sure we take into account unitized data
12621260
angles = self.convert_yunits(angles)
1263-
angles = np.asarray(angles, float)
1264-
self.set_xticks(angles * (np.pi / 180.0))
1261+
angles = np.deg2rad(angles)
1262+
self.set_xticks(angles)
12651263
if labels is not None:
12661264
self.set_xticklabels(labels)
12671265
elif fmt is not None:

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+8-12Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -604,22 +604,18 @@ def test_const_xy():
604604
@image_comparison(baseline_images=['polar_wrap_180', 'polar_wrap_360'],
605605
style='default')
606606
def test_polar_wrap():
607-
D2R = np.pi / 180.0
608-
609607
fig = plt.figure()
610-
611608
plt.subplot(111, polar=True)
612-
613-
plt.polar([179*D2R, -179*D2R], [0.2, 0.1], "b.-")
614-
plt.polar([179*D2R, 181*D2R], [0.2, 0.1], "g.-")
609+
plt.polar(np.deg2rad([179, -179]), [0.2, 0.1], "b.-")
610+
plt.polar(np.deg2rad([179, 181]), [0.2, 0.1], "g.-")
615611
plt.rgrids([0.05, 0.1, 0.15, 0.2, 0.25, 0.3])
616612
assert len(fig.axes) == 1, 'More than one polar axes created.'
617-
fig = plt.figure()
618613

614+
fig = plt.figure()
619615
plt.subplot(111, polar=True)
620-
plt.polar([2*D2R, -2*D2R], [0.2, 0.1], "b.-")
621-
plt.polar([2*D2R, 358*D2R], [0.2, 0.1], "g.-")
622-
plt.polar([358*D2R, 2*D2R], [0.2, 0.1], "r.-")
616+
plt.polar(np.deg2rad([2, -2]), [0.2, 0.1], "b.-")
617+
plt.polar(np.deg2rad([2, 358]), [0.2, 0.1], "g.-")
618+
plt.polar(np.deg2rad([358, 2]), [0.2, 0.1], "r.-")
623619
plt.rgrids([0.05, 0.1, 0.15, 0.2, 0.25, 0.3])
624620

625621

@@ -1253,11 +1249,11 @@ def test_arc_ellipse():
12531249
width, height = 1e-1, 3e-1
12541250
angle = -30
12551251

1256-
theta = np.arange(0.0, 360.0, 1.0) * np.pi / 180.0
1252+
theta = np.deg2rad(np.arange(360))
12571253
x = width / 2. * np.cos(theta)
12581254
y = height / 2. * np.sin(theta)
12591255

1260-
rtheta = angle * np.pi / 180.
1256+
rtheta = np.deg2rad(angle)
12611257
R = np.array([
12621258
[np.cos(rtheta), -np.sin(rtheta)],
12631259
[np.sin(rtheta), np.cos(rtheta)]])

‎lib/matplotlib/transforms.py

Copy file name to clipboardExpand all lines: lib/matplotlib/transforms.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ def transform_angles(self, angles, pts, radians=False, pushoff=1e-5):
16231623

16241624
# Convert back to degrees if desired
16251625
if not radians:
1626-
a = a * 180.0 / np.pi
1626+
a = np.rad2deg(a)
16271627

16281628
return a
16291629

@@ -2033,7 +2033,7 @@ def rotate_deg(self, degrees):
20332033
calls to :meth:`rotate`, :meth:`rotate_deg`, :meth:`translate`
20342034
and :meth:`scale`.
20352035
"""
2036-
return self.rotate(degrees * np.pi / 180.)
2036+
return self.rotate(np.deg2rad(degrees))
20372037

20382038
def rotate_around(self, x, y, theta):
20392039
"""

‎lib/matplotlib/widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/widgets.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,7 @@ def draw_shape(self, extents):
24312431
self.to_draw.width = 2 * a
24322432
self.to_draw.height = 2 * b
24332433
else:
2434-
rad = np.arange(31) * 12 * np.pi / 180
2434+
rad = np.deg2rad(np.arange(31) * 12)
24352435
x = a * np.cos(rad) + center[0]
24362436
y = b * np.sin(rad) + center[1]
24372437
self.to_draw.set_data(x, y)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.