Skip to content

Commit

Permalink
sagemathgh-36676: Restructure sage.*.all for modularization, replac…
Browse files Browse the repository at this point in the history
…e relative by absolute imports

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->
We restructure the `all.py` files for modularization.

Guided by the technical constraints outlined in
https://groups.google.com/g/sage-devel/c/ozh-7ZZ848s, sagemath#35095 defines
distribution packages (pip-installable packages) **sagemath-{brial,
combinat, eclib, flint, gap, giac, glpk, graphs, groups, homfly, lcalc,
libbraiding, libecm, linbox, modules, mpmath, ntl, pari, plot,
polyhedra, schemes, singular, standard-no-symbolics, symbolics}**.

When a namespace package such as `sage.misc` is filled by modules from
several distribution packages, we create modules named:
- `src/sage/misc/all__sagemath_environment.py`
- `src/sage/misc/all__sagemath_objects.py`
- `src/sage/misc/all__sagemath_repl.py`

Import statements are moved from `src/sage/misc/all.py` to these files
as appropriate, and `src/sage/misc/all.py` imports `*` from there.

Also some imports are replaced by lazy imports.

The new files provide the top level namespaces for the modularized
distribution packages, thus [enabling modularized testing](https://doc.s
agemath.org/html/en/developer/packaging_sage_library.html#testing-
distribution-packages).

This design was introduced in sagemath#29865 (merged in Jan 2022, early in the
Sage 9.6 development cycle).

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
- Copied from sagemath#35095.
- Part of sagemath#29705

Moreover, applied a one-line command to replace relative by absolute
imports, thus complementing sagemath#36666, which does not touch `.all*` files.

The changes to other files in `sage.modules` etc. come from the PRs
sagemath#36597, sagemath#36572, sagemath#36588, sagemath#36589 merged here and do not need review.

<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
- Depends on sagemath#36597 (merged here to resolve merge conflict)
- Depends on sagemath#36572 (merged here to
resolve merge conflict)
- Depends on sagemath#36588 (merged here to
resolve merge conflict)
- Depends on sagemath#36589 (merged here to
resolve merge conflict)
- Depends on sagemath#36449 (merged here to resolve merge conflict)

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36676
Reported by: Matthias Köppe
Reviewer(s): David Coudert, John H. Palmieri, Kwankyu Lee, Matthias Köppe, Tobias Diez
  • Loading branch information
