PyO3 / PyO3/rust-numpy

TypeError: argument 'input': 'ndarray' object is not an instance of 'ndarray'

Open
#547 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.4k
Forks
141
Avg merge
16m
Merged PRs (30d)
3

Description

When trying to capture an Array from Python using the following input scheme:

fn _set_node_vector<'py>(
    &mut self, 
    py: Python<'py>, 
    input: Bound<'py, numpy::PyArray1<Py<PyAny>>>,
) -> PyResult<()>

I have three cases:
a) Valid input: the array is correctly specified: v1 = np.array([1.0, 2.0], dtype=object)
b) Invalid i1 = np.array([1.0, 2.0]) (possibly because the dtype is float)
c) Invalid: i2 = np.array([[1.0, 2.0]], dtype=object) (shape is wrong)

In both invalid cases the error returned is:

TypeError: argument 'input': 'ndarray' object is not an instance of 'ndarray'

Bit more steering can be helpful...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the _set_node_vector signature shown in the issue and reproduce the three inputs: object-dtype 1D, default-dtype 1D, and object-dtype 2D arrays. Compare the resulting errors and make the invalid dtype and shape cases provide more useful guidance than the current generic TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python, rust
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.