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

SWIG seems to ignore Python constructors with std::vector<std::string> parameters #48

Open
parham-k opened this issue Mar 3, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@parham-k
Copy link
Member

parham-k commented Mar 3, 2022

Python wrapper tests on branch python-wrapper-tests are failing due to a TypeError when passing a list of strings in Python to a std::vector<std::string> parameter in C++. For example, instantiating a SeedNtHash with btllib.SeedNtHash("AGCTCAGATC", ["11011"], 1, len(seed[0])) raises:

Traceback (most recent call last):
  File "/Users/runner/work/1/s/tests/test_wrappers.py", line 54, in test_rolling
    nthash = btllib.SeedNtHash(seq, seed, 1, len(seed[0]))
TypeError: in method 'new_SeedNtHash', argument 2 of type 'std::vector< btllib::SpacedSeed,std::allocator< btllib::SpacedSeed > > const &'
Additional information:
Wrong number or type of arguments for overloaded function 'new_SeedNtHash'.
  Possible C/C++ prototypes are:
    btllib::SeedNtHash::SeedNtHash(std::string,std::vector< btllib::SpacedSeed,std::allocator< btllib::SpacedSeed > > const &,unsigned int,unsigned int,size_t)
    btllib::SeedNtHash::SeedNtHash(std::string,std::vector< btllib::SpacedSeed,std::allocator< btllib::SpacedSeed > > const &,unsigned int,unsigned int)

Maybe SWIG is not aware of a vector-of-strings type, in spite of having %template(VectorString) std::vector<std::string>;, %include <std_vector.i>, and %include <stl.i> in btllib.i and extra_common.i.

@vlad0x00
Copy link
Member

vlad0x00 commented Mar 3, 2022

It looks like SWIG is trying to call the constructor that accepts vector of SpacedSeed, which is a vector of unsigned.

On this line: https://github.com/bcgsc/btllib/blob/master/wrappers/extra_common.i#L88
The SeedNtHash constructor is ignored, so perhaps try playing around with removing lines that ignore constructors. I vaguely remember adding those to remove warnings.

@parham-k parham-k added the bug Something isn't working label Mar 21, 2022
@parham-k parham-k self-assigned this Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants