Skip to content

Commit 9d3b252

Browse files
authored
Merge pull request #42 from ACSVMath/module-cleanup
Overall module cleanup and refactoring backends
2 parents 16d6b87 + 1a191bb commit 9d3b252

File tree

19 files changed

+276
-141
lines changed

19 files changed

+276
-141
lines changed

docs/source/reference.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ Reference Manual
55
:maxdepth: 2
66

77
reference/asymptotics
8+
reference/backends
89
reference/debug
10+
reference/groebner
911
reference/helpers
1012
reference/kronecker
11-
reference/macaulay2
12-
reference/msolve
1313
reference/settings
1414
reference/whitney

docs/source/reference/backends.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Backend Interfaces
2+
==================
3+
4+
See :class:`.ACSVSettings` for information on how to
5+
configure the default computational backends. The module
6+
:mod:`.sage_acsv.groebner` is the entrypoint for Groebner basis
7+
computations.
8+
9+
.. toctree::
10+
:maxdepth: 2
11+
12+
backends/default
13+
backends/macaulay2
14+
backends/msolve
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
``default``
2+
===========
3+
4+
.. automodule:: sage_acsv.backends.default
5+
:members:
6+
:undoc-members:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
``macaulay2``
22
=============
33

4-
.. automodule:: sage_acsv.macaulay2
4+
.. automodule:: sage_acsv.backends.macaulay2
55
:members:
66
:undoc-members:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
``msolve``
22
==========
33

4-
.. automodule:: sage_acsv.msolve
4+
.. automodule:: sage_acsv.backends.msolve
55
:members:
66
:undoc-members:

docs/source/reference/groebner.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
``groebner``
2+
============
3+
4+
.. automodule:: sage_acsv.groebner
5+
:members:
6+
:undoc-members:

sage_acsv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
__version__ = importlib.metadata.version(__name__)
55

66
from sage_acsv.asymptotics import *
7-
from sage_acsv.kronecker import *
7+
from sage_acsv.kronecker import kronecker_representation
88
from sage_acsv.helpers import get_expansion_terms
99
from sage_acsv.settings import ACSVSettings

sage_acsv/asymptotics.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,23 @@
116116

117117
from copy import copy
118118

119-
from sage.all import AA, PolynomialRing, QQ, QQbar, SR, DifferentialWeylAlgebra, Ideal
120-
from sage.all import (
121-
gcd,
122-
prod,
123-
pi,
124-
matrix,
125-
exp,
126-
log,
127-
I,
128-
factorial,
129-
srange,
130-
shuffle,
131-
vector,
132-
)
119+
from sage.algebras.weyl_algebra import DifferentialWeylAlgebra
120+
from sage.arith.misc import gcd
121+
from sage.arith.srange import srange
122+
from sage.functions.log import log, exp
123+
from sage.functions.other import factorial
124+
from sage.matrix.constructor import matrix
125+
from sage.misc.misc_c import prod
126+
from sage.misc.prandom import shuffle
127+
from sage.modules.free_module_element import vector
128+
from sage.rings.asymptotic.asymptotic_ring import AsymptoticRing
129+
from sage.rings.ideal import Ideal
130+
from sage.rings.imaginary_unit import I
131+
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
132+
from sage.rings.qqbar import AA, QQbar
133+
from sage.rings.rational_field import QQ
134+
from sage.symbolic.constants import pi
135+
from sage.symbolic.ring import SR
133136

134137
from sage_acsv.kronecker import _kronecker_representation
135138
from sage_acsv.helpers import (
@@ -144,7 +147,7 @@
144147
from sage_acsv.debug import Timer, acsv_logger
145148
from sage_acsv.settings import ACSVSettings
146149
from sage_acsv.whitney import whitney_stratification
147-
from sage_acsv.macaulay2 import compute_primary_decomposition, compute_saturation
150+
from sage_acsv.groebner import compute_primary_decomposition, compute_saturation
148151

149152

150153
# we need to monkeypatch a function from the asymptotics module such that creating
@@ -337,8 +340,6 @@ def _diagonal_asymptotics_combinatorial_smooth(
337340
result = sum([a**n * b * c * d for (a, b, c, d) in result])
338341

339342
elif output_format == ACSVSettings.Output.ASYMPTOTIC:
340-
from sage.all import AsymptoticRing
341-
342343
AR = AsymptoticRing("QQbar^n * n^QQ", QQbar)
343344
n = AR.gen()
344345
result = sum(
@@ -653,7 +654,8 @@ def diagonal_asymptotics_combinatorial(
653654
vs_copy, r_copy = copy(vs), copy(r)
654655
for cp in min_crit_pts:
655656
vs, r = copy(vs_copy), copy(r_copy)
656-
# Step 1: Determine if pt is a transverse multiple point of H, and compute the factorization
657+
# Step 1: Determine if pt is a transverse multiple point of H,
658+
# and compute the factorization
657659
# for now, we'll just try to factor it in the polynomial ring
658660
R = PolynomialRing(QQbar, len(vs), vs)
659661
G = R(SR(G))
@@ -683,8 +685,10 @@ def diagonal_asymptotics_combinatorial(
683685
)
684686

685687
# Step 2: Find the locally parametrizing coordinates of the point pt
686-
# Since we have d variables and s factors, there should be d-s of these parametrizing coordinates
687-
# We will try to parametrize with the first d-s coordinates, shuffling the vs and r if it doesn't work
688+
# Since we have d variables and s factors, there should be d-s of these
689+
# parametrizing coordinates
690+
# We will try to parametrize with the first d-s coordinates, shuffling
691+
# the vs and r if it doesn't work
688692
for _ in range(s**2):
689693
Jac = matrix(
690694
[
@@ -717,7 +721,8 @@ def diagonal_asymptotics_combinatorial(
717721
x ** (multiplicities[i] - 1)
718722
for i, x in enumerate(list(vector(r) * Gamma.inverse())[:s])
719723
)
720-
# If cp lies on a single smooth component, we can compute asymptotics like in the smooth case
724+
# If cp lies on a single smooth component, we can compute asymptotics
725+
# like in the smooth case
721726
if s == 1 and sum(multiplicities) == 1:
722727
n = SR.var("n")
723728
expansion = sum(
@@ -785,8 +790,6 @@ def diagonal_asymptotics_combinatorial(
785790
result = sum([a**n * b * c * d for (a, b, c, d) in result])
786791

787792
elif output_format == ACSVSettings.Output.ASYMPTOTIC:
788-
from sage.all import AsymptoticRing
789-
790793
AR = AsymptoticRing("QQbar^n * n^QQ", QQbar)
791794
n = AR.gen()
792795
result = sum(

sage_acsv/backends/__init__.py

Whitespace-only changes.

sage_acsv/backends/default.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Default implementations of Groebner basis computations
2+
using SageMath."""
3+
4+
def compute_primary_decomposition(ideal):
5+
"""Return the primary decomposition of an ideal.
6+
7+
INPUT:
8+
9+
* ``ideal`` - A polynomial ideal
10+
"""
11+
return ideal.primary_decomposition()
12+
13+
def compute_groebner_basis(ideal):
14+
"""Return a Groebner basis of an ideal.
15+
16+
INPUT:
17+
18+
* ``ideal`` - A polynomial ideal
19+
"""
20+
return ideal.groebner_basis()
21+
22+
def compute_radical(ideal):
23+
"""Return the radical of an ideal.
24+
25+
INPUT:
26+
27+
* ``ideal`` - A polynomial ideal
28+
"""
29+
return ideal.radical()

0 commit comments

Comments
 (0)