Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use np.add.at functions via PyCall #123

Open
msyksphinz-self opened this issue Jun 13, 2020 · 1 comment
Open

How to use np.add.at functions via PyCall #123

msyksphinz-self opened this issue Jun 13, 2020 · 1 comment

Comments

@msyksphinz-self
Copy link

Hi, I'm using PyCall and Numpy, trying to call as follows:

require 'numpy'
np = Numpy
a = np.array([1, 2, 3, 4])
np.add.at(a, [0, 1], 1)

but following errors:

${HOME}/.gem/ruby/2.5.0/gems/pycall-1.3.1/lib/pycall/pyobject_wrapper.rb:43:in `add': <class 'ValueError'>: invalid number of arguments (PyCall::PyError)

Is it possible to use func.at via PyCall?

@inspire22
Copy link

Looks like you need to use PyCall.getattr(obj, attr) as per this (rejected) pull request #127

This is working for me:
PyCall.getattr(np, 'add').at(a, [0, 1], 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants