Skip to content

Commit aadf302

Browse files
committed
Fix identity comparisons in Python tests
1 parent 1ede1b6 commit aadf302

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

python/tests/unit/collision/test_collision.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def collision_groups_tester(cd):
2222
group = cd.createCollisionGroup()
2323
group.addShapeFrame(simple_frame1)
2424
group.addShapeFrame(simple_frame2)
25-
assert group.getNumShapeFrames() is 2
25+
assert group.getNumShapeFrames() == 2
2626

2727
#
2828
# ( s1,s2 ) collision!
@@ -44,19 +44,19 @@ def collision_groups_tester(cd):
4444

4545
group.collide(option, result)
4646
assert not result.isCollision()
47-
assert result.getNumContacts() is 0
47+
assert result.getNumContacts() == 0
4848

4949
option.enableContact = True
5050
simple_frame2.setTranslation([1.99, 0, 0])
5151

5252
group.collide(option, result)
5353
assert result.isCollision()
54-
assert result.getNumContacts() is not 0
54+
assert result.getNumContacts() != 0
5555

5656
# Repeat the same test with BodyNodes instead of SimpleFrames
5757

5858
group.removeAllShapeFrames()
59-
assert group.getNumShapeFrames() is 0
59+
assert group.getNumShapeFrames() == 0
6060

6161
skel1 = dart.dynamics.Skeleton()
6262
skel2 = dart.dynamics.Skeleton()
@@ -75,7 +75,7 @@ def collision_groups_tester(cd):
7575
group.addShapeFramesOf(body1)
7676
group.addShapeFramesOf(body2)
7777

78-
assert group.getNumShapeFrames() is 2
78+
assert group.getNumShapeFrames() == 2
7979

8080
assert group.collide()
8181

@@ -87,14 +87,14 @@ def collision_groups_tester(cd):
8787
joint2.setPosition(3, 0)
8888

8989
group.removeAllShapeFrames()
90-
assert group.getNumShapeFrames() is 0
90+
assert group.getNumShapeFrames() == 0
9191
group2 = cd.createCollisionGroup()
9292

9393
group.addShapeFramesOf(body1)
9494
group2.addShapeFramesOf(body2)
9595

96-
assert group.getNumShapeFrames() is 1
97-
assert group2.getNumShapeFrames() is 1
96+
assert group.getNumShapeFrames() == 1
97+
assert group2.getNumShapeFrames() == 1
9898

9999
assert group.collide(group2)
100100

python/tests/unit/dynamics/test_inverse_kinematics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def test_solve_for_free_joint():
2626
error_method = ik.getErrorMethod()
2727
assert error_method.getMethodName() == "TaskSpaceRegion"
2828
[lb, ub] = error_method.getBounds()
29-
assert len(lb) is 6
30-
assert len(ub) is 6
29+
assert len(lb) == 6
30+
assert len(ub) == 6
3131
error_method.setBounds(np.ones(6) * -1e-8, np.ones(6) * 1e-8)
3232
[lb, ub] = error_method.getBounds()
3333
assert lb == pytest.approx(-1e-8)

python/tests/unit/dynamics/test_meta_skeleton.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ def test_basic():
1919

2020
chain1 = dart.dynamics.Chain(shoulder, elbow, False, "midchain")
2121
assert chain1 is not None
22-
assert chain1.getNumBodyNodes() is 2
22+
assert chain1.getNumBodyNodes() == 2
2323

2424
chain2 = dart.dynamics.Chain(shoulder, elbow, True, "midchain")
2525
assert chain2 is not None
26-
assert chain2.getNumBodyNodes() is 3
26+
assert chain2.getNumBodyNodes() == 3
2727

28-
assert len(kr5.getPositions()) is not 0
29-
assert kr5.getNumJoints() is not 0
28+
assert len(kr5.getPositions()) != 0
29+
assert kr5.getNumJoints() != 0
3030
assert kr5.getRootJoint() is not None
31-
assert len(kr5.getRootJoint().getPositions()) is 0
31+
assert len(kr5.getRootJoint().getPositions()) == 0
3232

3333
rootBody = kr5.getBodyNode(0)
3434
assert rootBody is not None

python/tests/unit/math/test_random.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_seed():
3030

3131
for i in range(N):
3232
Random.setSeed(i)
33-
assert Random.getSeed() is i
33+
assert Random.getSeed() == i
3434
assert Random.uniform(min, max) == pytest.approx(first[i], tol)
3535
assert Random.uniform(min, max) == pytest.approx(second[i], tol)
3636
assert Random.uniform(min, max) == pytest.approx(third[i], tol)

python/tests/unit/optimizer/test_optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def evalGradient(self, x, grad):
3232

3333
def test_gradient_descent_solver():
3434
prob = dart.optimizer.Problem(2)
35-
assert prob.getDimension() is 2
35+
assert prob.getDimension() == 2
3636

3737
prob.setLowerBounds([-1e100, 0])
3838
prob.setInitialGuess([1.234, 5.678])
@@ -60,7 +60,7 @@ def test_nlopt_solver():
6060
return
6161

6262
prob = dart.optimizer.Problem(2)
63-
assert prob.getDimension() is 2
63+
assert prob.getDimension() == 2
6464

6565
prob.setLowerBounds([-1e100, 0])
6666
prob.setInitialGuess([1.234, 5.678])

python/tests/unit/simulation/test_world.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
def test_empty_world():
88
world = dart.simulation.World("my world")
9-
assert world.getNumSkeletons() is 0
10-
assert world.getNumSimpleFrames() is 0
9+
assert world.getNumSkeletons() == 0
10+
assert world.getNumSimpleFrames() == 0
1111

1212

1313
def test_collision_detector_change():

0 commit comments

Comments
 (0)