File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -604,7 +604,8 @@ def build_arg_list( # noqa: PLR0912
604604
605605def 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
640647def launch_external_viewer (fname : PathLike , waiting : float = 0 ) -> None :
You can’t perform that action at this time.
0 commit comments