Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set float64 #39

Merged
merged 5 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/adam/pytorch/torch_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,24 @@ def T(self) -> "TorchLike":
Returns:
TorchLike: transpose of array
"""
return TorchLike(self.array.T)
if len(self.array.shape) != 1:
return TorchLike(self.array.mT)
x = self.array
return TorchLike(x.permute(*torch.arange(x.ndim - 1, -1, -1)))

def __matmul__(self, other: Union["TorchLike", ntp.ArrayLike]) -> "TorchLike":
"""Overrides @ operator"""
if type(self) is type(other):
return TorchLike(self.array @ other.array)
return TorchLike(self.array @ other.array.float())
else:
return TorchLike(self.array @ torch.FloatTensor(other))
return TorchLike(self.array @ torch.tensor(other).float())

def __rmatmul__(self, other: Union["TorchLike", ntp.ArrayLike]) -> "TorchLike":
"""Overrides @ operator"""
if type(self) is type(other):
return TorchLike(other.array @ self.array)
else:
return TorchLike(torch.FloatTensor(other) @ self.array)
return TorchLike(torch.tensor(other).float() @ self.array)

def __mul__(self, other: Union["TorchLike", ntp.ArrayLike]) -> "TorchLike":
"""Overrides * operator"""
Expand Down
2 changes: 2 additions & 0 deletions tests/test_CasADi_computations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from adam.casadi import KinDynComputations
from adam.geometry import utils

np.random.seed(42)

model_path = gym_ignition_models.get_model_file("iCubGazeboV2_5")

joints_name_list = [
Expand Down
4 changes: 4 additions & 0 deletions tests/test_Jax_computations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
import jax.numpy as jnp
import numpy as np
import pytest
from jax import config

from adam.geometry import utils
from adam.jax import KinDynComputations

np.random.seed(42)
config.update("jax_enable_x64", True)

model_path = gym_ignition_models.get_model_file("iCubGazeboV2_5")

joints_name_list = [
Expand Down
2 changes: 2 additions & 0 deletions tests/test_NumPy_computations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from adam.geometry import utils
from adam.numpy import KinDynComputations

np.random.seed(42)

model_path = gym_ignition_models.get_model_file("iCubGazeboV2_5")

joints_name_list = [
Expand Down
3 changes: 3 additions & 0 deletions tests/test_pytorch_computations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
from adam.geometry import utils
from adam.pytorch import KinDynComputations

np.random.seed(42)
torch.set_default_dtype(torch.float64)

model_path = gym_ignition_models.get_model_file("iCubGazeboV2_5")

joints_name_list = [
Expand Down