Skip to content

Jp/permute array#664

Draft
TheJeran wants to merge 6 commits into
mainfrom
jp/permute_array
Draft

Jp/permute array#664
TheJeran wants to merge 6 commits into
mainfrom
jp/permute_array

Conversation

@TheJeran

@TheJeran TheJeran commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

This PR is to start laying the framework for allowing the selection/ordering of dimensions in datasets as well as moving away from the workflow that populated the dataArray while fetching data. Now the GetArray() function is simpler with just a call to GetCurrentArray() once all data is in the cache.

As of now Permuting only works on 3D and 2D data. For some reason the shape of the FlatMap of the permuted data doesn't show the new permuted data quite how I want. Also the AxisLines for the 2D shape still use the sizing logic from the OG data. It's a simple fix but I kinda wanna leave it as motivation to update the AxisLines coomponent to be less complicated.

Also the CountryBorders component and the ParseExtent don't work when permuted

Examples of data loaded with time on y-axis

image image

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces dimension permutation functionality to the visualization tool, allowing users to reorder dimensions via a new DimensionOrder UI component. The changes update the global and plot stores, metadata display, axis lines, and data fetching hooks to respect the permuted dimension order. The review feedback highlights critical improvements: updating permuteArray to return a Float16Array instead of a standard array to prevent type mismatches and performance overhead, adding missing dependencies (dataShape and dimNames) to React hooks to ensure correct reactivity, and simplifying the permutation check logic.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/utils/HelperFuncs.ts
Comment thread src/components/plots/AxisLines.tsx Outdated
Comment on lines +27 to +31
useEffect(()=>{ //The first render didn't have dimNames and used default value. UseEffect updates after fetch. Also updates when switching to variable with diff Dims
// At the moment it resets each time because of the double click issue with menus that got introduced in 0.3.0.
permuteRef.current = Array.from({ length: slotCount }, (_, i) => i)
useGlobalStore.setState({ permute: [...permuteRef.current] });
},[slotCount])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The useEffect hook currently only triggers when slotCount changes. If you switch to a different variable that has the same number of dimensions (e.g., switching from one 3D variable to another 3D variable), slotCount remains 3, meaning the effect won't run and the dimension permutation will not reset. Adding dimNames to the dependency array ensures the permutation resets correctly when switching variables.

Suggested change
useEffect(()=>{ //The first render didn't have dimNames and used default value. UseEffect updates after fetch. Also updates when switching to variable with diff Dims
// At the moment it resets each time because of the double click issue with menus that got introduced in 0.3.0.
permuteRef.current = Array.from({ length: slotCount }, (_, i) => i)
useGlobalStore.setState({ permute: [...permuteRef.current] });
},[slotCount])
useEffect(()=>{ //The first render didn't have dimNames and used default value. UseEffect updates after fetch. Also updates when switching to variable with diff Dims
// At the moment it resets each time because of the double click issue with menus that got introduced in 0.3.0.
permuteRef.current = Array.from({ length: slotCount }, (_, i) => i)
useGlobalStore.setState({ permute: [...permuteRef.current] });
},[dimNames, slotCount])

Comment thread src/utils/HelperFuncs.ts
Comment thread src/hooks/useDataFetcher.tsx
@lazarusA

Copy link
Copy Markdown
Member

Not the approach I'm aiming for in my PR. We should keep your current design and only tell zarrita what to get and in what shape, without touching internals. We will only need to pass selection ranges and dimension index, plus it will work with any shape.

@TheJeran

Copy link
Copy Markdown
Collaborator Author

@lazarusA Yea, the current zarrita logic is built around chunks and will need to be reconfigured for a universal selection

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.

2 participants