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

Include STL so steps_of_handle works #582

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

dpryan79
Copy link

@dpryan79 dpryan79 commented Jul 9, 2024

This patch fixes a minor bug in the python API wherein std::vector<handlegraph::step_handle_t, std::allocator<handlegraph::step_handle_t> > returned by steps_of_handle() is an unregistered type:

TypeError: Unregistered type : std::vector<handlegraph::step_handle_t, std::allocator<handlegraph::step_handle_t> >

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/local0/phylosopher/user_dirs/dryan/pangenome/wtf.py", line 45, in <module>
    og.for_each_step_in_path(ph, lambda nodeH: filterNodes(nog, og, nodeH, addedNodes, excludedNodes, args.minLen, args.minPaths))
  File "/local0/phylosopher/user_dirs/dryan/pangenome/wtf.py", line 45, in <lambda>
    og.for_each_step_in_path(ph, lambda nodeH: filterNodes(nog, og, nodeH, addedNodes, excludedNodes, args.minLen, args.minPaths))
                                           
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/local0/phylosopher/user_dirs/dryan/pangenome/wtf.py", line 18, in filterNodes
    for step in og.steps_of_handle(h, False):  # ignore orientation with False
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Unable to convert function return value to a Python type! The signature was
        (self: odgi.graph, arg0: odgi.handle, arg1: bool) -> std::vector<handlegraph::step_handle_t, std::allocator<handlegraph::step_handle_t> >

Did you forget to `#include <pybind11/stl.h>`? Or <pybind11/complex.h>,
<pybind11/functional.h>, <pybind11/chrono.h>, etc. Some automatic
conversions are optional and require extra headers to be included
when compiling your pybind11 module.

I've tested locally and this minor change corrects this and this function now returns an iterable list in python.

@AndreaGuarracino
Copy link
Member

Hot, thanks @dpryan79!

@AndreaGuarracino AndreaGuarracino merged commit f46b012 into pangenome:master Jul 9, 2024
@dpryan79 dpryan79 deleted the stl branch July 9, 2024 09:23
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

Successfully merging this pull request may close these issues.

2 participants