Implement the Tensor class#1033
Conversation
7ba284a to
914af8f
Compare
Pull Request Test Coverage Report for Build 4148330521
💛 - Coveralls |
There was a problem hiding this comment.
Hi! I think I will probably have to take another look at the PR to fully understand the uses of this new class. So far, I only have a question: I assume there is a good reason for this, but I wonder... why did you choose not to wrap Numbers into non-dimensional np.arrays from the start? I feel like this could simplify the code, but I probably don't have clear enough vision of how numpy works in these cases.
Thanks for raising this! I am actually no longer aware of why I tried so hard to achieve this.. 🤔 I just pushed a commit to revert this and see how this goes. This is actually what we were already doing in the |
a900578 to
7165f80
Compare
This matches what we did in the PolynomialTensor and avoids unnecessary complicated code to deal with Number objects where otherwise one always encounters an array.
The Jupyter Sphinx integration is currently unable to properly suppress warnings resulting in prints to stderr [1]. This causes the docs to fail building properly. Qiskit Terra already removed the usage of `jupyter-execute` statements a while ago [2], so we are following suit in this regard, too. [1]: jupyter/jupyter-sphinx#178 [2]: Qiskit/qiskit#9346
* Implement the Tensor class * Always wrap scalar numbers into numpy array This matches what we did in the PolynomialTensor and avoids unnecessary complicated code to deal with Number objects where otherwise one always encounters an array. * Add qiskit_nature.settings.tensor_wrapping * Add release note * fix: remove jupyter-execute blocks The Jupyter Sphinx integration is currently unable to properly suppress warnings resulting in prints to stderr [1]. This causes the docs to fail building properly. Qiskit Terra already removed the usage of `jupyter-execute` statements a while ago [2], so we are following suit in this regard, too. [1]: jupyter/jupyter-sphinx#178 [2]: Qiskit/qiskit#9346 * fix: rework settings.tensor_wrapping as settings.tensor_unwrapping * docs: update documentaiton of PolynomialTensor now that Tensor exists --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Summary
This class is designed to unify the usage of tensors throught the stack. It provides a central entry point for the handling of arrays enabling seamless interchange of dense and sparse arrays in any usecase. This is done by implementing this class as an
np.ndarraycontainer as described here. At the same time this class can also wrap asparse.SparseArray(which in turn implements thenp.ndarrayinterface).Details and comments
I have two major motivators for this proposal:
label_templateduringSparseLabelOp.from_polynomial_tensor#1032FCIDumpparser #933.