8000 fix: store dimensions in JSON state as array not object since order matters by seankmartin · Pull Request #803 · google/neuroglancer · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: store dimensions in JSON state as array not object since order matters #803

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

seankmartin
Copy link
Contributor
@seankmartin seankmartin commented Jul 7, 2025

Since JSON objects are unordered in the spec, this could cause issues in processing of neuroglancer states by external tools for objects stored in the state where the name order matters. For example, in something that saves states or processes states.

The primary case where this has come up is in the global viewer dimensions where the order of the names determines the default order of the viewer, so the order matters. I know the precomputed annotation info metadata has a similar pattern too though.

To help with this, this PR is proposing to change the dimensions to be stored in an array, not an object. Here, the dimensions are handled in a split path. One "legacy" path, for pure dictionary style objects, and a new path, which handles arrays. New states are saved as arrays in the JSON state. This happens pretty automatically in the viewer, but from Python there is an extra kind of conversion call which happens on init of a new state.

Old state dims:

"dimensions": {
    "x": [
      4e-9,
      "m"
    ],
    "y": [
      4e-9,
      "m"
    ],
    "z": [
      4e-8,
      "m"
    ]
  }

New dims:

"dimensions": [
    {
      "name": "x",
      "scale": [
        4e-9,
        "m"
      ]
    },
    {
      "name": "y",
      "scale": [
        4e-9,
        "m"
      ]
    },
    {
      "name": "z",
      "scale": [
        4e-8,
        "m"
      ]
    }
  ],

Since JSON dicts don't guarantee any kind of key order in the spec, this could cause issues in downstream processing of neuroglancer states
Here, the dimensions are handled in a split path. One legacy path, for dicts, and a new path, as arrays. New states are saved as arrays
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

Successfully merging this pull request may close these issues.

1 participant
0