[docs]defis_zero(expr:Number,numerical:bool=False,tolerance:float=1e-9)->bool:""" Return if the given expression is zero. Parameters ---------- expr: Expression that is checked. numerical: If ``True``, then the check is done only numerically with the given tolerance. If ``False`` (default), the check is done symbolically, ``sympy`` method ``equals`` is used. tolerance: The tolerance that is used in the numerical check coordinate-wise. """ifnotnumerical:zero_bool=sp.cancel(sp.sympify(expr)).equals(0)ifzero_boolisNone:raiseRuntimeError("It could not be determined by sympy "+"whether the given sympy expression is zero."+"Please report this as an issue on Github "+"(https://github.com/PyRigi/PyRigi/issues).")returnzero_boolelse:returnisclose(sympy_expr_to_float(expr,tolerance=tolerance),0,abs_tol=tolerance,)
[docs]defis_zero_vector(vector:Sequence[Number],numerical:bool=False,tolerance:float=1e-9)->bool:""" Return if the given vector is zero. Parameters ---------- vector: Vector that is checked. numerical: If ``True``, then the check is done only numerically with the given tolerance. If ``False`` (default), the check is done symbolically, ``sympy`` attribute ``is_zero`` is used. tolerance: The tolerance that is used in the numerical check coordinate-wise. """ifnotisinstance(vector,Matrix):vector=point_to_vector(vector)returnall([is_zero(coord,numerical=numerical,tolerance=tolerance)forcoordinvector])