Skip to content

Commit bee7382

Browse files
authored
Merge pull request #420 from chaoming0625/master
Remove windows CI because it always generates strange errors
2 parents 37e6a4b + 04858cb commit bee7382

File tree

15 files changed

+140
-110
lines changed

15 files changed

+140
-110
lines changed

.github/workflows/CI.yml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -151,40 +151,40 @@ jobs:
151151
#
152152

153153

154-
test_windows:
155-
runs-on: windows-latest
156-
strategy:
157-
fail-fast: false
158-
matrix:
159-
python-version: ["3.8", "3.9", "3.10", "3.11"]
160-
161-
steps:
162-
- uses: actions/checkout@v2
163-
- name: Set up Python ${{ matrix.python-version }}
164-
uses: actions/setup-python@v2
165-
with:
166-
python-version: ${{ matrix.python-version }}
167-
- name: Install dependencies
168-
run: |
169-
python -m pip install --upgrade pip
170-
python -m pip install flake8 pytest
171-
python -m pip install numpy>=1.21.0
172-
python -m pip install "jaxlib==0.4.11" -f https://whls.blob.core.windows.net/unstable/index.html --use-deprecated legacy-resolver
173-
python -m pip install jax==0.4.11
174-
python -m pip install -r requirements-dev.txt
175-
python -m pip install tqdm brainpylib
176-
pip uninstall brainpy -y
177-
python setup.py install
178-
- name: Lint with flake8
179-
run: |
180-
# stop the build if there are Python syntax errors or undefined names
181-
flake8 brainpy/ --count --select=E9,F63,F7,F82 --show-source --statistics
182-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
183-
flake8 brainpy/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
184-
- name: Test with pytest
185-
run: |
186-
cd brainpy
187-
pytest _src/
154+
# test_windows:
155+
# runs-on: windows-latest
156+
# strategy:
157+
# fail-fast: false
158+
# matrix:
159+
# python-version: ["3.8", "3.9", "3.10", "3.11"]
160+
#
161+
# steps:
162+
# - uses: actions/checkout@v2
163+
# - name: Set up Python ${{ matrix.python-version }}
164+
# uses: actions/setup-python@v2
165+
# with:
166+
# python-version: ${{ matrix.python-version }}
167+
# - name: Install dependencies
168+
# run: |
169+
# python -m pip install --upgrade pip
170+
# python -m pip install flake8 pytest
171+
# python -m pip install numpy>=1.21.0
172+
# python -m pip install "jaxlib==0.4.11" -f https://whls.blob.core.windows.net/unstable/index.html --use-deprecated legacy-resolver
173+
# python -m pip install jax==0.4.11
174+
# python -m pip install -r requirements-dev.txt
175+
# python -m pip install tqdm brainpylib
176+
# pip uninstall brainpy -y
177+
# python setup.py install
178+
# - name: Lint with flake8
179+
# run: |
180+
# # stop the build if there are Python syntax errors or undefined names
181+
# flake8 brainpy/ --count --select=E9,F63,F7,F82 --show-source --statistics
182+
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
183+
# flake8 brainpy/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
184+
# - name: Test with pytest
185+
# run: |
186+
# cd brainpy
187+
# pytest _src/
188188

189189

190190
# test_windows_py37:

