Skip to content

Commit

Permalink
sagemathgh-36666: Replace relative imports by absolute ones in `sage.…
Browse files Browse the repository at this point in the history
…{algebras,arith,categories,cpython,data_structures,misc,modular,rings,sat,symbolic}`

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

<!-- Why is this change required? What problem does it solve? -->
Final chunk of the cherry-pick from sagemath#35095 for sagemath#36228, see also
sagemath#36572 (comment)

This PR overlaps with sagemath#36572, sagemath#36588, sagemath#36589, but it does not touch
`.all*` files (no changes there are needed for sagemath#36228), thus avoiding
conflicts with sagemath#35095 (see also
sagemath#36524 (comment))
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- 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.
- [ ] 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: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36666
Reported by: Matthias Köppe
Reviewer(s): David Coudert, John H. Palmieri
  • Loading branch information
Release Manager committed Dec 9, 2023
2 parents 2051800 + b2222c3 commit a45062c
Show file tree
Hide file tree
Showing 48 changed files with 170 additions and 170 deletions.
2 changes: 1 addition & 1 deletion src/sage/algebras/quatalg/quaternion_algebra_cython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense
from sage.matrix.matrix_rational_dense cimport Matrix_rational_dense

from .quaternion_algebra_element cimport QuaternionAlgebraElement_rational_field
from sage.algebras.quatalg.quaternion_algebra_element cimport QuaternionAlgebraElement_rational_field

from sage.libs.gmp.mpz cimport mpz_t, mpz_lcm, mpz_init, mpz_set, mpz_clear, mpz_init_set, mpz_mul, mpz_fdiv_q, mpz_cmp_si

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ cdef class Action(Functor):
:class:`Action` itself, but other classes may use it
"""
def __init__(self, G, S, is_left=True, op=None):
from .groupoid import Groupoid
from sage.categories.groupoid import Groupoid
Functor.__init__(self, Groupoid(G), category(S))
self.G = G
self.US = ref(S)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ cdef class CallMorphism(Morphism):
cdef class IdentityMorphism(Morphism):

def __init__(self, parent):
from .homset import Homset, Hom
from sage.categories.homset import Homset, Hom
if not isinstance(parent, Homset):
parent = Hom(parent, parent)
Morphism.__init__(self, parent)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/cpython/getattr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Variants of getattr()

from cpython.object cimport PyObject, PyTypeObject, Py_TYPE, descrgetfunc

from .string cimport bytes_to_str
from sage.cpython.string cimport bytes_to_str

cdef extern from "Python.h":
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/cpython/wrapperdescr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Pure Python classes have normal methods, not slot wrappers::
# https://www.gnu.org/licenses/
# ****************************************************************************

from .string import bytes_to_str
from sage.cpython.string import bytes_to_str


def wrapperdescr_call(slotwrapper, self, *args, **kwds):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/cachefunc.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .function_mangling cimport ArgumentFixer
from sage.misc.function_mangling cimport ArgumentFixer

cpdef dict_key(o) noexcept
cpdef cache_key(o) noexcept
Expand Down
6 changes: 3 additions & 3 deletions src/sage/misc/lazy_import.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import os
import pickle
from warnings import warn
import inspect
from . import sageinspect
from sage.misc import sageinspect


# LazyImport.__repr__ uses try... except FeatureNotPresentError.
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def save_cache_file():
sage: sage.misc.lazy_import.save_cache_file()
"""
from sage.misc.temporary_file import atomic_write
from .lazy_import_cache import get_cache_file
from sage.misc.lazy_import_cache import get_cache_file

global star_imports
if star_imports is None:
Expand Down Expand Up @@ -1180,7 +1180,7 @@ def get_star_imports(module_name):
"""
global star_imports
if star_imports is None:
from .lazy_import_cache import get_cache_file
from sage.misc.lazy_import_cache import get_cache_file
star_imports = {}
try:
with open(get_cache_file(), "rb") as cache_file:
Expand Down
6 changes: 3 additions & 3 deletions src/sage/misc/persist.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import bz2
comp = zlib
comp_other = bz2

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


# We define two global dictionaries `already_pickled` and
Expand Down Expand Up @@ -1237,7 +1237,7 @@ def db(name):
The database directory is ``$HOME/.sage/db``.
"""
from .misc import SAGE_DB
from sage.misc.misc import SAGE_DB
return load('%s/%s'%(SAGE_DB,name))
Expand All @@ -1250,5 +1250,5 @@ def db_save(x, name=None):
try:
x.db(name)
except AttributeError:
from .misc import SAGE_DB
from sage.misc.misc import SAGE_DB
save(x, '%s/%s'%(SAGE_DB,name))
2 changes: 1 addition & 1 deletion src/sage/misc/sage_timeit_class.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The ``timeit`` command
This uses the function :func:`~sage.misc.sage_timeit.sage_timeit`.
"""

from . import sage_timeit
from sage.misc import sage_timeit


class SageTimeit:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modular/modsym/heilbronn.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ cdef extern from "<math.h>":
float roundf(float x)

cimport sage.modular.modsym.p1list as p1list
from . import p1list
from sage.modular.modsym import p1list
cdef p1list.export export
export = p1list.export()

from .apply cimport Apply
from sage.modular.modsym.apply cimport Apply
cdef Apply PolyApply= Apply()

from sage.matrix.matrix_rational_dense cimport Matrix_rational_dense
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/pollack_stevens/dist.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ from sage.rings.infinity import Infinity

#from sage.libs.flint.ulong_extras cimport *

from .sigma0 import Sigma0
from sage.modular.pollack_stevens.sigma0 import Sigma0

cdef long overflow = 1 << (4 * sizeof(long) - 1)
cdef long underflow = -overflow
Expand Down
32 changes: 16 additions & 16 deletions src/sage/rings/complex_double.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField):
sage: CDF.characteristic()
0
"""
from .integer import Integer
from sage.rings.integer import Integer
return Integer(0)

def random_element(self, double xmin=-1, double xmax=1, double ymin=-1, double ymax=1):
Expand Down Expand Up @@ -351,7 +351,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField):
sage: CDF((1,2)) # indirect doctest
1.0 + 2.0*I
"""
from . import complex_mpfr
from sage.rings import complex_mpfr
if isinstance(x, ComplexDoubleElement):
return x
elif isinstance(x, tuple):
Expand Down Expand Up @@ -417,10 +417,10 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField):
"""
if S is int or S is float:
return FloatToCDF(S)
from .rational_field import QQ
from .real_lazy import RLF
from .real_mpfr import RR
from .cc import CC
from sage.rings.rational_field import QQ
from sage.rings.real_lazy import RLF
from sage.rings.real_mpfr import RR
from sage.rings.cc import CC

