-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathways.py
More file actions
44 lines (39 loc) · 1.49 KB
/
ways.py
File metadata and controls
44 lines (39 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3
import json
from Compiler.types import cint, Matrix, MultiArray
def readWays(tau, match=False):
'''Read precomputed ways in dependency graph of box'''
jsonString = ''
filename = '../secure-edit-distance/Common-Data/waysMatch.json' if match else '../secure-edit-distance/Common-Data/ways.json'
with open(filename) as f:
jsonString = f.readline()
ways = json.loads(jsonString)
if str(tau) in ways:
return ways[str(tau)]
return []
def readWaysMultiProcMin(tau, match=False):
tt = str(tau)
jsonString = ''
filename = '../secure-edit-distance/Common-Data/waysMatch.json' if match else '../secure-edit-distance/Common-Data/ways.json'
with open(filename) as f:
jsonString = f.readline()
ways = json.loads(jsonString)
if tt in ways:
idxes = Matrix(len(ways[tt]), 2, cint)
for x in range(len(ways[tt])):
idxes[x][0] = ways[tt][x][0][0]
idxes[x][1] = ways[tt][x][0][1]
return idxes, ways[tt]
return [], []
def readWaysMultiProcAll(tau, match=False):
filename = '../secure-edit-distance/Common-Data/waysMatch.json' if match else '../secure-edit-distance/Common-Data/ways.json'
tt = str(tau)
jsonString = ''
with open(filename) as f:
jsonString = f.readline()
ways = json.loads(jsonString)
if tt in ways:
ww = MultiArray([len(ways[tt]), len(ways[tt][0]), len(ways[tt][0][0])], cint)
ww[:] = ways[tt]
return ww
return []