brainpy/_src/integrators/fde/tests/test_Caputo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
class TestCaputoL1(unittest.TestCase):
1212
def test1(self):
13+
bp.math.random.seed()
1314
bp.math.enable_x64()
1415
alpha = 0.9
1516
intg = bp.fde.CaputoL1Schema(lambda a, t: a,
@@ -32,4 +33,5 @@ def test1(self):
3233
print(memory_trace[0], )
3334
print(memory_trace2[0], bp.math.array_equal(memory_trace[0], memory_trace2[0]))
3435

36+
bp.math.clear_buffer_memory()
3537
bp.math.disable_x64()

brainpy/_src/integrators/fde/tests/test_GL.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def lorenz(x, y, z, t):
2020
dz = x * y - c * z
2121
return dx, dy, dz
2222

23+
bp.math.random.seed()
2324
integral = bp.fde.GLShortMemory(lorenz,
2425
alpha=0.99,
2526
num_memory=500,
@@ -32,5 +33,6 @@ def lorenz(x, y, z, t):
3233

3334
plt.plot(runner.mon.x.flatten(), runner.mon.z.flatten())
3435
plt.show(block=block)
36+
bp.math.clear_buffer_memory()
3537

3638

brainpy/_src/integrators/ode/tests/test_delay_ode.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def __init__(self, *args, **kwargs):
6262
for name in get_supported_methods()
6363
)
6464
def test1(self, method):
65+
bm.random.seed()
6566
case1_delay = bm.TimeDelay(bm.zeros((1,)), 1., before_t0=-1., interp_method='round')
6667
case2_delay = bm.TimeDelay(bm.zeros((1,)), 1., before_t0=-1., interp_method='linear_interp')
6768

@@ -87,6 +88,8 @@ def test1(self, method):
8788
# plt.show(block=block)
8889
# plt.close()
8990

91+
bm.clear_buffer_memory()
92+
9093

9194
class TestNonConstantHist(parameterized.TestCase):
9295
def get_eq(self, xdelay):
@@ -102,6 +105,8 @@ def __init__(self, *args, **kwargs):
102105
for name in get_supported_methods()
103106
)
104107
def test1(self, method):
108+
bm.random.seed()
109+
105110
delay1 = bm.TimeDelay(bm.zeros(1), 2., before_t0=lambda t: jnp.exp(-t) - 1, dt=0.01, interp_method='round')
106111
delay2 = bm.TimeDelay(bm.zeros(1), 2., before_t0=lambda t: jnp.exp(-t) - 1, dt=0.01)
107112
case1 = delay_odeint(4., self.get_eq(delay1), state_delays={'x': delay1}, dt=0.01, method=method)
@@ -114,3 +119,4 @@ def test1(self, method):
114119

115120
# self.assertTrue((case1['x'] - self.ref1['x']).mean() < 1e-1)
116121
# self.assertTrue((case2['x'] - self.ref2['x']).mean() < 1e-1)
122+
bm.clear_buffer_memory()

brainpy/_src/integrators/ode/tests/test_ode_method_adaptive_rk.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ def test_all_methods(self):
6666
adaptive_rk.CashKarp,
6767
adaptive_rk.BogackiShampine,
6868
adaptive_rk.HeunEuler]:
69+
bm.random.seed()
6970
run_integrator(method, show=False)
71+
bm.clear_buffer_memory()

brainpy/_src/integrators/ode/tests/test_ode_method_exp_euler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def update(self, tdi):
103103
self.n.value = n
104104
self.input[:] = 0.
105105

106+
bm.random.seed()
106107
hh1 = HH(1, method='exp_euler')
107108
runner1 = bp.DSRunner(hh1, inputs=('input', 2.), monitors=['V', 'h', 'n'])
108109
runner1.run(100)
@@ -125,4 +126,5 @@ def update(self, tdi):
125126
self.assertTrue(diff < 1e0)
126127

127128
plt.close()
129+
bm.clear_buffer_memory()
128130

brainpy/_src/integrators/ode/tests/test_ode_method_rk.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ def test_all_methods(self):
7474
explicit_rk.RK4,
7575
explicit_rk.Ralston4,
7676
explicit_rk.RK4Rule38]:
77+
bm.random.seed()
7778
mon_x, mon_y, mon_z = run_integrator(method)
7879
assert np.linalg.norm(mon_x - _baseline_x) / (duration / dt) < 0.1
7980
assert np.linalg.norm(mon_y - _baseline_y) / (duration / dt) < 0.1
8081
assert np.linalg.norm(mon_z - _baseline_z) / (duration / dt) < 0.1
82+
bm.clear_buffer_memory()

brainpy/_src/integrators/sde/tests/test_normal.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import unittest
55

66
import brainpy as bp
7+
import brainpy.math as bm
78
import matplotlib.pyplot as plt
89
from brainpy._src.integrators.sde.normal import ExponentialEuler
910

@@ -21,21 +22,24 @@ def lorenz_g(x, y, z, t, **kwargs):
2122
dy = lambda y, t, x, z, rho=28: x * (rho - z) - y
2223
dz = lambda z, t, x, y, beta=8 / 3: x * y - beta * z
2324