if S is ZZ or S is QQ or S is RDF or S is RLF:
return FloatToCDF(S)
Expand Down Expand Up @@ -502,7 +502,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField):
if prec == 53:
return self
else:
from .complex_mpfr import ComplexField
from sage.rings.complex_mpfr import ComplexField
return ComplexField(prec)


Expand Down Expand Up @@ -621,7 +621,7 @@ cdef class ComplexDoubleField_class(sage.rings.abc.ComplexDoubleField):
...
ValueError: n must be a positive integer
"""
from .integer import Integer
from sage.rings.integer import Integer
try:
n = Integer(n)
except TypeError:
Expand Down Expand Up @@ -968,7 +968,7 @@ cdef class ComplexDoubleElement(FieldElement):
True
"""
# Sending to another computer algebra system is slow anyway, right?
from .complex_mpfr import ComplexField
from sage.rings.complex_mpfr import ComplexField
return ComplexField()(self)._interface_init_(I)

def _mathematica_init_(self):
Expand All @@ -980,7 +980,7 @@ cdef class ComplexDoubleElement(FieldElement):
sage: mathematica(CDF(1e-25, 1e25)) # optional - mathematica
1.*^-25 + 1.*^25*I
"""
from .complex_mpfr import ComplexField
from sage.rings.complex_mpfr import ComplexField
return ComplexField()(self)._mathematica_init_()

def _maxima_init_(self, I=None):
Expand All @@ -995,7 +995,7 @@ cdef class ComplexDoubleElement(FieldElement):
sage: CDF(.5 + I)._maxima_init_() # needs sage.symbolic
'0.50000000000000000 + 1.0000000000000000*%i'
"""
from .complex_mpfr import ComplexField
from sage.rings.complex_mpfr import ComplexField
return ComplexField()(self)._maxima_init_(I)

