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

Function pretty

pretty.py:150–216  ·  view source on GitHub ↗

Pretty formating a predicate string.

(txt: str)

Source from the content-addressed store, hash-verified

148
149
150def pretty(txt: str) -> str:
151 """Pretty formating a predicate string."""
152 if isinstance(txt, str):
153 txt = txt.split(' ')
154 name, *args = txt
155 if name == 'ind':
156 return 'Y ' + ' '.join(args)
157 if name in ['fixc', 'fixl', 'fixb', 'fixt', 'fixp']:
158 return map_symbol_inv(name) + ' ' + ' '.join(args)
159 if name == 'acompute':
160 a, b, c, d = args
161 return 'A ' + ' '.join(args)
162 if name == 'rcompute':
163 a, b, c, d = args
164 return 'R ' + ' '.join(args)
165 if name == 'aconst':
166 a, b, c, d, y = args
167 return f'^ {pretty2a(a, b, c, d)} {y}'
168 if name == 'rconst':
169 a, b, c, d, y = args
170 return f'/ {pretty2r(a, b, c, d)} {y}'
171 if name == 'coll':
172 return 'C ' + ' '.join(args)
173 if name == 'collx':
174 return 'X ' + ' '.join(args)
175 if name == 'cyclic':
176 return 'O ' + ' '.join(args)
177 if name in ['midp', 'midpoint']:
178 x, a, b = args
179 return f'M {x} {a} {b}'
180 if name == 'eqangle':
181 a, b, c, d, e, f, g, h = args
182 return f'^ {pretty2a(a, b, c, d)} {pretty2a(e, f, g, h)}'
183 if name == 'eqratio':
184 a, b, c, d, e, f, g, h = args
185 return f'/ {pretty2r(a, b, c, d)} {pretty2r(e, f, g, h)}'
186 if name == 'eqratio3':
187 a, b, c, d, o, o = args # pylint: disable=redeclared-assigned-name
188 return f'S {o} {a} {b} {o} {c} {d}'
189 if name == 'cong':
190 a, b, c, d = args
191 return f'D {a} {b} {c} {d}'
192 if name == 'perp':
193 if len(args) == 2: # this is algebraic derivation.
194 ab, cd = args # ab = 'd( ... )'
195 return f'T {ab} {cd}'
196 a, b, c, d = args
197 return f'T {a} {b} {c} {d}'
198 if name == 'para':
199 if len(args) == 2: # this is algebraic derivation.
200 ab, cd = args # ab = 'd( ... )'
201 return f'P {ab} {cd}'
202 a, b, c, d = args
203 return f'P {a} {b} {c} {d}'
204 if name in ['simtri2', 'simtri', 'simtri*']:
205 a, b, c, x, y, z = args
206 return f'S {a} {b} {c} {x} {y} {z}'
207 if name in ['contri2', 'contri', 'contri*']:

Callers

nothing calls this directly

Calls 3

map_symbol_invFunction · 0.85
pretty2aFunction · 0.85
pretty2rFunction · 0.85

Tested by

no test coverage detected