8000 Fix dtype int vs char inconsistencies + dtype hashing by cournape · Pull Request #231 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Fix dtype int vs char inconsistencies + dtype hashing #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
STY: cleanup hashdesc.c to follow our C conventions.
  • Loading branch information
cournape committed Mar 6, 2012
commit b0861c76e1e8ccd7524d0cdde73560023821c987
36 changes: 21 additions & 15 deletions numpy/core/src/multiarray/hashdescr.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,17 @@ static int _array_descr_builtin(PyArray_Descr* descr, PyObject *l);
*/
static char _normalize_byteorder(char byteorder)
{
switch(byteorder) {
case '=':
if (PyArray_GetEndianness() == NPY_CPU_BIG) {
return '>';
} else {
return '<';
}
default:
return byteorder;
}
switch(byteorder) {
case '=':
if (PyArray_GetEndianness() == NPY_CPU_BIG) {
return '>';
}
else {
return '<';
}
default:
return byteorder;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could indent the case block. I have mixed feelings about that, but the 'toothbrush' is more used than the 'comb' in Numpy code, so I went with the first for the style guide.


/*
Expand Down Expand Up @@ -139,7 +140,8 @@ static int _array_descr_walk_fields(PyObject* fields, PyObject* l)
PyErr_SetString(PyExc_SystemError,
"(Hash) First item in compound dtype tuple not a descr ???");
return -1;
} else {
}
else {
Py_INCREF(fdescr);
st = _array_descr_walk((PyArray_Descr*)fdescr, l);
Py_DECREF(fdescr);
Expand All @@ -153,7 +155,8 @@ static int _array_descr_walk_fields(PyObject* fields, PyObject* l)
PyErr_SetString(PyExc_SystemError,
"(Hash) Second item in compound dtype tuple not an int ???");
return -1;
} else {
}
else {
Py_INCREF(foffset);
PyList_Append(l, foffset);
}
Expand Down Expand Up @@ -187,10 +190,12 @@ static int _array_descr_walk_subarray(PyArray_ArrayDescr* adescr, PyObject *l)
Py_INCREF(item);
PyList_Append(l, item);
}
} else if (PyInt_Check(adescr->shape)) {
}
else if (PyInt_Check(adescr->shape)) {
Py_INCREF(adescr->shape);
PyList_Append(l, adescr->shape);
} else {
}
else {
PyErr_SetString(PyExc_SystemError,
"(Hash) Shape of subarray dtype neither a tuple or int ???");
return -1;
Expand All @@ -212,7 +217,8 @@ static int _array_descr_walk(PyArray_Descr* descr, PyObject *l)

if (_is_array_descr_builtin(descr)) {
return _array_descr_builtin(descr, l);
} else {
}
else {
if(descr->fields != NULL && descr->fields != Py_None) {
if (!PyDict_Check(descr->fields)) {
PyErr_SetString(PyExc_SystemError,
Expand Down
0