Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Unexpected failure in .contains_properly. #896

Closed
thomcom opened this issue Feb 3, 2023 · 0 comments · Fixed by #910
Closed

[BUG]: Unexpected failure in .contains_properly. #896

thomcom opened this issue Feb 3, 2023 · 0 comments · Fixed by #910
Assignees
Labels
3 - Ready for Review Ready for review by team bug Something isn't working non-breaking Non-breaking change

Comments

@thomcom
Copy link
Contributor

thomcom commented Feb 3, 2023

Version

23.04

On which installation method(s) does this occur?

Rapids-Compose

Describe the issue

Using the naturalearth_lowres dataset produces an unexpected error with contains properly. We expect that a GeoSeries can be used as its own argument to .contains_properly, as in x.contains_properly(x) and will return False. With the naturalearth_lowres dataframe, an error is thrown.

Minimum reproducible example

import geopandas as gpd
import cuspatial
from shapely.geometry import Polygon
tpoly = cuspatial.GeoSeries([Polygon([[0, 1], [2, 3], [4, 5]])])
tpoly.contains_properly(tpoly)

df = cuspatial.GeoDataFrame(
    gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
)
df['geometry'].contains_properly(df['geometry'])

Relevant log output

0    False
dtype: bool

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[2], line 7
      3 import cuspatial
      4 df = cuspatial.GeoDataFrame(
      5     gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
      6 )
----> 7 df['geometry'].contains_properly(df['geometry'])

File ~/cuspatial/python/cuspatial/cuspatial/core/geoseries.py:874, in GeoSeries.contains_properly(self, other, align)
    794 def contains_properly(self, other, align=True):
    795     """Returns a `Series` of `dtype('bool')` with value `True` for each
    796     aligned geometry that contains _other_.
    797 
   (...)
    872         within the corresponding polygon in the input.
    873     """
--> 874     return ContainsProperlyBinpred(self, other, align)()

File ~/cuspatial/python/cuspatial/cuspatial/core/binpreds/binpreds.py:122, in BinaryPredicate.__call__(self)
    118 """Return the result of the binary predicate."""
    119 # Type disambiguation
    120 # Type disambiguation has a large effect on the decisions of the
    121 # algorithm.
--> 122 (lhs, rhs, indices) = self.preprocess(self.lhs, self.rhs)
    124 # Binpred call
    125 point_result = self._op(lhs, rhs)

File ~/cuspatial/python/cuspatial/cuspatial/core/binpreds/binpreds.py:154, in ContainsProperlyBinpred.preprocess(self, lhs, rhs)
    150 xy_points = geom.xy
    152 # Arrange into shape for calling point-in-polygon, intersection, or
    153 # equals
--> 154 point_indices = geom.point_indices()
    155 from cuspatial.core.geoseries import GeoSeries
    157 final_rhs = GeoSeries(
    158     GeoColumn._from_points_xy(xy_points._column)
    159 ).points

File ~/cuspatial/python/cuspatial/cuspatial/core/geoseries.py:242, in GeoSeries.PolygonGeoColumnAccessor.point_indices(self)
    240 offsets = cp.array(self.ring_offset)
    241 sizes = offsets[1:] - offsets[:-1]
--> 242 return cp.repeat(self._series.index, sizes)

File ~/compose/etc/conda/cuda_11.6/envs/notebooks/lib/python3.8/site-packages/cupy/_manipulation/tiling.py:70, in repeat(a, repeats, axis)
     56 def repeat(a, repeats, axis=None):
     57     """Repeat arrays along an axis.
     58 
     59     Args:
   (...)
     68 
     69     """
---> 70     return a.repeat(repeats, axis)

File ~/cudf/python/cudf/cudf/core/index.py:809, in RangeIndex.repeat(self, repeats, axis)
    808 def repeat(self, repeats, axis=None):
--> 809     return self._as_int_index().repeat(repeats, axis)

File ~/cudf/python/cudf/cudf/core/index.py:1492, in GenericIndex.repeat(self, repeats, axis)
   1490 def repeat(self, repeats, axis=None):
   1491     return self._from_columns_like_self(
-> 1492         Frame._repeat([*self._columns], repeats, axis), self._column_names
   1493     )

File ~/cudf/python/cudf/cudf/core/frame.py:2810, in Frame._repeat(columns, repeats, axis)
   2807 if not is_scalar(repeats):
   2808     repeats = as_column(repeats)
-> 2810 return libcudf.filling.repeat(columns, repeats)

File ~/compose/etc/conda/cuda_11.6/envs/notebooks/lib/python3.8/contextlib.py:75, in ContextDecorator.__call__.<locals>.inner(*args, **kwds)
     72 @wraps(func)
     73 def inner(*args, **kwds):
     74     with self._recreate_cm():
---> 75         return func(*args, **kwds)

File filling.pyx:57, in cudf._lib.filling.repeat()

File filling.pyx:68, in cudf._lib.filling._repeat_via_column()

RuntimeError: CUDF failure at: /home/tcomer/mnt/NVIDIA/rapids-docker/cudf/cpp/src/filling/repeat.cu:109: in and count must have equal size

Environment details

rapids-compose 23.04

Other/Misc.

No response

@thomcom thomcom added bug Something isn't working Needs Triage Need team to review and classify labels Feb 3, 2023
@thomcom thomcom self-assigned this Feb 8, 2023
@thomcom thomcom added 3 - Ready for Review Ready for review by team non-breaking Non-breaking change and removed Needs Triage Need team to review and classify labels Feb 8, 2023
@thomcom thomcom moved this to Review in cuSpatial Feb 8, 2023
@trxcllnt trxcllnt moved this from Review to In Progress in cuSpatial Mar 6, 2023
@rapids-bot rapids-bot bot closed this as completed in #910 Mar 18, 2023
@rapids-bot rapids-bot bot closed this as completed in f700030 Mar 18, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in cuSpatial Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team bug Something isn't working non-breaking Non-breaking change
Projects
Status: Done
2 participants