Skip to content

Commit

Permalink
Merge pull request #14 from qDNA-yonsei/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
israelferrazaraujo authored Mar 24, 2024
2 parents aed91fb + aeb0025 commit 0c79ecb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 30 deletions.
12 changes: 6 additions & 6 deletions qdna/embedding/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from qdna.embedding.iqp_feature_map import IqpFeatureMap
from qdna.embedding.ae_feature_map import AeFeatureMap
from .iqp_feature_map import IqpFeatureMap
from .ae_feature_map import AeFeatureMap

from qdna.embedding.nqe_z_feature_map import NqeZFeatureMap
from qdna.embedding.nqe_zz_feature_map import NqeZZFeatureMap
from qdna.embedding.nqe_iqp_feature_map import NqeIqpFeatureMap
from qdna.embedding.nqe_ae_feature_map import NqeAeFeatureMap
from .nqe_z_feature_map import NqeZFeatureMap
from .nqe_zz_feature_map import NqeZZFeatureMap
from .nqe_iqp_feature_map import NqeIqpFeatureMap
from .nqe_ae_feature_map import NqeAeFeatureMap
Empty file added qdna/embedding/util/__init__.py
Empty file.
25 changes: 1 addition & 24 deletions qdna/embedding/util/state_tree_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ def __str__(self):
f"{self.sign*self.norm}"
)

# def _abs(self):
# # SymPy's `Abs` function doesn't work with hybrid optimization backwards.
# """Absolute value of a ParameterExpression"""
# if _optionals.HAS_SYMENGINE:
# import symengine
# return ParameterExpression(self._parameter_symbols, symengine.Abs(self._symbol_expr))
# else:
# from sympy import Abs as sp_abs
# return ParameterExpression(self._parameter_symbols, sp_abs(self._symbol_expr))

def _sqrt(self):
"""Square root of a ParameterExpression"""
if _optionals.HAS_SYMENGINE:
Expand All @@ -60,21 +50,8 @@ def _sqrt(self):
return self._call(sp_sqrt)

def _sign(self):
# SymPy's `sign` function doesn't work with hybrid optimization backwards.
"""Sign of a ParameterExpression"""
# if _optionals.HAS_SYMENGINE:
# import symengine
# return ParameterExpression(
# self._parameter_symbols, symengine.sign(self._symbol_expr + 1e-4)
# )
# else:
# from sympy import sign
# return ParameterExpression(
# self._parameter_symbols, sign(self._symbol_expr + 1e-4)
# )

# If self is exactly `-10^-4`, the algorithm is interrupted.
# This is because the `sign` function will return 0, zeroing the norms.
# SymPy's `sign` function doesn't work with hybrid optimization backwards.
return self / _sqrt(self*self)

def state_decomposition(nqubits, data, normalize=False):
Expand Down

0 comments on commit 0c79ecb

Please sign in to comment.