Skip to content

Commit

Permalink
Fixed problem creating ufuncs from ananymous python functions. Found in
Browse files Browse the repository at this point in the history
scipy.stats regression tests.
  • Loading branch information
Jason McCampbell (Enthought, Inc) committed Apr 26, 2011
1 parent 3b9a522 commit 15a2cff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions numpy/NumpyDotNet/umath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ public static object frompyfunc(CodeContext cntx, object func, int nin, int nout
if (!IronPython.Runtime.Operations.PythonOps.IsCallable(cntx, func)) {
throw new ArgumentTypeException("function must be callback");
}

string funcName = (string)PythonOps.ObjectGetAttribute(cntx, func, "__name__") ?? "?";

string funcName = PythonOps.HasAttr(cntx, func, "__name__") ?
(string)PythonOps.GetBoundAttr(cntx, func, "__name__") : "?";
GCHandle funcHandle = NpyCoreApi.AllocGCHandle(func);
IntPtr ufunc = NpyCoreApi.UFuncFromPyFunc(nin, nout, funcName,
Marshal.GetFunctionPointerForDelegate(PyUFunc_Om_On_Delegate), GCHandle.ToIntPtr(funcHandle));
Expand Down

0 comments on commit 15a2cff

Please sign in to comment.