Skip to content

Commit

Permalink
GitHub Actions debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
C.A.P. Linssen committed May 4, 2021
1 parent ff08892 commit eaf2454
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/nestbuildmatrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
cpp_compiler: "clang"

steps:
- uses: actions/checkout@v2

# Steps represent a sequence of tasks that will be executed as part of the job
- name: Checkout repo content
Expand Down Expand Up @@ -137,3 +138,8 @@ jobs:
python extras/parse_build_log.py gha_build.sh.log ${{ github.workspace }}
env:
xNEST_BUILD_TYPE: FULL

- name: tmate
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3

19 changes: 16 additions & 3 deletions pynest/nest/tests/test_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
except ImportError:
HAVE_PANDAS = False

import nest.voltage_trace as nvtrace
import nest.raster_plot as nraster

class VisualizationTestCase(unittest.TestCase):
def nest_tmpdir(self):
Expand Down Expand Up @@ -88,35 +90,47 @@ def voltage_trace_verify(self, device):
x_data, y_data = line.get_data()
# Check that times are correct
self.assertEqual(list(x_data), list(np.unique(device.get('events', 'times'))))
print("times:")
print(x_data)
print(list(np.unique(device.get('events', 'times'))))
# Check that voltmeter data corresponds to the lines in the plot
self.assertTrue(all(np.isclose(ref_vm, y_data)))
print("v_m:")
print(ref_vm)
print(y_data)
plt.close(ax.get_figure())

@unittest.skipIf(not PLOTTING_POSSIBLE, 'Plotting impossible because matplotlib or display missing')
def test_voltage_trace_from_device(self):
"""Test voltage_trace from device"""
import nest.voltage_trace as nvtrace
nest.ResetKernel()
nodes = nest.Create('iaf_psc_alpha', 2)
pg = nest.Create('poisson_generator', 1, {'rate': 1000.})
device = nest.Create('voltmeter')
nest.Connect(pg, nodes)
nest.Connect(device, nodes)
wfwf = nest.Create('spike_recorder')
nest.Connect(pg, wfwf)
nest.Simulate(100)

# Test with data from device
print("From device:--------------------------------------")
print("Recording times: " + str(device.get('events')['times']))
nest.voltage_trace.from_device(device)
self.voltage_trace_verify(device)

# Test with fata from file
# Test with data from file
vm = device.get('events')
data = np.zeros([len(vm['senders']), 3])
data[:, 0] = vm['senders']
data[:, 1] = vm['times']
data[:, 2] = vm['V_m']
filename = os.path.join(self.nest_tmpdir(), 'voltage_trace.txt')
self.filenames.append(filename)
print("FILENAME::::::::::::::::: " + str(filename))
np.savetxt(filename, data)

print("From file:--------------------------------------")
nest.voltage_trace.from_file(filename)
self.voltage_trace_verify(device)

Expand Down Expand Up @@ -150,7 +164,6 @@ def spike_recorder_raster_verify(self, sr_ref):
@unittest.skipIf(not PLOTTING_POSSIBLE, 'Plotting impossible because matplotlib or display missing')
def test_raster_plot(self):
"""Test raster_plot"""
import nest.raster_plot as nraster

sr, sr_to_file = self.spike_recorder_data_setup(to_file=True)
spikes = sr.get('events')
Expand Down
6 changes: 6 additions & 0 deletions pynest/nest/voltage_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ def from_device(detec, neurons=None, title=None, grayscale=False,

plotids = []
for neuron in neurons:
print("times[neuron] = " + str(times[neuron]))
print("timefactor = " + str(timefactor))
time_values = numpy.array(times[neuron]) / timefactor
print("time_values = " + str(time_values))

if grayscale:
line_style = "k"
Expand All @@ -197,6 +200,9 @@ def from_device(detec, neurons=None, title=None, grayscale=False,
plt.plot(time_values, voltages[neuron],
line_style, label="Neuron %i" % neuron)
)
ax = plt.gca()
for line_idx, line in enumerate(ax.lines):
print("line " + str(line_idx) + " xdata = " + str(line.get_data()[0]))
except KeyError:
print("INFO: Wrong ID: {0}".format(neuron))

Expand Down

0 comments on commit eaf2454

Please sign in to comment.