Jp/permute array#664
Conversation
There was a problem hiding this comment.
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.
| 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]) |
There was a problem hiding this comment.
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.
| 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]) |
|
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. |
|
@lazarusA Yea, the current zarrita logic is built around chunks and will need to be reconfigured for a universal selection |
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 toGetCurrentArray()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
FlatMapof the permuted data doesn't show the new permuted data quite how I want. Also theAxisLinesfor 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 theAxisLinescoomponent 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