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

Appearance settings

Numpy array to C# array #564

Copy link
Copy link
@bobred

Description

@bobred
Issue body actions

Environment

  • Pythonnet version: 2.4.0
  • Python version: 3.6 (anaconda)
  • Operating System: Windows 7 (x86)

Details

I am using the code below to use some of the features of pylinac in C#. I would like to know how to convert the dynamic array in to a C# array. In the example below the array structure is 60 rows and 4000 columns.

{[[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]
...,
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]
[ 0. 0. 0. ..., 0. 0. 0.]]}

       `PythonEngine.PythonHome = @"C:\Anaconda3";
        
        using (Py.GIL())
        {
            try
            {
                dynamic pl = Py.Import("pylinac");
                dynamic np = Py.Import("numpy");
                dynamic tlog = pl.TrajectoryLog.from_demo();
                tlog.fluence.gamma.calc_map();
                dynamic array = tlog.fluence.actual.array.astype(np.float32, Py.kw("copy",  false));
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }`

Also when debugging in VS 2017 the process slows down when importing Py.Import("pylinac"), any ideas, should this be in a separate post?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.