File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2079,11 +2079,6 @@ PyArray_FromInterface(PyObject *origin)
20792079 /* Case for data access through pointer */
20802080 if (attr && PyTuple_Check (attr )) {
20812081 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- }
20872082 if (PyTuple_GET_SIZE (attr ) != 2 ) {
20882083 PyErr_SetString (PyExc_TypeError ,
20892084 "__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):
28352835 f .iface ['shape' ] = (2 ,)
28362836 assert_raises (ValueError , np .array , f )
28372837
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+
28382845def test_flat_element_deletion ():
28392846 it = np .ones (3 ).flat
28402847 try :
Original file line number Diff line number Diff line change @@ -236,6 +236,16 @@ def test_diag_indices_from():
236236 assert_array_equal (r , np .arange (4 ))
237237 assert_array_equal (c , np .arange (4 ))
238238
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+
239249
240250if __name__ == "__main__" :
241251 run_module_suite ()
You can’t perform that action at this time.
0 commit comments