← 输入框|github.com|刷新
Skip to content

np.gradient can not be called with the current pythonnet API #1804

Closed

Description

@henon

I am reopening an issue which was previously demoted to a question but turns out to be a shortcoming of the pythonnet API. As the discussion #1772 shows, there is no way to successfully call the function numpy.gradient(f, *varargs, axis=None, edge_order=1) as documented here: https://numpy.org/doc/stable/reference/generated/numpy.gradient.html

Here is an example in python

>>> import numpy as np
>>> dx=4.0
>>> dy=5.0
>>> zX=[[1,2,3],[4,5,6],[8,9,0]]
>>> np.gradient(zX, dx, dy)
[array([[ 0.75 ,  0.75 ,  0.75 ],
       [ 0.875,  0.875, -0.375],
       [ 1.   ,  1.   , -1.5  ]]), array([[ 0.2,  0.2,  0.2],
       [ 0.2,  0.2,  0.2],
       [ 0.2, -0.8, -1.8]])]
>>>

Various ways to call the function have been tried in #1772 but none work. This should be considered a bug.

Activity

  1. filmor commented on May 30, 2022

    @filmor
    Member

    The methods I gave you in the discussion work fine (the InvokeMethod was just missing the method name), I have added tests for them.

  2. henon commented on May 31, 2022

    @henon
    ContributorAuthor

    You are right, it works with the latest version. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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