25+
bm.random.seed()
2426
intg = ExponentialEuler(f=bp.JointEq([dx, dy, dz]),
2527
g=lorenz_g,
2628
intg_type=bp.integrators.ITO_SDE,
2729
wiener_type=bp.integrators.SCALAR_WIENER,
2830
var_type=bp.integrators.POP_VAR,
2931
show_code=True)
30-
runner = bp.integrators.IntegratorRunner(intg,
31-
monitors=['x', 'y', 'z'],
32-
dt=0.001, inits=[1., 1., 0.])
32+
runner = bp.IntegratorRunner(intg,
33+
monitors=['x', 'y', 'z'],
34+
dt=0.001, inits=[1., 1., 0.])
3335
runner.run(100.)
3436

3537
plt.plot(runner.mon.x.flatten(), runner.mon.y.flatten())
3638
if show:
3739
plt.show()
3840
plt.close()
41+
bm.clear_buffer_memory()
42+
3943

4044
def test2(self):
4145
p = 0.1
@@ -50,6 +54,7 @@ def lorenz_g(x, y, z, t, **kwargs):
5054
dy = lambda y, t, x, z, rho=28: x * (rho - z) - y
5155
dz = lambda z, t, x, y, beta=8 / 3: x * y - beta * z
5256

57+
bm.random.seed()
5358
intg = ExponentialEuler(f=bp.JointEq([dx, dy, dz]),
5459
g=lorenz_g,
5560
intg_type=bp.integrators.ITO_SDE,
@@ -60,6 +65,7 @@ def lorenz_g(x, y, z, t, **kwargs):
6065
dt=0.001, inits=[1., 1., 0.], jit=False)
6166
with self.assertRaises(ValueError):
6267
runner.run(100.)
68+
bm.clear_buffer_memory()
6369

6470
def test3(self):
6571
p = 0.1
@@ -70,6 +76,7 @@ def lorenz_g(x, y, z, t, **kwargs):
7076
bp.math.asarray([p * y, p2 * y]).T, \
7177
bp.math.asarray([p * z, p2 * z]).T
7278

79+
bm.random.seed()
7380
dx = lambda x, t, y, sigma=10: sigma * (y - x)
7481
dy = lambda y, t, x, z, rho=28: x * (rho - z) - y
7582
dz = lambda z, t, x, y, beta=8 / 3: x * y - beta * z
@@ -91,6 +98,7 @@ def lorenz_g(x, y, z, t, **kwargs):
9198
if show:
9299
plt.show()
93100
plt.close()
101+
bm.clear_buffer_memory()
94102

95103

96104
class TestMilstein(unittest.TestCase):
@@ -108,6 +116,7 @@ def test1(self):
108116
fy = lambda y, t, x, z: x * (rho - z) - y
109117
fz = lambda z, t, x, y: x * y - beta * z
110118