Release Manager committed Mar 31, 2024
2 parents 1cd4990 + bce2a59 commit ab97d70
Show file tree
Hide file tree
Showing 292 changed files with 1,990 additions and 1,640 deletions.
24 changes: 9 additions & 15 deletions pkgs/sagemath-categories/known-test-failures.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"ntests": 28
},
"sage.categories.affine_weyl_groups": {
"ntests": 14
"ntests": 15
},
"sage.categories.algebra_ideals": {
"failed": true,
Expand Down Expand Up @@ -148,7 +148,7 @@
},
"sage.categories.coxeter_groups": {
"failed": true,
"ntests": 362
"ntests": 363
},
"sage.categories.cw_complexes": {
"failed": true,
Expand Down Expand Up @@ -301,7 +301,7 @@
},
"sage.categories.finite_complex_reflection_groups": {
"failed": true,
"ntests": 178
"ntests": 199
},
"sage.categories.finite_coxeter_groups": {
"ntests": 6
Expand Down Expand Up @@ -493,10 +493,6 @@
"failed": true,
"ntests": 13
},
"sage.categories.inner_product_spaces": {
"failed": true,
"ntests": 9
},
"sage.categories.integral_domains": {
"failed": true,
"ntests": 22
Expand Down Expand Up @@ -783,7 +779,7 @@
},
"sage.cpython.debug": {
"failed": true,
"ntests": 14
"ntests": 13
},
"sage.cpython.dict_del_by_value": {
"failed": true,
Expand Down Expand Up @@ -826,7 +822,6 @@
"ntests": 321
},
"sage.doctest.reporting": {
"failed": true,
"ntests": 124
},
"sage.doctest.sources": {
Expand Down Expand Up @@ -1091,7 +1086,7 @@
},
"sage.misc.sageinspect": {
"failed": true,
"ntests": 329
"ntests": 332
},
"sage.misc.superseded": {
"failed": true,
Expand Down Expand Up @@ -1124,6 +1119,7 @@
"ntests": 128
},
"sage.repl.configuration": {
"failed": true,
"ntests": 22
},
"sage.repl.display.fancy_repr": {
Expand All @@ -1149,6 +1145,7 @@
"ntests": 42
},
"sage.repl.inputhook": {
"failed": true,
"ntests": 7
},
"sage.repl.interface_magic": {
Expand All @@ -1157,7 +1154,7 @@
},
"sage.repl.interpreter": {
"failed": true,
"ntests": 118
"ntests": 114
},
"sage.repl.ipython_extension": {
"failed": true,
Expand Down Expand Up @@ -1188,7 +1185,7 @@
},
"sage.repl.load": {
"failed": true,
"ntests": 42
"ntests": 38
},
"sage.repl.preparse": {
"failed": true,
Expand Down Expand Up @@ -1315,9 +1312,6 @@
"sage.structure.global_options": {
"ntests": 145
},
"sage.structure.graphics_file": {
"ntests": 8
},
"sage.structure.indexed_generators": {
"failed": true,
"ntests": 90
Expand Down
2 changes: 2 additions & 0 deletions src/doc/en/reference/calculus/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Using calculus

- :doc:`More about symbolic variables and functions <sage/calculus/var>`
- :doc:`Main operations on symbolic expressions <sage/symbolic/expression>`
- :doc:`sage/calculus/expr`
- :doc:`Assumptions about symbols and functions <sage/symbolic/assumptions>`
- :doc:`sage/symbolic/relation`
- :doc:`sage/symbolic/integration/integral`
Expand Down Expand Up @@ -65,6 +66,7 @@ Internal functionality supporting calculus

sage/symbolic/expression
sage/symbolic/callable
sage/calculus/expr
sage/symbolic/assumptions
sage/symbolic/relation
sage/calculus/calculus
Expand Down
58 changes: 7 additions & 51 deletions src/sage/algebras/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,56 +14,12 @@
# The full text of the GPL is available at:
#
# https://www.gnu.org/licenses/
# ****************************************************************************
from sage.misc.lazy_import import lazy_import

# old-style class for associative algebras, use Parent instead
from sage.rings.ring import Algebra

import sage.algebras.catalog as algebras

from .quatalg.all import *
from .steenrod.all import *
from .fusion_rings.all import *
from .lie_algebras.all import *
from .quantum_groups.all import *
from .lie_conformal_algebras.all import *

# Algebra base classes
from .free_algebra import FreeAlgebra
from .free_algebra_quotient import FreeAlgebraQuotient

from .finite_dimensional_algebras.all import FiniteDimensionalAlgebra

lazy_import('sage.algebras.group_algebra', 'GroupAlgebra')

lazy_import('sage.algebras.iwahori_hecke_algebra', 'IwahoriHeckeAlgebra')
lazy_import('sage.algebras.affine_nil_temperley_lieb',
'AffineNilTemperleyLiebTypeA')
lazy_import('sage.algebras.nil_coxeter_algebra', 'NilCoxeterAlgebra')
lazy_import('sage.algebras.schur_algebra', ['SchurAlgebra',
'SchurTensorModule'])

lazy_import('sage.algebras.hall_algebra', 'HallAlgebra')

lazy_import('sage.algebras.jordan_algebra', 'JordanAlgebra')

lazy_import('sage.algebras.octonion_algebra', 'OctonionAlgebra')

lazy_import('sage.algebras.shuffle_algebra', 'ShuffleAlgebra')

from .clifford_algebra import CliffordAlgebra, ExteriorAlgebra
from .weyl_algebra import DifferentialWeylAlgebra

lazy_import('sage.algebras.commutative_dga', 'GradedCommutativeAlgebra')

lazy_import('sage.algebras.rational_cherednik_algebra',
'RationalCherednikAlgebra')

lazy_import('sage.algebras.tensor_algebra', 'TensorAlgebra')

lazy_import('sage.algebras.q_system', 'QSystem')
# *****************************************************************************

lazy_import('sage.algebras.cluster_algebra', 'ClusterAlgebra')
from sage.algebras.all__sagemath_modules import *
from sage.algebras.all__sagemath_combinat import *

lazy_import('sage.algebras.yangian', 'Yangian')
from sage.algebras.quatalg.all import *
from sage.algebras.fusion_rings.all import *
from sage.algebras.lie_algebras.all import *
from sage.algebras.lie_conformal_algebras.all import *
37 changes: 37 additions & 0 deletions src/sage/algebras/all__sagemath_combinat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from sage.misc.lazy_import import lazy_import


# Algebra base classes
from sage.algebras.free_algebra import FreeAlgebra
from sage.algebras.free_algebra_quotient import FreeAlgebraQuotient

from sage.algebras.steenrod.all import *
from sage.algebras.quantum_groups.all import *

lazy_import('sage.algebras.iwahori_hecke_algebra', 'IwahoriHeckeAlgebra')
lazy_import('sage.algebras.affine_nil_temperley_lieb',
'AffineNilTemperleyLiebTypeA')
lazy_import('sage.algebras.nil_coxeter_algebra', 'NilCoxeterAlgebra')
lazy_import('sage.algebras.schur_algebra', ['SchurAlgebra',
'SchurTensorModule'])

lazy_import('sage.algebras.hall_algebra', 'HallAlgebra')

lazy_import('sage.algebras.jordan_algebra', 'JordanAlgebra')

lazy_import('sage.algebras.shuffle_algebra', 'ShuffleAlgebra')

lazy_import('sage.algebras.commutative_dga', 'GradedCommutativeAlgebra')

lazy_import('sage.algebras.rational_cherednik_algebra',
'RationalCherednikAlgebra')

lazy_import('sage.algebras.tensor_algebra', 'TensorAlgebra')

lazy_import('sage.algebras.q_system', 'QSystem')

lazy_import('sage.algebras.cluster_algebra', 'ClusterAlgebra')

lazy_import('sage.algebras.yangian', 'Yangian')

del lazy_import
14 changes: 14 additions & 0 deletions src/sage/algebras/all__sagemath_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from sage.misc.lazy_import import lazy_import

lazy_import('sage.algebras.group_algebra', 'GroupAlgebra')

# old-style class for associative algebras, use Parent instead
from sage.rings.ring import Algebra

from sage.algebras.finite_dimensional_algebras.all import FiniteDimensionalAlgebra
from sage.algebras.clifford_algebra import CliffordAlgebra, ExteriorAlgebra
from sage.algebras.weyl_algebra import DifferentialWeylAlgebra
lazy_import('sage.algebras.octonion_algebra', 'OctonionAlgebra')

import sage.algebras.catalog as algebras
del lazy_import
Empty file.
2 changes: 1 addition & 1 deletion src/sage/algebras/finite_dimensional_algebras/all.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .finite_dimensional_algebra import FiniteDimensionalAlgebra
from sage.algebras.finite_dimensional_algebras.finite_dimensional_algebra import FiniteDimensionalAlgebra
1 change: 1 addition & 0 deletions src/sage/algebras/fusion_rings/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@

lazy_import('sage.algebras.fusion_rings.fusion_ring', ['FusionRing'])
lazy_import('sage.algebras.fusion_rings.fusion_double', ['FusionDouble'])
del lazy_import
1 change: 0 additions & 1 deletion src/sage/algebras/hecke_algebras/all.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
"""
Hecke Algebras
"""
#from sage.misc.lazy_import import lazy_import
9 changes: 5 additions & 4 deletions src/sage/algebras/lie_algebras/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Lie Algebras
"""

#*****************************************************************************
# *****************************************************************************
# Copyright (C) 2013 Travis Scrimshaw <tscrim at ucdavis.edu>
#
# Distributed under the terms of the GNU General Public License (GPL)
Expand All @@ -14,10 +14,11 @@
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
#*****************************************************************************
# https://www.gnu.org/licenses/
# *****************************************************************************
from sage.misc.lazy_import import lazy_import

lazy_import('sage.algebras.lie_algebras.lie_algebra', 'LieAlgebra')
#from kac_moody import KacMoodyAlgebra
# from kac_moody import KacMoodyAlgebra
lazy_import('sage.algebras.lie_algebras', 'examples', 'lie_algebras')
del lazy_import
Empty file.
13 changes: 8 additions & 5 deletions src/sage/algebras/lie_conformal_algebras/all.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#******************************************************************************
# ******************************************************************************
# Copyright (C) 2020 Reimundo Heluani <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
# https://www.gnu.org/licenses/
# *****************************************************************************


from sage.misc.lazy_import import lazy_import
lazy_import('sage.algebras.lie_conformal_algebras.lie_conformal_algebra','LieConformalAlgebra')
lazy_import('sage.algebras.lie_conformal_algebras', 'examples', 'lie_conformal_algebras')
lazy_import('sage.algebras.lie_conformal_algebras.lie_conformal_algebra',
'LieConformalAlgebra')
lazy_import('sage.algebras.lie_conformal_algebras',
'examples', 'lie_conformal_algebras')
del lazy_import
1 change: 1 addition & 0 deletions src/sage/algebras/quantum_groups/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from sage.misc.lazy_import import lazy_import
lazy_import('sage.algebras.quantum_groups.fock_space', 'FockSpace')
lazy_import('sage.algebras.quantum_groups.quantum_group_gap', 'QuantumGroup')
del lazy_import
2 changes: 1 addition & 1 deletion src/sage/algebras/quatalg/all.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .quaternion_algebra import QuaternionAlgebra
from sage.algebras.quatalg.quaternion_algebra import QuaternionAlgebra
3 changes: 2 additions & 1 deletion src/sage/algebras/steenrod/all.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
The Steenrod algebra
"""
from .steenrod_algebra import SteenrodAlgebra, Sq
from sage.misc.lazy_import import lazy_import
lazy_import('sage.algebras.steenrod.steenrod_algebra', ['SteenrodAlgebra', 'Sq'])
lazy_import('sage.algebras.steenrod.steenrod_algebra_bases',
'steenrod_algebra_basis',
deprecation=(32647, 'removed from namespace'))
del lazy_import
Loading

0 comments on commit ab97d70

Please sign in to comment.