From 1383be38a14ff9cc4fc83ec1eb9f892c45b0189c Mon Sep 17 00:00:00 2001 From: Kata Martin Date: Wed, 15 Jan 2025 15:23:04 -0500 Subject: [PATCH] Move size check logic into shared helper --- components/utils/data.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/utils/data.js b/components/utils/data.js index fffe0e5..7c8c2a7 100644 --- a/components/utils/data.js +++ b/components/utils/data.js @@ -96,6 +96,10 @@ export const toKeyArray = (chunkKey, { chunk_separator }) => { return chunkKey.split(chunk_separator).map(Number) } +const isArrayOverSizeLimit = (dimensions) => { + return dimensions.reduce((product, d) => product * d, 1) >= MAX_ARRAY_LENGTH +} + const getChunkShapeOverride = (chunkShape, shape, dimensions, axes) => { if (chunkShape.length === 1) { return null @@ -104,8 +108,7 @@ const getChunkShapeOverride = (chunkShape, shape, dimensions, axes) => { const fullSpace = dimensions .filter((d) => [axes?.X, axes?.Y].includes(d)) - .every((d) => d <= 360) && - chunkShape.reduce((product, d) => product * d, 1) < MAX_ARRAY_LENGTH + .every((d) => d <= 360) && !isArrayOverSizeLimit(chunkShape) return dimensions.map((d, i) => { if ([axes?.X, axes?.Y].includes(d)) { @@ -353,7 +356,7 @@ export const getVariableInfo = async ( if ( isSpatialDimension(dimensions[i]) || !arr || - arr.shape > MAX_ARRAY_LENGTH + isArrayOverSizeLimit(arr.shape) ) { return null } else {