Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _canonicalize(self, expression):
if isinstance(expression, float):
return sympy.RealNumber(expression)
elif isinstance(expression, int):
return sympy.Integer(expression)
else:
#expression = expression.expand() This would be a good way to canonicalize, but is quite slow
return expression
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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.