Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pygmt/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,8 @@ def build_arg_list( # noqa: PLR0912

def is_nonstr_iter(value: Any) -> bool:
"""
Check if the value is iterable (e.g., list, tuple, array) but not a string.
Check if the value is iterable (e.g., list, tuple, array) but not a string or a 0-D
array.

Parameters
----------
Expand Down Expand Up @@ -633,8 +634,14 @@ def is_nonstr_iter(value: Any) -> bool:
True
>>> is_nonstr_iter(np.array(["abc", "def", "ghi"]))
True
>>> is_nonstr_iter(np.array(42))
False
"""
return isinstance(value, Iterable) and not isinstance(value, str)
return (
isinstance(value, Iterable)
and not isinstance(value, str)
and not (hasattr(value, "ndim") and value.ndim == 0)
Copy link

Copilot AI Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The condition hasattr(value, "ndim") and value.ndim == 0 could be made more explicit by importing numpy and using isinstance(value, np.ndarray) instead of hasattr(value, "ndim"). This would be more specific and avoid potential false positives from other objects that might have an ndim attribute.

Copilot uses AI. Check for mistakes.
)


def launch_external_viewer(fname: PathLike, waiting: float = 0) -> None:
Expand Down
Loading