diff --git a/kaizen/map/matcher.py b/kaizen/map/matcher.py index 396f5fa..a5d3f8b 100644 --- a/kaizen/map/matcher.py +++ b/kaizen/map/matcher.py @@ -56,9 +56,13 @@ def add( :param trace_information: information of the trace point for which the candidate was obtained :return: """ - assert all( - v is not None for v in [x, y, distance, road_information, trace_information] - ), "Expected ['x', 'y', 'candidate_id', 'distance', 'road_information', 'trace_information'] to be not None" + assert None not in { + x, + y, + distance, + road_information, + trace_information, + }, "Expected ['x', 'y', 'candidate_id', 'distance', 'road_information', 'trace_information'] to be not None" assert type(distance) is float, ( "Expected type to be 'float'," "got %s", @@ -71,7 +75,7 @@ def add( assert hasattr(road_information.property, "u") and hasattr( road_information.property, "v" - ), "Expected road to have start node 'u' and end node 'v'" "for every edge" + ), ("Expected road to have start node 'u' and end node 'v'" "for every edge") if isinstance(trace_information, dict): trace_information = SimpleNamespace(**trace_information) diff --git a/kaizen/map/navigator.py b/kaizen/map/navigator.py index e933003..7b58fd3 100644 --- a/kaizen/map/navigator.py +++ b/kaizen/map/navigator.py @@ -243,13 +243,17 @@ def path_finder_from_traces( filter_trace: bool = True, area_simplify: float = 0, ): - assert all( - v is not None - for v in [grid, traces, search_space_threshold, filter_trace, area_simplify] - ), ( + assert None not in { + grid, + traces, + search_space_threshold, + filter_trace, + area_simplify, + }, ( "Expected ['grid', 'trace', 'search_space_threshold', 'filter_trace', 'area_simplify'']" "to be not NONE" ) + assert isinstance(grid, Grid), ( "Expected 'grid' to be instance of 'Grid'" "got %s", (type(grid),), @@ -288,10 +292,13 @@ def path_finder_from_trace( filter_trace: bool = True, area_simplify: float = 0, ): - assert all( - v is not None - for v in [grid, trace, search_space_threshold, filter_trace, area_simplify] - ), ( + assert None not in { + grid, + trace, + search_space_threshold, + filter_trace, + area_simplify, + }, ( "Expected ['grid', 'trace', 'search_space_threshold', 'filter_trace', 'area_simplify'']" "to be not NONE" ) diff --git a/kaizen/map/road.py b/kaizen/map/road.py index 12ad543..7d1b110 100644 --- a/kaizen/map/road.py +++ b/kaizen/map/road.py @@ -1,7 +1,6 @@ from collections import OrderedDict, namedtuple from types import SimpleNamespace -import geopandas import networkx as nx import rtree from geopandas import GeoDataFrame @@ -32,11 +31,12 @@ def add( feature_geometry: dict, weight: float, ): - - assert all( - v is not None - for v in [feature_id, feature_property, feature_geometry, weight] - ), "Expected ['feature_id', 'feature_property', 'feature_geometry', 'weight'] to be not None" + assert None not in { + feature_id, + feature_property, + feature_geometry, + weight, + }, "Expected ['feature_id', 'feature_property', 'feature_geometry', 'weight'] to be not None" assert type(feature_id) is int, ( "Expected 'feature_id' type to be 'int'," "got %s", diff --git a/kaizen/map/trace.py b/kaizen/map/trace.py index 2b99633..25023a3 100644 --- a/kaizen/map/trace.py +++ b/kaizen/map/trace.py @@ -55,9 +55,13 @@ def add(self, x, y, trace_point_id, trace_id, **kwargs): :param kwargs: :return: """ - assert all( - v is not None for v in [x, y, trace_point_id, trace_id] - ), "Expected ['x', 'y', 'trace_point_id', 'trace_id'] to be not None" + assert None not in { + x, + y, + trace_point_id, + trace_id, + }, "Expected ['x', 'y', 'trace_point_id', 'trace_id'] to be not None" + self[trace_id].append( TracePoint(x, y, trace_point_id, trace_id, SimpleNamespace(**kwargs)) )