Skip to content
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

New indexing #196

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions jaxley/modules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,23 @@ def __init__(self):
self.group_views = {}

self.nodes: Optional[pd.DataFrame] = None
self.syn_edges: Optional[pd.DataFrame] = None

self.syn_edges = pd.DataFrame(
columns=[
"pre_locs",
"post_locs",
"pre_branch_index",
"post_branch_index",
"pre_cell_index",
"post_cell_index",
"type",
"type_ind",
"global_pre_comp_index",
"global_post_comp_index",
"global_pre_branch_index",
"global_post_branch_index",
]
)
self.branch_edges: Optional[pd.DataFrame] = None

self.cumsum_nbranches: Optional[jnp.ndarray] = None
Expand Down Expand Up @@ -865,9 +881,6 @@ def adjust_view(self, key: str, index: float):
self.view = self.view[self.view[key].isin(index)]
else:
assert index == "all"
self.view["comp_index"] -= self.view["comp_index"].iloc[0]
self.view["branch_index"] -= self.view["branch_index"].iloc[0]
self.view["cell_index"] -= self.view["cell_index"].iloc[0]
self.view["controlled_by_param"] -= self.view["controlled_by_param"].iloc[0]
return self

Expand Down
4 changes: 3 additions & 1 deletion jaxley/modules/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ def __init__(self, pointer, view):

def __call__(self, index: float):
self.allow_make_trainable = True
return super().adjust_view("branch_index", index)
new_view = super().adjust_view("branch_index", index)
new_view.view["comp_index"] -= new_view.view["comp_index"].iloc[0]
return new_view

def __getattr__(self, key):
assert key == "comp"
Expand Down
5 changes: 4 additions & 1 deletion jaxley/modules/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ def __init__(self, pointer, view):
def __call__(self, index: float):
if index == "all":
self.allow_make_trainable = False
return super().adjust_view("cell_index", index)
new_view = super().adjust_view("cell_index", index)
new_view.view["comp_index"] -= new_view.view["comp_index"].iloc[0]
new_view.view["branch_index"] -= new_view.view["branch_index"].iloc[0]
return new_view

def __getattr__(self, key):
assert key == "branch"
Expand Down