Skip to content

Commit

Permalink
Lazy import root systems, crystals and other combinatorics features t…
Browse files Browse the repository at this point in the history
…o save on startup time; fixes sagemath#15293
  • Loading branch information
nthiery authored and mkoeppe committed Apr 16, 2023
1 parent 3bcaa60 commit 84f7091
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/sage/combinat/all.py
Expand Up @@ -95,7 +95,7 @@

# Permutations
from .permutation import Permutation, Permutations, Arrangements, CyclicPermutations, CyclicPermutationsOfPartition
from .affine_permutation import AffinePermutationGroup
lazy_import('sage.combinat.affine_permutation', 'AffinePermutationGroup')
lazy_import('sage.combinat.colored_permutations', ['ColoredPermutations',
'SignedPermutation',
'SignedPermutations'])
Expand Down Expand Up @@ -203,10 +203,10 @@
['ParkingFunctions', 'ParkingFunction'])

# Trees and Tamari interval posets
from .ordered_tree import (OrderedTree, OrderedTrees,
LabelledOrderedTree, LabelledOrderedTrees)
from .binary_tree import (BinaryTree, BinaryTrees,
LabelledBinaryTree, LabelledBinaryTrees)
lazy_import('sage.combinat.ordered_tree', ['OrderedTree', 'OrderedTrees',
'LabelledOrderedTree', 'LabelledOrderedTrees'])
lazy_import('sage.combinat.binary_tree', ['BinaryTree', 'BinaryTrees',
'LabelledBinaryTree', 'LabelledBinaryTrees'])
lazy_import('sage.combinat.interval_posets', ['TamariIntervalPoset', 'TamariIntervalPosets'])
lazy_import('sage.combinat.rooted_tree', ('RootedTree', 'RootedTrees',
'LabelledRootedTree', 'LabelledRootedTrees'))
Expand Down
3 changes: 2 additions & 1 deletion src/sage/combinat/k_tableau.py
Expand Up @@ -37,7 +37,6 @@
from sage.misc.inherit_comparison import InheritComparisonClasscallMetaclass
from sage.combinat.skew_tableau import SkewTableau, SemistandardSkewTableaux
from sage.combinat.partition import Partition, Partitions
from sage.combinat.root_system.weyl_group import WeylGroup
from sage.combinat.core import Core
from sage.rings.integer_ring import ZZ
from sage.functions.generalized import sgn
Expand Down Expand Up @@ -1826,6 +1825,7 @@ def straighten_input(t, k):
...
ValueError: inconsistent number of rows: should be 4 but got 5
"""
from sage.combinat.root_system.weyl_group import WeylGroup
W = WeylGroup(['A', k, 1], prefix='s')
if len(t) > 0:
if isinstance(t[0], (list, tuple)):
Expand Down Expand Up @@ -1864,6 +1864,7 @@ def __classcall_private__(cls, t, k, inner_shape = []):
"""
if isinstance(t, cls):
return t
from sage.combinat.root_system.weyl_group import WeylGroup
W = WeylGroup(['A', k, 1], prefix='s')
w = cls.straighten_input(t, k)
weight = tuple(w[i].length() for i in range(len(w) - 1, -1, -1))
Expand Down
13 changes: 7 additions & 6 deletions src/sage/combinat/root_system/all.py
Expand Up @@ -121,12 +121,13 @@

from sage.misc.lazy_import import lazy_import

from .cartan_type import CartanType
from .dynkin_diagram import DynkinDiagram
from .cartan_matrix import CartanMatrix
from .coxeter_matrix import CoxeterMatrix
from .coxeter_type import CoxeterType
from .root_system import RootSystem, WeylDim
lazy_import('sage.combinat.root_system.cartan_type', 'CartanType')
lazy_import('sage.combinat.root_system.dynkin_diagram', 'DynkinDiagram')
lazy_import('sage.combinat.root_system.cartan_matrix', 'CartanMatrix')
lazy_import('sage.combinat.root_system.coxeter_matrix', 'CoxeterMatrix')
lazy_import('sage.combinat.root_system.coxeter_type', 'CoxeterType')
lazy_import('sage.combinat.root_system.root_system', 'RootSystem')
lazy_import('sage.combinat.root_system.root_system', 'WeylDim')
lazy_import('sage.combinat.root_system.weyl_group', ['WeylGroup',
'WeylGroupElement'])
lazy_import('sage.combinat.root_system.reflection_group_real',
Expand Down

0 comments on commit 84f7091

Please sign in to comment.