support for installing liba.pyi during pip install
[liba.git] / python / test / mf.py
blobec7248c2d435438ef5f2b5b95c655e6f8464a375
1 #!/usr/bin/env python
2 import os, sys
4 base = os.path.dirname(__file__)
5 path = os.path.dirname(base)
6 sys.path.insert(0, path)
7 if len(sys.argv) > 1:
8 sys.stdout = open(sys.argv[1], "w")
10 import liba # type: ignore
12 N = 1000
13 T = 6 / N
14 x = [0.0] * N
15 for i in range(N):
16 x[i] = (i - N / 2) * T
18 liba.mf.gauss(x, 1, 0)
19 liba.mf.gauss2(x, 1, -1, 1, +1)
20 liba.mf.gbell(x, 2, 4, 0)
21 liba.mf.sig(x, 2, 0)
22 liba.mf.dsig(x, 5, -2, +5, 2)
23 liba.mf.psig(x, 5, -2, -5, 2)
24 liba.mf.tri(x, 0, 1, 2)
25 liba.mf.trap(x, 0, 1, 2, 3)
26 liba.mf.lins(x, 1, 2)
27 liba.mf.linz(x, 1, 2)
28 liba.mf.s(x, 1, 2)
29 liba.mf.z(x, 1, 2)
30 liba.mf.pi(x, 0, 1, 2, 3)
32 S = 1
33 params = [
34 (liba.mf.TRI, -3 * S, -3 * S, -2 * S),
35 (liba.mf.TRI, -3 * S, -2 * S, -1 * S),
36 (liba.mf.TRI, -2 * S, -1 * S, +0 * S),
37 (liba.mf.TRI, -1 * S, +0 * S, +1 * S),
38 (liba.mf.TRI, +0 * S, +1 * S, +2 * S),
39 (liba.mf.TRI, +1 * S, +2 * S, +3 * S),
40 (liba.mf.TRI, +2 * S, +3 * S, +3 * S),
42 for param in params:
43 liba.mf()(param[0], x, param[1:])