Skip to content

Commit a5b9756

Browse files
author
Release Manager
committed
gh-39989: Refactor imports in PoorManMap and Sequence classes <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> Minor refactoring to prefer importing the object (`from sage.structure.sage_object import SageObject`) over the module (`import sage.structure.sage_object`). Part of making all sage modules import without `sage.all`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] 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 and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #39989 Reported by: Tobias Diez Reviewer(s): Frédéric Chapoton
2 parents edf324e + b275f17 commit a5b9756

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/sage/categories/poor_man_map.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# (at your option) any later version.
1313
# https://www.gnu.org/licenses/
1414
# ****************************************************************************
15-
import sage.structure.sage_object
15+
from sage.structure.sage_object import SageObject
1616

1717

18-
class PoorManMap(sage.structure.sage_object.SageObject):
18+
class PoorManMap(SageObject):
1919
"""
2020
A class for maps between sets which are not (yet) modeled by parents.
2121
@@ -264,7 +264,7 @@ def _sympy_(self):
264264
sage: h._sympy_() # needs sympy sage.symbolic
265265
sin
266266
"""
267-
from sympy import Lambda, sympify
267+
from sympy import sympify
268268
if len(self._functions) == 1:
269269
return sympify(self._functions[0])
270270
raise NotImplementedError

src/sage/structure/sequence.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@
7171
# ****************************************************************************
7272

7373
from sage.misc.persist import register_unpickle_override
74-
import sage.structure.sage_object
75-
import sage.structure.coerce
74+
from sage.structure.sage_object import SageObject
7675

7776

7877
def Sequence(x, universe=None, check=True, immutable=False, cr=False, cr_str=None, use_sage_types=False):
@@ -259,7 +258,9 @@ def Sequence(x, universe=None, check=True, immutable=False, cr=False, cr_str=Non
259258
x = list(x)
260259
else:
261260
try:
262-
from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal
261+
from sage.rings.polynomial.multi_polynomial_ideal import (
262+
MPolynomialIdeal,
263+
)
263264
except ImportError:
264265
pass
265266
else:
@@ -293,9 +294,9 @@ def Sequence(x, universe=None, check=True, immutable=False, cr=False, cr_str=Non
293294
universe = sage.structure.element.parent(x[len(x)-1])
294295

295296
try:
297+
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
296298
from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence
297299
from sage.rings.polynomial.pbori.pbori import BooleanMonomialMonoid
298-
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
299300
from sage.rings.quotient_ring import QuotientRing_nc
300301
except ImportError:
301302
pass
@@ -306,7 +307,7 @@ def Sequence(x, universe=None, check=True, immutable=False, cr=False, cr_str=Non
306307
return Sequence_generic(x, universe, check, immutable, cr, cr_str, use_sage_types)
307308

308309

309-
class Sequence_generic(sage.structure.sage_object.SageObject, list):
310+
class Sequence_generic(SageObject, list):
310311
"""
311312
A mutable list of elements with a common guaranteed universe,
312313
which can be set immutable.

0 commit comments

Comments
 (0)