Skip to content

Commit 940471b

Browse files
committed
[WIP] Remove _array usage
1 parent e904bf9 commit 940471b

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

tests/unit/test_models.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def test_symbolic2numeric_no_external_wrench(model_name: str, model: Callable, c
252252
)
253253

254254
U = cmd[i + (...,)]
255-
x_dot_symbolic2numeric = xp.asarray(model_symbolic2numeric(X._array, U._array))
255+
x_dot_symbolic2numeric = xp.asarray(model_symbolic2numeric(np.asarray(X), np.asarray(U)))
256256
x_dot_symbolic2numeric = xp.squeeze(x_dot_symbolic2numeric, axis=-1)
257257
assert np.allclose(x_dot, x_dot_symbolic2numeric), (
258258
"Symbolic and numeric model have different output"
@@ -320,11 +320,8 @@ def test_symbolic2numeric_external_wrench(model_name: str, model: Callable, conf
320320
)
321321

322322
U = cmd[i + (...,)]
323-
x_dot_symbolic2numeric = xp.asarray(model_symbolic2numeric(X._array, U._array))
323+
x_dot_symbolic2numeric = xp.asarray(model_symbolic2numeric(np.asarray(X), np.asarray(U)))
324324
x_dot_symbolic2numeric = xp.squeeze(x_dot_symbolic2numeric, axis=-1)
325-
print(x_dot)
326-
print(x_dot_symbolic2numeric)
327-
print(x_dot - x_dot_symbolic2numeric)
328325
assert np.allclose(x_dot, x_dot_symbolic2numeric), (
329326
"Symbolic and numeric model have different output"
330327
)
@@ -368,7 +365,7 @@ def test_numeric_batching(model_name: str, model: Callable, config: str):
368365
constants,
369366
rotor_vel=rotor_vel[i + (...,)] if rotor_vel is not None else None,
370367
)
371-
x_dot_non_batched = xp.concat([x for x in x_dot_non_batched if x is not None])
368+
x_dot_non_batched = xp.concat([x for x in x_dot_non_batched if x is not None], axis=-1)
372369

373370
assert np.allclose(x_dot_batched[i + (...,)], x_dot_batched_1[0, ...], atol=2e-8), (
374371
"Batching failed for batch size 1"
@@ -399,13 +396,13 @@ def test_numeric_jit(model_name: str, model: Callable, config: str):
399396
rotor_vel=rotor_vel if rotor_vel is not None else None,
400397
)
401398

402-
jppos, jpquat = jp.asarray(pos._array), jp.asarray(quat._array)
403-
jpvel, jpang_vel = jp.asarray(vel._array), jp.asarray(ang_vel._array)
399+
jppos, jpquat = jp.asarray(np.asarray(pos)), jp.asarray(np.asarray(quat))
400+
jpvel, jpang_vel = jp.asarray(np.asarray(vel)), jp.asarray(np.asarray(ang_vel))
404401
if rotor_vel is None:
405402
jprotor_vel = None
406403
else:
407-
jprotor_vel = jp.asarray(rotor_vel._array)
408-
jpcmd = jp.asarray(cmd._array)
404+
jprotor_vel = jp.asarray(np.asarray(rotor_vel))
405+
jpcmd = jp.asarray(np.asarray(cmd))
409406

410407
model_jit = jax.jit(model)
411408

0 commit comments

Comments
 (0)