Comments (12)
@kevinsung I'm late to the party, but one solution when all else fails is to import within the function. It looks like you've found a better solution through restructuring :)
from openfermion.
Great. Write "Fixes #94" in that PR so that when we merge it will close this issue automatically.
from openfermion.
These sorts of circular dependancies can be really annoying to deal with. You may need to change the order of imports in __init__
somewhere (breaking the alphabetical order) or you may need to do a much more specific import somewhere that does the import just inside a function instead of at the top of the file. In this sort of situation, I recommend just hacking to try to make things work. I do not think there is a nice general strategy to avoid this.
@Strilanc @maffoo @Spaceenter do you guys have any more enlightened software engineering tips for avoiding this sort of thing? @idk3 I know you dealt with this a lot in FermiLib. Any ideas?
from openfermion.
My past experience is that circular dependencies indicate design issues, and could usually be solved by a bit re-design.
For this case, it seems like 'util' should be the lowest level. I agree things like "swap_column" and "swap_rows" should belong to 'util'. But I feel trotter_error.py should probably belong to higher level, maybe even higher than Hamiltonion.
I think the layer should be util -> ops -> hamiltonion -> high-level "util" such as the trotter_error thing.
from openfermion.
I agree with @Spaceenter
from openfermion.
from openfermion.
In that case one solution is to move swap_rows
and swap_columns
to ops/_quadratic_hamiltonian.py
and import these functions in utils/_slater_determinants.py
.
from openfermion.
from openfermion.
However, I realized that in my pull request, I import other things from utils
in ops/_quadratic_hamiltonian.py
.
from openfermion.
Namely, I need to use givens_decomposition
and fermionic_gaussian_decomposition
from utils/_slater_determinants.py
in ops/_quadratic_hamiltonian.py
.
from openfermion.
Perhaps utils/_slater_determinants.py
needs a new home.
from openfermion.
Okay, I think I have a satisfactory solution. I will restructure the code to resolve this in PR #95 .
from openfermion.
Related Issues (20)
- Help with one-body and two-body coefficients for orbital removal
- UHF energy with openfermion HOT 1
- scipy > 1.9.3 breaks QuarticFermionicSimulationGate decompose method. HOT 5
- Incorrect Bounds on Trotter Error
- Incorrect formula to calculate required Trotter steps HOT 1
- Resource estimation code not tested as part of the CI
- Should move to black for formatting.
- Why does MajoranaOperator not subclass SymbolicOperator? HOT 1
- Some inconsistencies in molecular single factorization costings HOT 1
- Inconsistencies in the double factorized chemistry resource estimate costing function
- 91 tests fail HOT 7
- Nightly tests are broken HOT 1
- slight modification to function generate_hamiltonian ?
- Operation between MajoranaOperator and numbers? HOT 5
- QuadraticFermionicSimulationGate tests fail with cirq == 1.3.0 HOT 5
- Hubbard model notebook is flaky
- Trotter evolution time may be off by a factor of 2 HOT 2
- 1 test fails HOT 1
- get_sparse_operator fails on non-simplified QubitOperators
- Bad behavior when working with sympy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openfermion.