@@ -59,6 +59,24 @@ def coerce(request):
59
59
return request .param
60
60
61
61
62
+ class DuckArray :
63
+ """
64
+ A class which wraps around numpy (e.g. Pint's Quantity) but is not actually a numpy array
65
+ """
66
+ def __init__ (self , values ):
67
+ self .values = values
68
+
69
+ def __iter__ (self ):
70
+ it_here = iter (self .values )
71
+
72
+ for element in it_here :
73
+ yield element
74
+
75
+ @property
76
+ def ndim (self ):
77
+ return self .values .ndim
78
+
79
+
62
80
# collect all objects to be tested for list-like-ness; use tuples of objects,
63
81
# whether they are list-like or not (special casing for sets), and their ID
64
82
ll_params = [
@@ -93,6 +111,15 @@ def coerce(request):
93
111
(np .ndarray ((2 ,) * 4 ), True , "ndarray-4d" ),
94
112
(np .array ([[[[]]]]), True , "ndarray-4d-empty" ),
95
113
(np .array (2 ), False , "ndarray-0d" ),
114
+ (DuckArray (np .ndarray ((2 ,) * 1 )), True , "duck-ndarray-1d" ),
115
+ (DuckArray (np .array ([])), True , "duck-ndarray-1d-empty" ),
116
+ (DuckArray (np .ndarray ((2 ,) * 2 )), True , "duck-ndarray-2d" ),
117
+ (DuckArray (np .array ([[]])), True , "duck-ndarray-2d-empty" ),
118
+ (DuckArray (np .ndarray ((2 ,) * 3 )), True , "duck-ndarray-3d" ),
119
+ (DuckArray (np .array ([[[]]])), True , "duck-ndarray-3d-empty" ),
120
+ (DuckArray (np .ndarray ((2 ,) * 4 )), True , "duck-ndarray-4d" ),
121
+ (DuckArray (np .array ([[[[]]]])), True , "duck-ndarray-4d-empty" ),
122
+ (DuckArray (np .array (2 )), False , "duck-ndarray-0d" ),
96
123
(1 , False , "int" ),
97
124
(b"123" , False , "bytes" ),
98
125
(b"" , False , "bytes-empty" ),
0 commit comments