Skip to content

Commit db87eb3

Browse files
author
Release Manager
committed
gh-38236: `sage.geometry.hyperbolic_space`: Add `# needs` <!-- ^ 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". --> Some of these are from the use of a matrix norm, which `# needs scipy`. Also a norm-related change in `sage.modules.free_module_integer` - avoiding use of `norm`, which send us into symbolics land, in favor of just comparing norm squares - Cherry-picked from #35095. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] 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: #38236 Reported by: Matthias Köppe Reviewer(s): David Coudert
2 parents c2372a9 + 1cce2b8 commit db87eb3

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def SL2R_to_SO21(A):
649649
sage: from sage.geometry.hyperbolic_space.hyperbolic_coercion import SL2R_to_SO21
650650
sage: A = SL2R_to_SO21(identity_matrix(2))
651651
sage: J = matrix([[1,0,0],[0,1,0],[0,0,-1]]) #Lorentzian Gram matrix
652-
sage: norm(A.transpose()*J*A - J) < 10**-4
652+
sage: norm(A.transpose()*J*A - J) < 10**-4 # needs scipy
653653
True
654654
"""
655655
a, b, c, d = (A/A.det().sqrt()).list()
@@ -689,7 +689,7 @@ def SO21_to_SL2R(M):
689689
EXAMPLES::
690690
691691
sage: from sage.geometry.hyperbolic_space.hyperbolic_coercion import SO21_to_SL2R
692-
sage: (SO21_to_SL2R(identity_matrix(3)) - identity_matrix(2)).norm() < 10**-4
692+
sage: (SO21_to_SL2R(identity_matrix(3)) - identity_matrix(2)).norm() < 10**-4 # needs scipy
693693
True
694694
"""
695695
####################################################################

src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ def reflection_involution(self):
794794
sage: g = HM.get_geodesic((0,0,1), (1,0, n(sqrt(2))))
795795
sage: A = g.reflection_involution()
796796
sage: B = diagonal_matrix([1, -1, 1])
797-
sage: bool((B - A.matrix()).norm() < 10**-9)
797+
sage: bool((B - A.matrix()).norm() < 10**-9) # needs scipy
798798
True
799799
800800
The above tests go through the Upper Half Plane. It remains to
@@ -1602,7 +1602,7 @@ def perpendicular_bisector(self): # UHP
16021602
....: return bool(x.dist(m) < 1e-9)
16031603
sage: c, d, e = CC(1, 1), CC(2, 1), CC(2, 0.5)
16041604
sage: pairs = [(c, d), (d, c), (c, e), (e, c), (d, e), (e, d)]
1605-
sage: all(bisector_gets_midpoint(a, b) for a, b in pairs)
1605+
sage: all(bisector_gets_midpoint(a, b) for a, b in pairs) # needs scipy
16061606
True
16071607
"""
16081608
if self.length() == infinity:
@@ -2379,7 +2379,7 @@ def _plot_vertices(self, points=75):
23792379
sage: p1 = HM.get_point((4, -4, sqrt(33)))
23802380
sage: p2 = HM.get_point((-3,-3,sqrt(19)))
23812381
sage: g = HM.get_geodesic(p1, p2)
2382-
sage: g._plot_vertices(5)
2382+
sage: g._plot_vertices(5) # needs sage.plot
23832383
[(4.0, -4.0, 5.744562...),
23842384
(1.363213..., -1.637073..., 2.353372...),
23852385
(0.138568..., -0.969980..., 1.400022...),

src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs scipy
12
r"""
23
Hyperbolic Isometries
34

src/sage/geometry/hyperbolic_space/hyperbolic_model.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,13 @@ def get_isometry(self, A):
488488
[1 0]
489489
[0 1]
490490
491-
sage: HyperbolicPlane().KM().get_isometry(identity_matrix(3))
491+
sage: HyperbolicPlane().KM().get_isometry(identity_matrix(3)) # needs scipy
492492
Isometry in KM
493493
[1 0 0]
494494
[0 1 0]
495495
[0 0 1]
496496
497-
sage: HyperbolicPlane().HM().get_isometry(identity_matrix(3))
497+
sage: HyperbolicPlane().HM().get_isometry(identity_matrix(3)) # needs scipy
498498
Isometry in HM
499499
[1 0 0]
500500
[0 1 0]
@@ -586,6 +586,7 @@ def random_isometry(self, preserve_orientation=True, **kwargs):
586586
587587
EXAMPLES::
588588
589+
sage: # needs scipy
589590
sage: A = HyperbolicPlane().PD().random_isometry()
590591
sage: A.preserves_orientation()
591592
True
@@ -934,7 +935,7 @@ def get_background_graphic(self, **bdry_options):
934935
935936
EXAMPLES::
936937
937-
sage: hp = HyperbolicPlane().UHP().get_background_graphic()
938+
sage: hp = HyperbolicPlane().UHP().get_background_graphic() # needs sage.plot
938939
"""
939940
from sage.plot.line import line
940941
bd_min = bdry_options.get('bd_min', -5)
@@ -1104,9 +1105,9 @@ def random_isometry(self, preserve_orientation=True, **kwargs):
11041105
11051106
EXAMPLES::
11061107
1107-
sage: A = HyperbolicPlane().UHP().random_isometry()
1108-
sage: B = HyperbolicPlane().UHP().random_isometry(preserve_orientation=False)
1109-
sage: B.preserves_orientation()
1108+
sage: A = HyperbolicPlane().UHP().random_isometry() # needs scipy
1109+
sage: B = HyperbolicPlane().UHP().random_isometry(preserve_orientation=False) # needs scipy
1110+
sage: B.preserves_orientation() # needs scipy
11101111
False
11111112
"""
11121113
[a, b, c, d] = [RR.random_element() for k in range(4)]
@@ -1272,7 +1273,7 @@ def get_background_graphic(self, **bdry_options):
12721273
12731274
EXAMPLES::
12741275
1275-
sage: circ = HyperbolicPlane().PD().get_background_graphic()
1276+
sage: circ = HyperbolicPlane().PD().get_background_graphic() # needs sage.plot
12761277
"""
12771278
from sage.plot.circle import circle
12781279
return circle((0, 0), 1, axes=False, color='black')
@@ -1380,7 +1381,7 @@ def isometry_in_model(self, A):
13801381
EXAMPLES::
13811382
13821383
sage: A = matrix(3, [[1, 0, 0], [0, 17/8, 15/8], [0, 15/8, 17/8]])
1383-
sage: HyperbolicPlane().KM().isometry_in_model(A)
1384+
sage: HyperbolicPlane().KM().isometry_in_model(A) # needs scipy
13841385
True
13851386
"""
13861387
if isinstance(A, HyperbolicIsometry):
@@ -1396,7 +1397,7 @@ def get_background_graphic(self, **bdry_options):
13961397
13971398
EXAMPLES::
13981399
1399-
sage: circ = HyperbolicPlane().KM().get_background_graphic()
1400+
sage: circ = HyperbolicPlane().KM().get_background_graphic() # needs sage.plot
14001401
"""
14011402
from sage.plot.circle import circle
14021403
return circle((0, 0), 1, axes=False, color='black')
@@ -1490,7 +1491,7 @@ def isometry_in_model(self, A):
14901491
EXAMPLES::
14911492
14921493
sage: A = diagonal_matrix([1,1,-1])
1493-
sage: HyperbolicPlane().HM().isometry_in_model(A)
1494+
sage: HyperbolicPlane().HM().isometry_in_model(A) # needs scipy
14941495
True
14951496
"""
14961497
if isinstance(A, HyperbolicIsometry):
@@ -1505,7 +1506,7 @@ def get_background_graphic(self, **bdry_options):
15051506
15061507
EXAMPLES::
15071508
1508-
sage: H = HyperbolicPlane().HM().get_background_graphic()
1509+
sage: H = HyperbolicPlane().HM().get_background_graphic() # needs sage.plot
15091510
"""
15101511
from sage.plot.plot3d.all import plot3d
15111512
from sage.symbolic.ring import SR

src/sage/geometry/hyperbolic_space/hyperbolic_point.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def __rmul__(self, other):
318318
We also lift matrices into isometries::
319319
320320
sage: B = diagonal_matrix([-1, -1, 1])
321-
sage: B = HyperbolicPlane().HM().get_isometry(B)
321+
sage: B = HyperbolicPlane().HM().get_isometry(B) # needs scipy
322322
sage: B * HyperbolicPlane().HM().get_point((0, 1, sqrt(2)))
323323
Point in HM (0, -1, sqrt(2))
324324
"""
@@ -491,7 +491,7 @@ def symmetry_involution(self):
491491
sage: A.preserves_orientation()
492492
True
493493
494-
sage: A*A == HyperbolicPlane().UHP().get_isometry(identity_matrix(2))
494+
sage: A*A == HyperbolicPlane().UHP().get_isometry(identity_matrix(2)) # needs scipy
495495
True
496496
"""
497497
R = self.parent().realization_of().a_realization()
@@ -508,11 +508,11 @@ def show(self, boundary=True, **options):
508508
509509
EXAMPLES::
510510
511-
sage: HyperbolicPlane().PD().get_point(0).show()
511+
sage: HyperbolicPlane().PD().get_point(0).show() # needs sage.plot
512512
Graphics object consisting of 2 graphics primitives
513-
sage: HyperbolicPlane().KM().get_point((0,0)).show()
513+
sage: HyperbolicPlane().KM().get_point((0,0)).show() # needs sage.plot
514514
Graphics object consisting of 2 graphics primitives
515-
sage: HyperbolicPlane().HM().get_point((0,0,1)).show()
515+
sage: HyperbolicPlane().HM().get_point((0,0,1)).show() # needs sage.plot
516516
Graphics3d Object
517517
"""
518518
p = self.coordinates()
@@ -587,7 +587,7 @@ def show(self, boundary=True, **options):
587587
588588
sage: HyperbolicPlane().UHP().get_point(I).show()
589589
Graphics object consisting of 2 graphics primitives
590-
sage: HyperbolicPlane().UHP().get_point(0).show()
590+
sage: HyperbolicPlane().UHP().get_point(0).show() # needs sage.plot
591591
Graphics object consisting of 2 graphics primitives
592592
sage: HyperbolicPlane().UHP().get_point(infinity).show()
593593
Traceback (most recent call last):

src/sage/modules/free_module_integer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,10 @@ def LLL(self, *args, **kwds):
384384
basis = matrix(ZZ, len(basis), len(basis[0]), basis)
385385
basis.set_immutable()
386386

387-
if self.reduced_basis[0].norm() > basis[0].norm():
387+
b0 = basis[0]
388+
rb0 = self.reduced_basis[0]
389+
390+
if rb0.dot_product(rb0) > b0.dot_product(b0):
388391
self._reduced_basis = basis
389392
return basis
390393

0 commit comments

Comments
 (0)