-
Notifications
You must be signed in to change notification settings - Fork 52
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
WIP: refactoring hard coded parts in renaming cells in HNN #702
base: master
Are you sure you want to change the base?
Conversation
Glad to see you got everything setup @wagdy88! Next step is to start working through |
Then, you could refactor the logic for assigning a cell's position within the column according to |
0f22c81
to
5ca37a5
Compare
hnn_core/network.py
Outdated
@@ -387,20 +403,19 @@ def __init__(self, params, add_drives_from_params=False, | |||
# cell counts, real and artificial | |||
self._n_cells = 0 # used in tests and MPIBackend checks | |||
self.pos_dict = dict() | |||
self.cell_types = dict() | |||
# COMMENTED By WAGDY #self.cell_types = dict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove line.
hnn_core/network.py
Outdated
#if cell_name == "L2_basket": | ||
# self.gid_ranges[cell_name] = range(0,35) | ||
# elif cell_name == 'L2_pyramidal' | ||
# ..... | ||
# if self.gid_ranges[cell_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unless you have a plan for this later.
hnn_core/network.py
Outdated
Args: | ||
original_name (string): The original cell | ||
name in the network to be changed | ||
new_name (string): The desired new cell name in the network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow same format as is elsewhere in the repo for readability.
hnn_core/network.py
Outdated
def __init__(self, params, add_drives_from_params=False, | ||
legacy_mode=False): | ||
# Save the parameters used to create the Network | ||
_validate_type(params, dict, 'params') | ||
self._params = params | ||
# Update the cell names -if needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove line.
@@ -363,7 +378,8 @@ def __init__(self, params, add_drives_from_params=False, | |||
stacklevel=1) | |||
|
|||
# Source dict of names, first real ones only! | |||
cell_types = { | |||
# adding self before cell_types to make it an instance attribute | |||
self.cell_types = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to consider turning this into an OrderedDict
to be explicit about order mattering here. Either that or we need to find a way to make order at this point irrelevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved in conversation with @wagdy88: our solution will be to maintain the original order of Network.gid_ranges
after renaming, but not necessarily Network.cell_types
or Network.pos_dict
.
hnn_core/viz.py
Outdated
cell_types = cell_response._cell_type_names | ||
cell_type_colors = ['r', 'b', 'g', 'w'] | ||
# Ensure cell_types list matches the size of cell_type_colors dictionary | ||
if len(cell_types) != len(cell_type_colors): | ||
raise ValueError("cell_types list must " | ||
"match the number of items in cell_type_colors.") | ||
|
||
cell_types = ['L2_basket', 'L2_pyramidal', 'L5_basket', 'L5_pyramidal'] | ||
cell_type_colors = {'L5_pyramidal': 'r', 'L5_basket': 'b', | ||
'L2_pyramidal': 'g', 'L2_basket': 'w'} | ||
# Create a new dictionary with the new keys and old values | ||
new_cell_type_colors = dict(zip(cell_types, cell_type_colors)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should use a default colormap here and ask users to enter a dict of colors if they want a specific cell_type -> color mapping. @ntolley wdyt?
hnn_core/viz.py
Outdated
# re-arranged cell_colors to match old colors dictionary | ||
cell_colors = ['m', 'c', 'r', 'b'] | ||
colors = dict(zip(net.cell_types.keys(), cell_colors)) | ||
cell_markers = ['x', '^', 'x', '^'] | ||
markers = dict(zip(net.cell_types.keys(), cell_markers)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here as in plot_spikes_raster
.
# WAGDY: could try to create a dictionary | ||
# of src_cell and target_cell and then a | ||
# function that takes default cell names | ||
# from this dictionary and overrides it | ||
# with user cell names |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
017f975
to
8772a1d
Compare
df9e1f4
to
9e4ad07
Compare
removing hard coding in _create_cell_coords function and linking this with __init__ in class Network fixing the _create_cell_coords refactoring _create_cell_coords refactoring _create_cell_coords contd removing cell_name from 466 argument correcting styling error and fixing self.post_dict in class network making different corrections in network fixed line 463 working with line 465 network.py still working with line 407 adding a space added self before cell_types commented line 404 and added self to cell_types to make it an attribute to instance network de-indenting line 115 for pos_dict to get input from the whole code de-indenting lines 103 thru 115 in network corrected names of cells to match cell.name added a comment on the plan lines 81 thru 86 in network_models changing cell name to L2_basket added a rename_cell function and _rename_basket subfunction WIP making some re-organizing of comments to rename_cell function rename is working with gid_ranges ordered, still working on visualization fixing a typo modified rename function to order cell_types items visualization raster working and colors matching fixing extra white spaces etc... . Updating plot cell function WIP maintain original order in net.gid_ranges only modify net.gid_ranges in loop to simplify rename_cell cleaning up code modifying the discription removing extra lines fixed color_map in plot_raster marker set to o for all cells adding tests aethetic modification correct elif or error correcting a typo correcting pytests updating pytest fixing network tests cell-repsonse test _add_cell-type
9e4ad07
to
6b1d018
Compare
Work in Progress to refactor the hard-coded parts in the code for renaming cells in HNN.