Skip to content

Commit

Permalink
Warn the user if numpy failed to import
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Sep 26, 2024
1 parent a590b4d commit cdee423
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion modules/kernel/pyext/include/IMP_kernel.import_numpy.i
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ static int numpy_import_retval;

%init {
numpy_import_retval = _import_array();
/* If numpy was not found, continue anyway without numpy support */
/* If numpy was not found, continue anyway without numpy support, but warn
the user */
PyErr_Clear();
if (numpy_import_retval < 0) {
PyErr_WarnEx(PyExc_RuntimeWarning,
"IMP's NumPy support did not initialize correctly. Some NumPy-related "
"functionality will be unavailable. This is usually caused by "
"building IMP with a newer version of NumPy than is available "
"at runtime.", 1);
}
}
#endif

0 comments on commit cdee423

Please sign in to comment.