Skip to content

Commit

Permalink
Remove usage of FatalError and fix linspace to end at stop if endpoin…
Browse files Browse the repository at this point in the history
…t is True
  • Loading branch information
teoliphant committed Aug 21, 2006
1 parent 77732fa commit 9737794
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion numpy/core/code_generators/generate_array_api.py
Expand Up @@ -88,7 +88,7 @@
return 0;
}
#define import_array() { if (_import_array() < 0) {PyErr_Print(); Py_FatalError("numpy.core.multiarray failed to import... exiting.\n"); } }
#define import_array() { if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return; } }
#endif
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/code_generators/generate_ufunc_api.py
Expand Up @@ -48,7 +48,7 @@
return 0;
}
#define import_umath() { if (_import_umath() < 0) {PyErr_Print(); Py_FatalError("numpy.core.umath failed to import... exiting.\n"); }}
#define import_umath() { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import\n"); return; }}
#define import_ufunc import_umath
Expand Down
4 changes: 2 additions & 2 deletions numpy/core/src/ufuncobject.c
Expand Up @@ -3025,15 +3025,15 @@ ufunc_frompyfunc(PyObject *dummy, PyObject *args, PyObject *kwds) {
/*UFUNC_API*/
static int
PyUFunc_ReplaceLoopBySignature(PyUFuncObject *func,
PyUFuncGenericFunction *newfunc,
PyUFuncGenericFunction newfunc,
int *signature,
PyUFuncGenericFunction *oldfunc)
{
int i,j;
/* Find the location of the matching signature */
for (i=0; i<func->ntypes; i++) {
for (j=0; j<func->nargs; j++) {
if (signature[j] == func->types[i*self->nargs+j])
if (signature[j] == func->types[i*func->nargs+j])
break;
}
if (j >= func->nargs) return -1;
Expand Down
4 changes: 2 additions & 2 deletions numpy/f2py/rules.py
Expand Up @@ -173,8 +173,8 @@
\tm = #modulename#_module = Py_InitModule(\"#modulename#\", f2py_module_methods);
\tPyFortran_Type.ob_type = &PyType_Type;
\timport_array();
\tif (PyErr_Occurred())
\t\tPy_FatalError(\"can't initialize module #modulename# (failed to import numpy)\");
\tif (PyErr_Occurred())
\t\t{PyErr_SetString(PyExc_ImportError, \"can't initialize module #modulename# (failed to import numpy)\"); return;}
\td = PyModule_GetDict(m);
\ts = PyString_FromString(\"$R"""+"""evision: $\");
\tPyDict_SetItemString(d, \"__version__\", s);
Expand Down
2 changes: 2 additions & 0 deletions numpy/lib/function_base.py
Expand Up @@ -42,6 +42,8 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False):
else:
step = (stop-start)/float(num)
y = _nx.arange(0, num) * step + start
if endpoint:
y[-1] = stop
if retstep:
return y, step
else:
Expand Down
2 changes: 1 addition & 1 deletion numpy/numarray/numpy/libnumarray.h
Expand Up @@ -56,7 +56,7 @@ static void **libnumarray_API;
} \
}

#define import_libnumarray() _import_libnumarray(); if (PyErr_Occurred()) { PyErr_Print(); Py_FatalError("numpy.numarray._capi failed to import... exiting.\n"); }
#define import_libnumarray() _import_libnumarray(); if (PyErr_Occurred()) { PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.numarray._capi failed to import.\n"); return; }

#endif

Expand Down

0 comments on commit 9737794

Please sign in to comment.