File tree 3 files changed +17
-5
lines changed 3 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -2079,11 +2079,6 @@ PyArray_FromInterface(PyObject *origin)
2079
2079
/* Case for data access through pointer */
2080
2080
if (attr && PyTuple_Check (attr )) {
2081
2081
PyObject * dataptr ;
2082
- if (n == 0 ) {
2083
- PyErr_SetString (PyExc_ValueError ,
2084
- "__array_interface__ shape must be at least size 1" );
2085
- goto fail ;
2086
- }
2087
2082
if (PyTuple_GET_SIZE (attr ) != 2 ) {
2088
2083
PyErr_SetString (PyExc_TypeError ,
2089
2084
"__array_interface__ data must be a 2-tuple with "
Original file line number Diff line number Diff line change @@ -2835,6 +2835,13 @@ def __array_interface__(self):
2835
2835
f .iface ['shape' ] = (2 ,)
2836
2836
assert_raises (ValueError , np .array , f )
2837
2837
2838
+ # test scalar with no shape
2839
+ class ArrayLike (object ):
2840
+ array = np .array (1 )
2841
+ __array_interface__ = array .__array_interface__
2842
+ assert_equal (np .array (ArrayLike ()), 1 )
2843
+
2844
+
2838
2845
def test_flat_element_deletion ():
2839
2846
it = np .ones (3 ).flat
2840
2847
try :
Original file line number Diff line number Diff line change @@ -236,6 +236,16 @@ def test_diag_indices_from():
236
236
assert_array_equal (r , np .arange (4 ))
237
237
assert_array_equal (c , np .arange (4 ))
238
238
239
+ x = list (np .ndindex ((1 , 2 , 3 )))
240
+ assert_array_equal (x , expected )
241
+
242
+ # Make sure size argument is optional
243
+ x = list (np .ndindex ())
244
+ assert_equal (x , [()])
245
+
246
+ x = list (np .ndindex (()))
247
+ assert_equal (x , [()])
248
+
239
249
240
250
if __name__ == "__main__" :
241
251
run_module_suite ()
You can’t perform that action at this time.
0 commit comments