Skip to content

Commit

Permalink
[#35] Formatting, clean up lcss representation
Browse files Browse the repository at this point in the history
  • Loading branch information
machallboyd committed May 13, 2022
1 parent 0715337 commit 1e92ead
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
16 changes: 9 additions & 7 deletions mappymatch/maps/nx/nx_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,20 @@ def __init__(self, graph: nx.MultiDiGraph):
self._roads = self._build_rtree()

def _strip_verbose_data(self):
too_verbose = ('_nodes', '_roads')
base_dict = {k: v for k, v in self.__dict__.items() if not k in too_verbose}
too_verbose = ("_nodes", "_roads")
base_dict = {
k: v for k, v in self.__dict__.items() if not k in too_verbose
}
for label in too_verbose:
member_len = len(eval(f'self.{label}'))
base_dict[label] = f'list of {member_len} elements'
return ', '.join(f'{k}: {v}' for k, v in base_dict.items())
member_len = len(eval(f"self.{label}"))
base_dict[label] = f"list of {member_len} elements"
return ", ".join(f"{k}: {v}" for k, v in base_dict.items())

def __str__(self):
return 'NXMap(' + self._strip_verbose_data() + ')'
return "NXMap(" + self._strip_verbose_data() + ")"

def __repr__(self):
return 'NXMap(' + self._strip_verbose_data() + ')'
return "NXMap(" + self._strip_verbose_data() + ")"

def _build_rtree(self) -> List[Road]:
road_lookup = []
Expand Down
11 changes: 9 additions & 2 deletions mappymatch/matchers/lcss/lcss.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,18 @@ def __init__(
self.random_cuts = random_cuts
self.distance_threshold = distance_threshold

def _string_rep(self):
return (
"LCSSMatcher("
+ ", ".join(f"{k}: {v}" for k, v in self.__dict__.items())
+ ")"
)

def __repr__(self):
return(repr(self.__dict__))
return self._string_rep()

def __str__(self):
return(str(self.__dict__))
return self._string_rep()

def match_trace(self, trace: Trace) -> MatchResult:
def _join_segment(a: TrajectorySegment, b: TrajectorySegment):
Expand Down

0 comments on commit 1e92ead

Please sign in to comment.