Closed psteinb closed 2 weeks ago
Note for HEAD
(i.e. 3c1e7250), the following appears to work:
$ python -c 'from sbi import utils; from sbi.neural_nets import posterior_nn'
and gives no error! So it appears to be again caused by circular imports.
Hi Peter, thanks for reporting this! On the pypi
version it should be from sbi.utils import posterior_nn
.
Totally true and well spotted! I'll go with that for the time being. What I find a bit irritating (if not risky) is that in HEAD
the problem of circular imports is hidden due to the way, the ./tests/embedding_net_test.py
imports things.
Fully agreed, we should fix this.
Note also, the current version of the embedding net tutorial points to the syntax valid in HEAD
of sbi (which doesn't work neither in 0.22.0
nor in HEAD
). :frowning_face:
Thanks! See #1159
Just made a dependency graph using pyreverse :O
Seems like a big source of circular imports is sbi.utils.sbiutils and sbi.utils (and probably many more)
Fixed by #1179
Describe the bug I'd like to do
from sbi.neural_nets import posterior_nn
and I getTo Reproduce Please add a minimal code example that reproduces the problem:
3.12.3
and sbi0.22.0
The same happens from the CLI:
Expected behavior I can import
posterior_nn
.Additional context I tried the same with
HEAD
.and then:
Fun thing, if you run the tests in the same fresh environment of sbi, as in
python -m pytest ./tests/embedding_net_test.py
they do pass!