Skip to content

Commit

Permalink
Minor fix for numpy old version compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneGasperini committed Oct 2, 2024
1 parent 89c0b6c commit 9412a5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/qiskit_symb/circuit/gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _get_tensor(self):
"""todo"""
sympy_matrix = self.__sympy__()
newshape = (2, 2) * self.num_qubits
return numpy.reshape(sympy_matrix, shape=newshape)
return numpy.reshape(sympy_matrix, newshape)

def to_sympy(self):
"""todo"""
Expand Down
4 changes: 2 additions & 2 deletions src/qiskit_symb/quantum_info/quantumbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _get_circ_unitary(circ):
circ = transpile(circ, optimization_level=1)
dim = 2 ** circ.num_qubits
newshape = (2, 2) * circ.num_qubits
unitary = numpy.reshape(numpy.eye(dim), shape=newshape)
unitary = numpy.reshape(numpy.eye(dim), newshape)
for layer in circuit_to_dag(circ).layers():
for instr in layer['graph'].gate_nodes():
gate_tensor = Gate.get(instruction=instr)._get_tensor()
Expand All @@ -38,7 +38,7 @@ def _get_circ_unitary(circ):
unitary = numpy.einsum(indexing, gate_tensor, unitary,
dtype=object, casting='no', optimize='optimal')
gph = sympy.exp(sympy.I * circ.global_phase)
return gph * Matrix(numpy.reshape(unitary, shape=(dim, dim)))
return gph * Matrix(numpy.reshape(unitary, (dim, dim)))

@classmethod
def from_label(cls, label):
Expand Down

0 comments on commit 9412a5f

Please sign in to comment.