C# IronPython中的KdTree库

C# IronPython中的KdTree库,c#,ironpython,kdtree,C#,Ironpython,Kdtree,我需要在IronPython中使用。我从源代码构建了它,并使用AddReference添加了库。有很多在C#中使用此库的示例,但我无法将其转换为IronPython。我在创建对象时遇到问题: C#: 但我得到了: TypeError: expected ITypeMath[float], got FloatMath 我已经检查了源代码并找到了构造函数: public KdTree(int dimensions, ITypeMath<TKey> typeMath) 公共KdTree

我需要在IronPython中使用。我从源代码构建了它,并使用AddReference添加了库。有很多在C#中使用此库的示例,但我无法将其转换为IronPython。我在创建对象时遇到问题:

C#:

但我得到了:

TypeError: expected ITypeMath[float], got FloatMath
我已经检查了源代码并找到了构造函数:

public KdTree(int dimensions, ITypeMath<TKey> typeMath)
公共KdTree(int维,ITypeMath-typeMath)
FloatMath是对实现ITypeMath的TypeMath的扩展:

public class FloatMath : TypeMath<float>
public abstract class TypeMath<T> : ITypeMath<T>
公共类FloatMath:TypeMath
公共抽象类TypeMath:ITypeMath

看起来我无法将参数传递给构造函数,因为需要接口。我遗漏了什么?

也许你需要先创建一个变量来保存浮点数学对象?@weismat:我试过了。同样的错误。我甚至尝试使用clr.GetClrType(FloatMath)创建FloatMath,但没有任何改变。我刚刚用C#创建了一个包装器,它返回KdTree(维度,new FloatMath())。这不是一个完美的解决方案,但它很有效。我感觉IronPython并没有将python
float
和.net
System.float
视为等效类型。由于
FloatMath
直接定义为派生自
TypeMath
,因此IronPython没有用于获取任何所需元数据的挂钩。如果您提出了一个新的(python)类型,该类型派生了
TypeMath[float]
,并使用了它,会发生同样的情况吗?
public KdTree(int dimensions, ITypeMath<TKey> typeMath)
public class FloatMath : TypeMath<float>
public abstract class TypeMath<T> : ITypeMath<T>