Skip to content

Commit

Permalink
sagemathgh-36594: Replace relative imports by absolute ones in `sage.…
Browse files Browse the repository at this point in the history
…{matrix,matroids,modules,stats}`

    
<!-- ^^^^^
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? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
- Cherry-picked from sagemath#35095
- This is for sagemath#36228
<!-- 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.
- [ ] 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#36594
Reported by: Matthias Köppe
Reviewer(s): David Coudert, Matthias Köppe
  • Loading branch information
Release Manager committed Nov 5, 2023
2 parents a717ac0 + 4370ea2 commit 8b52cc3
Show file tree
Hide file tree
Showing 83 changed files with 220 additions and 201 deletions.
2 changes: 1 addition & 1 deletion src/sage/matrix/action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ AUTHOR:

import operator

from .matrix_space import MatrixSpace, is_MatrixSpace
from sage.matrix.matrix_space import MatrixSpace, is_MatrixSpace
from sage.modules.free_module import FreeModule, is_FreeModule
from sage.structure.coerce cimport coercion_model
from sage.categories.homset import Hom, End
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/args.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ cdef class MatrixArgs:
if self.space is None:
global MatrixSpace
if MatrixSpace is None:
from .matrix_space import MatrixSpace
from sage.matrix.matrix_space import MatrixSpace
self.space = MatrixSpace(self.base, self.nrows, self.ncols,
sparse=self.sparse, **self.kwds)

Expand Down Expand Up @@ -1114,7 +1114,7 @@ cdef class MatrixArgs:
if not (e.flags.c_contiguous is True or e.flags.f_contiguous is True):
raise TypeError('numpy matrix must be either c_contiguous or f_contiguous')

from .constructor import matrix
from sage.matrix.constructor import matrix
from sage.rings.real_double import RDF
from sage.rings.complex_double import CDF

Expand Down
6 changes: 3 additions & 3 deletions src/sage/matrix/change_ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Functions for changing the base ring of matrices quickly
"""

from .matrix_space import MatrixSpace
from .matrix_real_double_dense cimport Matrix_real_double_dense
from .matrix_integer_dense cimport Matrix_integer_dense
from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.matrix_real_double_dense cimport Matrix_real_double_dense
from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense

from sage.rings.real_double import RDF

Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/constructor.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ General matrix Constructor and display options
# http://www.gnu.org/licenses/
#*****************************************************************************

from .args cimport MatrixArgs
from sage.matrix.args cimport MatrixArgs
from sage.structure.global_options import GlobalOptions


Expand Down Expand Up @@ -654,7 +654,7 @@ def matrix(*args, **kwds):
Matrix = matrix


from .special import *
from sage.matrix.special import *


@matrix_method
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix.pxd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .matrix2 cimport Matrix
from sage.matrix.matrix2 cimport Matrix
20 changes: 10 additions & 10 deletions src/sage/matrix/matrix0.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ from sage.rings.integer_ring import is_IntegerRing

import sage.modules.free_module

from .matrix_misc import row_iterator
from sage.matrix.matrix_misc import row_iterator

_Fields = Fields()
_IntegralDomains = IntegralDomains()
Expand Down Expand Up @@ -1750,7 +1750,7 @@ cdef class Matrix(sage.structure.element.Matrix):
100 x 100 dense matrix over Integer Ring]
"""
from .constructor import options
from sage.matrix.constructor import options
if self._nrows <= options.max_rows() and self._ncols <= options.max_cols():
return self.str()
if self.is_sparse():
Expand Down Expand Up @@ -2051,7 +2051,7 @@ cdef class Matrix(sage.structure.element.Matrix):

