From bc7246670febe2bc628298ccb7b15a7286cab2cb Mon Sep 17 00:00:00 2001 From: John Lambert Date: Wed, 30 Jun 2021 16:10:26 -0400 Subject: [PATCH] define _PathLike macro --- argoverse/utils/sim2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/argoverse/utils/sim2.py b/argoverse/utils/sim2.py index c90e5d4c..fb41892d 100644 --- a/argoverse/utils/sim2.py +++ b/argoverse/utils/sim2.py @@ -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.""" @@ -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: @@ -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)