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

Remove self-cimports #36207

Merged
merged 7 commits into from
Sep 10, 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
1 change: 0 additions & 1 deletion src/sage/algebras/quatalg/quaternion_algebra_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Check that :trac:`20829` is fixed::

from sage.structure.element cimport AlgebraElement, Element
from sage.structure.richcmp cimport rich_to_bool, rich_to_bool_sgn, richcmp_item
from sage.algebras.quatalg.quaternion_algebra_element cimport QuaternionAlgebraElement_abstract
from sage.rings.rational cimport Rational
from sage.rings.integer cimport Integer
from sage.rings.number_field.number_field_element cimport NumberFieldElement
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/base/boost_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -561,15 +561,15 @@ cpdef bandwidth_heuristics(g, algorithm='cuthill_mckee'):

Given a wrong algorithm::

from sage.graphs.base.boost_graph import bandwidth_heuristics
sage: from sage.graphs.base.boost_graph import bandwidth_heuristics
sage: bandwidth_heuristics(graphs.PathGraph(3), algorithm='tip top')
Traceback (most recent call last):
...
ValueError: unknown algorithm 'tip top'

Given a graph with no edges::

from sage.graphs.base.boost_graph import bandwidth_heuristics
sage: from sage.graphs.base.boost_graph import bandwidth_heuristics
sage: bandwidth_heuristics(Graph())
(0, [])
sage: bandwidth_heuristics(graphs.RandomGNM(10,0)) # needs networkx
Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/comparability.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,6 @@ def is_permutation(g, algorithm="greedy", certificate=False, check=True,
....: break

"""
from sage.graphs.comparability import is_comparability
if certificate:

# First poset, we stop if it fails
Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/strongly_regular_db.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2649,7 +2649,6 @@ def SRG_126_50_13_24():
sage: G.is_strongly_regular(parameters=True)
(126, 50, 13, 24)
"""
from sage.graphs.strongly_regular_db import SRG_175_72_20_36
from sage.graphs.generators.smallgraphs import HoffmanSingletonGraph
hs = HoffmanSingletonGraph()
s = set(hs.vertices(sort=False)).difference(hs.neighbors(0) + [0])
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/flint/fmpz_poly.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from sage.arith.long cimport pyobject_to_long
from sage.cpython.string cimport char_to_str, str_to_bytes
from sage.structure.sage_object cimport SageObject
from sage.rings.integer cimport Integer
from sage.libs.flint.fmpz_poly cimport *


cdef class Fmpz_poly(SageObject):

Expand Down
1 change: 0 additions & 1 deletion src/sage/libs/flint/qsieve.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ been absorbed into flint.
from cysignals.signals cimport sig_on, sig_off
from sage.libs.flint.fmpz cimport fmpz_t, fmpz_init, fmpz_set_mpz
from sage.libs.flint.fmpz_factor cimport *
from sage.libs.flint.qsieve cimport *
from sage.rings.integer cimport Integer


Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_modn_sparse.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .matrix_sparse cimport Matrix_sparse
from sage.matrix.matrix_sparse cimport Matrix_sparse
from sage.modules.vector_modn_sparse cimport *

cdef class Matrix_modn_sparse(Matrix_sparse):
Expand Down
68 changes: 33 additions & 35 deletions src/sage/matrix/matrix_modn_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -86,44 +86,42 @@ from libc.limits cimport UINT_MAX
from cysignals.memory cimport check_calloc, sig_free
from cysignals.signals cimport sig_on, sig_off

from sage.ext.stdsage cimport PY_NEW
cimport sage.libs.linbox.givaro as givaro
cimport sage.libs.linbox.linbox as linbox

from sage.arith.misc import is_prime
from sage.data_structures.binary_search cimport *
from sage.ext.stdsage cimport PY_NEW
from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry

from sage.libs.gmp.mpz cimport mpz_set
from sage.libs.linbox.conversion cimport (get_method,
METHOD_DEFAULT,
METHOD_DENSE_ELIMINATION,
METHOD_SPARSE_ELIMINATION,
METHOD_BLACKBOX,
METHOD_WIEDEMANN,
new_linbox_matrix_modn_sparse,
new_linbox_matrix_integer_sparse,
new_linbox_vector_integer_dense,
new_sage_vector_integer_dense)
from sage.matrix.args cimport SparseEntry, MatrixArgs_init
from sage.matrix.matrix2 import Matrix as Matrix2
from sage.matrix.matrix_dense cimport Matrix_dense
from sage.matrix.matrix_integer_dense cimport Matrix_integer_dense
from sage.misc.verbose import verbose, get_verbose
from sage.modules.vector_integer_dense cimport Vector_integer_dense
from sage.modules.vector_integer_sparse cimport *
from sage.modules.vector_modn_sparse cimport *

cimport sage.libs.linbox.givaro as givaro
cimport sage.libs.linbox.linbox as linbox

from sage.libs.linbox.conversion cimport *

from .matrix2 cimport Matrix
cimport sage.matrix.matrix as matrix
cimport sage.matrix.matrix_sparse as matrix_sparse
cimport sage.matrix.matrix_dense as matrix_dense
from sage.rings.fast_arith cimport arith_int
from sage.rings.finite_rings.integer_mod cimport IntegerMod_int, IntegerMod_abstract
from sage.rings.integer cimport Integer
from sage.rings.rational_field import QQ
from sage.rings.integer_ring import ZZ

from sage.misc.verbose import verbose, get_verbose

from sage.matrix.matrix2 import Matrix as Matrix2
from .args cimport SparseEntry, MatrixArgs_init
from sage.arith.misc import is_prime

cimport sage.structure.element

from sage.data_structures.binary_search cimport *
from sage.modules.vector_integer_sparse cimport *

from .matrix_integer_dense cimport Matrix_integer_dense
from sage.modules.vector_integer_dense cimport Vector_integer_dense
from sage.rings.rational_field import QQ
from sage.structure.element cimport Matrix

################
# TODO: change this to use extern cdef's methods.
from sage.rings.fast_arith cimport arith_int
cdef arith_int ai
ai = arith_int()
################
Expand All @@ -133,7 +131,7 @@ ai = arith_int()
# Github Issue #12679.
MAX_MODULUS = 46341

cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
cdef class Matrix_modn_sparse(Matrix_sparse):
def __cinit__(self):
nr = self._nrows
nc = self._ncols
Expand Down Expand Up @@ -257,7 +255,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
else:
raise ValueError("unknown matrix format")

cdef sage.structure.element.Matrix _matrix_times_matrix_(self, sage.structure.element.Matrix _right):
cdef Matrix _matrix_times_matrix_(self, Matrix _right):
"""
This code is implicitly called for multiplying self by another
sparse matrix.
Expand Down Expand Up @@ -336,7 +334,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
set_entry(&ans.rows[i], j, s)
return ans

def _matrix_times_matrix_dense(self, sage.structure.element.Matrix _right):
def _matrix_times_matrix_dense(self, Matrix _right):
"""
Multiply self by the sparse matrix _right, and return the
result as a dense matrix.
Expand All @@ -361,7 +359,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
<class 'sage.matrix.matrix_mod2_dense.Matrix_mod2_dense'>
"""
cdef Matrix_modn_sparse right
cdef matrix_dense.Matrix_dense ans
cdef Matrix_dense ans
right = _right

cdef c_vector_modint* v
Expand Down Expand Up @@ -871,7 +869,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
self.cache('det', d)
return d
elif algorithm == 'generic':
d = matrix_sparse.Matrix_sparse.determinant(self)
d = Matrix_sparse.determinant(self)
self.cache('det', d)
return d
else:
Expand Down Expand Up @@ -949,7 +947,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
if algorithm == "generic":
return Matrix_sparse.solve_right(self, B)
else:
if isinstance(B, sage.structure.element.Matrix):
if isinstance(B, Matrix):
from sage.matrix.special import diagonal_matrix
m, d = self._solve_matrix_linbox(B, algorithm)
return m * diagonal_matrix([QQ((1,x)) for x in d])
Expand Down Expand Up @@ -1121,7 +1119,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse):
from sage.modules.free_module_element import vector

cdef Matrix_integer_dense B
if not isinstance(mat, Matrix):
if not isinstance(mat, Matrix2):
B = <Matrix_integer_dense?> matrix(ZZ, mat, sparse=False)
else:
B = <Matrix_integer_dense?> mat.change_ring(ZZ).dense_matrix()
Expand Down
2 changes: 0 additions & 2 deletions src/sage/modules/vector_modn_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

from cysignals.memory cimport sig_malloc, sig_free

from sage.modules.vector_modn_sparse cimport c_vector_modint


cdef int allocate_c_vector_modint(c_vector_modint* v, Py_ssize_t num_nonzero) except -1:
"""
Expand Down
1 change: 0 additions & 1 deletion src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2557,4 +2557,3 @@ cdef class CCtoMPC(Map):

# Support Python's numbers abstract base class
# import numbers
from sage.rings.complex_mpc import MPComplexNumber
1 change: 0 additions & 1 deletion src/sage/rings/ring_extension.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from sage.categories.map cimport Map
from sage.rings.ring cimport CommutativeRing, CommutativeAlgebra
from sage.rings.ring_extension cimport RingExtension_generic


cdef class RingExtension_generic(CommutativeAlgebra):
Expand Down
3 changes: 0 additions & 3 deletions src/sage/symbolic/constants_c_impl.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ The constant `e`
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.symbolic.expression cimport Expression


# keep exp(1) for fast access
# this is initialized in the constructor of the class E below to prevent
# circular imports while loading the library
Expand Down
1 change: 0 additions & 1 deletion src/sage/symbolic/expression.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6396,7 +6396,6 @@ cdef class Expression(Expression_abc):
sage: type(u._unpack_operands()[0])
<... 'tuple'>
"""
from sage.symbolic.expression import unpack_operands
return unpack_operands(self)

def operands(self):
Expand Down