From d2fcd7a4f947ecd33de070da9a2db89fbe86a4ef Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 18 Aug 2023 14:26:14 +0200 Subject: [PATCH] chore: extract statement into member function to improve readability --- osm4gpd/parse.py | 6 +++--- osm4gpd/unpacked/base.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/osm4gpd/parse.py b/osm4gpd/parse.py index 50ee293..f312359 100644 --- a/osm4gpd/parse.py +++ b/osm4gpd/parse.py @@ -101,7 +101,7 @@ def filter(self, *, tags: set[str]) -> OSMFile: def consolidate(self) -> gpd.GeoDataFrame: _node_parts = [ - consolidate_nodes(nodes) for nodes in self.nodes if len(nodes.ids) > 0 + consolidate_nodes(nodes) for nodes in self.nodes if not nodes.is_empty() ] if len(_node_parts) > 0: nodes = pd.concat(_node_parts) @@ -111,7 +111,7 @@ def consolidate(self) -> gpd.GeoDataFrame: _way_parts = [ consolidate_ways(ways, nodes=nodes) for ways in self.ways - if len(ways.ids) > 0 + if not ways.is_empty() ] if len(_way_parts) > 0: @@ -122,7 +122,7 @@ def consolidate(self) -> gpd.GeoDataFrame: _relation_parts = [ consolidate_relations(relations, ways=ways, nodes=nodes) for relations in self.relations - if len(relations.ids) > 0 + if not relations.is_empty() ] if len(_relation_parts) > 0: diff --git a/osm4gpd/unpacked/base.py b/osm4gpd/unpacked/base.py index 2fe5197..72e4954 100644 --- a/osm4gpd/unpacked/base.py +++ b/osm4gpd/unpacked/base.py @@ -13,3 +13,6 @@ class BaseGroup: version: list[int] visible: list[bool] changeset: list[int] + + def is_empty(self) -> bool: + return len(self.ids) == 0