MCPcopy Index your code
hub / github.com/google-deepmind/alphageometry / hashed_txt

Function hashed_txt

problem.py:1071–1133  ·  view source on GitHub ↗

Return a tuple unique to name and args upto arg permutation equivariant.

(name: str, args: list[str])

Source from the content-addressed store, hash-verified

1069
1070
1071def hashed_txt(name: str, args: list[str]) -> tuple[str, ...]:
1072 """Return a tuple unique to name and args upto arg permutation equivariant."""
1073
1074 if name in ['const', 'aconst', 'rconst']:
1075 a, b, c, d, y = args
1076 a, b = sorted([a, b])
1077 c, d = sorted([c, d])
1078 return name, a, b, c, d, y
1079
1080 if name in ['npara', 'nperp', 'para', 'cong', 'perp', 'collx']:
1081 a, b, c, d = args
1082
1083 a, b = sorted([a, b])
1084 c, d = sorted([c, d])
1085 (a, b), (c, d) = sorted([(a, b), (c, d)])
1086
1087 return (name, a, b, c, d)
1088
1089 if name in ['midp', 'midpoint']:
1090 a, b, c = args
1091 b, c = sorted([b, c])
1092 return (name, a, b, c)
1093
1094 if name in ['coll', 'cyclic', 'ncoll', 'diff', 'triangle']:
1095 return (name,) + tuple(sorted(list(set(args))))
1096
1097 if name == 'circle':
1098 x, a, b, c = args
1099 return (name, x) + tuple(sorted([a, b, c]))
1100
1101 if name in ['eqangle', 'eqratio', 'eqangle6', 'eqratio6']:
1102 a, b, c, d, e, f, g, h = args
1103 a, b = sorted([a, b])
1104 c, d = sorted([c, d])
1105 e, f = sorted([e, f])
1106 g, h = sorted([g, h])
1107 if tuple(sorted([a, b, e, f])) > tuple(sorted([c, d, g, h])):
1108 a, b, e, f, c, d, g, h = c, d, g, h, a, b, e, f
1109 if (a, b, c, d) > (e, f, g, h):
1110 a, b, c, d, e, f, g, h = e, f, g, h, a, b, c, d
1111
1112 if name == 'eqangle6':
1113 name = 'eqangle'
1114 if name == 'eqratio6':
1115 name = 'eqratio'
1116 return (name,) + (a, b, c, d, e, f, g, h)
1117
1118 if name in ['contri', 'simtri', 'simtri2', 'contri2', 'contri*', 'simtri*']:
1119 a, b, c, x, y, z = args
1120 (a, x), (b, y), (c, z) = sorted([(a, x), (b, y), (c, z)], key=sorted)
1121 (a, b, c), (x, y, z) = sorted([(a, b, c), (x, y, z)], key=sorted)
1122 return (name, a, b, c, x, y, z)
1123
1124 if name in ['eqratio3']:
1125 a, b, c, d, o, o = args # pylint: disable=redeclared-assigned-name
1126 (a, c), (b, d) = sorted([(a, c), (b, d)], key=sorted)
1127 (a, b), (c, d) = sorted([(a, b), (c, d)], key=sorted)
1128 return (name, a, b, c, d, o, o)

Callers 2

hashedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected