Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace relative imports by absolute ones in a few packages #36589

Merged
merged 3 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 85 additions & 24 deletions src/sage/arith/all.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,96 @@
from sage.misc.lazy_import import lazy_import

from .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,
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,
fundamental_discriminant,
squarefree_divisors,
radical,
binomial_coefficients,
jacobi_symbol,
dedekind_sum,
prime_factors, prime_range, valuation)
prime_factors,
prime_range,
valuation,
)

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

from sage.arith.functions import lcm

from .functions import lcm
LCM = lcm

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

sxrange = xsrange

σ = sigma
2 changes: 1 addition & 1 deletion src/sage/arith/power.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ square-and-multiply algorithm.

from cysignals.signals cimport sig_check

from .long cimport integer_check_long
from sage.arith.long cimport integer_check_long


cpdef generic_power(a, n) noexcept:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/cpython/all.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .debug import getattr_debug, type_debug
from .getattr import raw_getattr
from sage.cpython.debug import getattr_debug, type_debug
from sage.cpython.getattr import raw_getattr
2 changes: 1 addition & 1 deletion src/sage/cpython/debug.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cdef extern from "Python.h":
cdef extern from "sage/cpython/debugimpl.c":
void _type_debug(PyTypeObject*)

from .getattr cimport AttributeErrorMessage
from sage.cpython.getattr cimport AttributeErrorMessage


# Determine subtype_traverse, subtype_clear, subtype_dealloc functions
Expand Down
2 changes: 1 addition & 1 deletion src/sage/data_structures/all.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

from .bitset import Bitset, FrozenBitset
from sage.data_structures.bitset import Bitset, FrozenBitset
2 changes: 1 addition & 1 deletion src/sage/data_structures/bitset.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from .bitset_base cimport bitset_t
from sage.data_structures.bitset_base cimport bitset_t

# Python layer over bitset_t
cdef class FrozenBitset:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/data_structures/bitset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ linear in ``capacity``.
# http://www.gnu.org/licenses/
#*****************************************************************************

from .bitset_base cimport *
from sage.data_structures.bitset_base cimport *
from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE


Expand Down
56 changes: 28 additions & 28 deletions src/sage/misc/all.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from .lazy_attribute import lazy_attribute, lazy_class_attribute
from .lazy_import import lazy_import
from sage.misc.lazy_attribute import lazy_attribute, lazy_class_attribute
from sage.misc.lazy_import import lazy_import

from .all__sagemath_objects import *
from .all__sagemath_environment import *
from .all__sagemath_repl import *
from sage.misc.all__sagemath_objects import *
from sage.misc.all__sagemath_environment import *
from sage.misc.all__sagemath_repl import *

from .misc import (BackslashOperator,
from sage.misc.misc import (BackslashOperator,
exists, forall, is_iterator,
random_sublist,
pad_zeros,
Expand All @@ -15,27 +15,27 @@
lazy_import('sage.misc.misc', 'union',
deprecation=32096)

from .banner import version
from sage.misc.banner import version

from .dev_tools import import_statements
from sage.misc.dev_tools import import_statements

from .html import html, pretty_print_default
from sage.misc.html import html, pretty_print_default

from .table import table
from sage.misc.table import table

from .sage_timeit_class import timeit
from sage.misc.sage_timeit_class import timeit

from .edit_module import edit
from sage.misc.edit_module import edit

from .map_threaded import map_threaded
from sage.misc.map_threaded import map_threaded

from .session import load_session, save_session, show_identifiers
from sage.misc.session import load_session, save_session, show_identifiers

from .remote_file import get_remote_file
from sage.misc.remote_file import get_remote_file

from .mrange import xmrange, mrange, xmrange_iter, mrange_iter, cartesian_product_iterator
from sage.misc.mrange import xmrange, mrange, xmrange_iter, mrange_iter, cartesian_product_iterator

from .fpickle import pickle_function, unpickle_function
from sage.misc.fpickle import pickle_function, unpickle_function

lazy_import('sage.misc.pager', 'pager')

Expand All @@ -45,21 +45,21 @@
'constructions', 'help'])
lazy_import('pydoc', 'help', 'python_help')

from .classgraph import class_graph
from sage.misc.classgraph import class_graph

from .reset import reset, restore
from sage.misc.reset import reset, restore

from .mathml import mathml
from sage.misc.mathml import mathml

