在PTVS numpy的64位支持和numpy的System.Int64铸造 [英] numpy 64bit support in PTVS and numpy System.Int64 casting

查看:453
本文介绍了在PTVS numpy的64位支持和numpy的System.Int64铸造的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试写一些code与IronPython和numpy的调用.NET程序集。 版本信息: numpy的-2.0.0-1 SciPy的-1.0.0-2 IronPython的2.7.1

I am trying to write some code with IronPython and numpy that calls a .NET assembly. Version info: numpy-2.0.0-1 scipy-1.0.0-2 IronPython 2.7.1

我安装SciPy的和numpy的:

I installed scipy and numpy according to the instructions given here:

http://www.enthought.com/repo/.iron/

当我试图用ipy64.exe运行,我得到了以下内容:

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: 0x8007000
B)
NumpyDotNet stack trace:
  at NumpyDotNet.NpyCoreApi.GetNativeTypeInfo(Int32& intSize, Int32& longsize, Int32& longLongSize, Int32& longDoubleSize)
  at NumpyDotNet.NpyCoreApi..cctor()

一切都会运行ipy.exe。是numpy的对IronPython的当前版本不兼容64位?

Everything runs with ipy.exe. Is the current version of numpy for IronPython not 64-bit compatible?

问题的根源,我调查(可能会或可能不会涉及到以上)涉及调用,需要一个System.Int64作为参数.NET程序集的方法。蟒蛇本地廉政​​工作正常,但有一个numpy.int32调用(下ipy.exe)时,隐式转换失败,:

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.int32

在code我执行的是:

The code I am executing is:

values = array([1,2,3,4,5])
listValues = list(values);
System.Array[Int64](listValues)

如果我直接打表,即值= [1,2,3,4,5] 那么上述线路。

If I make a list directly, i.e. values = [1,2,3,4,5] then the above runs.

这是在32位或意见上的IronPython的numpy的64位支持的状态numpy的数组转换为System.Array的[的Int64]有什么建议?

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?

推荐答案

我需要的是什么:

listValues.tolist() instead of list(listValues)

列表()方法将保持包装的每个元素。该论坛的帖子有我一直在寻找的答案:的http://www.python-forum.org/pythonforum/viewtopic.php?f=3&t=2962&p=12102

我还是好奇的64位numpy的支持有关系吗?

I am still curious about the 64bit numpy support though?

这篇关于在PTVS numpy的64位支持和numpy的System.Int64铸造的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