Skip to content

Commit

Permalink
Clean up and test
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldeistler committed Jan 21, 2024
1 parent 2f6a20d commit 4ee3596
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion jaxley/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
_compute_index_of_child,
_compute_num_children,
compute_levels,
loc_of_index,
)
from jaxley.utils.plot_utils import plot_morph

Expand Down Expand Up @@ -656,8 +657,10 @@ def _scatter(self, ax, col, dims, view, morph_plot_kwargs):
np.isnan(self.xyzr[branch_ind][:, dims])
), "No coordinates available. Use `vis(detail='point')` or run `.compute_xyz()` before running `.vis()`."

comp_fraction = comp_ind / self.nseg
comp_fraction = loc_of_index(comp_ind, self.nseg)
coords = self.xyzr[branch_ind]

# Perform a linear interpolation between coordinates to get the location.
interpolated_loc_x = np.interp(
comp_fraction, np.linspace(0, 1, len(coords)), coords[:, dims[0]]
)
Expand Down
3 changes: 1 addition & 2 deletions jaxley/modules/compartment.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,10 @@ def vis(
dims=(0, 1),
morph_plot_kwargs: Dict = {},
):
nodes = self.set_global_index_and_index(self.view)
return self.pointer._scatter(
ax=ax,
col=col,
dims=dims,
view=nodes,
view=self.view,
morph_plot_kwargs=morph_plot_kwargs,
)
1 change: 1 addition & 0 deletions tests/test_plotting_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_cell():
_, ax = plt.subplots(1, 1, figsize=(3, 3))
ax = cell.vis(ax=ax)
ax = cell.branch([0, 1, 2]).vis(ax=ax, col="r")
ax = cell.branch(1).comp(0.9).vis(ax=ax, col="b")

# Plot 2.
cell.branch(0).add_to_group("soma")
Expand Down

0 comments on commit 4ee3596

Please sign in to comment.