Skip to content

Commit f3e0657

Browse files
committed
Merge pull request #35 from takluyver/travis-nbval
Run notebook tests on Travis
2 parents 789a58e + d331359 commit f3e0657

File tree

8 files changed

+17
-7
lines changed

8 files changed

+17
-7
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ sudo: false
88
before_install:
99
# We do this conditionally because it saves us some downloading if the
1010
# version is the same.
11+
- deactivate # Deactivate virtualenv
1112
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
1213
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
1314
else
@@ -19,7 +20,7 @@ before_install:
1920
install:
2021
- conda create -q -y -n fidimag-test python=$TRAVIS_PYTHON_VERSION cython matplotlib pytest scipy pytest-cov
2122
- source activate fidimag-test
22-
- pip install pyvtk six
23+
- pip install pyvtk six nbval
2324
# Download and compile FFTW & Sundials locally
2425
- bash bin/install.sh
2526

@@ -36,6 +37,7 @@ before_script:
3637
# command to run tests
3738
script:
3839
- make test-without-run-oommf
40+
- make test-ipynb
3941

4042

4143
notifications:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ test-quick:
4444

4545

4646
test-ipynb: create-dirs
47-
cd doc/ipynb && py.test . -v --ipynb --sanitize-with sanitize_file --junitxml=$(PROJECT_DIR)/test-reports/junit/test-ipynb-pytest.xml
47+
cd doc/ipynb && py.test . -v --nbval --sanitize-with sanitize_file --junitxml=$(PROJECT_DIR)/test-reports/junit/test-ipynb-pytest.xml
4848

4949
test-oommf:
5050
py.test -v -m "oommf"

doc/ipynb/1d_domain_wall.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
}
106106
],
107107
"source": [
108+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
108109
"Ms = 8.6e5 # magnetisation saturation (A/m)\n",
109110
"A = 1.3e-11 # exchange energy constant (J/m)\n",
110111
"K1 = 1.86e5 # anisotropy energy constant (J/m**3)\n",

doc/ipynb/current-driven-domain-wall.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@
320320
"x = np.arange(len(m0_z))\n",
321321
"index_max = np.argmax(np.abs(m0_z))\n",
322322
"\n",
323-
"print 'Maximum |m_z| at x =', x[index_max]"
323+
"print('Maximum |m_z| at x = %s' % x[index_max])"
324324
]
325325
},
326326
{
@@ -952,6 +952,7 @@
952952
}
953953
],
954954
"source": [
955+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
955956
"excite_system(mesh, 1.5e-9, 151);"
956957
]
957958
},

doc/ipynb/isolated_skyrmion.ipynb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,7 @@
12571257
}
12581258
],
12591259
"source": [
1260+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
12601261
"# Relax the system to its equilibrium.\n",
12611262
"sim.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=None, save_vtk_steps=None)"
12621263
]

doc/ipynb/spin-polarised-current-driven-skyrmion.ipynb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
}
106106
],
107107
"source": [
108+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
108109
"Ms = 1e6 # magnetisation saturation (A/m)\n",
109110
"A = 13e-11 # exchange stiffness (J/m)\n",
110111
"D = 5e-2 # DMI constant (J/m**2)\n",
@@ -289,6 +290,7 @@
289290
}
290291
],
291292
"source": [
293+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
292294
"sim2 = Sim(mesh, driver='llg_stt') # create simulation object\n",
293295
"\n",
294296
"# Set parameters.\n",

doc/ipynb/standard_problem_4.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
"sim.add(UniformExchange(A=A))\n",
155155
"sim.add(Demag())\n",
156156
"\n",
157-
"H0 = [Ms/sqrt(3) for _ in xrange(3)]\n",
157+
"H0 = [Ms/sqrt(3) for _ in range(3)]\n",
158158
"Ht = lambda t: 1 - t / 0.5e-9 if t < 0.5e-9 else 0\n",
159159
"sim.add(TimeZeeman(H0, Ht)) # saturating field which is reduced over 0.5 nanoseconds"
160160
]
@@ -909,7 +909,7 @@
909909
}
910910
],
911911
"source": [
912-
"%%time\n",
912+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
913913
"sim.set_m((1.0, 0.25, 0.1))\n",
914914
"sim.set_tols(rtol=1e-10, atol=1e-10)\n",
915915
"sim.relax(dt=1e-13, stopping_dmdt=0.01, max_steps=5000, save_m_steps=None, save_vtk_steps=None);\n",
@@ -998,7 +998,7 @@
998998
}
999999
],
10001000
"source": [
1001-
"%%time\n",
1001+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
10021002
"mu0 = 4 * np.pi * 1e-7 # magnetic constant (H/m)\n",
10031003
"mT = 1e-3 / mu0 # millitesla\n",
10041004
"\n",
@@ -1050,6 +1050,7 @@
10501050
}
10511051
],
10521052
"source": [
1053+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
10531054
"import matplotlib.pyplot as plt\n",
10541055
"%matplotlib inline\n",
10551056
"from fidimag.common.fileio import DataReader\n",

doc/ipynb/tutorial-basics.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,7 @@
13301330
}
13311331
],
13321332
"source": [
1333+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
13331334
"sim.relax(dt=1e-11, stopping_dmdt=0.01, max_steps=1000, save_m_steps=10, save_vtk_steps=100)"
13341335
]
13351336
},
@@ -1456,7 +1457,8 @@
14561457
}
14571458
],
14581459
"source": [
1459-
"ls"
1460+
"# PYTEST_VALIDATE_IGNORE_OUTPUT\n",
1461+
"%ls"
14601462
]
14611463
},
14621464
{

0 commit comments

Comments
 (0)