Skip to content

Commit 5e737ff

Browse files
committed
Update Python snippet
1 parent 945f3d2 commit 5e737ff

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed
Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
11
#!/usr/bin/env python
2+
"""Generate fixtures."""
23

4+
import os
5+
import json
6+
import math as m
37
import numpy as np
48
from scipy import special
5-
import math as m
6-
import json
7-
import os
89

9-
"""gen( x, name )
1010

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 )
1216

13-
# Arguments
17+
def gen( x, name ):
18+
"""Generate fixture data and write to file.
1419
15-
* `x`: domain
16-
* `name::str`: output filename
20+
# Arguments
1721
18-
# Examples
22+
* `x`: domain
23+
* `name::str`: output filename
1924
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+
"""
2632
# TODO: generate fixtures
2733

2834
# Store data to be written to file as a dictionary:
2935
data = {
3036
"x": x.tolist(),
3137
"expected": y.tolist()
32-
};
38+
}
3339

3440
# Based on the script directory, create an output filepath:
3541
filepath = os.path.join( dir, name )
3642

3743
with open( filepath, 'w' ) as outfile:
3844
json.dump( data, outfile )
3945

40-
# Get the file path:
41-
file = os.path.realpath( __file__ )
46+
def main():
47+
"""Generate fixture data."""
48+
gen( x, "TODO" )
4249

43-
# Extract the directory in which this file resides:
44-
dir = os.path.dirname( file )
4550

46-
# Generate fixture data:
47-
# TODO: generate input data (`x`)
48-
gen( x, "TODO" );
51+
if __name__=="__main__":
52+
main()

0 commit comments

Comments
 (0)