From 8172102c4ea460e0dcc3de8a79cdc0cdf77de5fa Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:32:05 +1300 Subject: [PATCH] Simplify to remove getattr(pa, "array", None) call Co-Authored-By: Dongdong Tian --- pygmt/tests/test_clib_virtualfile_from_vectors.py | 8 +++++--- pygmt/tests/test_text.py | 10 ++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pygmt/tests/test_clib_virtualfile_from_vectors.py b/pygmt/tests/test_clib_virtualfile_from_vectors.py index 55702f114b6..b76a9bfe168 100644 --- a/pygmt/tests/test_clib_virtualfile_from_vectors.py +++ b/pygmt/tests/test_clib_virtualfile_from_vectors.py @@ -15,8 +15,10 @@ try: import pyarrow as pa + + pa_array = pa.array except ImportError: - pa = None + pa_array = None @pytest.fixture(scope="module", name="dtypes") @@ -65,8 +67,8 @@ def test_virtualfile_from_vectors(dtypes): pytest.param(np.array, {"dtype": np.str_}, id="str"), pytest.param(np.array, {"dtype": np.object_}, id="object"), pytest.param( - getattr(pa, "array", None), - {}, # pa.string() + pa_array, + {}, # {"type": pa.string()} marks=skip_if_no(package="pyarrow"), id="pyarrow", ), diff --git a/pygmt/tests/test_text.py b/pygmt/tests/test_text.py index ce59d7d4bd6..593c07a7b4d 100644 --- a/pygmt/tests/test_text.py +++ b/pygmt/tests/test_text.py @@ -13,8 +13,10 @@ try: import pyarrow as pa + + pa_array = pa.array except ImportError: - pa = None + pa_array = None TEST_DATA_DIR = Path(__file__).parent / "data" POINTS_DATA = TEST_DATA_DIR / "points.txt" @@ -60,11 +62,7 @@ def test_text_single_line_of_text(region, projection): [ list, pytest.param(np.array, id="numpy"), - pytest.param( - getattr(pa, "array", None), - marks=skip_if_no(package="pyarrow"), - id="pyarrow", - ), + pytest.param(pa_array, marks=skip_if_no(package="pyarrow"), id="pyarrow"), ], ) def test_text_multiple_lines_of_text(region, projection, array_func):