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

OpenQL does not work with pathlib #471

Open
eendebakpt opened this issue Jan 17, 2023 · 2 comments
Open

OpenQL does not work with pathlib #471

eendebakpt opened this issue Jan 17, 2023 · 2 comments

Comments

@eendebakpt
Copy link

The OpenQL set and set_option methods do not work with pathlib duck typing for str. A minimal example:

import openql as ql
import tempfile
from pathlib import Path

output_dir = Path(tempfile.mkdtemp())
ql.initialize()
ql.set_option('output_dir', output_dir)

results in TypeError: in method 'set_option', argument 2 of type 'std::string const &'

@pablolh
Copy link
Contributor

pablolh commented Jan 23, 2023

Hello Pieter,

Thanks for reporting. It would indeed be nice for that to work.

The Python API of OpenQL is built with SWIG which makes it possible to call the C++ functions from within Python.
C++ has obviously no knowledge of pathlib. And it seems that there is no implicit conversion to string done before calling the C++ method.

I would assume that doing the conversion yourself (with str(...)) works just fine?

@eendebakpt
Copy link
Author

Yes, conversion the str works fine. But this is something users will bump into, as pathlib is becoming more the standard, so it would be nice if openql could support this. Perhaps swig has options for this, but I have not checked

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