-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat(calc): support matrix logic and products #2258
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
Draft
jpoz
wants to merge
13
commits into
qax-os:master
Choose a base branch
from
jpoz:jpoz/element-wise_array_operation_support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
feat(calc): support matrix logic and products #2258
jpoz
wants to merge
13
commits into
qax-os:master
from
jpoz:jpoz/element-wise_array_operation_support
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enable element-wise comparison and multiplication for matrix operands. Use broadcasting for scalar-matrix operations to ensure consistent behavior during complex formula evaluation. Add range-to-range matching support for COUNTIF. This enables formulas like SUMPRODUCT with conditionals and improves parity with standard spreadsheet matrix logic.
Verify element-wise operations and broadcasting logic for comparison and arithmetic operators in array formulas. Test matrix-matrix, scalar-matrix, and vector broadcasting for equality, relational operators, and multiplication. This ensures calculation consistency across varying input dimensions.
Expand test coverage for comparison operators in array formulas. Verify relational logic, inequality, and scalar broadcasting across different data types in SUMPRODUCT and COUNTIF. Ensure mixed-type comparisons and range overlaps evaluate correctly during formula calculation.
Verify `COUNTIF` behavior when matching numeric ranges against empty or nil criteria. This ensures the calculation engine handles type mismatches by returning zero instead of errors or false matches. Validating this edge case prevents regressions when evaluating formulas on sparse datasets that contain uninitialized cells.
Verify that array comparison and arithmetic functions return #VALUE! errors for incompatible matrix dimensions. Ensures the formula engine correctly identifies and rejects operands that cannot be broadcast, preventing invalid results during matrix operations.
Remove redundant dimension validation for left-hand operands in array operations. These checks are unnecessary because the broadcasting logic and output dimension calculation already handle these constraints. Add tests to verify that incompatible dimensions still correctly return #VALUE! errors. This ensures consistent spreadsheet behavior while reducing logic duplication in calculation functions.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2258 +/- ##
========================================
Coverage 99.55% 99.56%
========================================
Files 32 32
Lines 25778 26448 +670
========================================
+ Hits 25663 26332 +669
- Misses 60 61 +1
Partials 55 55
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Validate calculation engine behavior for row vector broadcasting in matrix formulas. Ensure mixed-type comparison operations follow spreadsheet logic for number and string inequalities.
Verify broadcasting behavior for single-cell matrix operands to ensure correct scaling of larger matrices. This covers both left and right operand positioning. Include validation for non-numeric input values within matrices. These tests ensure the calculator returns appropriate errors instead of proceeding with invalid data types.
Verify logic branches for mixed-type comparisons in array operations. Ensure string-to-number comparisons follow expected truthiness rules within the calculation engine. This addition targets specific code paths in calcGeArray and calcLeArray to ensure robust handling of mismatched types.
Add unit tests for calcEqArray to ensure correct scalar broadcasting. These cases verify that 1x1 matrices properly expand to match larger operands in both left and right positions. This targets logic paths where single-row or single-column dimensions require value replication across the resulting matrix.
Extract broadcasting and value comparison logic into shared helper functions. This removes redundant loops and index calculations from individual operators, ensuring a single source of truth for array logic. Standardize error handling in array multiplication by pushing error arguments to the stack. This aligns operator behavior with formula evaluation patterns and improves consistency across the calculation engine.
Validate matrix dimensions in operandToMatrix to ensure operands contain at least one element. Return a #VALUE! error instead of triggering panics on zero-row or zero-column arrays. Prevents index-out-of-bounds errors during array comparisons and multiplication. Includes regression tests for empty matrices and verification of valid scalar/matrix operations.
Add benchmarks for array formula operations, focusing on element-wise comparisons and scalar broadcasting. These metrics track calculation engine efficiency when processing matrix data. Include performance tests for SUMPRODUCT using conditional logic. These baselines ensure complex array-based calculations maintain stable performance during engine optimizations.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Details
Enable element-wise comparison and multiplication for matrix operands. Use broadcasting for scalar-matrix operations to ensure consistent behavior during complex formula evaluation.
Add range-to-range matching support for COUNTIF. This enables formulas like SUMPRODUCT with conditionals and improves parity with standard spreadsheet matrix logic.
Description
This PR adds element-wise array operation support to the calculation engine, enabling conditional array formulas and range-based calculations. This allows comparison and arithmetic operators to work with matrix data.
New Capabilities:
COUNTIF(D:D, D:D)can now check if each value exists anywhere in a criteria rangeSUMPRODUCT((A1:A6="Apple")*(B1:B6))enables filtering and aggregation based on conditions=,<>,<,<=,>,>=) and multiplication (*) now support array operations with scalar broadcastingComparison operators now return boolean arrays when operating on ranges, enabling conditional logic in formulas:
COUNTIF now accepts range references as criteria, checking if each search value matches any value in the criteria range:
SUMPRODUCT can now use comparison expressions to filter data before aggregation:
Related Issue
Motivation and Context
This change enables conditional array formulas and advanced range-based calculations that are essential for complex data analysis in spreadsheets.
What users couldn't do before:
What this unlocks:
This brings excelize's formula calculation capabilities in line with Excel's array formula support, enabling users to perform sophisticated data analysis directly in their spreadsheet formulas.
How Has This Been Tested
Various new tests
Types of changes
Checklist