|
1 | 1 | #!/usr/bin/env python |
| 2 | +"""Generate fixtures.""" |
2 | 3 |
|
| 4 | +import os |
| 5 | +import json |
| 6 | +import math as m |
3 | 7 | import numpy as np |
4 | 8 | from scipy import special |
5 | | -import math as m |
6 | | -import json |
7 | | -import os |
8 | 9 |
|
9 | | -"""gen( x, name ) |
10 | 10 |
|
11 | | -Generate fixture data and write to file. |
| 11 | +# Get the file path: |
| 12 | +FILE = os.path.realpath( __file__ ) |
| 13 | + |
| 14 | +# Extract the directory in which this file resides: |
| 15 | +DIR = os.path.dirname( file ) |
12 | 16 |
|
13 | | -# Arguments |
| 17 | +def gen( x, name ): |
| 18 | + """Generate fixture data and write to file. |
14 | 19 |
|
15 | | -* `x`: domain |
16 | | -* `name::str`: output filename |
| 20 | + # Arguments |
17 | 21 |
|
18 | | -# Examples |
| 22 | + * `x`: domain |
| 23 | + * `name::str`: output filename |
19 | 24 |
|
20 | | -``` python |
21 | | -python> x = linspace( -1000, 1000, 2001 ); |
22 | | -python> gen( x, \"./data.json\" ); |
23 | | -``` |
24 | | -""" |
25 | | -def gen( x, name ): |
| 25 | + # Examples |
| 26 | +
|
| 27 | + ``` python |
| 28 | + python> x = linspace( -1000, 1000, 2001 ) |
| 29 | + python> gen( x, \"./data.json\" ) |
| 30 | + ``` |
| 31 | + """ |
26 | 32 | # TODO: generate fixtures |
27 | 33 |
|
28 | 34 | # Store data to be written to file as a dictionary: |
29 | 35 | data = { |
30 | 36 | "x": x.tolist(), |
31 | 37 | "expected": y.tolist() |
32 | | - }; |
| 38 | + } |
33 | 39 |
|
34 | 40 | # Based on the script directory, create an output filepath: |
35 | 41 | filepath = os.path.join( dir, name ) |
36 | 42 |
|
37 | 43 | with open( filepath, 'w' ) as outfile: |
38 | 44 | json.dump( data, outfile ) |
39 | 45 |
|
40 | | -# Get the file path: |
41 | | -file = os.path.realpath( __file__ ) |
| 46 | +def main(): |
| 47 | + """Generate fixture data.""" |
| 48 | + gen( x, "TODO" ) |
42 | 49 |
|
43 | | -# Extract the directory in which this file resides: |
44 | | -dir = os.path.dirname( file ) |
45 | 50 |
|
46 | | -# Generate fixture data: |
47 | | -# TODO: generate input data (`x`) |
48 | | -gen( x, "TODO" ); |
| 51 | +if __name__=="__main__": |
| 52 | + main() |
0 commit comments