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

Skip to content

Commit 7bcca51

Browse files
committed
[examples/] use np.radians/np.degrees where appropriate
1 parent c3210d4 commit 7bcca51

File tree

5 files changed

+6
-14
lines changed

5 files changed

+6
-14
lines changed

examples/animation/double_pendulum_animated.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ def derivs(state, t):
4747
th2 = -10.0
4848
w2 = 0.0
4949

50-
rad = pi / 180
51-
5250
# initial state
53-
state = np.array([th1, w1, th2, w2]) * pi / 180.
51+
state = np.radians([th1, w1, th2, w2])
5452

5553
# integrate your ODE using scipy.integrate.
5654
y = integrate.odeint(derivs, state, t)

examples/pylab_examples/tricontour_demo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
# the three points that make up the triangle, ordered in either a clockwise or
4646
# anticlockwise manner.
4747

48-
xy = np.asarray([
48+
xy = np.degrees([
4949
[-0.101, 0.872], [-0.080, 0.883], [-0.069, 0.888], [-0.054, 0.890],
5050
[-0.045, 0.897], [-0.057, 0.895], [-0.073, 0.900], [-0.087, 0.898],
5151
[-0.090, 0.904], [-0.069, 0.907], [-0.069, 0.921], [-0.080, 0.919],
@@ -65,8 +65,6 @@
6565
[-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872],
6666
[-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933],
6767
[-0.077, 0.990], [-0.059, 0.993]])
68-
x = xy[:, 0]*180/3.14159
69-
y = xy[:, 1]*180/3.14159
7068
x0 = -5
7169
y0 = 52
7270
z = np.exp(-0.01*((x-x0)*(x-x0) + (y-y0)*(y-y0)))

examples/pylab_examples/tripcolor_demo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
# the three points that make up the triangle, ordered in either a clockwise or
5353
# anticlockwise manner.
5454

55-
xy = np.asarray([
55+
xy = np.degrees([
5656
[-0.101, 0.872], [-0.080, 0.883], [-0.069, 0.888], [-0.054, 0.890],
5757
[-0.045, 0.897], [-0.057, 0.895], [-0.073, 0.900], [-0.087, 0.898],
5858
[-0.090, 0.904], [-0.069, 0.907], [-0.069, 0.921], [-0.080, 0.919],
@@ -72,8 +72,6 @@
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
7775

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

examples/pylab_examples/triplot_demo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
# the three points that make up the triangle, ordered in either a clockwise or
4444
# anticlockwise manner.
4545

46-
xy = np.asarray([
46+
xy = np.degrees([
4747
[-0.101, 0.872], [-0.080, 0.883], [-0.069, 0.888], [-0.054, 0.890],
4848
[-0.045, 0.897], [-0.057, 0.895], [-0.073, 0.900], [-0.087, 0.898],
4949
[-0.090, 0.904], [-0.069, 0.907], [-0.069, 0.921], [-0.080, 0.919],
@@ -63,8 +63,6 @@
6363
[-0.057, 0.881], [-0.062, 0.876], [-0.078, 0.876], [-0.087, 0.872],
6464
[-0.030, 0.907], [-0.007, 0.905], [-0.057, 0.916], [-0.025, 0.933],
6565
[-0.077, 0.990], [-0.059, 0.993]])
66-
x = xy[:, 0]*180/3.14159
67-
y = xy[:, 1]*180/3.14159
6866

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

examples/units/ellipse_with_units.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
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.radians(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

19-
rtheta = angle*np.pi/180.
19+
rtheta = np.radians(angle)
2020
R = np.array([
2121
[np.cos(rtheta), -np.sin(rtheta)],
2222
[np.sin(rtheta), np.cos(rtheta)],

0 commit comments

Comments
 (0)