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

make_neuron_neuroglancer_link fails with show_inputs/show_outputs=True #31

Open
bdpedigo opened this issue Mar 20, 2024 · 1 comment
Open

Comments

@bdpedigo
Copy link
Contributor

MRE

import caveclient as cc
from nglui.statebuilder import make_neuron_neuroglancer_link

client = cc.CAVEclient("minnie65_phase3_v1")

# works
make_neuron_neuroglancer_link(client, 864691135941359220)

# breaks
make_neuron_neuroglancer_link(client, 864691135941359220, show_inputs=True)

# also breaks 
make_neuron_neuroglancer_link(client, 864691135941359220, show_outputs=True)

Output

Traceback (most recent call last):
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/sandbox/nglui_mre.py", line 10, in <module>
    make_neuron_neuroglancer_link(client, 864691135941359220, show_inputs=True)
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/helpers.py", line 630, in make_neuron_neuroglancer_link
    return package_state(dataframes, sb, client, shorten, return_as, ngl_url, link_text)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/helpers.py", line 374, in package_state
    url = make_url_robust(df, sb, client, shorten=shorten, ngl_url=ngl_url)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/helpers.py", line 329, in make_url_robust
    url = make_state_url(df, sb, client)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/helpers.py", line 288, in make_state_url
    state = sb.render_state(df, return_as="dict")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/statebuilder.py", line 269, in render_state
    return last_builder.render_state(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/statebuilder.py", line 158, in render_state
    self.handle_positions(data)
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/statebuilder.py", line 112, in handle_positions
    pos = l._set_view_options(self._temp_viewer, data, viewer_resolution=self._resolution)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/layers.py", line 461, in _set_view_options
    pos = rule._get_position(
          ^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/mappers.py", line 398, in _get_position
    data = self._preprocess_data(data, skip_columns=self.data_columns[1:], first=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/mappers.py", line 345, in _preprocess_data
    data = self._process_columns(data, skip_columns=skip_columns)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/nglui/statebuilder/mappers.py", line 330, in _process_columns
    data[col] = np.vstack(data[split_cols].values).tolist()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ben.pedigo/code/skedits/skedits-app/skedits/.venv/lib/python3.11/site-packages/numpy/core/shape_base.py", line 289, in vstack
    return _nx.concatenate(arrs, 0, dtype=dtype, casting=casting)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: need at least one array to concatenate
@bdpedigo
Copy link
Contributor Author

Update: this works when also passing a timestamp for which this root was valid, so that was my issue.

I still think the interface should behave more intuitively or at least guard against this - thoughts on inferring the latest timestamp that a root is valid, if none is provided? Or adding a check for whether the root is valid for the given timestamp, including None (now)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant