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

Replace imports from sage.geometry...all, update relint pattern #35798

Merged
merged 2 commits into from
Jul 1, 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
2 changes: 1 addition & 1 deletion src/.relint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
namespace package. Type import_statements("SOME_IDENTIFIER") to find a more specific import,
or use 'sage --fiximports' to fix automatically in the source file.
# Keep in sync with SAGE_ROOT/src/sage/misc/replace_dot_all.py
pattern: 'from\s+sage(|[.](arith|categories|combinat|crypto|databases|data_structures|dynamics|ext|game_theory|games|graphs|groups|interfaces|manifolds|matrix|matroids|misc|modules|monoids|numerical|probability|quadratic_forms|quivers|rings|sat|schemes|sets|stats|symbolic|tensor)[a-z0-9_.]*|[.]libs)[.]all\s+import'
pattern: 'from\s+sage(|[.](arith|categories|combinat|crypto|databases|data_structures|dynamics|ext|game_theory|games|geometry|graphs|groups|interfaces|manifolds|matrix|matroids|misc|modules|monoids|numerical|probability|quadratic_forms|quivers|rings|sat|schemes|sets|stats|symbolic|tensor)[a-z0-9_.]*|[.]libs)[.]all\s+import'
# imports from .all are allowed in all.py; also allow in some modules that need sage.all
filePattern: '(.*/|)(?!(all|benchmark|dev_tools|parsing|sage_eval))[^/.]*[.](py|pyx|pxi)$'

Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/root_system/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def __init__(self, space,

# Bounding box
from sage.rings.real_mpfr import RR
from sage.geometry.polyhedron.all import Polyhedron
from sage.geometry.polyhedron.constructor import Polyhedron
from itertools import product
if bounding_box in RR:
bounding_box = [[-bounding_box,bounding_box]] * self.dimension
Expand Down Expand Up @@ -1383,7 +1383,7 @@ def cone(self, rays=[], lines=[], color="black", thickness=1, alpha=1, wireframe
"""
if color is None:
return self.empty()
from sage.geometry.polyhedron.all import Polyhedron
from sage.geometry.polyhedron.constructor import Polyhedron
# TODO: we currently convert lines into rays, which simplify a
# bit the calculation of the intersection. But it would be
# nice to benefit from the new ``lines`` option of Polyhedra
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/root_system/root_lattice_realizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2539,7 +2539,7 @@ def plot_hedron(self, **options):
Line defined by 2 points: [(1.5, -0.5), (1.5, 0.5)]
Point set defined by 8 point(s): [(-1.5, -0.5), (-1.5, 0.5), (-0.5, -1.5), (-0.5, 1.5), (0.5, -1.5), (0.5, 1.5), (1.5, -0.5), (1.5, 0.5)]
"""
from sage.geometry.polyhedron.all import Polyhedron
from sage.geometry.polyhedron.constructor import Polyhedron
plot_options = self.plot_parse_options(**options)
if not self.cartan_type().is_finite():
raise ValueError("the Cartan type must be finite")
Expand Down Expand Up @@ -3061,7 +3061,7 @@ def plot_mv_polytope(self, mv_polytope, mark_endpoints=True,
sage: L.plot_mv_polytope(p)
Graphics3d Object
"""
from sage.geometry.polyhedron.all import Polyhedron
from sage.geometry.polyhedron.constructor import Polyhedron
plot_options = self.plot_parse_options(**options)

# Setup the shift for plotting
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/replace_dot_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
# Keep in sync with SAGE_ROOT/src/.relint.yml (namespace_pkg_all_import)

default_package_regex = (r"sage("
r"|[.](arith|categories|combinat|crypto|databases|data_structures|dynamics|ext|game_theory|games|graphs|groups|interfaces|manifolds|matrix|matroids|misc|modules|monoids|numerical|probability|quadratic_forms|quivers|rings|sat|schemes|sets|stats|tensor)[a-z0-9_.]*|[.]libs"
r"|[.](arith|categories|combinat|crypto|databases|data_structures|dynamics|ext|game_theory|games|geometry|graphs|groups|interfaces|manifolds|matrix|matroids|misc|modules|monoids|numerical|probability|quadratic_forms|quivers|rings|sat|schemes|sets|stats|tensor)[a-z0-9_.]*|[.]libs"
r")[.]all")


Expand Down
22 changes: 11 additions & 11 deletions src/sage/numerical/interactive_simplex_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

Since it has only two variables, we can solve it graphically::

sage: P.plot()
sage: P.plot() # optional - sage.plot
Graphics object consisting of 19 graphics primitives


Expand Down Expand Up @@ -182,7 +182,7 @@
from copy import copy

from sage.misc.abstract_method import abstract_method
from sage.geometry.all import Polyhedron
from sage.geometry.polyhedron.constructor import Polyhedron
from sage.matrix.special import column_matrix
from sage.matrix.special import identity_matrix
from sage.matrix.constructor import Matrix as matrix
Expand Down Expand Up @@ -1534,19 +1534,19 @@ def plot(self, *args, **kwds):
sage: b = (1000, 1500)
sage: c = (10, 5)
sage: P = InteractiveLPProblem(A, b, c, ["C", "B"], variable_type=">=")
sage: p = P.plot()
sage: p.show()
sage: p = P.plot() # optional - sage.plot
sage: p.show() # optional - sage.plot

In this case the plot works better with the following axes ranges::

sage: p = P.plot(0, 1000, 0, 1500)
sage: p.show()
sage: p = P.plot(0, 1000, 0, 1500) # optional - sage.plot
sage: p.show() # optional - sage.plot

TESTS:

We check that zero objective can be dealt with::

sage: InteractiveLPProblem(A, b, (0, 0), ["C", "B"], variable_type=">=").plot()
sage: InteractiveLPProblem(A, b, (0, 0), ["C", "B"], variable_type=">=").plot() # optional - sage.plot
Graphics object consisting of 8 graphics primitives
"""
FP = self.plot_feasible_set(*args, **kwds)
Expand Down Expand Up @@ -1611,13 +1611,13 @@ def plot_feasible_set(self, xmin=None, xmax=None, ymin=None, ymax=None,
sage: b = (1000, 1500)
sage: c = (10, 5)
sage: P = InteractiveLPProblem(A, b, c, ["C", "B"], variable_type=">=")
sage: p = P.plot_feasible_set()
sage: p.show()
sage: p = P.plot_feasible_set() # optional - sage.plot
sage: p.show() # optional - sage.plot

In this case the plot works better with the following axes ranges::

sage: p = P.plot_feasible_set(0, 1000, 0, 1500)
sage: p.show()
sage: p = P.plot_feasible_set(0, 1000, 0, 1500) # optional - sage.plot
sage: p.show() # optional - sage.plot
"""
if self.n() != 2:
raise ValueError("only problems with 2 variables can be plotted")
Expand Down
5 changes: 4 additions & 1 deletion src/sage/schemes/toric/fano_variety.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@

import re

from sage.geometry.all import Cone, FaceFan, Fan, LatticePolytope
from sage.geometry.cone import Cone
from sage.geometry.fan import FaceFan
from sage.geometry.fan import Fan
from sage.geometry.lattice_polytope import LatticePolytope
from sage.misc.latex import latex
from sage.misc.misc_c import prod
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
Expand Down
4 changes: 3 additions & 1 deletion src/sage/schemes/toric/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@

from sage.matrix.constructor import Matrix as matrix
from sage.matrix.special import identity_matrix
from sage.geometry.all import Fan, LatticePolytope, ToricLattice
from sage.geometry.fan import Fan
from sage.geometry.lattice_polytope import LatticePolytope
from sage.geometry.toric_lattice import ToricLattice
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.arith.misc import GCD as gcd
Expand Down
3 changes: 2 additions & 1 deletion src/sage/schemes/toric/morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@
from sage.misc.cachefunc import cached_method
from sage.matrix.constructor import matrix, identity_matrix
from sage.modules.free_module_element import vector
from sage.geometry.all import Cone, Fan
from sage.geometry.cone import Cone
from sage.geometry.fan import Fan

from sage.schemes.generic.scheme import is_Scheme
from sage.schemes.generic.morphism import (
Expand Down