Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

failure to convert numpy.float64 into System.Double #1936

Closed
@rzindler

Description

@rzindler

Environment

  • Pythonnet version: 3.0
  • Python version: 3.x
  • Operating System: Windows/Linux
  • .NET Runtime: x

Details

Passing in a numpy array to a C# function that takes a double[] parameter fails.

python code:
test_array = np.array([123, 345], np.float)
CSharpClass.Test(test_array)

C# code
public static void Test(double[] TestData) {...}

I already have a fix for this issue.

In Runtime.cs, change PyFloat_Check(...) to

    internal static bool PyFloat_Check(BorrowedReference ob)    {        return PyObject_TypeCheck(ob, PyFloatType);        //return PyObject_TYPE(ob) == PyFloatType; // existing code    }

This will convert any type that is derived from PyFloatType, which includes numpy.float64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp