Skip to content

Commit

Permalink
feat(nml.py): use natsort to properly sort segments/groups when optim…
Browse files Browse the repository at this point in the history
…ising
  • Loading branch information
sanjayankur31 committed Aug 16, 2023
1 parent e03f060 commit 2d109fe
Show file tree
Hide file tree
Showing 4 changed files with 604 additions and 587 deletions.
1 change: 1 addition & 0 deletions neuroml/nml/gds_imports-template.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import inspect
import networkx as nx
import numpy
import natsort

import neuroml
import neuroml.neuro_lex_ids
6 changes: 4 additions & 2 deletions neuroml/nml/helper_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,8 @@ def optimise_segment_group(self, seg_group_id):
if i not in new_includes:
new_includes.append(i)
includes = set(new_includes)
seg_group.includes = list(includes)
# sorted
seg_group.includes = natsort.natsorted(includes, key=lambda x:x.segment_groups)
# remove members that are included by included segment groups
if len(includes) > 0 and len(members) > 0:
Expand All @@ -1782,7 +1783,8 @@ def optimise_segment_group(self, seg_group_id):
for i in members:
if i.segments not in all_segment_ids_in_group:
new_members.append(i)
seg_group.members = list(new_members)
# sorted
seg_group.members = natsort.natsorted(new_members, key=lambda x: x.segments)
def set_spike_thresh(self, v, group_id="all"):
Expand Down
Loading

0 comments on commit 2d109fe

Please sign in to comment.