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] Update Network eq method #902

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 10 additions & 14 deletions hnn_core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,20 +465,16 @@ def __eq__(self, other):
return False

# Check all other attributes
all_attrs = dir(self)
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',
'update_weights'])
attrs_to_check = [x for x in all_attrs if x not in attrs_to_ignore]

for attr in attrs_to_check:
if getattr(self, attr) != getattr(other, attr):
attrs_to_ignore = ['connectivity']
for attr in vars(self).keys():
if attr.startswith('_') or attr in attrs_to_ignore:
continue

if hasattr(self, attr) and hasattr(other, attr):
if getattr(self, attr) != getattr(other, attr):
return False
else:
# Does not have the same set of attributes
return False

return True
Expand Down
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
Loading