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

sage.{categories,matrix,structure}: Replace imports from sage.*.all for namespace packages #34949

Closed
mkoeppe opened this issue Jan 29, 2023 · 12 comments · Fixed by #35012
Closed

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Jan 29, 2023

Using ./sage -fiximports from #34945.

Also remove trailing whitespace in the affected files.

Part of Meta-ticket #34201

CC: @alexchandler100 @tscrim @fchapoton

Component: refactoring

Author: Alex Chandler, Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/34949

@mkoeppe mkoeppe added this to the sage-9.8 milestone Jan 29, 2023
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jan 29, 2023

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jan 29, 2023

New commits:

a14d662sage -fiximports src/sage/{categories,matrix,structure}
9911481src/sage/{categories,matrix,structure}: Manual fixes to imports

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jan 29, 2023

Commit: 9911481

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jan 29, 2023

comment:3
[sagelib-9.8.beta7]     Error compiling Cython file:
[sagelib-9.8.beta7]     ------------------------------------------------------------
[sagelib-9.8.beta7]     ...
[sagelib-9.8.beta7]             if not isinstance(right, Element):
[sagelib-9.8.beta7]                 right = py_scalar_to_element(right)
[sagelib-9.8.beta7]                 if not isinstance(right, Element):
[sagelib-9.8.beta7]                     right = right.sage()
[sagelib-9.8.beta7]             from sage.arith.misc import GCD as gcd
[sagelib-9.8.beta7]                 from sage.arith.misc import GCD as gcd
[sagelib-9.8.beta7]     ^
[sagelib-9.8.beta7]     ------------------------------------------------------------
[sagelib-9.8.beta7] 
[sagelib-9.8.beta7]     sage/structure/element.pyx:4057:0: Possible inconsistent indentation
[sagelib-9.8.beta7] 
[sagelib-9.8.beta7]     Error compiling Cython file:
[sagelib-9.8.beta7]     ------------------------------------------------------------
[sagelib-9.8.beta7]     ...
[sagelib-9.8.beta7]             if not isinstance(right, Element):
[sagelib-9.8.beta7]                 right = py_scalar_to_element(right)
[sagelib-9.8.beta7]                 if not isinstance(right, Element):
[sagelib-9.8.beta7]                     right = right.sage()
[sagelib-9.8.beta7]             from sage.arith.misc import GCD as gcd
[sagelib-9.8.beta7]                 from sage.arith.misc import GCD as gcd
[sagelib-9.8.beta7]     ^
[sagelib-9.8.beta7]     ------------------------------------------------------------
[sagelib-9.8.beta7] 
[sagelib-9.8.beta7]     sage/structure/element.pyx:4057:0: Expected an identifier or literal

@jhpalmieri
Copy link
Member

comment:5

I think these changes are to blame:

diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
index e9430f0..92e83bd 100644
--- a/src/sage/structure/element.pyx
+++ b/src/sage/structure/element.pyx
@@ -4047,8 +4053,8 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement):
             right = py_scalar_to_element(right)
             if not isinstance(right, Element):
                 right = right.sage()
-        if not ((<Element>right)._parent is self._parent):
-            from sage.arith.all import gcd
+        from sage.arith.misc import GCD as gcd
+            from sage.arith.misc import GCD as gcd
             return coercion_model.bin_op(self, right, gcd)
         return self._gcd(right)
 
@@ -4081,8 +4087,8 @@ cdef class PrincipalIdealDomainElement(DedekindDomainElement):
             right = py_scalar_to_element(right)
             if not isinstance(right, Element):
                 right = right.sage()
-        if not ((<Element>right)._parent is self._parent):
-            from sage.arith.all import lcm
+        from sage.arith.functions import lcm
+            from sage.arith.functions import lcm
             return coercion_model.bin_op(self, right, lcm)
         return self._lcm(right)

@mkoeppe mkoeppe modified the milestones: sage-9.8, sage-9.9 Jan 29, 2023
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 30, 2023

Branch pushed to git repo; I updated commit sha1. New commits:

01cded9src/sage/structure/element.pyx: Fix up

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 30, 2023

Changed commit from 9911481 to 01cded9

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jan 30, 2023

comment:8

Thanks, fixed.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 30, 2023

Branch pushed to git repo; I updated commit sha1. New commits:

6203202sage.matrix: Consolidate imports from the same module

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 30, 2023

Changed commit from 01cded9 to 6203202

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jan 30, 2023

Changed author from Alex Chandler to Alex Chandler, Matthias Koeppe

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Feb 7, 2023

The branch is now on PR #35012

mkoeppe added a commit to mkoeppe/sage that referenced this issue Feb 12, 2023
@vbraun vbraun closed this as completed in cf49215 Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants