Skip to content

Commit

Permalink
Manifold.isometry_signature: making it return with an exception rathe…
Browse files Browse the repository at this point in the history
…r than silently with None.
  • Loading branch information
unhyperbolic committed Jul 23, 2024
1 parent 323ff7c commit 522adc7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
10 changes: 10 additions & 0 deletions doc_src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ News
- :meth:`isometry_signature <snappy.Manifold.isometry_signature>` now also
works for closed manifolds.

- It is now safe to call::

>>> M.isometry_signature(verified=True) == N.isometry_signature(verified=True)

to determine whether M and N are isometric hyperbolic manifolds since
:meth:`isometry_signature <snappy.Manifold.isometry_signature>` no longer
fails silently returning ``None`` but raises an exception if the signature
could not be computed.

- :meth:`inside_view <snappy.Manifold.inside_view>` shows the user as a paper
plane or eye ball. Also adding button to geodesics window to put camera
onto a geodesic.
Expand Down
45 changes: 28 additions & 17 deletions python/isometry_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def isometry_signature(
manifold, of_link=False, verified=False,
interval_bits_precs=verify.default_interval_bits_precs,
exact_bits_prec_and_degrees=verify.default_exact_bits_prec_and_degrees,
verbose=False):
verbose=False) -> str:
"""
The isomorphism signature of the canonical retriangulation. This is a
complete invariant of the isometry type of a hyperbolic 3-manifold and
Expand Down Expand Up @@ -69,8 +69,6 @@ def isometry_signature(
exact_bits_prec_and_degrees=exact_bits_prec_and_degrees,
verbose=verbose)

raise ValueError('isometry_signature needs all cusps to be complete')

def isometry_signature_cusped(
manifold, *,
of_link,
Expand All @@ -88,7 +86,7 @@ def isometry_signature_cusped(
verbose=verbose)

if not retrig:
return None
raise RuntimeError("Could not compute canonical retriangulation.")

return retrig.triangulation_isosig(decorated=of_link,
ignore_cusp_ordering=True,
Expand All @@ -109,8 +107,6 @@ def isometry_signature_closed(
bits_precs=interval_bits_precs,
verified=verified,
verbose=verbose)
if shortest_geodesics is None:
return None

if verbose:
print("Step 2: Drill each geodesic for potential isometry signatures")
Expand All @@ -127,9 +123,6 @@ def isometry_signature_closed(
verified=verified,
verbose=verbose)

if drilled_manifold is None:
return None

if not all(drilled_manifold.cusp_info('complete?')):
drilled_manifold = drilled_manifold.filled_triangulation()

Expand All @@ -143,7 +136,9 @@ def isometry_signature_closed(
verbose=verbose)

if retrig is None:
return None
raise RuntimeError(
"Could not compute canonical retriangulation of "
"drilled manifold. Geodesic was: %s." % shortest_geodesic)

isosig = retrig.triangulation_isosig(decorated=False)

Expand All @@ -159,6 +154,9 @@ def isometry_signature_closed(

def find_shortest_geodesics_precisions(
manifold, *, bits_precs, verified, verbose):

err = ValueError("bits_precs was empty.")

for bits_prec in bits_precs:
if verbose:
print("Using precision %d to find shortest geodesics" % bits_prec)
Expand All @@ -168,9 +166,13 @@ def find_shortest_geodesics_precisions(
bits_prec=bits_prec,
verified=verified,
verbose=verbose)
except (InsufficientPrecisionError, ValueError):
pass
return None
except (InsufficientPrecisionError,
ValueError,
RuntimeError # from Manifold.tetrahedra_shapes
) as e:
err = e

raise err

def find_shortest_geodesics(manifold, *, bits_prec, verified, verbose):
length_spectrum = manifold.length_spectrum_iter(
Expand Down Expand Up @@ -227,7 +229,7 @@ def compute_cutoff(systole):
if is_RealIntervalFieldElement(l):
is_int, f_int = f.is_int()
if not is_int:
raise Exception("Not an integer")
raise Exception("Not an integer.")
else:
f_int = f

Expand All @@ -236,17 +238,26 @@ def compute_cutoff(systole):
def drill_manifold_precisions(
manifold, word, *,
bits_precs, verified, verbose):

err = ValueError("bits_precs was empty.")

for bits_prec in bits_precs:
try:
if verbose:
print("Drilling with precision %d" % bits_prec)

return manifold.drill_word(
word,
bits_prec=bits_prec,
verified=verified,
verbose=verbose)
except (InsufficientPrecisionError, ValueError, WordAppearsToBeParabolic):
pass
except (InsufficientPrecisionError,
ValueError,
RuntimeError, # from Manifold.tetrahedra_shapes
WordAppearsToBeParabolic) as e:
err = e

return None
raise err

def compute_meridian_slopes(isosig, tri):
isosig_tri = Triangulation(isosig, remove_finite_vertices=False)
Expand Down
5 changes: 4 additions & 1 deletion python/verify/canonical.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,10 @@ def _verified_canonical_retriangulation(
try:
return interval_checked_canonical_triangulation(
Mcopy, interval_bits_prec)
except (RuntimeError, exceptions.NumericalVerifyError) as e:
except (RuntimeError,
ValueError, # Manifold.tetrahedra_shapes,
# KrawczykShapesEngine.log_gluing_LHSs
exceptions.NumericalVerifyError) as e:
if verbose:
_print_exception(e)
if isinstance(e, exceptions.NumericalVerifyError):
Expand Down

0 comments on commit 522adc7

Please sign in to comment.