Skip to content

Commit

Permalink
Merge pull request #726 from borglab/fix/numpy-deprecation
Browse files Browse the repository at this point in the history
Fix numpy deprecation warnings
  • Loading branch information
dellaert authored Mar 24, 2021
2 parents 74e4fc3 + 73b0436 commit 91f99b5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion python/gtsam/examples/ImuFactorISAM2Example.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

def vector3(x, y, z):
"""Create 3d double numpy array."""
return np.array([x, y, z], dtype=np.float)
return np.array([x, y, z], dtype=float)


g = 9.81
Expand Down
12 changes: 6 additions & 6 deletions python/gtsam/examples/PlanarManipulatorExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

def vector3(x, y, z):
"""Create 3D double numpy array."""
return np.array([x, y, z], dtype=np.float)
return np.array([x, y, z], dtype=float)


def compose(*poses):
Expand Down Expand Up @@ -94,7 +94,7 @@ def jacobian(self, q):
[-self.L1*math.sin(q[0]) - self.L2*math.sin(a)-self.L3*math.sin(b),
-self.L1*math.sin(a)-self.L3*math.sin(b),
- self.L3*math.sin(b)],
[1, 1, 1]], np.float)
[1, 1, 1]], float)

def poe(self, q):
""" Forward kinematics.
Expand Down Expand Up @@ -230,12 +230,12 @@ def test_fk_arm(self):
def test_jacobian(self):
"""Test Jacobian calculation."""
# at rest
expected = np.array([[-9.5, -6, -2.5], [0, 0, 0], [1, 1, 1]], np.float)
expected = np.array([[-9.5, -6, -2.5], [0, 0, 0], [1, 1, 1]], float)
J = self.arm.jacobian(Q0)
np.testing.assert_array_almost_equal(J, expected)

# at -90, 90, 0
expected = np.array([[-6, -6, -2.5], [3.5, 0, 0], [1, 1, 1]], np.float)
expected = np.array([[-6, -6, -2.5], [3.5, 0, 0], [1, 1, 1]], float)
J = self.arm.jacobian(Q2)
np.testing.assert_array_almost_equal(J, expected)

Expand Down Expand Up @@ -280,13 +280,13 @@ def test_ik(self):
def test_manipulator_jacobian(self):
"""Test Jacobian calculation."""
# at rest
expected = np.array([[0, 3.5, 7], [0, 0, 0], [1, 1, 1]], np.float)
expected = np.array([[0, 3.5, 7], [0, 0, 0], [1, 1, 1]], float)
J = self.arm.manipulator_jacobian(Q0)
np.testing.assert_array_almost_equal(J, expected)

# at -90, 90, 0
expected = np.array(
[[0, 0, 3.5], [0, -3.5, -3.5], [1, 1, 1]], np.float)
[[0, 0, 3.5], [0, -3.5, -3.5], [1, 1, 1]], float)
J = self.arm.manipulator_jacobian(Q2)
np.testing.assert_array_almost_equal(J, expected)

Expand Down
2 changes: 1 addition & 1 deletion python/gtsam/examples/Pose2SLAMExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

def vector3(x, y, z):
"""Create 3d double numpy array."""
return np.array([x, y, z], dtype=np.float)
return np.array([x, y, z], dtype=float)

# Create noise models
PRIOR_NOISE = gtsam.noiseModel.Diagonal.Sigmas(vector3(0.3, 0.3, 0.1))
Expand Down
2 changes: 1 addition & 1 deletion python/gtsam/examples/Pose2SLAMExample_g2o.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

def vector3(x, y, z):
"""Create 3d double numpy array."""
return np.array([x, y, z], dtype=np.float)
return np.array([x, y, z], dtype=float)


parser = argparse.ArgumentParser(
Expand Down
2 changes: 1 addition & 1 deletion python/gtsam/examples/Pose3SLAMExample_g2o.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def vector6(x, y, z, a, b, c):
"""Create 6d double numpy array."""
return np.array([x, y, z, a, b, c], dtype=np.float)
return np.array([x, y, z, a, b, c], dtype=float)


parser = argparse.ArgumentParser(
Expand Down
6 changes: 3 additions & 3 deletions python/gtsam/examples/PreintegrationExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ def defaultParams(g):
kGyroSigma = math.radians(0.5) / 60 # 0.5 degree ARW
kAccelSigma = 0.1 / 60 # 10 cm VRW
params.setGyroscopeCovariance(
kGyroSigma ** 2 * np.identity(3, np.float))
kGyroSigma ** 2 * np.identity(3, float))
params.setAccelerometerCovariance(
kAccelSigma ** 2 * np.identity(3, np.float))
kAccelSigma ** 2 * np.identity(3, float))
params.setIntegrationCovariance(
0.0000001 ** 2 * np.identity(3, np.float))
0.0000001 ** 2 * np.identity(3, float))
return params

def __init__(self, twist=None, bias=None, dt=1e-2):
Expand Down
4 changes: 2 additions & 2 deletions python/gtsam/tests/test_SO4.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def test_constructor(self):

def test_retract(self):
"""Test retraction to manifold."""
v = np.zeros((6,), np.float)
v = np.zeros((6,), float)
actual = I4.retract(v)
self.assertTrue(actual.equals(I4, 1e-9))

def test_local(self):
"""Check localCoordinates for trivial case."""
v0 = np.zeros((6,), np.float)
v0 = np.zeros((6,), float)
actual = I4.localCoordinates(I4)
np.testing.assert_array_almost_equal(actual, v0)

Expand Down
4 changes: 2 additions & 2 deletions python/gtsam/tests/test_SOn.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def test_constructor(self):

def test_retract(self):
"""Test retraction to manifold."""
v = np.zeros((6,), np.float)
v = np.zeros((6,), float)
actual = I4.retract(v)
self.assertTrue(actual.equals(I4, 1e-9))

def test_local(self):
"""Check localCoordinates for trivial case."""
v0 = np.zeros((6,), np.float)
v0 = np.zeros((6,), float)
actual = I4.localCoordinates(I4)
np.testing.assert_array_almost_equal(actual, v0)

Expand Down

0 comments on commit 91f99b5

Please sign in to comment.