Content-Length: 338520 | pFad | https://github.com/pythonnet/pythonnet/issues/1936

6A failure to convert numpy.float64 into System.Double · Issue #1936 · pythonnet/pythonnet · GitHub
Skip to content

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

@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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/pythonnet/pythonnet/issues/1936

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy