From d2e6deef994aac6a117e653a8a6fb6a2cfdf5659 Mon Sep 17 00:00:00 2001 From: George Dang <53052793+gtdang@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:23:51 -0400 Subject: [PATCH] refactor: updated check_equal_networks method to avoid listing methods to ignore Previously any new method added to the Network object had to be added to a hardcoded list to ignore making a comparison. Using var() instead of dir() to get at only the attributes avoids this by only accessing the attributes and not all attributes and methods. --- hnn_core/tests/test_gui.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/hnn_core/tests/test_gui.py b/hnn_core/tests/test_gui.py index d6f07e808..257caf70c 100644 --- a/hnn_core/tests/test_gui.py +++ b/hnn_core/tests/test_gui.py @@ -94,19 +94,11 @@ def check_drive(drive1, drive2, keys): message=f'{bias_name}>{cell_type}>') # Check all other attributes - all_attrs = dir(net1) - attrs_to_ignore = [x for x in all_attrs if x.startswith('_')] - attrs_to_ignore.extend(['add_bursty_drive', 'add_connection', - 'add_electrode_array', 'add_evoked_drive', - 'add_poisson_drive', 'add_tonic_bias', - 'clear_connectivity', 'clear_drives', - 'connectivity', 'copy', 'gid_to_type', - 'plot_cells', 'set_cell_positions', - 'to_dict', 'write_configuration', - 'external_drives', 'external_biases', - 'update_weights']) - attrs_to_check = [x for x in all_attrs if x not in attrs_to_ignore] - for attr in attrs_to_check: + attrs_to_ignore = ['connectivity', 'external_drives', 'external_biases'] + for attr in vars(net1).keys(): + if attr.startswith('_') or attr in attrs_to_ignore: + continue + check_equality(getattr(net1, attr), getattr(net2, attr), f'{attr} not equal')