Skip to content

Commit bf94645

Browse files
authored
ruff: Fix ICN002 geopandas import alias (#4430)
1 parent a2271a2 commit bf94645

File tree

8 files changed

+27
-23
lines changed

8 files changed

+27
-23
lines changed

examples/gallery/lines/linestrings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
"""
1313

1414
# %%
15-
import geopandas as gpd
15+
import geopandas
1616
import pygmt
1717

1818
# Read a sample dataset provided by Natural Earth. The dataset contains rivers stored
1919
# as LineString/MultiLineString geometry types. Here will focus on Asia.
2020
provider = "https://naciscdn.org/naturalearth"
21-
rivers = gpd.read_file(f"{provider}/50m/physical/ne_50m_rivers_lake_centerlines.zip")
21+
rivers = geopandas.read_file(
22+
f"{provider}/50m/physical/ne_50m_rivers_lake_centerlines.zip"
23+
)
2224
rivers_asia = rivers.cx[57:125, 7:47].copy()
2325

2426
fig = pygmt.Figure()

examples/gallery/maps/choropleth_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"""
1515

1616
# %%
17-
import geopandas as gpd
17+
import geopandas
1818
import pygmt
1919
from pygmt.params.position import Position
2020

2121
provider = "https://naciscdn.org/naturalearth"
22-
world = gpd.read_file(f"{provider}/110m/cultural/ne_110m_admin_0_countries.zip")
22+
world = geopandas.read_file(f"{provider}/110m/cultural/ne_110m_admin_0_countries.zip")
2323

2424
# The dataset contains different attributes, here we focus on the population within
2525
# the different countries (column "POP_EST") for the continent "Africa".

examples/gallery/symbols/points_cities.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
"""
1515

1616
# %%
17-
import geopandas as gpd
17+
import geopandas
1818
import pygmt
1919

2020
# Read a sample dataset provided by Natural Earth. The dataset contains cities stored
2121
# as Point geometry type. In this example we focus on Europe.
2222
provider = "https://naciscdn.org/naturalearth"
23-
cities = gpd.read_file(f"{provider}/50m/cultural/ne_50m_populated_places_simple.zip")
23+
cities = geopandas.read_file(
24+
f"{provider}/50m/cultural/ne_50m_populated_places_simple.zip"
25+
)
2426
cities = cities[cities["name"] != "Vatican City"].copy() # No overlap with label Rome
2527
# Create two subsets for small and large cities
2628
cities_small = cities[cities["worldcity"] != 1].copy()

examples/intro/04_table_inputs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# %%
2323
from pathlib import Path
2424

25-
import geopandas as gpd
25+
import geopandas
2626
import numpy as np
2727
import pandas as pd
2828
import pygmt
@@ -98,9 +98,9 @@
9898
# GMT and PyGMT do not support natively.
9999

100100
# Example GeoDataFrame
101-
gdf = gpd.GeoDataFrame(
101+
gdf = geopandas.GeoDataFrame(
102102
{
103-
"geometry": gpd.points_from_xy([2, 5, 9], [2, 3, 4]),
103+
"geometry": geopandas.points_from_xy([2, 5, 9], [2, 3, 4]),
104104
"value": [10, 20, 30],
105105
}
106106
)

pygmt/helpers/tempfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def tempfile_from_geojson(geojson):
132132
E.g. '1a2b3c4d5e6.gmt'.
133133
"""
134134
with GMTTempFile(suffix=".gmt") as tmpfile:
135-
import geopandas as gpd # noqa: PLC0415
135+
import geopandas # noqa: PLC0415
136136

137137
Path(tmpfile.name).unlink() # Ensure file is deleted first
138138
ogrgmt_kwargs = {
@@ -165,7 +165,7 @@ def tempfile_from_geojson(geojson):
165165
import json # noqa: PLC0415
166166

167167
jsontext = json.dumps(geojson.__geo_interface__)
168-
gpd.read_file(filename=io.StringIO(jsontext)).to_file(**ogrgmt_kwargs)
168+
geopandas.read_file(filename=io.StringIO(jsontext)).to_file(**ogrgmt_kwargs)
169169

170170
yield tmpfile.name
171171

pygmt/src/choropleth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def choropleth(
4040
4141
Examples
4242
--------
43-
>>> import geopandas as gpd
43+
>>> import geopandas
4444
>>> import pygmt
45-
>>> world = gpd.read_file(
45+
>>> world = geopandas.read_file(
4646
... "https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
4747
... )
4848
>>> world["POP_EST"] *= 1e-6 # Population in millions

pygmt/tests/test_choropleth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
import pytest
66
from pygmt import Figure, makecpt
77

8-
gpd = pytest.importorskip("geopandas")
8+
geopandas = pytest.importorskip("geopandas")
99

1010

1111
@pytest.fixture(scope="module", name="world")
1212
def fixture_world():
1313
"""
1414
Download and cache the Natural Earth countries dataset for testing.
1515
"""
16-
return gpd.read_file(
16+
return geopandas.read_file(
1717
"https://naciscdn.org/naturalearth/110m/cultural/ne_110m_admin_0_countries.zip"
1818
)
1919

pygmt/tests/test_geopandas.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pygmt.helpers import data_kind
1111
from pygmt.helpers.testing import skip_if_no
1212

13-
gpd = pytest.importorskip("geopandas")
13+
geopandas = pytest.importorskip("geopandas")
1414
shapely = pytest.importorskip("shapely")
1515

1616

@@ -36,7 +36,7 @@ def fixture_gdf():
3636
}
3737
)
3838
# Multipolygon first so the OGR_GMT file has @GMULTIPOLYGON in the header
39-
gdf = gpd.GeoDataFrame(
39+
gdf = geopandas.GeoDataFrame(
4040
index=["multipolygon", "polygon", "linestring"],
4141
geometry=[multipolygon, polygon, linestring],
4242
)
@@ -54,7 +54,7 @@ def fixture_gdf_ridge():
5454
fname=["@RidgeTest.shp", "@RidgeTest.shx", "@RidgeTest.dbf", "@RidgeTest.prj"],
5555
download="c",
5656
)
57-
gdf = gpd.read_file(shapefile[0])
57+
gdf = geopandas.read_file(shapefile[0])
5858
# Reproject the geometry
5959
gdf["geometry"] = (
6060
gdf.to_crs(crs="EPSG:3857")
@@ -98,7 +98,7 @@ def test_geopandas_plot_default_square():
9898
2d.
9999
"""
100100
point = shapely.geometry.Point(1, 2)
101-
gdf = gpd.GeoDataFrame(geometry=[point])
101+
gdf = geopandas.GeoDataFrame(geometry=[point])
102102
fig = Figure()
103103
fig.plot(data=gdf, region=[0, 2, 1, 3], projection="X2c", frame=True)
104104
return fig
@@ -111,7 +111,7 @@ def test_geopandas_plot3d_default_cube():
111111
geometry in 3d.
112112
"""
113113
multipoint = shapely.geometry.MultiPoint([(0.5, 0.5, 0.5), (1.5, 1.5, 1.5)])
114-
gdf = gpd.GeoDataFrame(geometry=[multipoint])
114+
gdf = geopandas.GeoDataFrame(geometry=[multipoint])
115115
fig = Figure()
116116
fig.plot3d(
117117
data=gdf,
@@ -131,7 +131,7 @@ def test_geopandas_plot_non_default_circle():
131131
2d.
132132
"""
133133
point = shapely.geometry.Point(1, 2)
134-
gdf = gpd.GeoDataFrame(geometry=[point])
134+
gdf = geopandas.GeoDataFrame(geometry=[point])
135135
fig = Figure()
136136
fig.plot(data=gdf, region=[0, 2, 1, 3], projection="X2c", frame=True, style="c0.2c")
137137
return fig
@@ -144,7 +144,7 @@ def test_geopandas_plot3d_non_default_circle():
144144
in 3d.
145145
"""
146146
multipoint = shapely.geometry.MultiPoint([(0.5, 0.5, 0.5), (1.5, 1.5, 1.5)])
147-
gdf = gpd.GeoDataFrame(geometry=[multipoint])
147+
gdf = geopandas.GeoDataFrame(geometry=[multipoint])
148148
fig = Figure()
149149
fig.plot3d(
150150
data=gdf,
@@ -280,7 +280,7 @@ def test_geopandas_nonascii():
280280
(1, 3),
281281
]
282282
)
283-
gdf = gpd.GeoDataFrame(
283+
gdf = geopandas.GeoDataFrame(
284284
{
285285
"name_ascii": ["Fiji"],
286286
"name_utf8": ["فيجي"], # Arabic

0 commit comments

Comments
 (0)