Skip to content

Commit

Permalink
Move GeoSeries GeoDataframe into core package and hide column i…
Browse files Browse the repository at this point in the history
…mplementation in internal `_column` package (#657)

This PR moves geoseries and geodataframe into `core` package and moves `geocolumn`, `geometa` into internal `_column` package as they are considered non-public interface. `pygeoarrow` is moved to `io` package as it's obviously about interoperability.

Minor changes includes removing `geoutils` module and moves the helper function into geodataframe since it's only used in one module.

Contributes to #644 #599 #525

Authors:
  - Michael Wang (https://github.com/isVoid)

Approvers:
  - H. Thomson Comer (https://github.com/thomcom)

URL: #657
  • Loading branch information
isVoid authored Aug 22, 2022
1 parent ae8cf80 commit 2c33dd3
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 29 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repos:
hooks:
- id: black
files: python/cuspatial/.*
args: ["--config", "pyproject.toml"]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.7
hooks:
Expand Down
4 changes: 2 additions & 2 deletions python/cuspatial/cuspatial/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
trajectory_bounding_boxes,
trajectory_distances_and_speeds,
)
from .geometry.geoseries import GeoSeries
from .geometry.geodataframe import GeoDataFrame
from .core.geoseries import GeoSeries
from .core.geodataframe import GeoDataFrame
from .io.shapefile import read_polygon_shapefile
from .io.geopandas import from_geopandas

Expand Down
1 change: 1 addition & 0 deletions python/cuspatial/cuspatial/core/_column/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Copyright (c) 2022, NVIDIA CORPORATION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import cudf
from cudf.core.column import ColumnBase

from cuspatial.geometry.geometa import GeoMeta
from cuspatial.core._column.geometa import GeoMeta

T = TypeVar("T", bound="GeoColumn")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Copyright (c) 2020-2022, NVIDIA CORPORATION

from geopandas import GeoDataFrame as gpGeoDataFrame
from geopandas.geoseries import is_geometry_type as gp_is_geometry_type

import cudf

from cuspatial.geometry.geocolumn import GeoColumn, GeoMeta
from cuspatial.geometry.geoseries import GeoSeries
from cuspatial.geometry.geoutil import is_geometry_type
from cuspatial.core._column.geocolumn import GeoColumn, GeoMeta
from cuspatial.core.geoseries import GeoSeries
from cuspatial.io.geopandas_reader import GeoPandasReader


Expand Down Expand Up @@ -131,3 +131,14 @@ def _from_data(cls, new_data, name=None, index=False):
return GeoSeries(new_column, name=name, index=index)
else:
return cudf.Series(new_column, name=name, index=index)


def is_geometry_type(obj):
"""
Returns `True` if the column is a `GeoPandas` or `cuspatial.GeoSeries`
"""
if isinstance(obj, (GeoSeries, GeoColumn)):
return True
if gp_is_geometry_type(obj):
return True
return False
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import cudf

import cuspatial.geometry.pygeoarrow as pygeoarrow
from cuspatial.geometry.geocolumn import GeoColumn, GeoMeta
import cuspatial.io.pygeoarrow as pygeoarrow
from cuspatial.core._column.geocolumn import GeoColumn, GeoMeta
from cuspatial.io.geopandas_reader import Feature_Enum

T = TypeVar("T", bound="GeoSeries")
Expand Down
Empty file.
16 changes: 0 additions & 16 deletions python/cuspatial/cuspatial/geometry/geoutil.py

This file was deleted.

3 changes: 1 addition & 2 deletions python/cuspatial/cuspatial/io/geopandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from geopandas import GeoDataFrame as gpGeoDataFrame
from geopandas.geoseries import GeoSeries as gpGeoSeries

from cuspatial.geometry.geodataframe import GeoDataFrame
from cuspatial.geometry.geoseries import GeoSeries
from cuspatial import GeoDataFrame, GeoSeries


def from_geopandas(gpdf):
Expand Down
2 changes: 1 addition & 1 deletion python/cuspatial/cuspatial/io/geopandas_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import cudf

from cuspatial.geometry import pygeoarrow
from cuspatial.io import pygeoarrow


class Feature_Enum(Enum):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 NVIDIA CORPORATION
# Copyright (c) 2022, NVIDIA CORPORATION

from typing import List

Expand Down
2 changes: 1 addition & 1 deletion python/cuspatial/cuspatial/tests/test_geodataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_groupby(gpdf):

def test_type_persistence(gpdf):
cugpdf = cuspatial.from_geopandas(gpdf)
assert type(cugpdf["geometry"]) == cuspatial.geometry.geoseries.GeoSeries
assert type(cugpdf["geometry"]) == cuspatial.GeoSeries


def test_interleaved_point(gpdf, polys):
Expand Down

0 comments on commit 2c33dd3

Please sign in to comment.