Skip to content

Commit

Permalink
Set Python error if NumPy init failed
Browse files Browse the repository at this point in the history
If NumPy initialization failed, raise a
proper Python exception when we try to
call functions that require NumPy.
  • Loading branch information
benmwebb committed Sep 26, 2024
1 parent c267067 commit a590b4d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/kernel/pyext/IMP_kernel.numpy.i
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PyObject *_get_floats_data_numpy(PyObject *m_pyobj, unsigned sz, double *data)
{
#if IMP_KERNEL_HAS_NUMPY
if (numpy_import_retval != 0) {
PyErr_SetString(PyExc_ImportError,
"IMP's NumPy support did not initialize correctly");
return NULL;
}

Expand Down Expand Up @@ -41,6 +43,8 @@ PyObject *_get_ints_data_numpy(PyObject *m_pyobj, unsigned sz, int *data)
{
#if IMP_KERNEL_HAS_NUMPY
if (numpy_import_retval != 0) {
PyErr_SetString(PyExc_ImportError,
"IMP's NumPy support did not initialize correctly");
return NULL;
}

Expand Down Expand Up @@ -108,6 +112,8 @@ PyObject *_get_spheres_data_numpy(PyObject *m_pyobj, unsigned sz,
{
#if IMP_KERNEL_HAS_NUMPY
if (numpy_import_retval != 0) {
PyErr_SetString(PyExc_ImportError,
"IMP's NumPy support did not initialize correctly");
return NULL;
}

Expand Down

0 comments on commit a590b4d

Please sign in to comment.