Skip to content

Commit

Permalink
define _PathLike macro
Browse files Browse the repository at this point in the history
  • Loading branch information
John Lambert committed Jun 30, 2021
1 parent 59a971f commit bc72466
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions argoverse/utils/sim2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from argoverse.utils.helpers import assert_np_array_shape
from argoverse.utils.json_utils import save_json_dict

_PathLike = Union[str, "os.PathLike[str]"]


class Sim2:
"""Implements the Similarity(2) class."""
Expand Down Expand Up @@ -145,7 +147,7 @@ def transform_point_cloud(self, point_cloud: np.ndarray) -> np.ndarray:
"""Alias for `transform_from()`, for synchrony w/ API provided by SE(2) and SE(3) classes."""
return self.transform_from(point_cloud)

def save_as_json(self, save_fpath: Union[str, "os.PathLike[str]"]) -> None:
def save_as_json(self, save_fpath: _PathLike) -> None:
"""Save the Sim(2) object to a JSON representation on disk.
Args:
Expand All @@ -159,7 +161,7 @@ def save_as_json(self, save_fpath: Union[str, "os.PathLike[str]"]) -> None:
save_json_dict(save_fpath, dict_for_serialization)

@classmethod
def from_json(cls, json_fpath: Union[str, "os.PathLike[str]"]) -> "Sim2":
def from_json(cls, json_fpath: _PathLike) -> "Sim2":
"""Generate class inst. from a JSON file containing Sim(2) parameters as flattened matrices (row-major)."""
with open(json_fpath, "r") as f:
json_data = json.load(f)
Expand Down

0 comments on commit bc72466

Please sign in to comment.