Skip to content

Commit

Permalink
Update geopandas to version 1.0 (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
hamdanal committed Jun 28, 2024
1 parent ab28f7b commit 430a354
Show file tree
Hide file tree
Showing 21 changed files with 242 additions and 287 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: mixed-line-ending
- id: check-case-conflict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9 # must match requirements-tests.txt
rev: v0.5.0 # must match requirements-tests.txt
hooks:
- id: ruff
- id: ruff-format
8 changes: 4 additions & 4 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Tools
# -----
ruff==0.4.9 # must match .pre-commit-config.yaml
ruff==0.5.0 # must match .pre-commit-config.yaml
pytest>=8.0
rich-argparse>=1.5.2
mypy==1.10.0
pyright==1.1.367
mypy==1.10.1
pyright==1.1.369

# Runtime dependencies
# --------------------
geopandas>=0.14.4,<1.0
geopandas>=1.0.0

# Transient dependencies
# ----------------------
Expand Down
4 changes: 2 additions & 2 deletions stubs/geopandas-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import pandas

import geopandas

from . import datasets as datasets
from ._config import options as options
from .array import points_from_xy as points_from_xy
from .geodataframe import GeoDataFrame as GeoDataFrame
from .geoseries import GeoSeries as GeoSeries
from .io.arrow import _read_feather, _read_parquet
from .io.file import _read_file
from .io.file import _list_layers, _read_file
from .io.sql import _read_postgis
from .tools import clip as clip, overlay as overlay, sjoin as sjoin, sjoin_nearest as sjoin_nearest
from .tools._show_versions import show_versions as show_versions

list_layers = _list_layers
read_file = _read_file
read_feather = _read_feather
read_parquet = _read_parquet
Expand Down
56 changes: 44 additions & 12 deletions stubs/geopandas-stubs/array.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import builtins
from _typeshed import Incomplete, Unused
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from typing import Any, ClassVar, Literal, NoReturn, SupportsIndex, overload
from typing_extensions import Self, TypeAlias, deprecated

Expand All @@ -13,7 +13,7 @@ from shapely import Geometry, Point
from shapely.geometry.base import BaseGeometry

from geopandas.base import _ConvertibleToCRS
from geopandas.sindex import PyGEOSSTRTreeIndex
from geopandas.sindex import SpatialIndex

_ArrayOrGeom: TypeAlias = GeometryArray | ArrayLike | Geometry
_Origin: TypeAlias = Literal["center", "centroid"] | Point | tuple[float, float] | tuple[float, float, float]
Expand All @@ -29,14 +29,19 @@ class GeometryDtype(ExtensionDtype):
@classmethod
def construct_array_type(cls) -> builtins.type[GeometryArray]: ...

def isna(value: object) -> bool: ...
def from_shapely(data, crs: _ConvertibleToCRS | None = None) -> GeometryArray: ...
def to_shapely(geoms: GeometryArray) -> NDArray[np.object_]: ...
def from_wkb(data, crs: _ConvertibleToCRS | None = None) -> GeometryArray: ...
def from_wkb(
data, crs: _ConvertibleToCRS | None = None, on_invalid: Literal["raise", "warn", "ignore"] = "raise"
) -> GeometryArray: ...
@overload
def to_wkb(geoms: GeometryArray, hex: Literal[False] = False, **kwargs) -> NDArray[np.bytes_]: ...
@overload
def to_wkb(geoms: GeometryArray, hex: Literal[True], **kwargs) -> NDArray[np.str_]: ...
def from_wkt(data, crs: _ConvertibleToCRS | None = None) -> GeometryArray: ...
def from_wkt(
data, crs: _ConvertibleToCRS | None = None, on_invalid: Literal["raise", "warn", "ignore"] = "raise"
) -> GeometryArray: ...
def to_wkt(geoms: GeometryArray, **kwargs) -> NDArray[np.str_]: ...
def points_from_xy(
x: ArrayLike, y: ArrayLike, z: ArrayLike | None = None, crs: _ConvertibleToCRS | None = None
Expand All @@ -45,10 +50,7 @@ def points_from_xy(
class GeometryArray(ExtensionArray):
def __init__(self, data: GeometryArray | NDArray[np.object_], crs: _ConvertibleToCRS | None = None) -> None: ...
@property
@deprecated("Attribute `.data` is deprecated. Use method `to_numpy()` instead.")
def data(self) -> NDArray[np.object_]: ...
@property
def sindex(self) -> PyGEOSSTRTreeIndex: ...
def sindex(self) -> SpatialIndex: ...
@property
def has_sindex(self) -> bool: ...
@property
Expand All @@ -62,14 +64,17 @@ class GeometryArray(ExtensionArray):
@overload
def __getitem__(self, idx: int | np.integer[Any]) -> BaseGeometry: ... # Always 1-D, doesn't accept tuple
@overload
def __getitem__(self, idx: slice | Sequence[int] | NDArray[np.bool_] | NDArray[np.integer[Any]]) -> GeometryArray: ...
def __getitem__(
self, idx: slice | Sequence[SupportsIndex] | NDArray[np.bool_] | NDArray[np.integer[Any]]
) -> GeometryArray: ...
@overload
def __getitem__(
self, idx: int | np.integer[Any] | slice | Sequence[int] | NDArray[np.bool_] | NDArray[np.integer[Any]]
) -> BaseGeometry | GeometryArray: ...
def __setitem__(self, key, value: _ArrayOrGeom | pd.DataFrame | pd.Series[Any]) -> None: ...
@property
def is_valid(self) -> NDArray[np.bool_]: ...
def is_valid_reason(self) -> NDArray[np.object_]: ...
@property
def is_empty(self) -> NDArray[np.bool_]: ...
@property
Expand All @@ -79,21 +84,27 @@ class GeometryArray(ExtensionArray):
@property
def is_closed(self) -> NDArray[np.bool_]: ...
@property
def is_ccw(self) -> NDArray[np.bool_]: ...
@property
def has_z(self) -> NDArray[np.bool_]: ...
@property
def geom_type(self) -> NDArray[np.int_]: ...
def geom_type(self) -> NDArray[np.int64]: ...
@property
def area(self) -> NDArray[np.float64]: ...
@property
def length(self) -> NDArray[np.float64]: ...
def count_coordinates(self) -> NDArray[np.int64]: ...
def count_geometries(self) -> NDArray[np.int64]: ...
def count_interior_rings(self) -> NDArray[np.int64]: ...
def get_precision(self) -> NDArray[np.float64]: ...
def get_geometry(self, index: SupportsIndex | ArrayLike) -> NDArray[np.object_]: ...
@property
def boundary(self) -> GeometryArray: ...
@property
def centroid(self) -> GeometryArray: ...
def concave_hull(self, ratio: float, allow_holes: bool) -> NDArray[np.object_]: ...
@property
def convex_hull(self) -> GeometryArray: ...
def delaunay_triangles(self, tolerance: float, only_edges: bool) -> GeometryArray: ...
@property
def envelope(self) -> GeometryArray: ...
def minimum_rotated_rectangle(self) -> GeometryArray: ...
Expand All @@ -113,29 +124,43 @@ class GeometryArray(ExtensionArray):
def representative_point(self) -> GeometryArray: ...
def minimum_bounding_circle(self) -> GeometryArray: ...
def minimum_bounding_radius(self) -> NDArray[np.float64]: ...
def minimum_clearance(self) -> NDArray[np.float64]: ...
def normalize(self) -> GeometryArray: ...
def make_valid(self) -> GeometryArray: ...
def reverse(self) -> GeometryArray: ...
def segmentize(self, max_segment_length: float | ArrayLike) -> GeometryArray: ...
def force_2d(self) -> GeometryArray: ...
def force_3d(self, z: float | ArrayLike = 0) -> GeometryArray: ...
def transform(
self, transformation: Callable[[NDArray[np.float64]], NDArray[np.float64]], include_z: bool = False
) -> GeometryArray: ...
def line_merge(self, directed: bool = False) -> GeometryArray: ...
def set_precision(
self, grid_size: float, mode: Literal["valid_output", "pointwise", "keep_collapsed", 0, 1, 2] = "valid_output"
) -> GeometryArray: ...
def covers(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def covered_by(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def contains(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def contains_properly(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def crosses(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def disjoint(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def geom_equals(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def intersects(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def overlaps(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def touches(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def within(self, other: _ArrayOrGeom) -> NDArray[np.bool_]: ...
def dwithin(self, other: _ArrayOrGeom, distance: float) -> NDArray[np.bool_]: ...
def geom_equals_exact(self, other: _ArrayOrGeom, tolerance: float | ArrayLike) -> NDArray[np.bool_]: ...
@deprecated("Method `geom_almost_equals` is deprecated. Use `geom_equals_exact` instead.")
@deprecated("Use method `geom_equals_exact` instead.")
def geom_almost_equals(self, other: _ArrayOrGeom, decimal: float) -> NDArray[np.bool_]: ...
def clip_by_rect(self, xmin: float, ymin: float, xmax: float, ymax: float) -> GeometryArray: ...
def difference(self, other: _ArrayOrGeom) -> GeometryArray: ...
def intersection(self, other: _ArrayOrGeom) -> GeometryArray: ...
def symmetric_difference(self, other: _ArrayOrGeom) -> GeometryArray: ...
def union(self, other: _ArrayOrGeom) -> GeometryArray: ...
def shortest_line(self, other: _ArrayOrGeom) -> GeometryArray: ...
def snap(self, other: _ArrayOrGeom, tolerance: float | ArrayLike) -> GeometryArray: ...
def shared_paths(self, other: _ArrayOrGeom) -> GeometryArray: ...
def distance(self, other: _ArrayOrGeom) -> NDArray[np.float64]: ...
def hausdorff_distance(self, other: _ArrayOrGeom, **kwargs: Any) -> NDArray[np.float64]: ...
def frechet_distance(self, other: _ArrayOrGeom, **kwargs) -> NDArray[np.float64]: ...
Expand All @@ -144,7 +169,10 @@ class GeometryArray(ExtensionArray):
def simplify(self, tolerance: float | ArrayLike, preserve_topology: bool = True) -> GeometryArray: ...
def project(self, other: _ArrayOrGeom, normalized: bool = False) -> NDArray[np.float64]: ...
def relate(self, other: _ArrayOrGeom) -> NDArray[np.str_]: ...
def relate_pattern(self, other, pattern: str) -> NDArray[np.bool_]: ...
def unary_union(self) -> BaseGeometry: ...
def union_all(self, method: Literal["coverage", "unary"] = "unary") -> BaseGeometry: ...
def intersection_all(self) -> BaseGeometry: ...
def affine_transform(self, matrix: Incomplete) -> GeometryArray: ...
def translate(self, xoff: float = 0.0, yoff: float = 0.0, zoff: float = 0.0) -> GeometryArray: ...
def rotate(self, angle: float, origin: _Origin = "center", use_radians: bool = False) -> GeometryArray: ...
Expand Down Expand Up @@ -195,3 +223,7 @@ class GeometryArray(ExtensionArray):
def __eq__(self, other: object) -> NDArray[np.bool_]: ... # type: ignore[override]
def __ne__(self, other: object) -> NDArray[np.bool_]: ... # type: ignore[override]
def __contains__(self, item: object) -> bool: ...

def transform(
data: NDArray[np.object_], func: Callable[[NDArray[np.float64], NDArray[np.float64]], NDArray[np.float64]]
) -> NDArray[np.object_]: ...
Loading

0 comments on commit 430a354

Please sign in to comment.