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

Copy .NET to numpy array: python 3 breaks constructor IntPtr.__overloads__[int](np_arr.__array_interface__['data'][0]) #1116

Closed
Milestone
@greg814

Description

@greg814

Environment

Pythonnet version: 2.4.0 (in both python versions)

Python version:

  • code working in Python 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 21:01:17) [MSC v.1500 64 bit (AMD64)] on win32

  • code not working in Python 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)] on win32

  • Operating System: Windows 10 Professional 64-bit

Details

Trying to copy a .NET array to a numpy array using Marshal as in the example on themailing list:

import clrfrom System import Array, Double, IntPtr, Randomfrom System.Runtime.InteropServices import Marshalimport numpy as npr = Random()src = Array.CreateInstance(Double, 10000000)for i in xrange(len(src)): src[i] = r.NextDouble()from System.Runtime.InteropServices import Marshaldest = np.empty(len(src))dest_ptr = IntPtr.__overloads__[int](dest.__array_interface__['data'][0])Marshal.Copy(src, 0, dest_ptr, len(src))

was working fine in python 2 but in 3 results in

Traceback (most recent call last):  File "test.py", line 12, in <module>    dest_ptr = IntPtr.__overloads__[int](dest.__array_interface__['data'][0])TypeError: no constructor matches given arguments

TODO
How can the changedpython 3 int be used in this constructor?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp