Skip to content

Commit

Permalink
fix illegal escape sequences, update macOS_app
Browse files Browse the repository at this point in the history
  • Loading branch information
culler committed Dec 2, 2024
1 parent 25a31d0 commit 868a039
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dist/
build/
notabot.cfg
Frameworks*
old/
__pycache__/
.DS_Store
Expand Down
6 changes: 3 additions & 3 deletions dev/extended_ptolemy/extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def simplify_equation(poly):
def extended_ptolemy_equations(manifold, gen_obs_class=None,
nonzero_cond=True, return_full_var_dict = False,
notation = 'short'):
"""
r"""
We assign ptolemy coordinates ['a', 'b', 'c', 'd', 'e', 'f'] to the
*directed* edges::
Expand All @@ -165,12 +165,12 @@ def extended_ptolemy_equations(manifold, gen_obs_class=None,
1
/|\
d/ | \e
d / | \ e
/ | \
/ | \
2----|----3 with back edge from 2 to 3 labelled f.
\ | /
b\ |a /c
b \ |a / c
\ | /
\|/
0
Expand Down
20 changes: 10 additions & 10 deletions dev/extended_ptolemy/phc_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def restore_forbidden(var_str):
def ideal_to_file(ideal, filename):
outfile = open(filename, 'w')
polys = ideal.gens()
outfile.write('%d\n' % len(polys))
outfile.write(r'%d\n' % len(polys))
for p in polys:
outfile.write(' ' + remove_forbidden(repr(p)) + ';\n')
outfile.write(' ' + remove_forbidden(repr(p)) + r';\n')
outfile.close()

def parse_file(filename, prec=53):
Expand All @@ -55,23 +55,23 @@ def parse_file(filename, prec=53):
data = data.split('THE SOLUTIONS')[-1]
data = re.subn('[*]{3,}', '', data)[0]
ans = []
solutions = re.findall('(solution \d+ : \s* start residual .*?) ==', data, re.DOTALL)
solutions = re.findall(r'(solution \d+ : \s* start residual .*?) ==', data, re.DOTALL)
for sol in solutions:
kind = sol.split('=')[-1].strip()
if kind == 'no solution':
continue
mult = int(re.search('^m : (\d+)', sol, re.MULTILINE).group(1))
err = float(re.search('== err :\s+(.*?)\s+= ', sol).group(1))
coors = re.findall('^ (.*) :\s+(\S*)\s+(\S*)', sol, re.MULTILINE)
mult = int(re.search(r'^m : (\d+)', sol, re.MULTILINE).group(1))
err = float(re.search(r'== err :\s+(.*?)\s+= ', sol).group(1))
coors = re.findall(r'^ (.*) :\s+(\S*)\s+(\S*)', sol, re.MULTILINE)
if kind.startswith('real'):
coors = {restore_forbidden(var):RR(real) for var, real, imag in coors}
ans.append({'kind':'real', 'mult':mult, 'err':err, 'coors':coors})
elif kind.startswith('complex'):
coors = {restore_forbidden(var):CC(RR(real), RR(imag)) for var, real, imag in coors}
ans.append({'kind':'complex', 'mult':mult, 'err':err, 'coors':coors})

num_real = int(re.search('Number of real solutions\s+:\s(.*).', data).group(1))
num_complex = int(re.search('Number of complex solutions\s+:\s(.*).', data).group(1))
num_real = int(re.search(r'Number of real solutions\s+:\s(.*).', data).group(1))
num_complex = int(re.search(r'Number of complex solutions\s+:\s(.*).', data).group(1))
kinds = [sol['kind'] for sol in ans]
assert kinds.count('real') == num_real
assert kinds.count('complex') == num_complex
Expand Down Expand Up @@ -185,9 +185,9 @@ def direct_hack(backend, ideal, **kwargs):
polys = [repr(eqn) for eqn in ideal.gens()]

data = {'backend':backend, 'vars':vars, 'polys':polys, 'kwargs':kwargs}
problem_data = json.dumps(data).encode('base64').replace('\n', '')
problem_data = json.dumps(data).encode('base64').replace(r'\n', '')
ans_data = os.popen('sage -python ' + __file__ + ' ' + problem_data).read()
ans_data = re.sub('PHCv.*? released .*? works!\n', '', ans_data)
ans_data = re.sub(r'PHCv.*? released .*? works!\n', '', ans_data)
if len(ans_data):
ans = json.loads(ans_data)
for sol in ans:
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion macOS_app/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def run(self):
APP = ['SnapPyApp.py']
DATA_FILES = ['SnapPy.sdef']
OPTIONS = {'argv_emulation': False,
'excludes': 'scipy,numpy,wx,wxversion,wxPython,matplotlib,sphinx,idlelib,docutils,curses,cython,Cython,pandas,OpenGL',
'excludes': 'scipy,numpy,wx,wxversion,wxPython,matplotlib,sphinx,'
'idlelib,docutils,curses,cython,Cython,pandas,OpenGL,'
'setuptools,test',
'packages': packages,
'includes': 'tkinter,gzip,tarfile,readline,pydoc,fractions',
'iconfile': 'icons/SnapPy.icns',
Expand Down

0 comments on commit 868a039

Please sign in to comment.