Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
fbailly committed Mar 29, 2021
1 parent ed9234c commit fdbcb12
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions test/binding/Python3/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,40 @@ def test_np_mx_to_generalized():
# --- Options --- #
def test_imu_to_array():
m = biorbd.Model("../../models/IMUandCustomRT/pyomecaman_withIMUs.bioMod")
q = np.zeros( (m.nbQ(), ) )
q = np.zeros((m.nbQ(),))

if biorbd.currentLinearAlgebraBackend() == 1:
from casadi import MX

q_sym = MX.sym("q", m.nbQ(), 1)
imu_func = biorbd.to_casadi_func("imu", m.IMU, q_sym)
imu = imu_func(q)[:, :4]

else:
imu = m.IMU(q)[0].to_array()

np.testing.assert_almost_equal(imu, np.array([
[0.99003329, -0.09933467, 0.09983342, 0.26719],
[0.10925158, 0.98903828, -0.09933467, 0.04783],
[-0.08887169, 0.10925158, 0.99003329, -0.20946],
[0., 0., 0., 1.]]))
np.testing.assert_almost_equal(
imu,
np.array(
[
[0.99003329, -0.09933467, 0.09983342, 0.26719],
[0.10925158, 0.98903828, -0.09933467, 0.04783],
[-0.08887169, 0.10925158, 0.99003329, -0.20946],
[0.0, 0.0, 0.0, 1.0],
]
),
)


def test_vector3d():
biorbd_model = biorbd.Model()
vec = np.random.rand(3, )
vec = np.random.rand(
3,
)
biorbd_model.setGravity(vec)

if biorbd.currentLinearAlgebraBackend() == 1:
from casadi import MX

vec = MX.ones(3, 1)
biorbd_model.setGravity(vec)


0 comments on commit fdbcb12

Please sign in to comment.