Skip to content

Commit 071f111

Browse files
committed
Make (type, 1) case equivalent to type
1 parent ece9e80 commit 071f111

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎numpy/core/src/multiarraymodule.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3375,6 +3375,11 @@ _convert_from_tuple(PyObject *obj)
33753375
"invalid shape in fixed-type tuple.");
33763376
goto fail;
33773377
}
3378+
/* If (type, 1) was given, it is equivalent to type... */
3379+
if (shape.len == 1 && shape.ptr[0] == 1 && PyNumber_Check(val)) {
3380+
PyDimMem_FREE(shape.ptr);
3381+
return type;
3382+
}
33783383
newdescr = PyArray_DescrNewFromType(PyArray_VOID);
33793384
if (newdescr == NULL) {PyDimMem_FREE(shape.ptr); goto fail;}
33803385
newdescr->elsize = type->elsize;

0 commit comments

Comments
 (0)