diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index ed0d8a65501..995d085573d 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -39,7 +39,7 @@ # Sage matrix imports see :trac:`34283` # Sage imports -import sage.structure.coerce +import sage.structure.coerce_actions from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation import sage.rings.integer as integer @@ -1054,7 +1054,7 @@ def _get_action_(self, S, op, self_on_left): return matrix_action.MatrixPolymapAction(self, S) else: # action of base ring - return sage.structure.coerce.RightModuleAction(S, self) + return sage.structure.coerce_actions.RightModuleAction(S, self) else: if is_MatrixSpace(S): # matrix multiplications @@ -1065,7 +1065,7 @@ def _get_action_(self, S, op, self_on_left): return matrix_action.PolymapMatrixAction(self, S) else: # action of base ring - return sage.structure.coerce.LeftModuleAction(S, self) + return sage.structure.coerce_actions.LeftModuleAction(S, self) except TypeError: return None diff --git a/src/sage/stats/time_series.pyx b/src/sage/stats/time_series.pyx index 01a735a9679..bf4ffbc178e 100644 --- a/src/sage/stats/time_series.pyx +++ b/src/sage/stats/time_series.pyx @@ -36,19 +36,19 @@ AUTHOR: - William Stein """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2008 William Stein # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** cimport cython from cpython.bytes cimport PyBytes_FromStringAndSize, PyBytes_AsString -from libc.math cimport exp, floor, log, pow, sqrt +from libc.math cimport exp, log, pow, sqrt from libc.string cimport memcpy from cysignals.memory cimport sig_malloc, sig_free from sage.structure.richcmp cimport rich_to_bool diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx index 52abd7d918b..f20e3fcf884 100644 --- a/src/sage/structure/category_object.pyx +++ b/src/sage/structure/category_object.pyx @@ -47,18 +47,17 @@ This example illustrates generators for a free module over `\ZZ`. ((1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1)) """ -#***************************************************************************** +# **************************************************************************** # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.cpython.getattr import dir_with_other_class from sage.cpython.getattr cimport getattr_from_other_class from sage.categories.category import Category -from sage.structure.debug_options cimport debug from sage.misc.cachefunc import cached_method from sage.structure.dynamic_class import DynamicMetaclass @@ -668,7 +667,7 @@ cdef class CategoryObject(SageObject): sage: print(latex(f)) 5 x_{1}^{10} + x_{0}^{3} """ - from sage.misc.latex import latex, latex_variable_name + from sage.misc.latex import latex_variable_name try: names = self._latex_names if names is not None: @@ -676,7 +675,8 @@ cdef class CategoryObject(SageObject): except AttributeError: pass # Compute the latex versions of the variable names. - self._latex_names = [latex_variable_name(x) for x in self.variable_names()] + self._latex_names = [latex_variable_name(x) + for x in self.variable_names()] return self._latex_names def latex_name(self): diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx index eab5852a410..d5b4c12aaae 100644 --- a/src/sage/structure/coerce.pyx +++ b/src/sage/structure/coerce.pyx @@ -64,36 +64,35 @@ For more information on how to specify coercions, conversions, and actions, see the documentation for :class:`Parent`. """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2007 Robert Bradshaw # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** -from cpython.object cimport (PyObject, PyTypeObject, - PyObject_CallObject, PyObject_RichCompare, Py_TYPE, - Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE) +from cpython.object cimport (PyTypeObject, PyObject_CallObject, + PyObject_RichCompare, Py_TYPE, + Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT) from cpython.weakref cimport PyWeakref_GET_OBJECT, PyWeakref_NewRef from libc.string cimport strncmp cimport gmpy2 -cdef add, mul, truediv -from operator import add, mul, truediv +cdef mul, truediv +from operator import mul, truediv from .richcmp cimport rich_to_bool, revop from .sage_object cimport SageObject from .parent cimport Parent_richcmp_element_without_coercion from .element cimport bin_op_exception, parent, Element -from .coerce_actions import LeftModuleAction, RightModuleAction from .coerce_exceptions import CoercionException from sage.rings.integer_fake cimport is_Integer from sage.categories.map cimport Map from sage.categories.morphism import IdentityMorphism -from sage.categories.action cimport Action, InverseAction, PrecomposedAction +from sage.categories.action cimport Action, PrecomposedAction from sage.sets.pythonclass cimport Set_PythonType import traceback @@ -1653,7 +1652,6 @@ cdef class CoercionModel: sage: print(cm.discover_coercion(QQ, QQ^3)) None """ - from sage.categories.homset import Hom if R is S: return None, None diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index b7ee6a3a06a..026991c25d8 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -290,15 +290,11 @@ continue down the MRO and find the ``_add_`` method in the category. cimport cython from cpython cimport * -from cpython.ref cimport PyObject from sage.ext.stdsage cimport * -import types cdef add, sub, mul, truediv, floordiv, mod, matmul, pow -cdef iadd, isub, imul, itruediv, ifloordiv, imod, ipow -from operator import (add, sub, mul, truediv, floordiv, mod, matmul, pow, - iadd, isub, imul, itruediv, ifloordiv, imod, imatmul, ipow) +from operator import (add, sub, mul, truediv, floordiv, mod, matmul, pow) cdef dict _coerce_op_symbols = dict( add='+', sub='-', mul='*', truediv='/', floordiv='//', mod='%', matmul='@', pow='^', @@ -310,8 +306,6 @@ from sage.structure.parent cimport Parent from sage.cpython.type cimport can_assign_class from sage.cpython.getattr cimport getattr_from_other_class from sage.misc.lazy_format import LazyFormat -from sage.misc import sageinspect -from sage.misc.classcall_metaclass cimport ClasscallMetaclass from sage.arith.long cimport integer_check_long_py from sage.arith.power cimport generic_power as arith_generic_power from sage.arith.numerical_approx cimport digits_to_bits @@ -711,7 +705,6 @@ cdef class Element(SageObject): ... AssertionError: self.an_element() is not in self """ - from sage.categories.objects import Objects tester = self._tester(**options) SageObject._test_category(self, tester = tester) category = self.category() diff --git a/src/sage/structure/formal_sum.py b/src/sage/structure/formal_sum.py index 4552b62a546..7a788c3994f 100644 --- a/src/sage/structure/formal_sum.py +++ b/src/sage/structure/formal_sum.py @@ -49,7 +49,7 @@ True """ -#***************************************************************************** +# **************************************************************************** # Copyright (C) 2004 William Stein # # Distributed under the terms of the GNU General Public License (GPL) @@ -61,8 +61,8 @@ # # The full text of the GPL is available at: # -# http://www.gnu.org/licenses/ -#***************************************************************************** +# https://www.gnu.org/licenses/ +# **************************************************************************** from sage.misc.repr import repr_lincomb import operator @@ -73,7 +73,7 @@ from sage.structure.richcmp import richcmp from sage.rings.integer_ring import ZZ from sage.structure.parent import Parent -from sage.structure.coerce import LeftModuleAction, RightModuleAction +from sage.structure.coerce_actions import LeftModuleAction, RightModuleAction from sage.categories.action import PrecomposedAction from sage.structure.unique_representation import UniqueRepresentation diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx index 1f5511a02c7..564368806c0 100644 --- a/src/sage/structure/parent.pyx +++ b/src/sage/structure/parent.pyx @@ -103,7 +103,7 @@ This came up in some subtle bug once:: # https://www.gnu.org/licenses/ # **************************************************************************** -from cpython.object cimport PyObject, Py_NE, Py_EQ, Py_LE, Py_GE +from cpython.object cimport Py_EQ, Py_LE, Py_GE from cpython.bool cimport * from types import MethodType, BuiltinMethodType @@ -111,7 +111,6 @@ import operator from copy import copy from sage.cpython.type cimport can_assign_class -cimport sage.categories.morphism as morphism cimport sage.categories.map as map from sage.structure.debug_options cimport debug from sage.structure.sage_object cimport SageObject @@ -119,7 +118,7 @@ from sage.misc.cachefunc import cached_method from sage.misc.lazy_attribute import lazy_attribute from sage.categories.sets_cat import Sets, EmptySetError from sage.misc.lazy_string cimport _LazyString -from sage.sets.pythonclass cimport Set_PythonType_class, Set_PythonType +from sage.sets.pythonclass cimport Set_PythonType_class from .category_object import CategoryObject from .coerce cimport coercion_model from .coerce cimport parent_is_integers @@ -2599,7 +2598,6 @@ cdef class Parent(sage.structure.category_object.CategoryObject): # If needed, it will be passed to Left/RightModuleAction. from sage.categories.action import Action, PrecomposedAction from sage.categories.homset import Hom - from .coerce_actions import LeftModuleAction, RightModuleAction cdef Parent R for action in self._action_list: diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx index a0c497dc65d..b0e5ae7cd48 100644 --- a/src/sage/symbolic/ring.pyx +++ b/src/sage/symbolic/ring.pyx @@ -205,22 +205,14 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing): return False else: - from sage.rings.real_mpfr import mpfr_prec_min - from sage.rings.fraction_field import is_FractionField - from sage.rings.real_mpfi import is_RealIntervalField - from sage.rings.real_arb import RealBallField - from sage.rings.complex_arb import ComplexBallField from sage.rings.polynomial.polynomial_ring import is_PolynomialRing from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing from sage.rings.polynomial.laurent_polynomial_ring_base import LaurentPolynomialRing_generic - from sage.rings.complex_mpfr import ComplexField from sage.rings.infinity import InfinityRing, UnsignedInfinityRing from sage.rings.real_lazy import RLF, CLF from sage.rings.finite_rings.finite_field_base import FiniteField - from sage.interfaces.maxima import Maxima - from .subring import GenericSymbolicSubring if R._is_numerical():