Skip to content

Commit 1a7367a

Browse files
committed
Add regression test to avoid helper init bug again
1 parent eafae82 commit 1a7367a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import unittest
2+
3+
4+
def regression_helper_init_scalar():
5+
import fidimag
6+
import numpy as np
7+
# Create simulation
8+
mesh = fidimag.common.CuboidMesh(nx=10, ny=2, nz=1,
9+
dx=1, dy=1, dz=1)
10+
sim = fidimag.atomistic.Sim(mesh)
11+
# Set the magnetisation and save it to mu_s.npy
12+
sim.mu_s = 3
13+
np.save('mu_s.npy', sim.mu_s)
14+
15+
# Create another simulation with less elements in the x direction
16+
mesh2 = fidimag.common.CuboidMesh(nx=5, ny=2, nz=1,
17+
dx=1, dy=1, dz=1)
18+
sim2 = fidimag.atomistic.Sim(mesh2)
19+
# Set the magnetisation loading the other simulation file
20+
sim2.mu_s = np.load('mu_s.npy')
21+
22+
23+
class regression_test(unittest.TestCase):
24+
25+
def test_init_scalar(self):
26+
self.assertRaises(ValueError, regression_helper_init_scalar)

0 commit comments

Comments
 (0)