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

Import Errors #725

Open
Anasdec opened this issue Jun 26, 2024 · 5 comments
Open

Import Errors #725

Anasdec opened this issue Jun 26, 2024 · 5 comments

Comments

@Anasdec
Copy link

Anasdec commented Jun 26, 2024

I'm having an import issue for past few days and still not able to solve it.

It's to do with importing _broadcast_shape from numpy.

Below is the error I get
Untitled

@psychedde1ic
Copy link

I also have an issue with numpy as a result import issue.

ImportError: cannot import name '_broadcast_shape' from 'numpy.lib.stride_tricks'

is there any way to fix it? thanks!

@Anasdec
Copy link
Author

Anasdec commented Jun 27, 2024

@psychedde1ic have you managed to get the issue solved?

@Diapolo10
Copy link

In case any other poor souls come across this issue, I did some digging and the issue stems from changes in Numpy 1.26.

It seems this commit removed _broadcast_shape and moved it under np.lib._stride_tricks_impl._broadcast_shape. All main Numpy versions newer than 1.25.2 have this change.

So the solution for users would be to use Numpy version 1.25.2 or older. The developers of VectorBT would need to add this new import (if they really want to rely on undocumented parts not in Numpy's public API) if they want to continue supporting newer Numpy versions. Personally I'd recommend refactoring the code to only rely on the public parts of the API to avoid similar problems in the future, as a better long-term solution.

@Agent-AA
Copy link

I also came across this issue. As @Diapolo10 said, the _broadcast_shape function still exists; it just got moved to a different file. Instead of reverting to an older Numpy version, I fixed the issue by commenting out the problematic import statement in the reshape_fns.py file and manually copied and pasted the _broadcast_shape function from _stride_tricks_impl.py into reshape_fns.py. A better solution from the devs would still be appreciated.

@polakowo
Copy link
Owner

Thanks. Fixed in 0.26.2

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

5 participants