119+
bm.random.seed()
111120
intg = bp.sdeint(f=bp.JointEq(fx, fy, fz),
112121
g=bp.JointEq(gx, gy, gz),
113122
intg_type=bp.integrators.ITO_SDE,
@@ -124,4 +133,4 @@ def test1(self):
124133
if show:
125134
plt.show()
126135
plt.close()
127-
136+
bm.clear_buffer_memory()

brainpy/_src/integrators/sde/tests/test_sde_scalar.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
import unittest
44

5+
import matplotlib.pyplot as plt
56
import numpy as np
67
import pytest
78

89
import brainpy as bp
910
from brainpy.integrators import sde
10-
import matplotlib.pyplot as plt
11-
1211

1312
block = False
1413
sigma = 10
@@ -29,6 +28,7 @@ def lorenz_g(x, y, z, t):
2928

3029

3130
def lorenz_system(method, **kwargs):
31+
bp.math.random.seed()
3232
integral = bp.math.jit(method(f=lorenz_f,
3333
g=lorenz_g,
3434
show_code=True,
@@ -57,6 +57,7 @@ def lorenz_system(method, **kwargs):
5757
ax.set_xlabel('z')
5858
plt.show(block=block)
5959
plt.close(fig)
60+
bp.math.clear_buffer_memory()
6061

6162

6263
class TestScalarWienerIntegral(unittest.TestCase):

brainpy/_src/integrators/tests/test_integ_runner.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
class TestIntegratorRunnerForODEs(TestCase):
1212
def test_ode(self):
13+
1314
sigma = 10
1415
beta = 8 / 3
1516
rho = 28
@@ -21,16 +22,16 @@ def lorenz(x, y, z, t):
2122
dz = x * y - beta * z
2223
return dx, dy, dz
2324

24-
runner = bp.integrators.IntegratorRunner(lorenz, monitors=['x', 'y', 'z'], inits=[1., 1., 1.])
25+
runner = bp.IntegratorRunner(lorenz, monitors=['x', 'y', 'z'], inits=[1., 1., 1.])
2526
runner.run(100.)
2627
fig = plt.figure()
2728
fig.add_subplot(111, projection='3d')
2829
plt.plot(runner.mon.x[:, 0], runner.mon.y[:, 0], runner.mon.z[:, 0], )
2930
plt.show()
3031

31-
runner = bp.integrators.IntegratorRunner(lorenz,
32-
monitors=['x', 'y', 'z'],
33-
inits=[1., (1., 0.), (1., 0.)])
32+
runner = bp.IntegratorRunner(lorenz,
33+
monitors=['x', 'y', 'z'],
34+
inits=[1., (1., 0.), (1., 0.)])
3435
runner.run(100.)
3536
for i in range(2):
3637
fig = plt.figure()
@@ -47,7 +48,7 @@ def test_ode2(self):
4748
dw = lambda w, t, V: (V + a - b * w) / tau
4849
fhn = bp.odeint(bp.JointEq([dV, dw]), method='rk4', dt=0.1)
4950

50-
runner = bp.integrators.IntegratorRunner(fhn, monitors=['V', 'w'], inits=[1., 1.])
51+
runner = bp.IntegratorRunner(fhn, monitors=['V', 'w'], inits=[1., 1.])
5152
runner.run(100., args=dict(Iext=1.5))
5253
bp.visualize.line_plot(runner.mon.ts, runner.mon['V'], legend='V')
5354
bp.visualize.line_plot(runner.mon.ts, runner.mon['w'], legend='w', show=True)
@@ -61,9 +62,9 @@ def test_ode3(self):
6162
fhn = bp.odeint(bp.JointEq([dV, dw]), method='rk4', dt=0.1)
6263

6364
Iext, duration = bp.inputs.section_input([0., 1., 0.5], [200, 500, 200], return_length=True)
64-
runner = bp.integrators.IntegratorRunner(fhn,
65-
monitors=['V', 'w'],
66-
inits=[1., 1.])
65+
runner = bp.IntegratorRunner(fhn,
66+
monitors=['V', 'w'],
67+
inits=[1., 1.])
6768
runner.run(duration, dyn_args=dict(Iext=Iext))
6869
bp.visualize.line_plot(runner.mon.ts, runner.mon['V'], legend='V')
6970
bp.visualize.line_plot(runner.mon.ts, runner.mon['w'], legend='w', show=True)
@@ -76,9 +77,9 @@ def test_ode_continuous_run(self):
7677
dw = lambda w, t, V: (V + a - b * w) / tau
7778
fhn = bp.odeint(bp.JointEq([dV, dw]), method='rk4', dt=0.1)
7879

79-
runner = bp.integrators.IntegratorRunner(fhn,
80-
monitors=['V', 'w'],
81-
inits=[1., 1.])
80+
runner = bp.IntegratorRunner(fhn,
81+
monitors=['V', 'w'],
82+
inits=[1., 1.])
8283
Iext, duration = bp.inputs.section_input([0., 1., 0.5], [200, 200, 200], return_length=True)
8384
runner.run(duration, dyn_args=dict(Iext=Iext))
8485
bp.visualize.line_plot(runner.mon.ts, runner.mon['V'], legend='V')
@@ -100,9 +101,9 @@ def test_ode_dyn_args(self):
100101
Iext, duration = bp.inputs.section_input([0., 1., 0.5],
101102
[200, 500, 199],
102103
return_length=True)
103-
runner = bp.integrators.IntegratorRunner(fhn,
104-
monitors=['V', 'w'],
105-
inits=[1., 1.])
104+
runner = bp.IntegratorRunner(fhn,
105+
monitors=['V', 'w'],
106+
inits=[1., 1.])
106107
with self.assertRaises(ValueError):
107108
runner.run(duration + 1, dyn_args=dict(Iext=Iext))
108109

0 commit comments

Comments
 (0)