diff --git a/pygmt/src/plot.py b/pygmt/src/plot.py index a9a21fbbce1..13e4a598a7b 100644 --- a/pygmt/src/plot.py +++ b/pygmt/src/plot.py @@ -226,7 +226,7 @@ def plot(self, data=None, x=None, y=None, size=None, direction=None, **kwargs): and data.geom_type.isin(["Point", "MultiPoint"]).all() ): # checking if the geometry of a geoDataFrame is Point or MultiPoint kwargs["S"] = "s0.2c" - elif kwargs.get("S") is None and kind == "file" and data.endswith(".gmt"): + elif kwargs.get("S") is None and kind == "file" and str(data).endswith(".gmt"): # checking that the data is a file path to set default style try: with open(which(data), mode="r", encoding="utf8") as file: diff --git a/pygmt/src/plot3d.py b/pygmt/src/plot3d.py index adecd87a5eb..daa94927a91 100644 --- a/pygmt/src/plot3d.py +++ b/pygmt/src/plot3d.py @@ -196,7 +196,7 @@ def plot3d( and data.geom_type.isin(["Point", "MultiPoint"]).all() ): # checking if the geometry of a geoDataFrame is Point or MultiPoint kwargs["S"] = "u0.2c" - elif kwargs.get("S") is None and kind == "file" and data.endswith(".gmt"): + elif kwargs.get("S") is None and kind == "file" and str(data).endswith(".gmt"): # checking that the data is a file path to set default style try: with open(which(data), mode="r", encoding="utf8") as file: diff --git a/pygmt/tests/test_plot.py b/pygmt/tests/test_plot.py index 8627c03eeb7..448bff8b365 100644 --- a/pygmt/tests/test_plot.py +++ b/pygmt/tests/test_plot.py @@ -4,6 +4,7 @@ """ import datetime import os +from pathlib import Path import numpy as np import pandas as pd @@ -452,8 +453,11 @@ def test_plot_datetime(): return fig -@pytest.mark.mpl_image_compare -def test_plot_ogrgmt_file_multipoint_default_style(): +@pytest.mark.mpl_image_compare( + filename="test_plot_ogrgmt_file_multipoint_default_style.png" +) +@pytest.mark.parametrize("func", [str, Path]) +def test_plot_ogrgmt_file_multipoint_default_style(func): """ Make sure that OGR/GMT files with MultiPoint geometry are plotted as squares and not as line (default GMT style). @@ -467,7 +471,9 @@ def test_plot_ogrgmt_file_multipoint_default_style(): with open(tmpfile.name, "w", encoding="utf8") as file: file.write(gmt_file) fig = Figure() - fig.plot(data=tmpfile.name, region=[0, 2, 1, 3], projection="X2c", frame=True) + fig.plot( + data=func(tmpfile.name), region=[0, 2, 1, 3], projection="X2c", frame=True + ) return fig diff --git a/pygmt/tests/test_plot3d.py b/pygmt/tests/test_plot3d.py index 1eda151946a..9983302b00b 100644 --- a/pygmt/tests/test_plot3d.py +++ b/pygmt/tests/test_plot3d.py @@ -2,6 +2,7 @@ Tests plot3d. """ import os +from pathlib import Path import numpy as np import pytest @@ -423,8 +424,11 @@ def test_plot3d_scalar_xyz(): return fig -@pytest.mark.mpl_image_compare -def test_plot3d_ogrgmt_file_multipoint_default_style(): +@pytest.mark.mpl_image_compare( + filename="test_plot3d_ogrgmt_file_multipoint_default_style.png" +) +@pytest.mark.parametrize("func", [str, Path]) +def test_plot3d_ogrgmt_file_multipoint_default_style(func): """ Make sure that OGR/GMT files with MultiPoint geometry are plotted as cubes and not as line (default GMT style). @@ -440,7 +444,7 @@ def test_plot3d_ogrgmt_file_multipoint_default_style(): file.write(gmt_file) fig = Figure() fig.plot3d( - data=tmpfile.name, + data=func(tmpfile.name), perspective=[315, 25], region=[0, 2, 0, 2, 0, 2], projection="X2c",