Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if USE_SYMENGINE: # pragma: no cover # noqa: C901
import operator
from six.moves import reduce
optlang._USING_SYMENGINE = True
Integer = symengine.Integer
Real = symengine.RealDouble
Basic = symengine.Basic
Number = symengine.Number
Zero = Integer(0)
One = Integer(1)
NegativeOne = Integer(-1)
sympify = symengine.sympy_compat.sympify
Add = symengine.Add
Mul = symengine.Mul
Pow = symengine.sympy_compat.Pow
class Symbol(symengine_Symbol):
def __new__(cls, name, *args, **kwargs):
if not isinstance(name, six.string_types):
raise TypeError("name should be a string, not %s" % repr(type(name)))
return symengine_Symbol.__new__(cls, name)
def __init__(self, name, *args, **kwargs):
super(Symbol, self).__init__(name)
self._name = name
def __repr__(self):
return self._name
from __future__ import absolute_import
import symengine
Integer = symengine.Integer
Real = symengine.RealNumber
Basic = symengine.Basic
Number = symengine.Number
Zero = Integer(0)
One = Integer(1)
NegativeOne = Integer(-1)
sympify = symengine.sympify
Add = symengine.Add
Mul = symengine.Mul
Pow = symengine.Pow
class UniqueSymbol(symengine.Symbol):
"""
Present a uniform facade to the ``symengine.Symbol`` class.
``symengine.Symbol`` already creates unique objects even when they have
the same name. The use of ``__slots__`` is propagated.
Attributes
----------
name : str
The name of the symbol.