diff options
author | John Kirkham <kirkhamj@janelia.hhmi.org> | 2016-01-10 12:38:43 -0500 |
---|---|---|
committer | John Kirkham <kirkhamj@janelia.hhmi.org> | 2016-01-10 12:41:40 -0500 |
commit | 599dee9d8c29bdf427d6d381d77583bb65177a13 (patch) | |
tree | 069ed51ddbd6bd13ce6f57297711751f5fa03018 /doc | |
parent | e89f45756e36082e2ceac5c129cd83a7f76c3ee8 (diff) | |
download | numpy-599dee9d8c29bdf427d6d381d77583bb65177a13.tar.gz |
STY: Fix indentation in example from docs.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/newdtype_example/floatint.c | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/doc/newdtype_example/floatint.c b/doc/newdtype_example/floatint.c index cf698a7f9..fa97a882d 100644 --- a/doc/newdtype_example/floatint.c +++ b/doc/newdtype_example/floatint.c @@ -14,10 +14,10 @@ typedef struct _floatint { } PyFloatIntObject; static PyTypeObject PyFloatInt_Type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "floatint.floatint", /*tp_name*/ - sizeof(PyFloatIntObject), /*tp_basicsize*/ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "floatint.floatint", /*tp_name*/ + sizeof(PyFloatIntObject), /*tp_basicsize*/ }; static PyArray_ArrFuncs _PyFloatInt_Funcs; @@ -45,17 +45,18 @@ static PyArray_Descr _PyFloatInt_Dtype = { static void twoint_copyswap(void *dst, void *src, int swap, void *arr) { - if (src != NULL) - memcpy(dst, src, sizeof(double)); - + if (src != NULL) { + memcpy(dst, src, sizeof(double)); + } + if (swap) { - register char *a, *b, c; - a = (char *)dst; - b = a + 7; - c = *a; *a++ = *b; *b-- = c; - c = *a; *a++ = *b; *b-- = c; - c = *a; *a++ = *b; *b-- = c; - c = *a; *a++ = *b; *b = c; + register char *a, *b, c; + a = (char *)dst; + b = a + 7; + c = *a; *a++ = *b; *b-- = c; + c = *a; *a++ = *b; *b-- = c; + c = *a; *a++ = *b; *b-- = c; + c = *a; *a++ = *b; *b = c; } } @@ -64,12 +65,11 @@ twoint_getitem(char *ip, PyArrayObject *ap) { npy_int32 a[2]; if ((ap==NULL) || PyArray_ISBEHAVED_RO(ap)) { - a[0] = *((npy_int32 *)ip); - a[1] = *((npy_int32 *)ip + 1); + a[0] = *((npy_int32 *)ip); + a[1] = *((npy_int32 *)ip + 1); } else { - ap->descr->f->copyswap(a, ip, !PyArray_ISNOTSWAPPED(ap), - ap); + ap->descr->f->copyswap(a, ip, !PyArray_ISNOTSWAPPED(ap), ap); } return Py_BuildValue("(ii)", a[0], a[1]); } @@ -79,17 +79,16 @@ twoint_setitem(PyObject *op, char *ov, PyArrayObject *ap) { npy_int32 a[2]; if (!PyTuple_Check(op)) { - PyErr_SetString(PyExc_TypeError, "must be a tuple"); - return -1; + PyErr_SetString(PyExc_TypeError, "must be a tuple"); + return -1; } if (!PyArg_ParseTuple(op, "ii", a, a+1)) return -1; if (ap == NULL || PyArray_ISBEHAVED(ap)) { - memcpy(ov, a, sizeof(double)); + memcpy(ov, a, sizeof(double)); } else { - ap->descr->f->copyswap(ov, a, !PyArray_ISNOTSWAPPED(ap), - ap); + ap->descr->f->copyswap(ov, a, !PyArray_ISNOTSWAPPED(ap), ap); } return 0; } @@ -145,7 +144,7 @@ PyMODINIT_FUNC initfloatint(void) { dtype = _register_dtype(); Py_XINCREF(dtype); if (dtype != NULL) { - PyDict_SetItemString(d, "floatint_type", (PyObject *)dtype); + PyDict_SetItemString(d, "floatint_type", (PyObject *)dtype); } Py_INCREF(&PyFloatInt_Type); PyDict_SetItemString(d, "floatint", (PyObject *)&PyFloatInt_Type); |