Skip to content

Commit

Permalink
Avoid slow matrix manipulation in QuantumBase.to_sympy
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneGasperini committed Nov 7, 2023
1 parent 1c18aad commit 33b0c1b
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/qiskit_symb/quantum_info/quantumbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import sympy
from sympy import lambdify, Symbol
from sympy.core.rules import Transform
from sympy.matrices import matrix2numpy
from qiskit import QuantumCircuit

Expand Down Expand Up @@ -63,13 +62,7 @@ def from_circuit(cls, circuit):

def to_sympy(self):
"""todo"""
# pylint: disable=unnecessary-lambda
sympy_matrix = self._data
sympy_matrix = sympy_matrix.xreplace(
Transform(lambda x: x.round(3), lambda x: x.is_Float))
sympy_matrix = sympy_matrix.xreplace(
Transform(lambda x: int(x), lambda x: x.is_Float and x == int(x)))
return sympy_matrix
return self._data

def to_numpy(self):
"""todo"""
Expand Down

0 comments on commit 33b0c1b

Please sign in to comment.