Skip to content

Commit

Permalink
Pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kashton-bdai committed Dec 15, 2023
1 parent 24f4444 commit f73659c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
3 changes: 2 additions & 1 deletion vlfm/mapping/obstacle_map.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.

from typing import Any, Union

import cv2
import numpy as np
from typing import Union, Any
from frontier_exploration.frontier_detection import detect_frontier_waypoints
from frontier_exploration.utils.fog_of_war import reveal_fog_of_war

Expand Down
4 changes: 3 additions & 1 deletion vlfm/mapping/traj_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def draw_trajectory(
img = self._draw_agent(img, camera_positions[-1], camera_yaw)
return img

def _draw_path(self, img: np.ndarray, camera_positions: Union[np.ndarray, List[np.ndarray]]) -> np.ndarray:
def _draw_path(
self, img: np.ndarray, camera_positions: Union[np.ndarray, List[np.ndarray]]
) -> np.ndarray:
"""Draws the path on the image and returns it"""
if len(camera_positions) < 2:
return img
Expand Down
2 changes: 1 addition & 1 deletion vlfm/policy/reality_policies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.

from dataclasses import dataclass
from typing import Any, Dict, List, Tuple, Union, Optional
from typing import Any, Dict, List, Tuple, Union

import numpy as np
import torch
Expand Down
2 changes: 1 addition & 1 deletion vlfm/policy/utils/non_habitat_policy/resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# https://github.com/facebookresearch/habitat-lab/blob/main/habitat-baselines/habitat_baselines/rl/ddppo/policy/resnet.py
# This is a filtered down version that only support ResNet-18

from typing import List, Optional, Type, cast
from typing import List, Optional, Type

from torch import Tensor
from torch import nn as nn
Expand Down
9 changes: 5 additions & 4 deletions vlfm/policy/utils/non_habitat_policy/rnn_state_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# https://github.com/facebookresearch/habitat-lab/blob/main/habitat-baselines/habitat_baselines/rl/models/rnn_state_encoder.py
# This is a filtered down version that only supports LSTM

from typing import Dict, Optional, Tuple, Any
from typing import Any, Dict, Optional, Tuple

import torch
import torch.nn as nn
Expand All @@ -20,6 +20,7 @@ class RNNStateEncoder(nn.Module):
is that it takes an addition masks input that resets the hidden state between two adjacent
timesteps to handle episodes ending in the middle of a rollout.
"""

def __init__(
self,
input_size: int,
Expand Down Expand Up @@ -131,16 +132,16 @@ def __init__(
):
super().__init__(input_size, hidden_size, num_layers)

# Note: Type handling mypy errors in pytorch libraries prevent
# Note: Type handling mypy errors in pytorch libraries prevent
# directly setting hidden_states type
def pack_hidden(
self, hidden_states: Any # type is Tuple[torch.Tensor, torch.Tensor]
self, hidden_states: Any # type is Tuple[torch.Tensor, torch.Tensor]
) -> torch.Tensor:
return torch.cat(hidden_states, 0)

def unpack_hidden(
self, hidden_states: torch.Tensor
) -> Any: # type is Tuple[torch.Tensor, torch.Tensor]
) -> Any: # type is Tuple[torch.Tensor, torch.Tensor]
lstm_states = torch.chunk(hidden_states.contiguous(), 2, 0)
return (lstm_states[0], lstm_states[1])

Expand Down
4 changes: 1 addition & 3 deletions vlfm/reality/pointnav_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def _compute_velocities(self, action: Dict[str, Any]) -> Tuple[float, float]:
lin_vel = lin_dist / self._time_step
return ang_vel, lin_vel

def _compute_displacements(
self, action: Dict[str, Any]
) -> Tuple[float, float]:
def _compute_displacements(self, action: Dict[str, Any]) -> Tuple[float, float]:
displacements = []
for action_key, max_dist in (
("angular", self._max_ang_dist),
Expand Down
2 changes: 1 addition & 1 deletion vlfm/utils/geometry_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) 2023 Boston Dynamics AI Institute LLC. All rights reserved.

import math
from typing import Tuple, Union
from typing import Tuple

import numpy as np

Expand Down

0 comments on commit f73659c

Please sign in to comment.