Skip to content

Commit

Permalink
Use custom sympify hack in ParameterConstraint init
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Apr 18, 2023
1 parent cc5331e commit 0ed9a24
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions qupulse/pulses/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from qupulse.serialization import AnonymousSerializable
from qupulse.expressions import Expression
from qupulse.parameter_scope import Scope, ParameterNotProvidedException
from qupulse.utils.sympy import sympify

__all__ = ["ParameterNotProvidedException", "ParameterConstraintViolation", "ParameterConstraint"]

Expand All @@ -22,9 +23,9 @@ def __init__(self, relation: Union[str, sympy.Expr]):
super().__init__()
if isinstance(relation, str) and '==' in relation:
# The '==' operator is interpreted by sympy as exactly, however we need a symbolical evaluation
self._expression = sympy.Eq(*sympy.sympify(relation.split('==')))
self._expression = sympy.Eq(*sympify(relation.split('==')))
else:
self._expression = sympy.sympify(relation)
self._expression = sympify(relation)
if not isinstance(self._expression, sympy.logic.boolalg.Boolean):
raise ValueError('Constraint is not boolean')
self._expression = Expression(self._expression)
Expand Down

0 comments on commit 0ed9a24

Please sign in to comment.