Skip to content

Commit

Permalink
sagemathgh-38096: sage.combinat, sage.games: Use more `lazy_impor…
Browse files Browse the repository at this point in the history
…t` in all.py files

    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

This helps with the modularization, but is also desirable for reducing
the start-up time of Sage.
- Cherry-picked from sagemath#37900

Related: sagemath#35520

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [ ] 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 and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#38096
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
  • Loading branch information
Release Manager committed Jun 15, 2024
2 parents 4d6b879 + d84e10a commit 875628d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/sage/categories/weyl_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,9 +572,10 @@ def stanley_symmetric_function(self):
- [Pon2010]_
"""
import sage.combinat.sf
from sage.rings.rational_field import QQ
m = sage.combinat.sf.sf.SymmetricFunctions(QQ).monomial()
from sage.combinat.sf.sf import SymmetricFunctions

m = SymmetricFunctions(QQ).monomial()
return m.from_polynomial_exp(self.stanley_symmetric_function_as_polynomial())

@cached_in_parent_method
Expand Down
9 changes: 7 additions & 2 deletions src/sage/combinat/ncsf_qsym/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
from sage.misc.namespace_package import install_doc
install_doc(__package__, __doc__)

from sage.combinat.ncsf_qsym.qsym import QuasiSymmetricFunctions
from sage.combinat.ncsf_qsym.ncsf import NonCommutativeSymmetricFunctions
from sage.misc.lazy_import import lazy_import

lazy_import('sage.combinat.ncsf_qsym.qsym', 'QuasiSymmetricFunctions')
lazy_import('sage.combinat.ncsf_qsym.ncsf', 'NonCommutativeSymmetricFunctions')

del install_doc
del lazy_import
9 changes: 7 additions & 2 deletions src/sage/combinat/ncsym/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
from sage.misc.namespace_package import install_doc
install_doc(__package__, __doc__)

from sage.combinat.ncsym.ncsym import SymmetricFunctionsNonCommutingVariables
from sage.combinat.ncsym.dual import SymmetricFunctionsNonCommutingVariablesDual
from sage.misc.lazy_import import lazy_import

lazy_import('sage.combinat.ncsym.ncsym', 'SymmetricFunctionsNonCommutingVariables')
lazy_import('sage.combinat.ncsym.dual', 'SymmetricFunctionsNonCommutingVariablesDual')

del install_doc
del lazy_import
14 changes: 9 additions & 5 deletions src/sage/combinat/root_system/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@
from sage.misc.lazy_import import lazy_import

from sage.combinat.root_system.cartan_type import CartanType
from sage.combinat.root_system.dynkin_diagram import DynkinDiagram
from sage.combinat.root_system.cartan_matrix import CartanMatrix
from sage.combinat.root_system.coxeter_matrix import CoxeterMatrix
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')
from sage.combinat.root_system.coxeter_type import CoxeterType
from sage.combinat.root_system.root_system import RootSystem, WeylDim
lazy_import('sage.combinat.root_system.weyl_group', ['WeylGroup',
Expand All @@ -138,5 +138,9 @@
'WeightRing'])
from sage.combinat.root_system.branching_rules import BranchingRule, branching_rule_from_plethysm, branching_rule

lazy_import('sage.combinat.root_system.non_symmetric_macdonald_polynomials', 'NonSymmetricMacdonaldPolynomials')
lazy_import('sage.combinat.root_system.integrable_representations', 'IntegrableRepresentation')
lazy_import('sage.combinat.root_system.non_symmetric_macdonald_polynomials',
'NonSymmetricMacdonaldPolynomials')
lazy_import('sage.combinat.root_system.integrable_representations',
'IntegrableRepresentation')
del lazy_import
del install_doc
7 changes: 6 additions & 1 deletion src/sage/combinat/words/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,16 @@
from sage.misc.namespace_package import install_doc
install_doc(__package__, __doc__)

from sage.misc.lazy_import import lazy_import

from sage.combinat.words.alphabet import Alphabet, build_alphabet
from sage.combinat.words.morphism import WordMorphism
from sage.combinat.words.paths import WordPaths
lazy_import('sage.combinat.words.paths', 'WordPaths')
from sage.combinat.words.word import Word
from sage.combinat.words.word_options import WordOptions
from sage.combinat.words.word_generators import words
from sage.combinat.words.words import Words, FiniteWords, InfiniteWords
from sage.combinat.words.lyndon_word import LyndonWord, LyndonWords, StandardBracketedLyndonWords

del install_doc
del lazy_import
8 changes: 6 additions & 2 deletions src/sage/games/all.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
from sage.games.sudoku import Sudoku, sudoku
from sage.games.hexad import Minimog

from sage.misc.lazy_import import lazy_import

lazy_import('sage.games.sudoku', ['Sudoku', 'sudoku'])
lazy_import('sage.games.hexad', ['Minimog'])
del lazy_import
4 changes: 2 additions & 2 deletions src/sage/structure/parent.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
sage: # needs sage.combinat sage.modules
sage: R = QQ['q,t'].fraction_field()
sage: Sym = sage.combinat.sf.sf.SymmetricFunctions(R)
sage: Sym = SymmetricFunctions(R)
sage: H = Sym.macdonald().H()
sage: P = Sym.macdonald().P()
sage: m = Sym.monomial()
Expand Down Expand Up @@ -2180,7 +2180,7 @@ cdef class Parent(sage.structure.category_object.CategoryObject):
sage: # needs sage.combinat sage.modules
sage: R = QQ['q,t'].fraction_field()
sage: Sym = sage.combinat.sf.sf.SymmetricFunctions(R)
sage: Sym = SymmetricFunctions(R)
sage: P = Sym.macdonald().P()
sage: Ht = Sym.macdonald().Ht()
sage: Ht._internal_coerce_map_from(P)
Expand Down

0 comments on commit 875628d

Please sign in to comment.