from .defaults import (set_default_variable_name,
from sage.misc.defaults import (set_default_variable_name,
series_precision, set_series_precision)

lazy_import("sage.misc.cython", "cython_lambda")
lazy_import("sage.misc.cython", "cython_compile", "cython")

from .func_persist import func_persist
from sage.misc.func_persist import func_persist

from .functional import (additive_order,
from sage.misc.functional import (additive_order,
base_ring,
base_field,
basis,
Expand Down Expand Up @@ -118,15 +118,15 @@
transpose)


from .latex import LatexExpr, latex, view
from sage.misc.latex import LatexExpr, latex, view

from .randstate import seed, set_random_seed, initial_seed, current_randstate
from sage.misc.randstate import seed, set_random_seed, initial_seed, current_randstate

from .prandom import *
from sage.misc.prandom import *

from .timing import walltime, cputime
from sage.misc.timing import walltime, cputime

from .explain_pickle import explain_pickle, unpickle_newobj, unpickle_global, unpickle_build, unpickle_instantiate, unpickle_persistent, unpickle_extension, unpickle_appends
from sage.misc.explain_pickle import explain_pickle, unpickle_newobj, unpickle_global, unpickle_build, unpickle_instantiate, unpickle_persistent, unpickle_extension, unpickle_appends

lazy_import('sage.misc.inline_fortran', 'fortran')

Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/all__sagemath_environment.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .temporary_file import tmp_dir, tmp_filename
from sage.misc.temporary_file import tmp_dir, tmp_filename
30 changes: 15 additions & 15 deletions src/sage/misc/all__sagemath_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@

import sage.structure.all # to break a cyclic import

from .lazy_attribute import lazy_attribute, lazy_class_attribute
from .lazy_import import lazy_import
from sage.misc.lazy_attribute import lazy_attribute, lazy_class_attribute
from sage.misc.lazy_import import lazy_import

from .verbose import (set_verbose, set_verbose_files,
from sage.misc.verbose import (set_verbose, set_verbose_files,
get_verbose_files, unset_verbose_files, get_verbose)
lazy_import('sage.misc.verbose', 'verbose',
deprecation=17815)
from .call import attrcall
from sage.misc.call import attrcall

from .misc_c import prod, running_total, balanced_sum
from sage.misc.misc_c import prod, running_total, balanced_sum
mul = prod
add = sum

from .repr import repr_lincomb
from sage.misc.repr import repr_lincomb

from .flatten import flatten
from sage.misc.flatten import flatten

from .persist import save, load, dumps, loads, db, db_save
from sage.misc.persist import save, load, dumps, loads, db, db_save

from .constant_function import ConstantFunction
from sage.misc.constant_function import ConstantFunction

from .sage_unittest import TestSuite
from sage.misc.sage_unittest import TestSuite

from .decorators import specialize, sage_wraps, infix_operator
from sage.misc.decorators import specialize, sage_wraps, infix_operator

from .unknown import Unknown, UnknownError
from sage.misc.unknown import Unknown, UnknownError

from .cachefunc import CachedFunction, cached_function, cached_method, cached_in_parent_method, disk_cached_function
from sage.misc.cachefunc import CachedFunction, cached_function, cached_method, cached_in_parent_method, disk_cached_function

from .abstract_method import abstract_method
from sage.misc.abstract_method import abstract_method

from .timing import walltime, cputime
from sage.misc.timing import walltime, cputime
4 changes: 2 additions & 2 deletions src/sage/misc/all__sagemath_repl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .sage_eval import sage_eval, sageobj
from sage.misc.sage_eval import sage_eval, sageobj

from .sage_input import sage_input
from sage.misc.sage_input import sage_input
2 changes: 1 addition & 1 deletion src/sage/misc/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"Benchmarks"

from .misc import cputime
from sage.misc.misc import cputime

from sage.all import *

Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/copying.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"License"

import os
from . import pager
from sage.misc import pager

from sage.env import SAGE_ROOT

Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from sage.env import (SAGE_LOCAL, cython_aliases,
sage_include_directories)
from .temporary_file import spyx_tmp, tmp_filename
from sage.misc.temporary_file import spyx_tmp, tmp_filename
from sage.repl.user_globals import get_globals
from sage.misc.sage_ostools import restore_cwd, redirection
from sage.cpython.string import str_to_bytes
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/func_persist.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def bern(n):
import inspect
import os

from . import persist
from sage.misc import persist

class func_persist:
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/lazy_import_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import hashlib

from ..env import SAGE_LIB, DOT_SAGE
from sage.env import SAGE_LIB, DOT_SAGE


def get_cache_file():
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import sys
import warnings

from .lazy_string import lazy_string
from sage.misc.lazy_string import lazy_string
from sage.env import DOT_SAGE, HOSTNAME
from sage.misc.lazy_import import lazy_import

Expand Down
4 changes: 2 additions & 2 deletions src/sage/misc/sagedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
import sys
import pydoc
from sage.misc.temporary_file import tmp_dir
from .viewer import browser
from . import sageinspect
from sage.misc.viewer import browser
from sage.misc import sageinspect
import sage.version
from sage.env import SAGE_DOC, SAGE_SRC

Expand Down
Loading