pybind / pybind/pybind11

python conversion of std::pair and std::array

Open
#1,495 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

I have C++ functions, one accept std::vector<std::pair<double,double>> and the other accept std::vector<std::array<double, 2>> as param.
I tried to call with numpy array, the first one will success while the second one will fail.

I look into the param type, there are some difference:

The first one has param type List[Tuple[float, float]]

The second one has param type List[List[float[2]]]

I'm wondering how this will affect the compatibility of numpy?
And if I do want std::vector<std::array<double, 2>> to accept numpy input, how should I do that ?

Contributor guide

Open the contributing guide

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 by reproducing the reported conversions for C++ functions accepting std::vector<std::pair<double, double>> and std::vector<std::array<double, 2>> with NumPy input. Compare the resulting parameter types and conversion behavior; done means the std::array form's NumPy compatibility is explained and the appropriate behavior or limitation is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, numpy, python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.