Skip to content

Commit

Permalink
Fixed some mypy issues. Added drm to dev requirements so unit tests p…
Browse files Browse the repository at this point in the history
…ass.
  • Loading branch information
luisenp committed Sep 8, 2022
1 parent 8fa6736 commit 07967bd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
10 changes: 5 additions & 5 deletions examples/homography_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from torch.utils.data import DataLoader, Dataset

import theseus as th
from theseus.third_party.easyaug import RandomGeoAug, GeoAugParam, RandomPhotoAug
from theseus.third_party.easyaug import GeoAugParam, RandomGeoAug, RandomPhotoAug
from theseus.third_party.utils import grid_sample

FONT = cv2.FONT_HERSHEY_DUPLEX
Expand All @@ -36,10 +36,10 @@ def prepare_data():
dataset_root = os.path.join(os.getcwd(), "data")
chunks = [
"revisitop1m.1",
#"revisitop1m.2", # Uncomment for more data.
#"revisitop1m.3",
#"revisitop1m.4",
#"revisitop1m.5",
# "revisitop1m.2", # Uncomment for more data.
# "revisitop1m.3",
# "revisitop1m.4",
# "revisitop1m.5",
]
dataset_paths = []
for chunk in chunks:
Expand Down
1 change: 1 addition & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mypy>=0.910
nox==2020.8.22
pre-commit>=2.9.2
isort>=5.6.4
differentiable-robot-model>=0.2.3
types-PyYAML==5.4.3
numdifftools>=0.9.40
mock>=4.0.3
Expand Down
6 changes: 4 additions & 2 deletions theseus/embodied/kinematics/kinematics_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def __init__(self, urdf_path: str):
try:
import differentiable_robot_model as drm
except ModuleNotFoundError as e:
print("UrdfRobotModel requires installing differentiable-robot-model.")
print("Please run `pip install differentiable-robot-model`.")
print(
"UrdfRobotModel requires installing differentiable-robot-model. "
"Please run `pip install differentiable-robot-model`."
)
raise e

self.drm_model = drm.DifferentiableRobotModel(urdf_path)
Expand Down
2 changes: 1 addition & 1 deletion theseus/optimizer/linear_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(
row_ptr: np.ndarray,
num_rows: int,
num_cols: int,
dtype: np.dtype = np.float_,
dtype: np.dtype = np.float_, # type: ignore
):
self.col_ind = col_ind
self.row_ptr = row_ptr
Expand Down
2 changes: 1 addition & 1 deletion theseus/theseus_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def jacobians(self) -> Tuple[List[torch.Tensor], torch.Tensor]:
return [self.var.project(euclidean_grad, is_sparse=True)], self.error()

def dim(self) -> int:
return np.prod(self.var.tensor.shape[1:])
return int(np.prod(self.var.tensor.shape[1:]))

def _copy_impl(self, new_name: Optional[str] = None) -> "CostFunction":
return _DLMPerturbation(
Expand Down
10 changes: 5 additions & 5 deletions theseus/utils/examples/tactile_pose_estimation/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def __init__(
stop = max(int(np.ceil(num_episodes * val_ratio)), 2)
idx = order[:stop] if data_mode == "val" else order[stop:]

self.img_feats = data["img_feats"][idx]
self.eff_poses = data["eff_poses"][idx]
self.obj_poses = data["obj_poses"][idx]
self.contact_episode = data["contact_episode"][idx]
self.contact_flag = data["contact_flag"][idx]
self.img_feats = data["img_feats"][idx] # type: ignore
self.eff_poses = data["eff_poses"][idx] # type: ignore
self.obj_poses = data["obj_poses"][idx] # type: ignore
self.contact_episode = data["contact_episode"][idx] # type: ignore
self.contact_flag = data["contact_flag"][idx] # type: ignore
# Check sizes of the attributes assigned above
self.dataset_size: int = -1
for key in data:
Expand Down

0 comments on commit 07967bd

Please sign in to comment.