QHyper.parser#
Module for parsing sympy expressions to Polynomial.
This module provides a way to parse sympy expressions and string to
Polynomial.
It is not recommended to use this module for large polynomials as it is very
slow in comparison to creating Polynomial directly from the dict.
Functions
- from_str(equation)[source]#
Method to parse a string to a polynomial. Uses ast parser to parse the equation. This method is very slow in comparison to creating Polynomial directly from the dict. Although, for smaller polynomials, it is not noticeable.
- Parameters:
equation (str) – The equation to be parsed in form of string.
- Returns:
The parsed polynomial.
- Return type:
- from_sympy(equation)[source]#
Method to convert a sympy expression to a polynomial. Uses ast parser to parse the equation. This method is very slow in comparison to creating Polynomial directly from the dict. Although, for smaller polynomials, it is not noticeable.
- Parameters:
equation (sympy.core.Expr) – The sympy expression to be converted.
- Returns:
The converted polynomial.
- Return type:
- to_sympy(poly)[source]#
Method to convert a polynomial to a sympy expression. Might be handy to display the polynomial in a more readable form.
- Parameters:
poly (Polynomial) – The polynomial to be converted.
- Returns:
The sympy expression.
- Return type:
str