标签云

微信群

扫码加入我们

WeChat QR Code

I am trying to write some code with IronPython and numpy that calls a .NET assembly.Version info:numpy-2.0.0-1scipy-1.0.0-2IronPython 2.7.1I installed scipy and numpy according to the instructions given here:http://www.enthought.com/repo/.iron/When I try to run with ipy64.exe I get the following:Failed while initializing NpyCoreApi: BadImageFormatException:An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)NumpyDotNet stack trace:at NumpyDotNet.NpyCoreApi.GetNativeTypeInfo(Int32& intSize, Int32& longsize, Int32& longLongSize, Int32& longDoubleSize)at NumpyDotNet.NpyCoreApi..cctor()Everything runs with ipy.exe. Is the current version of numpy for IronPython not 64-bit compatible? The root problem I am investigating (may or may not be related to above) involves invoking a .NET assembly method that requires a System.Int64 as an argument. The python native int works fine but when invoking with a numpy.int32 (under ipy.exe) the implicit cast fails with:E======================================================================ERROR: data_type_tests System.Array[Int64](listValues)TypeError: expected Int64, got numpy.int32The code I am executing is:values = array([1,2,3,4,5])listValues = list(values);System.Array[Int64](listValues)If I make a list directly, i.e. values = [1,2,3,4,5]then the above runs.Any suggestions on converting the numpy array to a System.Array[Int64] under 32 bit or comments on the state of the numpy 64 bit support on IronPython?


More specifically: I am wondering how I cast a numpy array type back to a python list that contains <type 'int'> elements instead of <type 'numpy.int32> elements (since the base int type works with the api mentioned above). I would like to do this conversion in a performance-wise way. Manually iterating over all elements and invoking 'ToInt64' or the like seems wasteful.

2019年04月18日33分20秒

Curious if this post may be related: comments.gmane.org/gmane.comp.python.numeric.general/46855

2019年04月18日33分20秒

The exception - BadFormatException - is due to trying to load a module of the wrong bitness into the process. It's not clear which module it is. Have you tried debugging it with fusion logging?

2019年04月18日33分20秒

The module is NpyAccessLib.dll

2019年04月18日33分20秒