Skip to content

Updated GetCurrentArray to use chunkstrides#607

Merged
TheJeran merged 1 commit intomainfrom
jp/getcurrent-fix
Mar 23, 2026
Merged

Updated GetCurrentArray to use chunkstrides#607
TheJeran merged 1 commit intomainfrom
jp/getcurrent-fix

Conversation

@TheJeran
Copy link
Collaborator

GetCurrentArray() was using a global stride value but the copychunk2array() function wants individual chunkstrides. This was the cause for when analyzing certain datasets would produce completely wrong values on the edges.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical bug in the analysis workflow that caused incorrect values at the edges of datasets. By updating GetCurrentArray() to use individual chunk strides, the analysis now produces accurate results. The changes primarily involve modifying how data chunks are processed and passed to the GPU computation, ensuring correct stride information is used during the copyChunk2array() function call.

Highlights

  • Incorrect Edge Values: The primary issue addressed by this PR is the correction of inaccurate values at the edges of datasets during analysis. This was due to the GetCurrentArray() function using a global stride value instead of individual chunk strides.
  • Chunk Strides Implementation: The PR updates GetCurrentArray() to utilize individual chunk strides, which are required by the copychunk2array() function. This ensures that the analysis produces correct values across the entire dataset.
  • Code Modification: The changes involve modifying AnalysisWG.tsx to remove an unnecessary dataArray initialization and directly use GetCurrentArray(analysisStore) for input. Additionally, HelperFuncs.ts is updated to pass chunk.shape and chunk.stride directly to copyChunkToArray().

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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

Choose a reason for hiding this comment

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

Code Review

The pull request addresses an issue in GetCurrentArray() where a global stride value was being used instead of individual chunkstrides, leading to incorrect values on the edges of certain datasets. The changes involve modifying GetCurrentArray() to pass chunk-specific strides to copychunk2array() and removing an unnecessary length check in AnalysisWG.tsx. These adjustments ensure accurate data analysis across different datasets.

Comment on lines 287 to +290
copyChunkToArray(
thisData,
chunkShape,
chunkStride,
chunk.shape,
chunk.stride,

Choose a reason for hiding this comment

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

critical

By directly passing chunk.shape and chunk.stride to copyChunkToArray, you ensure that the correct chunk-specific parameters are used for copying data. This resolves the original issue where a global stride value was causing incorrect data analysis on the edges of certain datasets.

Suggested change
copyChunkToArray(
thisData,
chunkShape,
chunkStride,
chunk.shape,
chunk.stride,
copyChunkToArray(
thisData,
chunk.shape,
chunk.stride,
typedArray,
dataShape,
strides as [number, number, number],


// --- 2. Dispatch GPU computation based on the operation ---
const inputArray = analysisMode ? analysisArray : dataArray;
const inputArray = GetCurrentArray(analysisStore)

Choose a reason for hiding this comment

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

high

By calling GetCurrentArray(analysisStore) directly, you ensure that the inputArray always reflects the most up-to-date data based on the current state of analysisStore. This eliminates the need for a conditional assignment based on analysisMode and ensures that the correct data is used for GPU computation.

if (!operation || dataArray.length <= 1) {
if (!operation) {
return;
}

Choose a reason for hiding this comment

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

medium

The check for dataArray.length <= 1 is no longer needed because GetCurrentArray is always called, and the function itself handles cases where the data might be invalid or empty. Removing this check simplifies the logic and avoids potential issues if dataArray is unexpectedly empty or has a length of 1.

Comment on lines +278 to 279

for (let z = zStartIdx; z < zEndIdx; z++) {

Choose a reason for hiding this comment

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

medium

The variables chunkShape and chunkStride are no longer needed as temporary variables. The chunk shape and stride are now directly accessed from the chunk object within the loop, simplifying the code and reducing memory usage.

@TheJeran TheJeran merged commit 1338e7f into main Mar 23, 2026
6 checks passed
@TheJeran TheJeran deleted the jp/getcurrent-fix branch March 23, 2026 09:26
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