Skip to content

Commit

Permalink
sagemathgh-38086: all*.py files: Use 'del lazy_import', 'del instal…
Browse files Browse the repository at this point in the history
…l_doc'

    
<!-- ^ 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". -->

- Cherry-picked from sagemath#37900

Includes style fixes from there as well.

### 📝 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#38086
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
  • Loading branch information
Release Manager committed May 29, 2024
2 parents 9817b21 + 5372cb9 commit 2fd96b0
Show file tree
Hide file tree
Showing 48 changed files with 158 additions and 162 deletions.
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
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 <heluani@potuz.net>
#
# 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
12 changes: 6 additions & 6 deletions src/sage/all__sagemath_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

# This import also sets up the interrupt handler
from cysignals.signals import (AlarmInterrupt, SignalError,
sig_on_reset as sig_on_count)
sig_on_reset as sig_on_count)

from time import sleep
from time import sleep

from sage.misc.all__sagemath_objects import *
from sage.structure.all import *
from sage.arith.power import generic_power as power
from sage.misc.all__sagemath_objects import *
from sage.structure.all import *
from sage.arith.power import generic_power as power
from sage.categories.all__sagemath_objects import *

from sage.cpython.all import *
from sage.cpython.all import *

from cysignals.alarm import alarm, cancel_alarm

Expand Down
34 changes: 18 additions & 16 deletions src/sage/all__sagemath_repl.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
############ setup warning filters before importing Sage stuff ####
# Set up warning filters before importing Sage stuff

import sys
import warnings

__with_pydebug = hasattr(sys, 'gettotalrefcount') # This is a Python debug build (--with-pydebug)
# This is a Python debug build (--with-pydebug)
__with_pydebug = hasattr(sys, 'gettotalrefcount')
if __with_pydebug:
# a debug build does not install the default warning filters. Sadly, this breaks doctests so we
# have to re-add them:
Expand All @@ -16,38 +18,38 @@

# Ignore all deprecations from IPython etc.
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='(IPython|ipykernel|jupyter_client|jupyter_core|nbformat|notebook|ipywidgets|storemagic|jedi)')
module='(IPython|ipykernel|jupyter_client|jupyter_core|nbformat|notebook|ipywidgets|storemagic|jedi)')

# scipy 1.18 introduced reprecation warnings on a number of things they are moving to
# numpy, e.g. DeprecationWarning: scipy.array is deprecated
# and will be removed in SciPy 2.0.0, use numpy.array instead
# This affects networkx 2.2 up and including 2.4 (cf. :issue:29766)
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='(scipy|networkx)')
module='(scipy|networkx)')

# However, be sure to keep OUR deprecation warnings
warnings.filterwarnings('default', category=DeprecationWarning,
message=r'[\s\S]*See https?://trac\.sagemath\.org/[0-9]* for details.')
message=r'[\s\S]*See https?://trac\.sagemath\.org/[0-9]* for details.')

# Ignore Python 3.9 deprecation warnings
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='ast')
module='ast')

# Ignore packaging 20.5 deprecation warnings
warnings.filterwarnings('ignore', category=DeprecationWarning,
module='(.*[.]_vendor[.])?packaging')
module='(.*[.]_vendor[.])?packaging')

# Ignore a few warnings triggered by pythran 0.12.1
warnings.filterwarnings('ignore', category=DeprecationWarning,
message='\n\n `numpy.distutils` is deprecated since NumPy 1.23.0',
module='pythran.dist')
message='\n\n `numpy.distutils` is deprecated since NumPy 1.23.0',
module='pythran.dist')
warnings.filterwarnings('ignore', category=DeprecationWarning,
message='pkg_resources is deprecated as an API|'
'Deprecated call to `pkg_resources.declare_namespace(.*)`',
module='pkg_resources|setuptools.sandbox')
message='pkg_resources is deprecated as an API|'
'Deprecated call to `pkg_resources.declare_namespace(.*)`',
module='pkg_resources|setuptools.sandbox')
warnings.filterwarnings('ignore', category=DeprecationWarning,
message='msvccompiler is deprecated and slated to be removed',
module='distutils.msvccompiler')
message='msvccompiler is deprecated and slated to be removed',
module='distutils.msvccompiler')

