Skip to content

Commit

Permalink
refactor: updated check_equal_networks method to avoid listing method…
Browse files Browse the repository at this point in the history
…s 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.
  • Loading branch information
gtdang authored and ntolley committed Oct 17, 2024
1 parent 32b15e3 commit 7a42650
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions hnn_core/tests/test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down

0 comments on commit 7a42650

Please sign in to comment.