From f1368a66ef97b162206d64a41c49bc810b5d8190 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 8 Sep 2023 15:15:50 -0700 Subject: [PATCH 1/2] Replace relative cimports --- .../combinat/designs/orthogonal_arrays_find_recursive.pyx | 2 +- src/sage/graphs/base/c_graph.pxd | 2 +- src/sage/graphs/base/dense_graph.pxd | 2 +- src/sage/graphs/base/graph_backends.pyx | 2 +- src/sage/graphs/base/sparse_graph.pxd | 2 +- src/sage/graphs/base/static_sparse_backend.pxd | 7 +++++-- src/sage/graphs/base/static_sparse_backend.pyx | 2 +- src/sage/graphs/base/static_sparse_graph.pyx | 4 ++-- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx index 6b6bd11dfb1..753a21c8ae9 100644 --- a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +++ b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx @@ -951,7 +951,7 @@ cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n) noexcept: return False -from .designs_pyx cimport _OA_cache, _OA_cache_size +from sage.combinat.designs.designs_pyx cimport _OA_cache, _OA_cache_size cdef int is_available(int k,int n) except -1: r""" Return whether Sage can build an OA(k,n) diff --git a/src/sage/graphs/base/c_graph.pxd b/src/sage/graphs/base/c_graph.pxd index 1d5fb583eb5..b29cc3c9527 100644 --- a/src/sage/graphs/base/c_graph.pxd +++ b/src/sage/graphs/base/c_graph.pxd @@ -6,7 +6,7 @@ #************************************************************************** from sage.data_structures.bitset cimport bitset_t -from .graph_backends cimport GenericGraphBackend +from sage.graphs.base.graph_backends cimport GenericGraphBackend from libc.stdint cimport uint32_t cdef class CGraph: diff --git a/src/sage/graphs/base/dense_graph.pxd b/src/sage/graphs/base/dense_graph.pxd index f5c194cec8a..6c4145694fe 100644 --- a/src/sage/graphs/base/dense_graph.pxd +++ b/src/sage/graphs/base/dense_graph.pxd @@ -8,7 +8,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** -from .c_graph cimport CGraph, CGraphBackend +from sage.graphs.base.c_graph cimport CGraph, CGraphBackend from sage.data_structures.binary_matrix cimport binary_matrix_t cdef class DenseGraph(CGraph): diff --git a/src/sage/graphs/base/graph_backends.pyx b/src/sage/graphs/base/graph_backends.pyx index c0ffc56533e..a09bb0cd73c 100644 --- a/src/sage/graphs/base/graph_backends.pyx +++ b/src/sage/graphs/base/graph_backends.pyx @@ -57,7 +57,7 @@ Classes and methods # (at your option) any later version. # https://www.gnu.org/licenses/ # **************************************************************************** -from .c_graph cimport CGraphBackend +from sage.graphs.base.c_graph cimport CGraphBackend cdef class GenericGraphBackend(SageObject): diff --git a/src/sage/graphs/base/sparse_graph.pxd b/src/sage/graphs/base/sparse_graph.pxd index b925e9170ec..3795c8ff0f0 100644 --- a/src/sage/graphs/base/sparse_graph.pxd +++ b/src/sage/graphs/base/sparse_graph.pxd @@ -8,7 +8,7 @@ # https://www.gnu.org/licenses/ # **************************************************************************** -from .c_graph cimport CGraph, CGraphBackend +from sage.graphs.base.c_graph cimport CGraph, CGraphBackend cimport cython cdef struct SparseGraphLLNode: diff --git a/src/sage/graphs/base/static_sparse_backend.pxd b/src/sage/graphs/base/static_sparse_backend.pxd index db62534cb09..fb72a89180b 100644 --- a/src/sage/graphs/base/static_sparse_backend.pxd +++ b/src/sage/graphs/base/static_sparse_backend.pxd @@ -1,7 +1,9 @@ -from .c_graph cimport CGraph, CGraphBackend -from .static_sparse_graph cimport short_digraph, ushort from libc.stdint cimport uint64_t, uint32_t, INT32_MAX, UINT32_MAX + from sage.data_structures.bitset cimport * +from sage.graphs.base.c_graph cimport CGraph, CGraphBackend +from sage.graphs.base.static_sparse_graph cimport short_digraph, ushort + cdef class StaticSparseCGraph(CGraph): cdef short_digraph g @@ -12,6 +14,7 @@ cdef class StaticSparseCGraph(CGraph): cpdef int out_degree(self, int u) except -1 cpdef int in_degree(self, int u) except -1 + cdef class StaticSparseBackend(CGraphBackend): cdef int _order cdef bint _multiedges diff --git a/src/sage/graphs/base/static_sparse_backend.pyx b/src/sage/graphs/base/static_sparse_backend.pyx index ae76a399240..0d1361c940a 100644 --- a/src/sage/graphs/base/static_sparse_backend.pyx +++ b/src/sage/graphs/base/static_sparse_backend.pyx @@ -43,7 +43,7 @@ from sage.graphs.base.static_sparse_graph cimport (init_short_digraph, has_edge, free_short_digraph, edge_label) -from .c_graph cimport CGraphBackend +from sage.graphs.base.c_graph cimport CGraphBackend from sage.data_structures.bitset cimport FrozenBitset from libc.stdint cimport uint32_t from sage.data_structures.bitset_base cimport * diff --git a/src/sage/graphs/base/static_sparse_graph.pyx b/src/sage/graphs/base/static_sparse_graph.pyx index 90e47b6e069..ddb30927931 100644 --- a/src/sage/graphs/base/static_sparse_graph.pyx +++ b/src/sage/graphs/base/static_sparse_graph.pyx @@ -191,8 +191,8 @@ from memory_allocator cimport MemoryAllocator from sage.data_structures.bitset_base cimport * from sage.graphs.base.c_graph cimport CGraph -from .static_sparse_backend cimport StaticSparseCGraph -from .static_sparse_backend cimport StaticSparseBackend +from sage.graphs.base.static_sparse_backend cimport StaticSparseCGraph +from sage.graphs.base.static_sparse_backend cimport StaticSparseBackend cdef extern from "fenv.h": From d486801a6a2ad28b40427f74a463bd67c9b8501b Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 6 Sep 2023 20:25:37 -0700 Subject: [PATCH 2/2] Replace relative imports in Cython files --- src/sage/coding/ag_code_decoders.pyx | 4 +-- src/sage/combinat/designs/designs_pyx.pyx | 2 +- .../designs/evenly_distributed_sets.pyx | 2 +- .../orthogonal_arrays_find_recursive.pyx | 28 +++++++++---------- src/sage/graphs/base/graph_backends.pyx | 6 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/sage/coding/ag_code_decoders.pyx b/src/sage/coding/ag_code_decoders.pyx index 162c7210fc5..15231e6aa87 100644 --- a/src/sage/coding/ag_code_decoders.pyx +++ b/src/sage/coding/ag_code_decoders.pyx @@ -66,8 +66,8 @@ from sage.rings.function_field.constructor import FunctionField from sage.modules.free_module_element import vector from sage.matrix.constructor import matrix -from .encoder import Encoder -from .decoder import Decoder, DecodingError +from sage.coding.encoder import Encoder +from sage.coding.decoder import Decoder, DecodingError from sage.modules.free_module_element cimport FreeModuleElement from sage.matrix.matrix cimport Matrix diff --git a/src/sage/combinat/designs/designs_pyx.pyx b/src/sage/combinat/designs/designs_pyx.pyx index 027cc00fbb0..d1800d4382e 100644 --- a/src/sage/combinat/designs/designs_pyx.pyx +++ b/src/sage/combinat/designs/designs_pyx.pyx @@ -804,7 +804,7 @@ def is_quasi_difference_matrix(M,G,int k,int lmbda,int mu,int u,verbose=False): Column 1 contains 2 empty entries instead of the expected lambda.u=1.1=1 False """ - from .difference_family import group_law + from sage.combinat.designs.difference_family import group_law assert k>=2 assert lmbda >=1 diff --git a/src/sage/combinat/designs/evenly_distributed_sets.pyx b/src/sage/combinat/designs/evenly_distributed_sets.pyx index 36d48d50b30..db567154ab4 100644 --- a/src/sage/combinat/designs/evenly_distributed_sets.pyx +++ b/src/sage/combinat/designs/evenly_distributed_sets.pyx @@ -310,7 +310,7 @@ cdef class EvenlyDistributedSetsBacktracker: xe = self.K.multiplicative_generator() ** (self.e) df = [[xe**j*b for b in B] for j in range((self.q-1)/(2*self.e))] if check: - from .difference_family import is_difference_family + from sage.combinat.designs.difference_family import is_difference_family if not is_difference_family(self.K, df, self.q, self.k, 1): raise RuntimeError("a wrong evenly distributed set was " "produced by the Sage library for the parameters:\n" diff --git a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx index 753a21c8ae9..518c7199a77 100644 --- a/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx +++ b/src/sage/combinat/designs/orthogonal_arrays_find_recursive.pyx @@ -47,7 +47,7 @@ Functions """ from sage.misc.cachefunc import cached_function -from .orthogonal_arrays import orthogonal_array +from sage.combinat.designs.orthogonal_arrays import orthogonal_array from sage.rings.integer cimport smallInteger from sage.arith.misc import prime_powers @@ -153,7 +153,7 @@ cpdef find_product_decomposition(int k,int n) noexcept: # faster to use that rather than calling the divisors function continue if is_available(k, n1) and is_available(k, n2): - from .orthogonal_arrays import wilson_construction + from sage.combinat.designs.orthogonal_arrays import wilson_construction return wilson_construction, (None,k,n1,n2,(),False) return False @@ -203,7 +203,7 @@ cpdef find_wilson_decomposition_with_one_truncated_group(int k,int n) noexcept: is_available(k ,m+1) and is_available(k+1,r ) and is_available(k ,u )): - from .orthogonal_arrays import wilson_construction + from sage.combinat.designs.orthogonal_arrays import wilson_construction return wilson_construction, (None,k,r,m,(u,),False) return False @@ -266,7 +266,7 @@ cpdef find_wilson_decomposition_with_two_truncated_groups(int k,int n) noexcept: r2 = r1_p_r2-r1 if is_available(k,r2): assert n == r*m+r1+r2 - from .orthogonal_arrays import wilson_construction + from sage.combinat.designs.orthogonal_arrays import wilson_construction return wilson_construction, (None,k,r,m,(r1,r2),False) return False @@ -306,7 +306,7 @@ cpdef find_construction_3_3(int k,int n) noexcept: if (is_available(k+i, nn ) and is_available(k , mm+i)): - from .orthogonal_arrays_build_recursive import construction_3_3 + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_3_3 return construction_3_3, (k,nn,mm,i) cpdef find_construction_3_4(int k,int n) noexcept: @@ -349,7 +349,7 @@ cpdef find_construction_3_4(int k,int n) noexcept: if (is_available(k+r+1,nn) and is_available(k , s) and (is_available(k,mm+r) or is_available(k,mm+r+1))): - from .orthogonal_arrays_build_recursive import construction_3_4 + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_3_4 return construction_3_4, (k,nn,mm,r,s) cpdef find_construction_3_5(int k,int n) noexcept: @@ -399,7 +399,7 @@ cpdef find_construction_3_5(int k,int n) noexcept: (r==0 or is_available(k,r)) and (s==0 or is_available(k,s)) and (t==0 or is_available(k,t))): - from .orthogonal_arrays_build_recursive import construction_3_5 + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_3_5 return construction_3_5, (k,nn,mm,r,s,t) cpdef find_construction_3_6(int k,int n) noexcept: @@ -440,7 +440,7 @@ cpdef find_construction_3_6(int k,int n) noexcept: if (is_available(k+i,nn) and smallInteger(nn).is_prime_power()): - from .orthogonal_arrays_build_recursive import construction_3_6 + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_3_6 return construction_3_6, (k,nn,mm,i) cpdef find_q_x(int k,int n) noexcept: @@ -492,7 +492,7 @@ cpdef find_q_x(int k,int n) noexcept: # is_available(k+1,q) and is_available(k, x+2 ) and smallInteger(q).is_prime_power()): - from .orthogonal_arrays_build_recursive import construction_q_x + from sage.combinat.designs.orthogonal_arrays_build_recursive import construction_q_x return construction_q_x, (k,q,x) return False @@ -546,7 +546,7 @@ cpdef find_thwart_lemma_3_5(int k,int N) noexcept: sage: for k,n in kn: # not tested -- too long ....: assert designs.orthogonal_array(k,n,existence=True) is True """ - from .orthogonal_arrays_build_recursive import thwart_lemma_3_5 + from sage.combinat.designs.orthogonal_arrays_build_recursive import thwart_lemma_3_5 cdef int n,m,a,b,c,d,NN,na,nb,nc for n in prime_powers(k+2,N-2): # There must exist a OA(k+3,n) thus n>=k+2 @@ -661,7 +661,7 @@ cpdef find_thwart_lemma_4_1(int k,int n) noexcept: not is_available(k,mm+4)): continue - from .orthogonal_arrays_build_recursive import thwart_lemma_4_1 + from sage.combinat.designs.orthogonal_arrays_build_recursive import thwart_lemma_4_1 return thwart_lemma_4_1,(k,nn,mm) return False @@ -706,7 +706,7 @@ cpdef find_three_factor_product(int k,int n) noexcept: not is_available(k,n2) or not is_available(k,n3)): continue - from .orthogonal_arrays_build_recursive import three_factor_product + from sage.combinat.designs.orthogonal_arrays_build_recursive import three_factor_product return three_factor_product,(k-1,n1,n2,n3) return False @@ -731,7 +731,7 @@ cpdef find_brouwer_separable_design(int k,int n) noexcept: sage: find_brouwer_separable_design(5,14) False """ - from .orthogonal_arrays_build_recursive import brouwer_separable_design + from sage.combinat.designs.orthogonal_arrays_build_recursive import brouwer_separable_design cdef int q,x,baer_subplane_size, max_t, min_t, t,e1,e2,e3,e4 for q in prime_powers(2,n): @@ -945,7 +945,7 @@ cpdef find_brouwer_van_rees_with_one_truncated_column(int k,int n) noexcept: values = int_as_sum(remainder, available_multipliers, r) if values is not None: - from .orthogonal_arrays import wilson_construction + from sage.combinat.designs.orthogonal_arrays import wilson_construction return (wilson_construction, (None,k,r,m,[[(x,1) for x in values]])) diff --git a/src/sage/graphs/base/graph_backends.pyx b/src/sage/graphs/base/graph_backends.pyx index a09bb0cd73c..863f61be013 100644 --- a/src/sage/graphs/base/graph_backends.pyx +++ b/src/sage/graphs/base/graph_backends.pyx @@ -722,9 +722,9 @@ cdef class GenericGraphBackend(SageObject): sage: loads(dumps(gi)) == gi True """ - from .static_sparse_backend import StaticSparseBackend - from .sparse_graph import SparseGraphBackend - from .dense_graph import DenseGraphBackend + from sage.graphs.base.static_sparse_backend import StaticSparseBackend + from sage.graphs.base.sparse_graph import SparseGraphBackend + from sage.graphs.base.dense_graph import DenseGraphBackend # implementation, data_structure, multiedges, directed, loops if isinstance(self, CGraphBackend):