diff --git a/syngular/polynomial.py b/syngular/polynomial.py index 711f518..e73c13d 100644 --- a/syngular/polynomial.py +++ b/syngular/polynomial.py @@ -167,7 +167,7 @@ def reduce(self): @staticmethod def __rstr__(polynomial, field): polynomial = polynomial.replace(" ", "").replace("+-", "-") - polynomial = re.sub(r"(\+|\-)I\*{0,1}([\d\.]+)", r"\1\2j", polynomial) # format complex nbrs + polynomial = re.sub(r"(\+|\-)I\*{0,1}([\d\.e\+\-]+)", r"\1\2j", polynomial) # format complex nbrs parentheses = [(("(", ), (")", )), (("{", ), ("}", )), (("[", "⟨", "<", ), ("]", "⟩", ">"))] lopen_parentheses = [parenthesis[0] for parenthesis in parentheses] lclos_parentheses = [parenthesis[1] for parenthesis in parentheses] diff --git a/syngular/variety.py b/syngular/variety.py index e3ff516..6453e45 100644 --- a/syngular/variety.py +++ b/syngular/variety.py @@ -9,6 +9,8 @@ from copy import copy, deepcopy from pyadic import ModP +from mpmath.libmp.libhyper import NoConvergence + from .tools import RootNotInFieldError, RootPrecisionError from .field import Field from .polynomial import Monomial, Polynomial @@ -32,10 +34,10 @@ def wrapper(self, field, base_point={}, directions=None, valuations=tuple(), ind res = func(self, field, base_point=base_point, directions=directions, valuations=valuations, indepSetNbr=indepSetNbr, seed=seed, verbose=verbose) break - except (RootNotInFieldError, RootPrecisionError) as e: + except (RootNotInFieldError, RootPrecisionError, NoConvergence, AssertionError) as e: if try_nbr != max_tries - 1: if verbose: - print(f"Caught {type(e).__name__}, retrying...") + print(f"Caught {type(e).__name__} at try number {try_nbr}, retrying...") if seed is not None: # maintain pseudo-randomness, but change seed, else retring has no effect. random.seed(seed) seed += random.randint(10 ** 5, 10**6) @@ -157,7 +159,7 @@ def point_on_variety(self, field, base_point={}, directions=None, valuations=tup if prime is None and oSemiNumericalIdeal.groebner_basis == ['1']: raise RootPrecisionError if not oSemiNumericalIdeal.dim == 0: - raise Exception("The dimension of the semi-numerical ideal was not zero.") + raise AssertionError("The dimension of the semi-numerical ideal was not zero.") root_dicts = lex_groebner_solve(oSemiNumericalIdeal.groebner_basis, prime=prime) check_solutions(oSemiNumericalIdeal.groebner_basis, root_dicts, field) # they may be stricter then wanted for mpc.