Skip to content

Commit d5c0eeb

Browse files
authored
Merge pull request sympy#20248 from moorepants/remove-kanes-dep
Removed deprecation warning for swapped arguments in kanes_equations.
2 parents c1e29b4 + a68205f commit d5c0eeb

File tree

5 files changed

+19
-55
lines changed

5 files changed

+19
-55
lines changed

sympy/physics/mechanics/kane.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from sympy.physics.mechanics.functions import (msubs, find_dynamicsymbols,
99
_f_list_parser)
1010
from sympy.physics.mechanics.linearize import Linearizer
11-
from sympy.utilities.exceptions import SymPyDeprecationWarning
1211
from sympy.utilities.iterables import iterable
1312

1413
__all__ = ['KanesMethod']
@@ -522,17 +521,6 @@ def kanes_equations(self, bodies, loads=None):
522521
Must be either a non-empty iterable of tuples or None which corresponds
523522
to a system with no constraints.
524523
"""
525-
if (bodies is None and loads is not None) or isinstance(bodies[0], tuple):
526-
# This switches the order if they use the old way.
527-
bodies, loads = loads, bodies
528-
SymPyDeprecationWarning(value='The API for kanes_equations() has changed such '
529-
'that the loads (forces and torques) are now the second argument '
530-
'and is optional with None being the default.',
531-
feature='The kanes_equation() argument order',
532-
useinstead='switched argument order to update your code, For example: '
533-
'kanes_equations(loads, bodies) > kanes_equations(bodies, loads).',
534-
issue=10945, deprecated_since_version="1.1").warn()
535-
536524
if not self._k_kqdot:
537525
raise AttributeError('Create an instance of KanesMethod with '
538526
'kinematic differential equations to use this method.')

sympy/physics/mechanics/tests/test_kane.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from sympy.testing.pytest import warns_deprecated_sympy
2-
31
from sympy.core.backend import (cos, expand, Matrix, sin, symbols, tan, sqrt, S,
42
zeros)
53
from sympy import simplify
@@ -24,10 +22,7 @@ def test_one_dof():
2422
BL = [pa]
2523

2624
KM = KanesMethod(N, [q], [u], kd)
27-
# The old input format raises a deprecation warning, so catch it here so
28-
# it doesn't cause py.test to fail.
29-
with warns_deprecated_sympy():
30-
KM.kanes_equations(FL, BL)
25+
KM.kanes_equations(BL, FL)
3126

3227
MM = KM.mass_matrix
3328
forcing = KM.forcing
@@ -67,10 +62,7 @@ def test_two_dof():
6762
# pass relevant information, and form Fr & Fr*. Then we calculate the mass
6863
# matrix and forcing terms, and finally solve for the udots.
6964
KM = KanesMethod(N, q_ind=[q1, q2], u_ind=[u1, u2], kd_eqs=kd)
70-
# The old input format raises a deprecation warning, so catch it here so
71-
# it doesn't cause py.test to fail.
72-
with warns_deprecated_sympy():
73-
KM.kanes_equations(FL, BL)
65+
KM.kanes_equations(BL, FL)
7466
MM = KM.mass_matrix
7567
forcing = KM.forcing
7668
rhs = MM.inv() * forcing
@@ -96,8 +88,7 @@ def test_pend():
9688
BL = [pa]
9789

9890
KM = KanesMethod(N, [q], [u], kd)
99-
with warns_deprecated_sympy():
100-
KM.kanes_equations(FL, BL)
91+
KM.kanes_equations(BL, FL)
10192
MM = KM.mass_matrix
10293
forcing = KM.forcing
10394
rhs = MM.inv() * forcing
@@ -160,8 +151,7 @@ def test_rolling_disc():
160151
# terms, then solve for the u dots (time derivatives of the generalized
161152
# speeds).
162153
KM = KanesMethod(N, q_ind=[q1, q2, q3], u_ind=[u1, u2, u3], kd_eqs=kd)
163-
with warns_deprecated_sympy():
164-
KM.kanes_equations(ForceList, BodyList)
154+
KM.kanes_equations(BodyList, ForceList)
165155
MM = KM.mass_matrix
166156
forcing = KM.forcing
167157
rhs = MM.inv() * forcing
@@ -217,15 +207,13 @@ def test_aux():
217207

218208
KM = KanesMethod(N, q_ind=[q1, q2, q3], u_ind=[u1, u2, u3, u4, u5],
219209
kd_eqs=kd)
220-
with warns_deprecated_sympy():
221-
(fr, frstar) = KM.kanes_equations(ForceList, BodyList)
210+
(fr, frstar) = KM.kanes_equations(BodyList, ForceList)
222211
fr = fr.subs({u4d: 0, u5d: 0}).subs({u4: 0, u5: 0})
223212
frstar = frstar.subs({u4d: 0, u5d: 0}).subs({u4: 0, u5: 0})
224213

225214
KM2 = KanesMethod(N, q_ind=[q1, q2, q3], u_ind=[u1, u2, u3], kd_eqs=kd,
226215
u_auxiliary=[u4, u5])
227-
with warns_deprecated_sympy():
228-
(fr2, frstar2) = KM2.kanes_equations(ForceList, BodyList)
216+
(fr2, frstar2) = KM2.kanes_equations(BodyList, ForceList)
229217
fr2 = fr2.subs({u4d: 0, u5d: 0}).subs({u4: 0, u5: 0})
230218
frstar2 = frstar2.subs({u4d: 0, u5d: 0}).subs({u4: 0, u5: 0})
231219

@@ -288,8 +276,7 @@ def test_parallel_axis():
288276
(C, N.x * F)]
289277

290278
km = KanesMethod(N, [q1, q2], [u1, u2], kindiffs)
291-
with warns_deprecated_sympy():
292-
(fr, frstar) = km.kanes_equations(forceList, bodyList)
279+
(fr, frstar) = km.kanes_equations(bodyList, forceList)
293280
mm = km.mass_matrix_full
294281
assert mm[3, 3] == Iz
295282

sympy/physics/mechanics/tests/test_kane2.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
find_dynamicsymbols, KanesMethod, inertia,
55
inertia_of_point_mass, Point,
66
ReferenceFrame, RigidBody)
7-
from sympy.testing.pytest import warns_deprecated_sympy
87

98

109
def test_aux_dep():
@@ -178,8 +177,7 @@ def test_aux_dep():
178177
)
179178

180179
# fr, frstar, frstar_steady and kdd(kinematic differential equations).
181-
with warns_deprecated_sympy():
182-
(fr, frstar)= kane.kanes_equations(forceList, bodyList)
180+
(fr, frstar)= kane.kanes_equations(bodyList, forceList)
183181
frstar_steady = frstar.subs(ud_zero).subs(u_dep_dict).subs(steady_conditions)\
184182
.subs({q[3]: -r*cos(q[1])}).expand()
185183
kdd = kane.kindiffdict()
@@ -267,8 +265,7 @@ def test_non_central_inertia():
267265

268266
forces = [(pS_star, -M*g*F.x), (pQ, Q1*A.x + Q2*A.y + Q3*A.z)]
269267
bodies = [rbA, rbB, rbC]
270-
with warns_deprecated_sympy():
271-
fr, fr_star = km.kanes_equations(forces, bodies)
268+
fr, fr_star = km.kanes_equations(bodies, forces)
272269
vc_map = solve(vc, [u4, u5])
273270

274271
# KanesMethod returns the negative of Fr, Fr* as defined in Kane1985.
@@ -289,8 +286,7 @@ def test_non_central_inertia():
289286
rb.frame)
290287
bodies2.append(RigidBody('', rb.masscenter, rb.frame, rb.mass,
291288
(I, pD)))
292-
with warns_deprecated_sympy():
293-
fr2, fr_star2 = km.kanes_equations(forces, bodies2)
289+
fr2, fr_star2 = km.kanes_equations(bodies2, forces)
294290

295291
t = trigsimp(fr_star2.subs(vc_map).subs({u3: 0})).doit()
296292
assert (fr_star_expected - t).expand() == zeros(3, 1)
@@ -379,8 +375,7 @@ def test_sub_qdot():
379375
-(mA + 2*mB +2*J/R**2) * u2.diff(t) + mA*a*u1**2,
380376
0])
381377

382-
with warns_deprecated_sympy():
383-
fr, fr_star = km.kanes_equations(forces, bodies)
378+
fr, fr_star = km.kanes_equations(bodies, forces)
384379
assert (fr.expand() == fr_expected.expand())
385380
assert ((fr_star_expected - trigsimp(fr_star)).expand() == zeros(3, 1))
386381

@@ -440,8 +435,7 @@ def test_sub_qdot2():
440435
u_expr += qd[3:]
441436
kde = [ui - e for ui, e in zip(u, u_expr)]
442437
km1 = KanesMethod(A, q, u, kde)
443-
with warns_deprecated_sympy():
444-
fr1, _ = km1.kanes_equations(forces, [])
438+
fr1, _ = km1.kanes_equations([], forces)
445439

446440
## Calculate generalized active forces if we impose the condition that the
447441
# disk C is rolling without slipping
@@ -450,8 +444,7 @@ def test_sub_qdot2():
450444
vc = [pC_hat.vel(A) & uv for uv in [A.x, A.y]]
451445
km2 = KanesMethod(A, q, u_indep, kde,
452446
u_dependent=u_dep, velocity_constraints=vc)
453-
with warns_deprecated_sympy():
454-
fr2, _ = km2.kanes_equations(forces, [])
447+
fr2, _ = km2.kanes_equations([], forces)
455448

456449
fr1_expected = Matrix([
457450
-R*g*m*sin(q[1]),

sympy/physics/mechanics/tests/test_kane3.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from sympy import evalf, symbols, pi, sin, cos, sqrt, acos, Matrix
22
from sympy.physics.mechanics import (ReferenceFrame, dynamicsymbols, inertia,
33
KanesMethod, RigidBody, Point, dot, msubs)
4-
from sympy.testing.pytest import slow, ON_TRAVIS, skip, warns_deprecated_sympy
4+
from sympy.testing.pytest import slow, ON_TRAVIS, skip
55

66

77
@slow
@@ -171,8 +171,7 @@ def test_bicycle():
171171
u_ind=[u2, u3, u5],
172172
u_dependent=[u1, u4, u6], velocity_constraints=conlist_speed,
173173
kd_eqs=kd)
174-
with warns_deprecated_sympy():
175-
(fr, frstar) = KM.kanes_equations(FL, BL)
174+
(fr, frstar) = KM.kanes_equations(BL, FL)
176175

177176
# This is the start of entering in the numerical values from the benchmark
178177
# paper to validate the eigen values of the linearized equations from this

sympy/physics/mechanics/tests/test_linearize.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from sympy.physics.mechanics import dynamicsymbols, ReferenceFrame, Point,\
44
dot, cross, inertia, KanesMethod, Particle, RigidBody, Lagrangian,\
55
LagrangesMethod
6-
from sympy.testing.pytest import slow, warns_deprecated_sympy
6+
from sympy.testing.pytest import slow
77

88

99
@slow
@@ -74,8 +74,7 @@ def test_linearize_rolling_disc_kane():
7474
KM = KanesMethod(N, [q1, q2, q3, q4, q5], [u1, u2, u3], kd_eqs=kindiffs,
7575
q_dependent=[q6], configuration_constraints=f_c,
7676
u_dependent=[u4, u5, u6], velocity_constraints=f_v)
77-
with warns_deprecated_sympy():
78-
(fr, fr_star) = KM.kanes_equations(FL, BL)
77+
(fr, fr_star) = KM.kanes_equations(BL, FL)
7978

8079
# Test generalized form equations
8180
linearizer = KM.to_linearizer()
@@ -158,8 +157,7 @@ def test_linearize_pendulum_kane_minimal():
158157

159158
# Solve for eom with kanes method
160159
KM = KanesMethod(N, q_ind=[q1], u_ind=[u1], kd_eqs=kde)
161-
with warns_deprecated_sympy():
162-
(fr, frstar) = KM.kanes_equations([(P, R)], [pP])
160+
(fr, frstar) = KM.kanes_equations([pP], [(P, R)])
163161

164162
# Linearize
165163
A, B, inp_vec = KM.linearize(A_and_B=True, simplify=True)
@@ -218,8 +216,7 @@ def test_linearize_pendulum_kane_nonminimal():
218216
KM = KanesMethod(N, q_ind=[q2], u_ind=[u2], q_dependent=[q1],
219217
u_dependent=[u1], configuration_constraints=f_c,
220218
velocity_constraints=f_v, acceleration_constraints=f_a, kd_eqs=kde)
221-
with warns_deprecated_sympy():
222-
(fr, frstar) = KM.kanes_equations([(P, R)], [pP])
219+
(fr, frstar) = KM.kanes_equations([pP], [(P, R)])
223220

224221
# Set the operating point to be straight down, and non-moving
225222
q_op = {q1: L, q2: 0}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy