Skip to content

Commit 0e8bc15

Browse files
authored
Duplicate mutable objects to avoid failures when running tests in random order (#2943)
1 parent 12a0af9 commit 0e8bc15

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pygmt/tests/test_geopandas.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,15 @@ def test_geopandas_plot_int_dtypes(gdf_ridge, dtype):
191191
This is a regression test for
192192
https://github.com/GenericMappingTools/pygmt/issues/2497
193193
"""
194+
gdf = gdf_ridge.copy()
194195
# Convert NPOINTS column to integer type
195-
gdf_ridge["NPOINTS"] = gdf_ridge.NPOINTS.astype(dtype=dtype)
196+
gdf["NPOINTS"] = gdf.NPOINTS.astype(dtype=dtype)
196197

197198
# Plot figure with three polygons colored based on NPOINTS value
198199
fig = Figure()
199200
makecpt(cmap="lisbon", series=[10, 60, 10], continuous=True)
200201
fig.plot(
201-
data=gdf_ridge,
202+
data=gdf,
202203
frame=True,
203204
pen="1p,black",
204205
fill="+z",
@@ -215,21 +216,22 @@ def test_geopandas_plot_int64_as_float(gdf_ridge):
215216
Check that big 64-bit integers are correctly mapped to float type in
216217
geopandas.GeoDataFrame object.
217218
"""
219+
gdf = gdf_ridge.copy()
218220
factor = 2**32
219221
# Convert NPOINTS column to int64 type and make big integers
220-
gdf_ridge["NPOINTS"] = gdf_ridge.NPOINTS.astype(dtype="int64")
221-
gdf_ridge["NPOINTS"] *= factor
222+
gdf["NPOINTS"] = gdf.NPOINTS.astype(dtype="int64")
223+
gdf["NPOINTS"] *= factor
222224

223225
# Make sure the column is bigger than the largest 32-bit integer
224-
assert gdf_ridge["NPOINTS"].abs().max() > 2**31 - 1
226+
assert gdf["NPOINTS"].abs().max() > 2**31 - 1
225227

226228
# Plot figure with three polygons colored based on NPOINTS value
227229
fig = Figure()
228230
makecpt(
229231
cmap="lisbon", series=[10 * factor, 60 * factor, 10 * factor], continuous=True
230232
)
231233
fig.plot(
232-
data=gdf_ridge,
234+
data=gdf,
233235
frame=True,
234236
pen="1p,black",
235237
fill="+z",

pygmt/tests/test_grdimage_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_grdimage_image_dataarray_unsupported_dtype(dtype, xr_image):
7373
Plot a 3-band RGB image using xarray.DataArray input, with an unsupported data type.
7474
"""
7575
fig = Figure()
76-
image = xr_image.astype(dtype=dtype)
76+
image = xr_image.copy().astype(dtype=dtype)
7777
with pytest.warns(expected_warning=RuntimeWarning) as record:
7878
fig.grdimage(grid=image)
7979
assert len(record) == 1

0 commit comments

Comments
 (0)