Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfc5c3b

Browse files
committed
3K: BUG: alias divide -> true_divide correctly; just replacing the name in generate_umath.py is not the correct thing to do
1 parent 3ddc421 commit cfc5c3b

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

numpy/core/code_generators/generate_umath.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,8 @@ def english_upper(s):
682682
}
683683

684684
if sys.version_info[0] >= 3:
685-
defdict['divide'] = defdict['true_divide']
685+
# Will be aliased to true_divide in umathmodule.c.src:InitOtherOperators
686+
del defdict['divide']
686687

687688
def indent(st,spaces):
688689
indention = ' '*spaces

numpy/core/src/umath/umathmodule.c.src

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,12 @@ InitOtherOperators(PyObject *dictionary) {
225225
"Compute y = x1 * 2**x2.",0);
226226
PyDict_SetItemString(dictionary, "ldexp", f);
227227
Py_DECREF(f);
228+
229+
#if defined(NPY_PY3K)
230+
f = PyDict_GetItemString(dictionary, "true_divide");
231+
PyDict_SetItemString(dictionary, "divide", f);
232+
Py_DECREF(f);
233+
#endif
228234
return;
229235
}
230236

0 commit comments

Comments
 (0)