Skip to content

Commit

Permalink
add xyz attrs to module.nodes (#275)
Browse files Browse the repository at this point in the history
* add: add update_nodes_with_xyz to include xyz coords in module.nodes. fixes #273"

* enh: added special case when nseg == dim of branch coordinates.

* fix: remove if cases, in seg_interp, make func hidden

* fix: use interpolate_xyz from cell utils

* fix: rm argsort

* chore: ran black, isort

* fix: ensure adherence to #30.

* chore: ran black

* fix rm interpolate
  • Loading branch information
jnsbck authored Mar 15, 2024
1 parent 5b085d7 commit 4429745
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions jaxley/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ def __init__(self):
# x, y, z coordinates and radius.
self.xyzr: List[np.ndarray] = []

def _update_nodes_with_xyz(self):
"""Add xyz coordinates to nodes."""
loc = np.linspace(1 - 0.5 / self.nseg, 0.5 / self.nseg, self.nseg)
xyz = (
[interpolate_xyz(loc, xyzr).T for xyzr in self.xyzr]
if len(loc) > 0
else [self.xyzr]
)
idcs = self.nodes["comp_index"]
self.nodes.loc[idcs, ["x", "y", "z"]] = np.vstack(xyz)

def __repr__(self):
return f"{type(self).__name__} with {len(self.channels)} different channels. Use `.show()` for details."

Expand Down

0 comments on commit 4429745

Please sign in to comment.