# only use floating point formatting for inexact types that have
# custom implementation of __format__
from .constructor import options
from sage.matrix.constructor import options
prec = options.precision()
if prec is None or callable(rep_mapping) or not entries \
or type(entries[0]).__format__ is Element.__format__ \
Expand Down Expand Up @@ -2135,7 +2135,7 @@ cdef class Matrix(sage.structure.element.Matrix):
-0.35104242112828943 0.5084492941557279]
-0.9541798283979341 -0.8948790563276592]
"""
from .constructor import options
from sage.matrix.constructor import options
if self._nrows <= options.max_rows() and self._ncols <= options.max_cols():
return self.str(character_art=True)
else:
Expand Down Expand Up @@ -2164,7 +2164,7 @@ cdef class Matrix(sage.structure.element.Matrix):
sage: unicode_art(A)
100 x 100 dense matrix over Integer Ring
"""
from .constructor import options
from sage.matrix.constructor import options
if self._nrows <= options.max_rows() and self._ncols <= options.max_cols():
return self.str(unicode=True, character_art=True)
else:
Expand Down Expand Up @@ -2375,7 +2375,7 @@ cdef class Matrix(sage.structure.element.Matrix):
[ 5 25]
[125 625]
"""
from .constructor import matrix
from sage.matrix.constructor import matrix
return matrix(self.nrows(), self.ncols(), [e(*args, **kwargs) for e in self.list()])

###################################################
Expand Down Expand Up @@ -3850,7 +3850,7 @@ cdef class Matrix(sage.structure.element.Matrix):
raise ValueError("length of v must be at most the number of rows of self")
if not self._nrows:
return self.parent().row_space().zero_vector()
from .constructor import matrix
from sage.matrix.constructor import matrix
v = matrix(list(v)+[0]*(self._nrows-len(v)))
return (v * self)[0]

Expand Down Expand Up @@ -3927,7 +3927,7 @@ cdef class Matrix(sage.structure.element.Matrix):
raise ValueError("length of v must be at most the number of columns of self")
if not self._ncols:
return self.parent().column_space().zero_vector()
from .constructor import matrix
from sage.matrix.constructor import matrix
v = matrix(self._ncols, 1, list(v)+[0]*(self._ncols-len(v)))
return (self * v).column(0)

Expand Down Expand Up @@ -6178,7 +6178,7 @@ def set_max_rows(n):
"""
from sage.misc.superseded import deprecation
deprecation(30552, "'set_max_rows' is replaced by 'matrix.options.max_rows'")
from .constructor import options
from sage.matrix.constructor import options
options.max_rows = n-1