warnings.filterwarnings('ignore', category=DeprecationWarning,
message='The distutils(.sysconfig module| package) is deprecated',
Expand Down Expand Up @@ -105,8 +107,8 @@
from sage.all__sagemath_objects import *
from sage.all__sagemath_environment import *

from sage.doctest.all import *
from sage.repl.all import *
from sage.doctest.all import *
from sage.repl.all import *
from sage.misc.all__sagemath_repl import *

# For doctesting. These are overwritten later
Expand Down
2 changes: 1 addition & 1 deletion src/sage/all_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from sage.misc.lazy_import import lazy_import

for pkg in ['axiom', 'fricas', 'gap' , 'gap3', 'giac', 'gp',
for pkg in ['axiom', 'fricas', 'gap', 'gap3', 'giac', 'gp',
'gnuplot', 'kash', 'magma', 'macaulay2', 'maple',
'mathematica', 'mathics', 'matlab',
'mupad', 'mwrank', 'octave', 'qepcad', 'singular',
Expand Down
108 changes: 24 additions & 84 deletions src/sage/arith/all.py
Original file line number Diff line number Diff line change
@@ -1,96 +1,36 @@
from sage.misc.lazy_import import lazy_import

from sage.arith.misc import (
algdep,
bernoulli,
is_prime,
is_prime_power,
is_pseudoprime,
is_pseudoprime_power,
prime_powers,
primes_first_n,
eratosthenes,
primes,
next_prime_power,
next_probable_prime,
next_prime,
previous_prime,
previous_prime_power,
random_prime,
divisors,
sigma,
gcd,
GCD,
xlcm,
xgcd,
xkcd,
inverse_mod,
get_gcd,
get_inverse_mod,
power_mod,
rational_reconstruction,
mqrr_rational_reconstruction,
trial_division,
factor,
prime_divisors,
odd_part,
prime_to_m_part,
is_square,
is_squarefree,
euler_phi,
carmichael_lambda,
crt,
CRT,
CRT_list,
CRT_basis,
CRT_vectors,
multinomial,
multinomial_coefficients,
binomial,
factorial,
kronecker_symbol,
kronecker,
legendre_symbol,
primitive_root,
nth_prime,
quadratic_residues,
moebius,
continuant,
number_of_divisors,
hilbert_symbol,
hilbert_conductor,
hilbert_conductor_inverse,
falling_factorial,
rising_factorial,
integer_ceil,
integer_floor,
two_squares,
three_squares,
four_squares,
sum_of_k_squares,
subfactorial,
is_power_of_two,
differences,
sort_complex_numbers_for_display,
fundamental_discriminant,
squarefree_divisors,
radical,
binomial_coefficients,
jacobi_symbol,
dedekind_sum,
prime_factors,
prime_range,
valuation,
)
from sage.arith.misc import (algdep, bernoulli, is_prime, is_prime_power,
is_pseudoprime, is_pseudoprime_power,
prime_powers, primes_first_n, eratosthenes, primes,
next_prime_power, next_probable_prime, next_prime,
previous_prime, previous_prime_power, random_prime,
divisors, sigma, gcd, GCD, xlcm, xgcd, xkcd,
inverse_mod, get_gcd, get_inverse_mod, power_mod,
rational_reconstruction, mqrr_rational_reconstruction,
trial_division, factor, prime_divisors, odd_part, prime_to_m_part,
is_square, is_squarefree, euler_phi, carmichael_lambda, crt, CRT,
CRT_list, CRT_basis, CRT_vectors, multinomial, multinomial_coefficients,
binomial, factorial, kronecker_symbol, kronecker, legendre_symbol,
primitive_root, nth_prime, quadratic_residues, moebius,
continuant, number_of_divisors, hilbert_symbol, hilbert_conductor,
hilbert_conductor_inverse, falling_factorial, rising_factorial,
integer_ceil, integer_floor,
two_squares, three_squares, four_squares, sum_of_k_squares,
subfactorial, is_power_of_two, differences,
sort_complex_numbers_for_display,
fundamental_discriminant, squarefree_divisors,
radical, binomial_coefficients, jacobi_symbol,
dedekind_sum,
prime_factors, prime_range, valuation)

lazy_import("sage.arith.misc", ("Sigma", "Moebius", "Euler_Phi"), deprecation=30322)

from sage.arith.functions import lcm

LCM = lcm

from sage.arith.srange import xsrange, srange, ellipsis_iter, ellipsis_range

sxrange = xsrange

σ = sigma
del lazy_import
34 changes: 18 additions & 16 deletions src/sage/categories/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,31 +109,31 @@
# * with basis
from sage.categories.modules_with_basis import ModulesWithBasis
FreeModules = ModulesWithBasis
from sage.categories.hecke_modules import HeckeModules
from sage.categories.algebras_with_basis import AlgebrasWithBasis
from sage.categories.coalgebras_with_basis import CoalgebrasWithBasis
from sage.categories.bialgebras_with_basis import BialgebrasWithBasis
from sage.categories.hecke_modules import HeckeModules
from sage.categories.algebras_with_basis import AlgebrasWithBasis
from sage.categories.coalgebras_with_basis import CoalgebrasWithBasis
from sage.categories.bialgebras_with_basis import BialgebrasWithBasis
from sage.categories.hopf_algebras_with_basis import HopfAlgebrasWithBasis

# finite dimensional * with basis
from sage.categories.finite_dimensional_modules_with_basis import FiniteDimensionalModulesWithBasis
from sage.categories.finite_dimensional_algebras_with_basis import FiniteDimensionalAlgebrasWithBasis
from sage.categories.finite_dimensional_coalgebras_with_basis import FiniteDimensionalCoalgebrasWithBasis
from sage.categories.finite_dimensional_bialgebras_with_basis import FiniteDimensionalBialgebrasWithBasis
from sage.categories.finite_dimensional_modules_with_basis import FiniteDimensionalModulesWithBasis
from sage.categories.finite_dimensional_algebras_with_basis import FiniteDimensionalAlgebrasWithBasis
from sage.categories.finite_dimensional_coalgebras_with_basis import FiniteDimensionalCoalgebrasWithBasis
from sage.categories.finite_dimensional_bialgebras_with_basis import FiniteDimensionalBialgebrasWithBasis
from sage.categories.finite_dimensional_hopf_algebras_with_basis import FiniteDimensionalHopfAlgebrasWithBasis

# graded *
from sage.categories.graded_modules import GradedModules
from sage.categories.graded_algebras import GradedAlgebras
from sage.categories.graded_coalgebras import GradedCoalgebras
from sage.categories.graded_bialgebras import GradedBialgebras
from sage.categories.graded_modules import GradedModules
from sage.categories.graded_algebras import GradedAlgebras
from sage.categories.graded_coalgebras import GradedCoalgebras
from sage.categories.graded_bialgebras import GradedBialgebras
from sage.categories.graded_hopf_algebras import GradedHopfAlgebras

# graded * with basis
from sage.categories.graded_modules_with_basis import GradedModulesWithBasis
from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis
from sage.categories.graded_coalgebras_with_basis import GradedCoalgebrasWithBasis
from sage.categories.graded_bialgebras_with_basis import GradedBialgebrasWithBasis
from sage.categories.graded_modules_with_basis import GradedModulesWithBasis
from sage.categories.graded_algebras_with_basis import GradedAlgebrasWithBasis
from sage.categories.graded_coalgebras_with_basis import GradedCoalgebrasWithBasis
from sage.categories.graded_bialgebras_with_basis import GradedBialgebrasWithBasis
from sage.categories.graded_hopf_algebras_with_basis import GradedHopfAlgebrasWithBasis

# Coxeter groups
Expand All @@ -155,3 +155,5 @@

# lie conformal algebras
lazy_import('sage.categories.lie_conformal_algebras', 'LieConformalAlgebras')
del lazy_import
del install_doc
8 changes: 6 additions & 2 deletions src/sage/categories/all__sagemath_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@

from sage.categories.cartesian_product import cartesian_product

from sage.categories.functor import ForgetfulFunctor, IdentityFunctor
from sage.categories.functor import (ForgetfulFunctor,
IdentityFunctor)

from sage.categories.homset import Hom, hom, End, end, Homset, HomsetWithBase
from sage.categories.homset import (Hom, hom,
End, end,
Homset, HomsetWithBase)

from sage.categories.morphism import Morphism

from sage.categories.realizations import Realizations

from sage.categories.sets_with_partial_maps import SetsWithPartialMaps
del lazy_import
14 changes: 8 additions & 6 deletions src/sage/coding/all.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

from sage.misc.lazy_import import lazy_import as _lazy_import
from sage.misc.lazy_import import lazy_import

_lazy_import("sage.coding.code_constructions", ["permutation_action",
"walsh_matrix"])
lazy_import("sage.coding.code_constructions", ["permutation_action",
"walsh_matrix"])

_lazy_import("sage.coding.linear_code", "LinearCode")
lazy_import("sage.coding.linear_code", "LinearCode")

# Functions removed from the global namespace

_lazy_import('sage.coding', 'codes_catalog', 'codes')
_lazy_import('sage.coding', 'channels_catalog', 'channels')
lazy_import('sage.coding', 'codes_catalog', 'codes')
lazy_import('sage.coding', 'channels_catalog', 'channels')

del lazy_import
2 changes: 2 additions & 0 deletions src/sage/combinat/chas/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@

lazy_import('sage.combinat.chas.fsym', ['FreeSymmetricFunctions'])
lazy_import('sage.combinat.chas.wqsym', ['WordQuasiSymmetricFunctions'])
del lazy_import
del install_doc
3 changes: 2 additions & 1 deletion src/sage/combinat/cluster_algebra_quiver/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
install_doc(__package__, __doc__)

from sage.misc.lazy_import import lazy_import
lazy_import("sage.combinat.cluster_algebra_quiver.quiver_mutation_type", "QuiverMutationType")
lazy_import("sage.combinat.cluster_algebra_quiver.quiver_mutation_type",
"QuiverMutationType")
lazy_import("sage.combinat.cluster_algebra_quiver.quiver", "ClusterQuiver")
lazy_import("sage.combinat.cluster_algebra_quiver.cluster_seed", "ClusterSeed")

Expand Down
Loading

0 comments on commit 2fd96b0

Please sign in to comment.