def _sympy_(self):
Expand Down Expand Up @@ -1097,7 +1097,7 @@ cdef class ComplexDoubleElement(FieldElement):
sage: format(CDF(0, 0), '+#.4')
'+0.000'
"""
from .complex_mpfr import _format_complex_number
from sage.rings.complex_mpfr import _format_complex_number
return _format_complex_number(GSL_REAL(self._complex),
GSL_IMAG(self._complex),
format_spec)
Expand Down Expand Up @@ -2382,12 +2382,12 @@ cdef class ComplexDoubleElement(FieldElement):
"""
if not GSL_IMAG(self._complex):
if GSL_REAL(self._complex) == 0:
from .infinity import unsigned_infinity
from sage.rings.infinity import unsigned_infinity
return unsigned_infinity
try:
from .integer import Integer
from sage.rings.integer import Integer
if Integer(GSL_REAL(self._complex)) < 0:
from .cc import CC
from sage.rings.cc import CC
return CC(self).gamma()
except TypeError:
pass
Expand Down Expand Up @@ -2429,7 +2429,7 @@ cdef class ComplexDoubleElement(FieldElement):
Infinity
"""
if GSL_REAL(self._complex) == 1 and GSL_IMAG(self._complex) == 0:
from .infinity import unsigned_infinity
from sage.rings.infinity import unsigned_infinity
return unsigned_infinity

global complex_double_element_zeta
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/complex_interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ cdef class ComplexIntervalFieldElement(FieldElement):
0.500000000000000? + 3.39927010637040?*I
"""
if not self:
from .real_mpfi import RIF
from sage.rings.real_mpfi import RIF
return RIF(0).log()
re = abs(self).log()
im = self.argument()
Expand Down Expand Up @@ -2291,6 +2291,6 @@ def create_ComplexIntervalFieldElement(s_real, s_imag=None, int pad=0, min_prec=
#else:
# bits = max(int(math.log(base,2)*len(s_imag)),int(math.log(base,2)*len(s_imag)))

from .complex_interval_field import ComplexIntervalField
from sage.rings.complex_interval_field import ComplexIntervalField
C = ComplexIntervalField(prec=max(bits+pad, min_prec))
return ComplexIntervalFieldElement(C, s_real, s_imag)
4 changes: 2 additions & 2 deletions src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def late_import():
import sage.rings.qqbar
AA = sage.rings.qqbar.AA
QQbar = sage.rings.qqbar.QQbar
from .real_lazy import CLF, RLF
from .complex_double import CDF
from sage.rings.real_lazy import CLF, RLF
from sage.rings.complex_double import CDF

_mpfr_rounding_modes = ['RNDN', 'RNDZ', 'RNDU', 'RNDD']

Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/complex_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def late_import():
QQbar = sage.rings.qqbar.QQbar
import sage.symbolic.ring
SR = sage.symbolic.ring.SR
from .real_lazy import CLF, RLF
from .complex_double import CDF
from sage.rings.real_lazy import CLF, RLF
from sage.rings.complex_double import CDF

cdef object numpy_complex_interface = {'typestr': '=c16'}
cdef object numpy_object_interface = {'typestr': '|O'}
Expand Down Expand Up @@ -372,7 +372,7 @@ class ComplexField_class(sage.rings.abc.ComplexField):
try:
return self.__real_field
except AttributeError:
from .real_mpfr import RealField
from sage.rings.real_mpfr import RealField
self.__real_field = RealField(self._prec)
return self.__real_field

Expand Down Expand Up @@ -2931,7 +2931,7 @@ cdef class ComplexNumber(sage.structure.element.FieldElement):
if base is None:
return ComplexNumber(self._parent, rho.log(), theta)
else:
from .real_mpfr import RealField
from sage.rings.real_mpfr import RealField
return ComplexNumber(self._parent, rho.log()/RealNumber(RealField(self.prec()),base).log(), theta/RealNumber(RealField(self.prec()),base).log())

def additive_order(self):
Expand Down
12 changes: 6 additions & 6 deletions src/sage/rings/finite_rings/finite_field_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ cdef class FiniteField(Field):
pass

from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from .finite_field_constructor import GF
from sage.rings.finite_rings.finite_field_constructor import GF
R = PolynomialRing(GF(self.characteristic()), 'x')
self._modulus = R((-1,1)) # Polynomial x - 1
return self._modulus
Expand Down Expand Up @@ -1288,7 +1288,7 @@ cdef class FiniteField(Field):
inclusion_map = self.coerce_map_from(base)

from sage.matrix.constructor import matrix
from .maps_finite_field import (
from sage.rings.finite_rings.maps_finite_field import (
MorphismVectorSpaceToFiniteField, MorphismFiniteFieldToVectorSpace)

E = self
Expand Down Expand Up @@ -1379,7 +1379,7 @@ cdef class FiniteField(Field):
if isinstance(R, FiniteField):
if R is self:
return True
from .residue_field import ResidueField_generic
from sage.rings.finite_rings.residue_field import ResidueField_generic
if isinstance(R, ResidueField_generic):
return False
if R.characteristic() == self.characteristic():
Expand Down Expand Up @@ -1543,7 +1543,7 @@ cdef class FiniteField(Field):
sage: L(u).minpoly() == u.minpoly()
True
"""
from .finite_field_constructor import GF
from sage.rings.finite_rings.finite_field_constructor import GF
from sage.rings.polynomial.polynomial_element import Polynomial
from sage.rings.integer import Integer
if name is None and names is not None:
Expand Down Expand Up @@ -1719,7 +1719,7 @@ cdef class FiniteField(Field):
sage: GF(3^8, 'a').subfield(4)
Finite Field in a4 of size 3^4
"""
from .finite_field_constructor import GF
from sage.rings.finite_rings.finite_field_constructor import GF
p = self.characteristic()
n = self.degree()
if not n % degree == 0:
Expand Down Expand Up @@ -1926,7 +1926,7 @@ cdef class FiniteField(Field):
sage: GF(next_prime(2^16, 2), 'a').is_conway()
False
"""
from .conway_polynomials import conway_polynomial, exists_conway_polynomial
from sage.rings.finite_rings.conway_polynomials import conway_polynomial, exists_conway_polynomial
p = self.characteristic()
n = self.degree()
return (exists_conway_polynomial(p, n)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/hom_finite_field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ cdef class FrobeniusEndomorphism_finite_field(FrobeniusEndomorphism_generic):
"""
if self._degree_fixed == 1:
k = FiniteField(self.domain().characteristic())
from .hom_prime_finite_field import FiniteFieldHomomorphism_prime
from sage.rings.finite_rings.hom_prime_finite_field import FiniteFieldHomomorphism_prime
f = FiniteFieldHomomorphism_prime(Hom(k, self.domain()))
else:
k = FiniteField(self.domain().characteristic()**self._degree_fixed,
Expand Down
Loading

0 comments on commit a45062c

Please sign in to comment.