Skip to content

Commit

Permalink
Fix Shapely deprecation (#123)
Browse files Browse the repository at this point in the history
Summary:
Directly iterating over multipart geometries is being removed in an upcoming version of Shapely and triggers excessive warnings with current versions of Shapely. Switching to iterating over the `.geoms` field as suggested by the migration guide: https://shapely.readthedocs.io/en/stable/migration.html#multi-part-geometries-will-no-longer-be-sequences-length-iterable-indexable

Pull Request resolved: #123

Reviewed By: lyttonhao

Differential Revision: D41604488

Pulled By: vaibhava0

fbshipit-source-id: 1c68f034e4d509256446f770785abc1c34e4051d
  • Loading branch information
normster authored and facebook-github-bot committed Dec 13, 2022
1 parent 652b17d commit d39b53d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fvcore/transforms/transform.py
Expand Up @@ -718,7 +718,9 @@ def apply_polygons(self, polygons: list) -> list:
cropped = polygon.intersection(crop_box)
if cropped.is_empty:
continue
if not isinstance(cropped, geometry.collection.BaseMultipartGeometry):
if isinstance(cropped, geometry.collection.BaseMultipartGeometry):
cropped = cropped.geoms
else:
cropped = [cropped]
# one polygon may be cropped to multiple ones
for poly in cropped:
Expand Down

0 comments on commit d39b53d

Please sign in to comment.