Skip to content

Commit

Permalink
38254: have is_recoverable check all symmetry mutants
Browse files Browse the repository at this point in the history
  • Loading branch information
soehms committed Jun 27, 2024
1 parent 29849eb commit a936a13
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
7 changes: 3 additions & 4 deletions src/sage/knots/free_knotinfo_monoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,14 @@ def hp_mirr(hp):
res_rec = search_composition(max_cr - c, h)
if res_rec:
res += [Kgen * k for k in res_rec]
res_t = tuple(res)
if c > former_cr and res_t:
k = self._check_elements(knot, res_t)
if c > former_cr and res:
k = self._check_elements(knot, tuple(res))
if k:
# matching item found
return tuple([k])
former_cr = c

return tuple(sorted(set(res_t)))
return tuple(sorted(set(res)))

hp = knot.homfly_polynomial(normalization='vz')
return search_composition(13, hp)
Expand Down
49 changes: 25 additions & 24 deletions src/sage/knots/knotinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ def is_recoverable(self, unique=True):
sage: L5a1_0.is_recoverable(unique=False)
True
"""
def recover(mirror, braid):
def recover(sym_mut, braid):
r"""
Check if ``self`` can be recovered form its associated
Sage link.
Expand All @@ -2268,41 +2268,42 @@ def recover(mirror, braid):
l = self.link(self.items.braid_notation)
else:
l = self.link()
if mirror:
if self.is_amphicheiral():
# no need to test again
return True
if sym_mut is SymmetryMutant.mirror_image:
l = l.mirror_image()
elif sym_mut is SymmetryMutant.reverse:
l = l.reverse()

Check warning on line 2274 in src/sage/knots/knotinfo.py

View check run for this annotation

Codecov / codecov/patch

src/sage/knots/knotinfo.py#L2274

Added line #L2274 was not covered by tests
elif sym_mut is SymmetryMutant.concordance_inverse:
l = l.mirror_image().reservse()

Check warning on line 2276 in src/sage/knots/knotinfo.py

View check run for this annotation

Codecov / codecov/patch

src/sage/knots/knotinfo.py#L2276

Added line #L2276 was not covered by tests

def check_result(L, m):
def check_result(res):
r"""
Check a single result from ``get_knotinfo``.
"""
if type(res) is tuple:
L, s = res
else:
L, s = res.to_knotinfo()[0]
if not isinstance(L, KnotInfoBase):
return False
if L != self:
return False
if mirror:
return m is SymmetryMutant.mirror_image
else:
return m is SymmetryMutant.itself
return s == sym_mut

try:
ki = l.get_knotinfo()
if type(ki) is tuple:
L, m = ki
else:
L, m = l.get_knotinfo().to_knotinfo()[0]
if isinstance(L, KnotInfoBase):
return check_result(L, m)
elif unique:
return False
res = l.get_knotinfo(unique=unique)
except NotImplementedError:
if unique:
return False
Llist = l.get_knotinfo(unique=False)
return any(check_result(L, m) for (L, m) in Llist)
return False

Check warning on line 2295 in src/sage/knots/knotinfo.py

View check run for this annotation

Codecov / codecov/patch

src/sage/knots/knotinfo.py#L2295

Added line #L2295 was not covered by tests
if unique:
return check_result(res)
else:
return any(check_result(r) for r in res)

from sage.misc.misc import some_tuples
return all(recover(mirror, braid) for mirror, braid in some_tuples([True, False], 2, 4))
if SymmetryMutant.unknown.matches(self):
sym_muts = [SymmetryMutant.unknown]

Check warning on line 2303 in src/sage/knots/knotinfo.py

View check run for this annotation

Codecov / codecov/patch

src/sage/knots/knotinfo.py#L2303

Added line #L2303 was not covered by tests
else:
sym_muts = [s for s in SymmetryMutant if s.is_minimal(self)]
return all(recover(sym, braid) for sym, braid in some_tuples(sym_muts, 2, 8))

def inject(self, verbose=True):
"""
Expand Down

0 comments on commit a936a13

Please sign in to comment.