Skip to content

Commit

Permalink
python/snap/polished_reps.py: Use try..except for imports from Sage
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Oct 31, 2024
1 parent fc01d3a commit ada49ea
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions python/snap/polished_reps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@

if _within_sage:
import sage
from sage.rings.real_mpfr import RealField
from sage.rings.complex_mpfr import ComplexField
from sage.arith.misc import GCD as gcd
from sage.misc.misc_c import prod
from sage.combinat.subset import powerset
from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.constructor import Matrix as matrix
from sage.modules.free_module_element import free_module_element as vector
from sage.rings.integer_ring import Z as ZZ
try:
# Monolithic Sage library
from sage.all import RealField, ComplexField, gcd, prod, powerset
from sage.all import MatrixSpace, matrix, vector, ZZ
except ImportError:
# Modularized Sage library
from sage.rings.real_mpfr import RealField
from sage.rings.complex_mpfr import ComplexField
from sage.arith.misc import GCD as gcd
from sage.misc.misc_c import prod
from sage.combinat.subset import powerset
from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.constructor import Matrix as matrix
from sage.modules.free_module_element import free_module_element as vector
from sage.rings.integer_ring import Z as ZZ
Object = sage.structure.sage_object.SageObject
identity = lambda A: MatrixSpace(A.base_ring(), A.nrows())(1)
abelian_group_elt = lambda v: vector(ZZ, v)
Expand Down

0 comments on commit ada49ea

Please sign in to comment.