Comments (4)
@idk3 I made a new issue at #274 to implement the changes discussed here. Do you think that covers everything? If so I think we can close this issue.
from openfermion.
- The
keys()
method of dictionaries actually returns a key view, which is a set-like object. See https://docs.python.org/3/library/stdtypes.html#dict-views. - EDIT: Okay actually I might agree with you. Maybe we should be able to compare and add PolynomialTensors that have different keys.
However, this does lead me to another question: why is equality comparison here implemented with an__eq__
method, while for SymbolicOperators it is implemented with theisclose
method? I don't see a reason to do it differently for both. TypeError
is generally raised to indicate that an operation is not meant to be performed in some way on some objects; it appears to me that this is how it's being used here. The returned error message can contain more specifics about the problem.
from openfermion.
-
This is true in Python 3 but not in Python 2, see e.g. https://stackoverflow.com/questions/5629023/key-order-in-python-dictionaries .
-
This is a fair question in general - I don't have a good solution really. I agree that
isclose
is a better way to handle things rather than__eq__
at least for the purposes of consistency. -
I think you're misinterpreting a point about functions and methods from the docs (I think you might be looking at the second paragraph of https://docs.python.org/3/library/exceptions.html#TypeError ?). The paragraph below clarifies this - "Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError, but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError." In this case the arguments would be of the correct type but incorrect value (the dictionaries
x.n_body_tensors
andy.n_body_tensors
have different keys), and a ValueError or similar would be the appropriate error to raise.
from openfermion.
- We can handle this by adding the line
from builtins import dict
and initializing our dictionaries withdict()
. I think that's the preferred way to use thefuture
module to handle this compatibility issue.
Three. Okay, I agree that we should raise ValueError in some of these cases then.
from openfermion.
Related Issues (20)
- multiplicity limitation in molecular data
- 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
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.