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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: refactor to adapt to changes to shapely dependency #1376

Merged
merged 7 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 3 additions & 9 deletions google/cloud/bigquery/_pandas_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@
if pandas is not None: # pragma: NO COVER

def _to_wkb():
# Create a closure that:
# - Adds a not-null check. This allows the returned function to
# be used directly with apply, unlike `shapely.wkb.dumps`.
# - Avoid extra work done by `shapely.wkb.dumps` that we don't need.
# - Caches the WKBWriter (and write method lookup :) )
# - Avoids adding WKBWriter, lgeos, and notnull to the module namespace.
from shapely.geos import WKBWriter, lgeos # type: ignore

write = WKBWriter(lgeos).write
from shapely import wkb # type: ignore

write = wkb.dumps
notnull = pandas.notnull

def _to_wkb(v):
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
_COORDINATE_REFERENCE_SYSTEM = "EPSG:4326"

try:
import shapely.geos # type: ignore
import shapely # type: ignore
except ImportError:
shapely = None
else:
_read_wkt = shapely.geos.WKTReader(shapely.geos.lgeos).read
_read_wkt = shapely.wkt.loads

import google.api_core.exceptions
from google.api_core.page_iterator import HTTPIterator
Expand Down