Skip to content

Commit

Permalink
ruff fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cleder committed Feb 2, 2024
1 parent d566493 commit dd6042c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pygeoif/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def shape(
>>> geom2 = shape(geom)
>>> geom == geom2
True
"""
type_map = {
"Point": Point,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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__

Expand Down
2 changes: 2 additions & 0 deletions pygeoif/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class Feature:
{'Name': 'Sample Point', 'Other': 'Other Data'}
>>> a.properties['Name']
'Sample Point'
"""

def __init__(
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions pygeoif/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class Point(_Geometry):
-1.0
>>> p.x
1.0
"""

_geoms: PointType
Expand All @@ -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,
Expand Down Expand Up @@ -339,6 +341,7 @@ class LineString(_Geometry):
----------
geoms : sequence
A sequence of Points
"""

_geoms: Tuple[Point, ...]
Expand All @@ -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))

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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, ...]
Expand All @@ -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)
Expand Down Expand Up @@ -747,6 +754,7 @@ class MultiPoint(_MultiGeometry):
----------
geoms : sequence
A sequence of Points
"""

_geoms: Tuple[Point, ...]
Expand All @@ -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]
Expand Down Expand Up @@ -825,6 +834,7 @@ class MultiLineString(_MultiGeometry):
----------
geoms : sequence
A sequence of LineStrings
"""

_geoms: Tuple[LineString, ...]
Expand All @@ -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]
Expand Down Expand Up @@ -909,6 +920,7 @@ class MultiPolygon(_MultiGeometry):
----------
geoms : sequence
A sequence of `Polygon` instances
"""

_geoms: Tuple[Polygon, ...]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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"], ...]
Expand All @@ -1059,6 +1073,7 @@ def __init__(
Args:
----
geometries (Iterable[Geometry]
"""
object.__setattr__(self, "_geoms", tuple(geom for geom in geometries if geom))

Expand Down Expand Up @@ -1099,6 +1114,7 @@ def __len__(self) -> int:
Returns
-------
int: Number of geometries in the collection.
"""
return len(self._geoms)

Expand Down

0 comments on commit dd6042c

Please sign in to comment.