def set_max_cols(n):
Expand All @@ -6195,5 +6195,5 @@ def set_max_cols(n):
"""
from sage.misc.superseded import deprecation
deprecation(30552, "'set_max_cols' is replaced by 'matrix.options.max_cols'")
from .constructor import options
from sage.matrix.constructor import options
options.max_cols = n-1
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix1.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .matrix0 cimport Matrix as Matrix0
from sage.matrix.matrix0 cimport Matrix as Matrix0

cdef class Matrix(Matrix0):
cdef _stack_impl(self, bottom) noexcept
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix2.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Generic matrices
# http://www.gnu.org/licenses/
#*****************************************************************************

from .matrix1 cimport Matrix as Matrix1
from sage.matrix.matrix1 cimport Matrix as Matrix1

cdef class Matrix(Matrix1):
cdef _det_by_minors(self, Py_ssize_t level) noexcept
Expand Down
10 changes: 5 additions & 5 deletions src/sage/matrix/matrix2.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ from sage.arith.numerical_approx cimport digits_to_bits
from copy import copy

import sage.modules.free_module
from . import berlekamp_massey
from sage.matrix import berlekamp_massey
from sage.modules.free_module_element import is_FreeModuleElement
from sage.matrix.matrix_misc import permanental_minor_polynomial

Expand Down Expand Up @@ -8832,7 +8832,7 @@ cdef class Matrix(Matrix1):
output_window = output.matrix_window()


from . import strassen
from sage.matrix import strassen
strassen.strassen_window_multiply(output_window, self_window, right_window, cutoff)
return output

Expand Down Expand Up @@ -8870,7 +8870,7 @@ cdef class Matrix(Matrix1):
self._echelon_in_place_classical()
return

from . import strassen
from sage.matrix import strassen
pivots = strassen.strassen_echelon(self.matrix_window(), cutoff)
self.cache('pivots', pivots)
verbose('done with strassen', tm)
Expand Down Expand Up @@ -8909,7 +8909,7 @@ cdef class Matrix(Matrix1):
...
IndexError: matrix window index out of range
"""
from . import matrix_window
from sage.matrix import matrix_window
if nrows == -1:
nrows = self._nrows - row
if ncols == -1:
Expand Down Expand Up @@ -15117,7 +15117,7 @@ cdef class Matrix(Matrix1):
except (OverflowError, TypeError):
from sage.rings.real_mpfr import RealField
# Try using MPFR, which handles large numbers much better, but is slower.
from .misc_mpfr import hadamard_row_bound_mpfr
from sage.matrix.misc_mpfr import hadamard_row_bound_mpfr
R = RealField(53, rnd='RNDU')
A = self.change_ring(R)
m1 = hadamard_row_bound_mpfr(A)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_complex_ball_dense.pxd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from sage.libs.arb.types cimport acb_mat_t
from .matrix_dense cimport Matrix_dense
from sage.matrix.matrix_dense cimport Matrix_dense
from sage.matrix.matrix_generic_dense cimport Matrix_generic_dense
from sage.structure.parent cimport Parent

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_complex_ball_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ from sage.libs.arb.acb cimport *
from sage.libs.arb.acb_mat cimport *
from sage.libs.gmp.mpz cimport mpz_fits_ulong_p, mpz_get_ui
from sage.matrix.constructor import matrix
from .args cimport SparseEntry, MatrixArgs_init
from sage.matrix.args cimport SparseEntry, MatrixArgs_init
from sage.rings.complex_interval cimport ComplexIntervalFieldElement
from sage.rings.complex_arb cimport (
ComplexBall,
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_complex_double_dense.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .matrix_double_dense cimport Matrix_double_dense
from sage.matrix.matrix_double_dense cimport Matrix_double_dense

cdef class Matrix_complex_double_dense(Matrix_double_dense):
pass
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_cyclo_dense.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sage.libs.gmp.types cimport mpz_t
from .matrix_dense cimport Matrix_dense
from .matrix_rational_dense cimport Matrix_rational_dense
from sage.matrix.matrix_dense cimport Matrix_dense
from sage.matrix.matrix_rational_dense cimport Matrix_rational_dense

cdef class Matrix_cyclo_dense(Matrix_dense):

Expand Down
16 changes: 8 additions & 8 deletions src/sage/matrix/matrix_cyclo_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ from sage.libs.flint.fmpz cimport fmpz_init, fmpz_clear, fmpz_set_mpz, fmpz_one,
from sage.libs.flint.fmpq cimport fmpq_is_zero, fmpq_set_mpq, fmpq_canonicalise
from sage.libs.flint.fmpq_mat cimport fmpq_mat_entry_num, fmpq_mat_entry_den, fmpq_mat_entry

from .args cimport MatrixArgs_init
from .constructor import matrix
from .matrix_space import MatrixSpace
from .matrix cimport Matrix
from . import matrix_dense
from .matrix_integer_dense cimport _lift_crt
from sage.matrix.args cimport MatrixArgs_init
from sage.matrix.constructor import matrix
from sage.matrix.matrix_space import MatrixSpace
from sage.matrix.matrix cimport Matrix
from sage.matrix import matrix_dense
from sage.matrix.matrix_integer_dense cimport _lift_crt
from sage.structure.element cimport Matrix as baseMatrix
from .misc_flint import matrix_integer_dense_rational_reconstruction
from sage.matrix.misc_flint import matrix_integer_dense_rational_reconstruction

from sage.arith.misc import binomial, previous_prime
from sage.rings.rational_field import QQ
Expand Down Expand Up @@ -1535,7 +1535,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
K = self.base_ring()
phi = K.defining_polynomial()
from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF
from .constructor import matrix
from sage.matrix.constructor import matrix
F = GF(p)
aa = [a for a, _ in phi.change_ring(F).roots()]
n = K.degree()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_dense.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .matrix cimport Matrix
from sage.matrix.matrix cimport Matrix

cdef class Matrix_dense(Matrix):
cdef void set_unsafe_int(self, Py_ssize_t i, Py_ssize_t j, int value) noexcept
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_domain_dense.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .matrix cimport Matrix
from sage.matrix.matrix cimport Matrix

cdef class Matrix_domain_dense(Matrix):
pass
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_domain_sparse.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .matrix cimport Matrix
from sage.matrix.matrix cimport Matrix

cdef class Matrix_domain_sparse(Matrix):
pass
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_double_dense.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .matrix_numpy_dense cimport Matrix_numpy_dense
from sage.matrix.matrix_numpy_dense cimport Matrix_numpy_dense


cdef class Matrix_double_dense(Matrix_numpy_dense):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_double_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import sage.rings.real_double
import sage.rings.complex_double

from sage.structure.element cimport Vector
from .constructor import matrix
from sage.matrix.constructor import matrix
cimport sage.structure.element

cimport numpy as cnumpy
Expand Down
3 changes: 2 additions & 1 deletion src/sage/matrix/matrix_double_sparse.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .matrix_generic_sparse cimport Matrix_generic_sparse
from sage.matrix.matrix_generic_sparse cimport Matrix_generic_sparse


cdef class Matrix_double_sparse(Matrix_generic_sparse):
pass
5 changes: 3 additions & 2 deletions src/sage/matrix/matrix_double_sparse.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .matrix2 cimport Matrix
from .matrix_generic_sparse cimport Matrix_generic_sparse
from sage.matrix.matrix2 cimport Matrix
from sage.matrix.matrix_generic_sparse cimport Matrix_generic_sparse


cdef class Matrix_double_sparse(Matrix_generic_sparse):
r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_gap.pxd
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .matrix_dense cimport Matrix_dense
from sage.matrix.matrix_dense cimport Matrix_dense
from sage.libs.gap.element cimport GapElement


cdef class Matrix_gap(Matrix_dense):
cdef GapElement _libgap

cpdef GapElement gap(self) noexcept
cdef Matrix_gap _new(self, Py_ssize_t nrows, Py_ssize_t ncols) noexcept

2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_gap.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Wrappers on GAP matrices

from sage.libs.gap.libgap import libgap
from sage.structure.element cimport Matrix
from .args cimport MatrixArgs_init
from sage.matrix.args cimport MatrixArgs_init


cdef class Matrix_gap(Matrix_dense):
Expand Down
3 changes: 2 additions & 1 deletion src/sage/matrix/matrix_generic_dense.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .matrix_dense cimport Matrix_dense
from sage.matrix.matrix_dense cimport Matrix_dense


cdef class Matrix_generic_dense(Matrix_dense):
cdef list _entries
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_generic_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ from cpython.number cimport *
from cpython.ref cimport *

cimport sage.matrix.matrix_dense as matrix_dense
from . import matrix_dense
from .args cimport MatrixArgs_init
from sage.matrix import matrix_dense
from sage.matrix.args cimport MatrixArgs_init

cimport sage.matrix.matrix as matrix

Expand Down
3 changes: 2 additions & 1 deletion src/sage/matrix/matrix_generic_sparse.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .matrix_sparse cimport Matrix_sparse
from sage.matrix.matrix_sparse cimport Matrix_sparse


cdef class Matrix_generic_sparse(Matrix_sparse):
cdef dict _entries
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_generic_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ EXAMPLES::
"""
cimport sage.matrix.matrix_sparse as matrix_sparse
cimport sage.structure.element
from .args cimport MatrixArgs_init
from sage.matrix.args cimport MatrixArgs_init


cdef class Matrix_generic_sparse(matrix_sparse.Matrix_sparse):
Expand Down Expand Up @@ -451,7 +451,7 @@ def Matrix_sparse_from_rows(X):
if not X:
raise ArithmeticError("X must be nonempty")

from . import matrix_space
from sage.matrix import matrix_space
entries = {}
R = X[0].base_ring()
ncols = X[0].degree()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_gf2e_dense.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from sage.libs.m4rie cimport mzed_t
from sage.libs.m4ri cimport m4ri_word
from .matrix_dense cimport Matrix_dense
from sage.matrix.matrix_dense cimport Matrix_dense


cdef class Matrix_gf2e_dense(Matrix_dense):
Expand Down
Loading

0 comments on commit 8b52cc3

Please sign in to comment.