Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 13181ea

Browse filesBrowse files
committed
refactor(strfuncs): forward __format__ of 0d arrays to scalar types
1 parent 5f3dadd commit 13181ea
Copy full SHA for 13181ea

File tree

1 file changed

+5
-5
lines changed
Filter options

1 file changed

+5
-5
lines changed

‎numpy/core/src/multiarray/strfuncs.c

Copy file name to clipboardExpand all lines: numpy/core/src/multiarray/strfuncs.c
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ array_format(PyArrayObject *self, PyObject *args)
100100
if (!PyArg_ParseTuple(args, "O:__format__", &format_spec))
101101
return NULL;
102102

103-
/* if len(format_spec) == 0 this function is equivalent to __str__ */
104-
if (PyUnicode_GET_LENGTH(format_spec) == 0)
105-
// use the builtin
106-
return PyObject_Str((PyObject *)self);
107-
108103
/* 0d arrays - forward to the scalar type */
109104
if (PyArray_NDIM(self) == 0) {
110105
PyObject *item = PyArray_ToScalar(PyArray_DATA(self), self);
@@ -118,6 +113,11 @@ array_format(PyArrayObject *self, PyObject *args)
118113
return res;
119114
}
120115

116+
/* if len(format_spec) == 0 this function is equivalent to __str__ */
117+
if (PyUnicode_GET_LENGTH(format_spec) == 0)
118+
// use the builtin
119+
return PyObject_Str((PyObject *)self);
120+
121121
/* nd arrays - forward to _default_array_format */
122122
// ndim > 0
123123
PyObject *format_func = NULL;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.