-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserializeanswers.py
More file actions
executable file
·32 lines (28 loc) · 1.3 KB
/
serializeanswers.py
File metadata and controls
executable file
·32 lines (28 loc) · 1.3 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
#!/usr/bin/env python3
"""
The purpose of this script is to generate answers for unit tests. I can
type in the answer I expect and it puts it in json form so I can
compare it to the dftintegrate's outputed json.
"""
import json
from dftintegrate import customserializer as cs
def serialize(dict_, filename):
with open(filename, 'w', encoding='utf-8') as out:
json.dump(dict_, out, indent=2, default=cs.tojson)
if __name__ == '__main__':
dict_ = {
"coefficients": {"1": [2.5+0j,
-0.16666666666666666+0.16666666666666669j,
-0.16666666666666666+4.1633363423443364e-17j,
-0.49999999999999978-0.49999999999999978j]},
"reciprocals": {"(0, 0, 0)": [[0, 0, 0]],
"(0, 0, 1)": [[0, 0, 1], [1, 0, 0], [0, 1, 0]],
"(0, 1, 1)": [[0, 1, 1], [1, 0, 1], [1, 1, 0]],
"(1, 1, 1)": [[1, 1, 1]]},
"series": [[(1+0j), (3+0j), (3+0j), (1+0j)],
[(1+0j), (0+3j), (-3+0j), (0-1j)],
[(1+0j), (-3+0j), (3+0j), (-1+0j)],
[(1+0j), (0-3j), (-3+0j), (0+1j)]]
}
filename = "/Users/matt/codes/projects/dftintegrate/tests/fourier/makefitjson/answer/test1/fit.json"
serialize(dict_, filename)