From dd6042c547a769cae10377942d5c657a66fc351f Mon Sep 17 00:00:00 2001 From: Christian Ledermann Date: Fri, 2 Feb 2024 16:35:24 +0000 Subject: [PATCH] ruff fix --- pygeoif/factories.py | 3 +++ pygeoif/feature.py | 2 ++ pygeoif/geometry.py | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/pygeoif/factories.py b/pygeoif/factories.py index b0f61450..ff8e32ee 100644 --- a/pygeoif/factories.py +++ b/pygeoif/factories.py @@ -130,6 +130,7 @@ def shape( >>> geom2 = shape(geom) >>> geom == geom2 True + """ type_map = { "Point": Point, @@ -173,6 +174,7 @@ def num(number: str) -> float: Returns ------- float or an integer if the string can be converted to an integer + """ f = float(number) return int(f) if int(f) == f else f @@ -328,6 +330,7 @@ def mapping( >>> pt = Point(0, 0) >>> mapping(pt) {'type': 'Point', 'bbox': (0, 0, 0, 0), 'coordinates': (0, 0)} + """ return ob.__geo_interface__ diff --git a/pygeoif/feature.py b/pygeoif/feature.py index 0669d181..90747f29 100644 --- a/pygeoif/feature.py +++ b/pygeoif/feature.py @@ -75,6 +75,7 @@ class Feature: {'Name': 'Sample Point', 'Other': 'Other Data'} >>> a.properties['Name'] 'Sample Point' + """ def __init__( @@ -168,6 +169,7 @@ class FeatureCollection: {'geometry': {'type': 'Point', 'coordinates': (1.0, -1.0)}, 'type': 'Feature', 'properties': {'Other': 'Other Data2', 'Name': 'Sample Point2'}}]} + """ def __init__(self, features: Sequence[Feature]) -> None: diff --git a/pygeoif/geometry.py b/pygeoif/geometry.py index 9b862777..b4f4e4ad 100644 --- a/pygeoif/geometry.py +++ b/pygeoif/geometry.py @@ -233,6 +233,7 @@ class Point(_Geometry): -1.0 >>> p.x 1.0 + """ _geoms: PointType @@ -245,6 +246,7 @@ def __init__(self, x: float, y: float, z: Optional[float] = None) -> None: ---------- 2 or 3 coordinate parameters: x, y, [z] : float Easting, northing, and elevation. + """ object.__setattr__( self, @@ -339,6 +341,7 @@ class LineString(_Geometry): ---------- geoms : sequence A sequence of Points + """ _geoms: Tuple[Point, ...] @@ -357,6 +360,7 @@ def __init__(self, coordinates: LineType) -> None: Create a line with two segments >>> a = LineString([(0, 0), (1, 0), (1, 1)]) + """ object.__setattr__(self, "_geoms", self._set_geoms(coordinates)) @@ -475,6 +479,7 @@ def __init__(self, coordinates: LineType) -> None: ---- coordinates (Sequence): A sequence of (x, y [,z]) numeric coordinate pairs or triples + """ super().__init__(coordinates) if not self.is_empty and self._geoms[0].coords != self._geoms[-1].coords: @@ -536,6 +541,7 @@ class Polygon(_Geometry): The ring which bounds the positive space of the polygon. interiors : sequence A sequence of rings which bound all existing holes. + """ _geoms: Tuple[LinearRing, ...] @@ -562,6 +568,7 @@ def __init__( >>> coords = ((0., 0.), (0., 1.), (1., 1.), (1., 0.), (0., 0.)) >>> polygon = Polygon(coords) + """ interiors = tuple(LinearRing(hole) for hole in holes) if holes else () exterior = LinearRing(shell) @@ -747,6 +754,7 @@ class MultiPoint(_MultiGeometry): ---------- geoms : sequence A sequence of Points + """ _geoms: Tuple[Point, ...] @@ -772,6 +780,7 @@ def __init__(self, points: Sequence[PointType], unique: bool = False) -> None: 2 >>> type(ob.geoms[0]) == Point True + """ if unique: points = set(points) # type: ignore [assignment] @@ -825,6 +834,7 @@ class MultiLineString(_MultiGeometry): ---------- geoms : sequence A sequence of LineStrings + """ _geoms: Tuple[LineString, ...] @@ -846,6 +856,7 @@ def __init__(self, lines: Sequence[LineType], unique: bool = False) -> None: Construct a collection containing one line string. >>> lines = MultiLineString( [[[0.0, 0.0], [1.0, 2.0]]] ) + """ if unique: lines = {tuple(line) for line in lines} # type: ignore [assignment] @@ -909,6 +920,7 @@ class MultiPolygon(_MultiGeometry): ---------- geoms : sequence A sequence of `Polygon` instances + """ _geoms: Tuple[Polygon, ...] @@ -942,6 +954,7 @@ def __init__(self, polygons: Sequence[PolygonType], unique: bool = False) -> Non 1 >>> type(ob.geoms[0]) == Polygon True + """ if unique: polygons = set(polygons) # type: ignore [assignment] @@ -1045,6 +1058,7 @@ class isn't generally supported by ordinary GIS sw (viewers and so on). So {'type': 'GeometryCollection', 'geometries': [{'type': 'Point', 'coordinates': (1.0, -1.0)}, {'type': 'Point', 'coordinates': (1.0, -1.0)}]} + """ _geoms: Tuple[Union[Geometry, "GeometryCollection"], ...] @@ -1059,6 +1073,7 @@ def __init__( Args: ---- geometries (Iterable[Geometry] + """ object.__setattr__(self, "_geoms", tuple(geom for geom in geometries if geom)) @@ -1099,6 +1114,7 @@ def __len__(self) -> int: Returns ------- int: Number of geometries in the collection. + """ return len(self._geoms)