Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #14

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading