graph with inhom compartments#779
Conversation
jnsbck
left a comment
There was a problem hiding this comment.
Hey, thanks for the contribution. I think this is nice to have and I am fine to merge this in principle. Please have a look at the comments I left and make sure all the checks and tests pass.
jaxley/io/graph.py
Outdated
| counts_by_branch = cell_groups.groupby("branch_index").size().sort_index() | ||
|
|
||
| for _, ncomps in counts_by_branch.items(): | ||
| branches.append(Branch([comp for _ in range(int(ncomps))])) |
There was a problem hiding this comment.
Lets add a check to see if all ncomps are the same. If yes, then instantiate the branches as before, i.e. [branch] * num_branches. This is much faster since only one Branch instance needs to be created, rather than many.
tests/test_graph.py
Outdated
|
|
||
| def node_match(a, b): | ||
| for key in a.keys(): | ||
| try: |
There was a problem hiding this comment.
Lets use an isinstance rather than a try except if possible.
There was a problem hiding this comment.
Also which attributes is the exception for?
In addition, you might wanna use np.isclose rather than != on floats.
There was a problem hiding this comment.
The exception is raised for xyzr which is an array
I also fixed the float comparison in the test
Handles building a cell from a graph with inhomogeneous branches, i.e. different number of compartments.