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

TypeError when running examples #346

Closed
nikoltoll opened this issue Jun 21, 2023 · 3 comments
Closed

TypeError when running examples #346

nikoltoll opened this issue Jun 21, 2023 · 3 comments

Comments

@nikoltoll
Copy link

When I run an example, for instance sklearn_regressor.py, I get the following error in explain.py:

File c:\users\nikur\code\shapr\python\shaprpy\explain.py:30
n_combinations: int | None = None,

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

@martinju
Copy link
Member

I am not a python expert, but by googling this, it seems that it's an issue with Python versions pre 3.10, see e.g. fastapi/typer#371

The examples runs fine on my end with Python 3.11.3. I guess you are on 3.9 or earlier?

@nikoltoll
Copy link
Author

Yes the Python version was the problem. I substituted all | by ‘or’, but then I got an error that explain returned four arguments instead of three. This was easily solved by adding a fourth argument. This turned out to be timing info coming from R. Now it works, thanks!

@martinju
Copy link
Member

Great! Feel free to add a PR if you believe substituting | by or is a fix that works on more python versions.

Seems like I forgot to update some of the examples after expanding the output from the function call. Will fox that.

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