File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 69
69
"fill_diagonal" ,
70
70
"flatnonzero" ,
71
71
"indices" ,
72
+ "iterable" ,
72
73
"ix_" ,
73
74
"mask_indices" ,
74
75
"ndindex" ,
@@ -1033,6 +1034,47 @@ def indices(
1033
1034
return res
1034
1035
1035
1036
1037
+ def iterable (y ):
1038
+ """
1039
+ Check whether or not an object can be iterated over.
1040
+
1041
+ For full documentation refer to :obj:`numpy.iterable`.
1042
+
1043
+ Parameters
1044
+ ----------
1045
+ y : object
1046
+ Input object.
1047
+
1048
+ Returns
1049
+ -------
1050
+ out : bool
1051
+ Return ``True`` if the object has an iterator method or is a sequence
1052
+ and ``False`` otherwise.
1053
+
1054
+ Examples
1055
+ --------
1056
+ >>> import dpnp as np
1057
+ >>> np.iterable([1, 2, 3])
1058
+ True
1059
+ >>> np.iterable(2)
1060
+ False
1061
+
1062
+ In most cases, the results of ``np.iterable(obj)`` are consistent with
1063
+ ``isinstance(obj, collections.abc.Iterable)``. One notable exception is
1064
+ the treatment of 0-dimensional arrays:
1065
+
1066
+ >>> from collections.abc import Iterable
1067
+ >>> a = np.array(1.0) # 0-dimensional array
1068
+ >>> isinstance(a, Iterable)
1069
+ True
1070
+ >>> np.iterable(a)
1071
+ False
1072
+
1073
+ """
1074
+
1075
+ return numpy .iterable (y )
1076
+
1077
+
1036
1078
def ix_ (* args ):
1037
1079
"""Construct an open mesh from multiple sequences.
1038
1080
You can’t perform that action at this time.
0 commit comments