MCPcopy Create free account
hub / github.com/google-deepmind/alphageometry / try_to_map

Function try_to_map

dd.py:827–852  ·  view source on GitHub ↗

Recursively try to match the remaining points given current mapping.

(
    clause_enum: list[tuple[pr.Clause, list[tuple[gm.Point, ...]]]],
    mapping: dict[str, gm.Point],
)

Source from the content-addressed store, hash-verified

825
826
827def try_to_map(
828 clause_enum: list[tuple[pr.Clause, list[tuple[gm.Point, ...]]]],
829 mapping: dict[str, gm.Point],
830) -> Generator[dict[str, gm.Point], None, None]:
831 """Recursively try to match the remaining points given current mapping."""
832 if not clause_enum:
833 yield mapping
834 return
835
836 clause, enum = clause_enum[0]
837 for points in enum:
838 mpcpy = dict(mapping)
839
840 fail = False
841 for p, a in zip(points, clause.args):
842 if a in mpcpy and mpcpy[a] != p or p in mpcpy and mpcpy[p] != a:
843 fail = True
844 break
845 mpcpy[a] = p
846 mpcpy[p] = a
847
848 if fail:
849 continue
850
851 for m in try_to_map(clause_enum[1:], mpcpy):
852 yield m
853
854
855def match_generic(

Callers 1

match_genericFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected