Skip to content

Commit

Permalink
Update dipole test
Browse files Browse the repository at this point in the history
  • Loading branch information
rythorpe committed May 5, 2020
1 parent 32afd31 commit f5b5c5c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions hnn_core/tests/test_dipole.py
Expand Up @@ -2,9 +2,10 @@
import os.path as op

import numpy as np
from numpy.testing import assert_array_equal

import hnn_core
from hnn_core import read_params
from hnn_core import read_params, import_dipole
from hnn_core.dipole import Dipole

matplotlib.use('agg')
Expand All @@ -14,6 +15,7 @@ def test_dipole():
"""Test dipole object."""
hnn_core_root = op.join(op.dirname(hnn_core.__file__), '..')
params_fname = op.join(hnn_core_root, 'param', 'default.json')
dpl_out_fname = '/tmp/dpl1.txt'
params = read_params(params_fname)
times = np.random.random(6000)
data = np.random.random((6000, 3))
Expand All @@ -23,5 +25,9 @@ def test_dipole():
dipole.scale(params['dipole_scalefctr'])
dipole.smooth(params['dipole_smooth_win'] / params['dt'])
dipole.plot(layer='agg')
dipole.write('/tmp/dpl1.txt')
assert op.exists('/tmp/dpl1.txt')
dipole.write(dpl_out_fname)
dipole_read = import_dipole(dpl_out_fname)
assert_array_equal(dipole_read.t, dipole.t.round(3))
for dpl_key in dipole.dpl.keys():
assert_array_equal(dipole_read.dpl[dpl_key],
dipole.dpl[dpl_key].round(4))

0 comments on commit f5b5c5c

Please sign in to comment.