Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] Added data check on axes in test_gui.py #726

Merged
merged 8 commits into from
Mar 13, 2024
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 111 additions & 2 deletions hnn_core/tests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def test_gui_upload_params():
original_tstep = gui.widget_dt.value
gui.widget_dt.value = 1
# simulate upload default.json
file1_url = "https://raw.githubusercontent.com/jonescompneurolab/hnn-core/master/hnn_core/param/default.json" # noqa
file2_url = "https://raw.githubusercontent.com/jonescompneurolab/hnn-core/master/hnn_core/param/gamma_L5weak_L2weak.json" # noqa
file1_url = "https://raw.githubusercontent.com/jonescompneurolab/hnn-core/master/hnn_core/param/default.json" # noqa
file2_url = "https://raw.githubusercontent.com/jonescompneurolab/hnn-core/master/hnn_core/param/gamma_L5weak_L2weak.json" # noqa
samadpls marked this conversation as resolved.
Show resolved Hide resolved
gui._simulate_upload_connectivity(file1_url)
gui._simulate_upload_drives(file1_url)

Expand Down Expand Up @@ -396,6 +396,7 @@ def test_gui_figure_overlay():


def test_gui_adaptive_spectrogram():
"""Test the adaptive spectrogram functionality of the HNNGUI."""
gui = HNNGUI()
gui.compose()
gui.params['N_pyr_x'] = 3
Expand All @@ -422,6 +423,114 @@ def test_gui_adaptive_spectrogram():
plt.close('all')


def test_gui_layer2_dipole():
gtdang marked this conversation as resolved.
Show resolved Hide resolved
samadpls marked this conversation as resolved.
Show resolved Hide resolved
"""Test the visualization of layer 2 dipole in the HNNGUI."""
gui = HNNGUI()
gui.compose()
gui.params['N_pyr_x'] = 3
gui.params['N_pyr_y'] = 3

gui.run_button.click()
figid = 1
figname = f'Figure {figid}'
axname = 'ax1'
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'layer2 dipole', {}, 'clear')
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'layer2 dipole', {}, 'plot')
# Check if data is plotted on the axes
assert len(gui.viz_manager.figs[figid].axes) == 2
# Check default figs have data on their axis
assert gui.viz_manager.figs[figid].axes[1].has_data()
plt.close('all')


def test_gui_layer5_dipole():
samadpls marked this conversation as resolved.
Show resolved Hide resolved
"""Test the visualization of layer 5 dipole in the HNNGUI."""
gui = HNNGUI()
gui.compose()
gui.params['N_pyr_x'] = 3
gui.params['N_pyr_y'] = 3

gui.run_button.click()
figid = 1
figname = f'Figure {figid}'
axname = 'ax1'
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'layer5 dipole', {}, 'clear')
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'layer5 dipole', {}, 'plot')
# Check if data is plotted on the axes
assert len(gui.viz_manager.figs[figid].axes) == 2
# Check default figs have data on their axis
assert gui.viz_manager.figs[figid].axes[1].has_data()
plt.close('all')


def test_gui_spikes():
"""Test the visualization of spikes in the GUI."""
gui = HNNGUI()
gui.compose()
gui.params['N_pyr_x'] = 3
gui.params['N_pyr_y'] = 3

gui.run_button.click()
figid = 1
figname = f'Figure {figid}'
axname = 'ax1'
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'spikes', {}, 'clear')
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'spikes', {}, 'plot')
# Check if data is plotted on the axes
assert len(gui.viz_manager.figs[figid].axes) == 2
# Check default figs have data on their axis
assert gui.viz_manager.figs[figid].axes[1].has_data()
plt.close('all')


def test_gui_psd():
"""Test the PSD visualization in the HNNGUI."""
gui = HNNGUI()
gui.compose()
gui.params['N_pyr_x'] = 3
gui.params['N_pyr_y'] = 3

gui.run_button.click()
figid = 1
figname = f'Figure {figid}'
axname = 'ax1'
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'PSD', {}, 'clear')
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'PSD', {}, 'plot')
# Check if data is plotted on the axes
assert len(gui.viz_manager.figs[figid].axes) == 2
# Check default figs have data on their axis
assert gui.viz_manager.figs[figid].axes[1].has_data()


def test_gui_network():
"""Test the network visualization functionality of the HNNGUI."""
gui = HNNGUI()
gui.compose()
gui.params['N_pyr_x'] = 3
gui.params['N_pyr_y'] = 3

gui.run_button.click()
figid = 1
figname = f'Figure {figid}'
axname = 'ax1'
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'network', {}, 'clear')
gui._simulate_viz_action("edit_figure", figname, axname, 'default',
'network', {}, 'plot')
# Check if data is plotted on the axes
assert len(gui.viz_manager.figs[figid].axes) == 2
# Check default figs have data on their axis
assert gui.viz_manager.figs[figid].axes[1].has_data()


def test_unlink_relink_widget():
"""Tests the unlinking and relinking of widgets decorator."""

Expand Down