Skip to content

Commit 408199c

Browse files
authored
Merge branch 'AliasSystem/alias' into AliasSystem/aliassystem
2 parents 571d0dd + d0ebbcb commit 408199c

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484

8585
# Run the benchmark tests
8686
- name: Run benchmarks
87-
uses: CodSpeedHQ/action@c28fe9fbe7d57a3da1b7834ae3761c1d8217612d # v3.7.0
87+
uses: CodSpeedHQ/action@0b6e7a3d96c9d2a6057e7bcea6b45aaf2f7ce60b # v3.8.0
8888
with:
8989
# 'bash -el -c' is needed to use the custom shell.
9090
# See https://github.com/CodSpeedHQ/action/issues/65.

.github/workflows/ci_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
GH_TOKEN: ${{ github.token }}
152152

153153
- name: Install uv
154-
uses: astral-sh/setup-uv@bd01e18f51369d5a26f1651c3cb451d3417e3bba # v6.3.1
154+
uses: astral-sh/setup-uv@7edac99f961f18b581bbd960d59d049f04c0002f # v6.4.1
155155
with:
156156
activate-environment: true
157157
python-version: ${{ matrix.python-version }}

pygmt/helpers/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ def build_arg_list( # noqa: PLR0912
604604

605605
def is_nonstr_iter(value: Any) -> bool:
606606
"""
607-
Check if the value is iterable (e.g., list, tuple, array) but not a string.
607+
Check if the value is iterable (e.g., list, tuple, array) but not a string or a 0-D
608+
array.
608609
609610
Parameters
610611
----------
@@ -633,8 +634,14 @@ def is_nonstr_iter(value: Any) -> bool:
633634
True
634635
>>> is_nonstr_iter(np.array(["abc", "def", "ghi"]))
635636
True
637+
>>> is_nonstr_iter(np.array(42))
638+
False
636639
"""
637-
return isinstance(value, Iterable) and not isinstance(value, str)
640+
return (
641+
isinstance(value, Iterable)
642+
and not isinstance(value, str)
643+
and not (hasattr(value, "ndim") and value.ndim == 0)
644+
)
638645

639646

640647
def launch_external_viewer(fname: PathLike, waiting: float = 0) -> None:

pygmt/tests/test_datatypes_dataset.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import pandas as pd
88
import pytest
9+
from packaging.version import Version
910
from pygmt import which
1011
from pygmt.clib import Session
1112
from pygmt.helpers import GMTTempFile
@@ -25,8 +26,12 @@ def dataframe_from_pandas(filepath_or_buffer, sep=r"\s+", comment="#", header=No
2526

2627
# By default, pandas reads text strings with whitespaces as multiple columns, but
2728
# GMT concatenates all trailing text as a single string column. Need do find all
28-
# string columns (with dtype="object") and combine them into a single string column.
29-
string_columns = df.select_dtypes(include=["object"]).columns
29+
# string columns and combine them into a single string column.
30+
# For pandas<3.0, string columns have dtype="object".
31+
# For pandas>=3.0, string columns have dtype="str".
32+
# TODO(pandas>=3.0): Remove the pandas version check.
33+
dtype = "object" if Version(pd.__version__) < Version("3.0.0.dev0") else "str"
34+
string_columns = df.select_dtypes(include=[dtype]).columns
3035
if len(string_columns) > 1:
3136
df[string_columns[0]] = df[string_columns].apply(lambda x: " ".join(x), axis=1)
3237
df = df.drop(string_columns[1:], axis=1)

0 commit comments

Comments
 (0)