Open ashsaki opened 6 months ago
This is done by design. The symmetry-aware integrals used to store the 2-body terms report their shape as the correct 4-dimensional shape of the electron repulsion integrals but have a different size because of the encoded symmetries. This brings potentially massive memory savings for storing these objects.
Many numpy methods are handled automatically but reshape
cannot work in the general case. All you need to do to fix your code is to unfold
the S8Integrals
to s1 symmetry using the method found in this module. This results in a 4d array that you can reshape as intended.
Looking at that old entanglement forging code, it expects to use a numpy array so you would probably want to make sure that you actually have one. The Tensor
class (which is the base class of S8Integrals
) can be either dense or sparse. So to ensure you have a numpy array you should call its .to_dense()
method to get a dense Tensor
and then extract its .array
property to get the actual inner numpy array.
Here is the code in full:
from qiskit_nature.second_q.operators.symmetric_two_body import unfold
numpy_array = unfold(eri).to_dense().array
Environment
What is happening?
from qiskit_nature.second_q.operators.tensor_ordering import to_chemist_ordering
in0.7.2
returns different size object compared to0.6.2
leading to breaking behavior.How can we reproduce the issue?
MWE
Result
0.6.2
Result
0.7.2
It leads to errors in previous workflows such as in
circuit-knitting-toolbox
(GitHub Link) as size406
is not compatible with shape(7, 7, 7, 7)
.What should happen?
The Tensor object's size and shape should be compatible.
Any suggestions?
No response