Skip to content

Commit 3402919

Browse files
committed
STY: better brace usage
1 parent 21ff0b0 commit 3402919

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

bottleneck/src/nonreduce_axis_template.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ NRA(partition, DTYPE0) {
5656
a = (PyArrayObject *)PyArray_NewCopy(a, NPY_ANYORDER);
5757
init_iter_one(&it, a, axis);
5858

59-
if (LENGTH == 0) return (PyObject *)a;
59+
if (LENGTH == 0) {
60+
return (PyObject *)a;
61+
}
6062
if (n < 0 || n > LENGTH - 1) {
6163
PyErr_Format(PyExc_ValueError,
6264
"`n` (=%d) must be between 0 and %zd, inclusive.",
@@ -106,8 +108,10 @@ NRA_MAIN(partition, PARSE_PARTITION)
106108
j--; \
107109
} \
108110
} while (m <= j); \
109-
if (j < k) l = m; \
110-
if (k < m) r = j;
111+
if (j < k) \
112+
l = m; \
113+
if (k < m) \
114+
r = j;
111115

112116
#define ARGPARTITION(dtype0, dtype1) \
113117
while (l < r) { \
@@ -168,7 +172,9 @@ NRA(argpartition, DTYPE0) {
168172
PyObject *y = PyArray_EMPTY(PyArray_NDIM(a), PyArray_SHAPE(a), NPY_DTYPE1, 0);
169173
iter2 it;
170174
init_iter2(&it, a, y, axis);
171-
if (LENGTH == 0) return y;
175+
if (LENGTH == 0) {
176+
return y;
177+
}
172178
if (n < 0 || n > LENGTH - 1) {
173179
PyErr_Format(PyExc_ValueError,
174180
"`n` (=%d) must be between 0 and %zd, inclusive.",

bottleneck/src/nonreduce_template.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -242,36 +242,34 @@ nonreducer(char * name,
242242
if (old_obj == NULL) {
243243
RUNTIME_ERR("`old_obj` should never be NULL; please report this bug.");
244244
goto error;
245-
} else {
246-
old = PyFloat_AsDouble(old_obj);
247-
if (error_converting(old)) {
248-
TYPE_ERR("`old` must be a number");
249-
goto error;
250-
}
245+
}
246+
const double old_value = PyFloat_AsDouble(old_obj);
247+
if (error_converting(old_value)) {
248+
TYPE_ERR("`old` must be a number");
249+
goto error;
251250
}
252251

253252
/* new */
254253
if (new_obj == NULL) {
255254
RUNTIME_ERR("`new_obj` should never be NULL; please report this bug.");
256255
goto error;
257-
} else {
258-
new = PyFloat_AsDouble(new_obj);
259-
if (error_converting(new)) {
260-
TYPE_ERR("`new` must be a number");
261-
goto error;
262-
}
256+
}
257+
const double new_value = PyFloat_AsDouble(new_obj);
258+
if (error_converting(new_value)) {
259+
TYPE_ERR("`new` must be a number");
260+
goto error;
263261
}
264262

265-
dtype = PyArray_TYPE(a);
263+
const int dtype = PyArray_TYPE(a);
266264

267265
if (dtype == NPY_float64) {
268-
y = nr_float64(a, old, new);
266+
y = nr_float64(a, old_value, new_value);
269267
} else if (dtype == NPY_float32) {
270-
y = nr_float32(a, old, new);
268+
y = nr_float32(a, old_value, new_value);
271269
} else if (dtype == NPY_int64) {
272-
y = nr_int64(a, old, new);
270+
y = nr_int64(a, old_value, new_value);
273271
} else if (dtype == NPY_int32) {
274-
y = nr_int32(a, old, new);
272+
y = nr_int32(a, old_value, new_value);
275273
} else {
276274
y = slow(name, args, kwds);
277275
}
@@ -372,7 +370,9 @@ initnonreduce(void)
372370
#else
373371
PyObject *m = Py_InitModule3("nonreduce", nonreduce_methods, nonreduce_doc);
374372
#endif
375-
if (m == NULL) return RETVAL;
373+
if (m == NULL) {
374+
return RETVAL;
375+
}
376376
import_array();
377377
if (!intern_strings()) {
378378
return RETVAL;

0 commit comments

Comments
 (0)