@@ -9,19 +9,25 @@ numpy_system(PyObject *self, PyObject *args)
99 int sts;
1010
1111 if (!PyArg_ParseTuple (args, " s" , &command))
12+ {
1213 return NULL ;
14+ }
15+
1316 sts = system (command);
1417 return PyLong_FromLong (sts);
1518}
1619
1720static PyObject *
18- numpy_add (PyObject *self, PyObject *args){
21+ numpy_add (PyObject *self, PyObject *args)
22+ {
1923 PyArrayObject *arr;
2024 PyArg_ParseTuple (args, " O" , &arr);
21- if (PyErr_Occurred ()){
25+ if (PyErr_Occurred ())
26+ {
2227 return NULL ;
2328 }
24- if (!PyArray_Check (arr) || PyArray_TYPE (arr) != NPY_DOUBLE) {
29+ if (!PyArray_Check (arr) || PyArray_TYPE (arr) != NPY_DOUBLE)
30+ {
2531 PyErr_SetString (PyExc_TypeError, " Argument must be a numpy array of type double!" );
2632 return NULL ;
2733 }
@@ -31,9 +37,11 @@ numpy_add(PyObject *self, PyObject *args){
3137 int64_t size = PyArray_SIZE (arr);
3238
3339 double total=0 ;
34- for (int i=0 ; i < size; i++){
40+ for (int i=0 ; i < size; i++)
41+ {
3542 total += data[i];
3643 }
44+
3745 return PyFloat_FromDouble (total);
3846}
3947
@@ -42,13 +50,15 @@ static PyObject *SpamError = NULL;
4250static int
4351numpy_module_exec (PyObject *m)
4452{
45- if (SpamError != NULL ) {
53+ if (SpamError != NULL )
54+ {
4655 PyErr_SetString (PyExc_ImportError,
4756 " cannot initialize numpy module more than once" );
4857 return -1 ;
4958 }
5059 SpamError = PyErr_NewException (" numpy.error" , NULL , NULL );
51- if (PyModule_AddObjectRef (m, " SpamError" , SpamError) < 0 ) {
60+ if (PyModule_AddObjectRef (m, " SpamError" , SpamError) < 0 )
61+ {
5262 return -1 ;
5363 }
5464
0 commit comments