Skip to content

fix(calc): correct FREQUENCY output and simplify implementation#2286

Open
shcabin wants to merge 2 commits intoqax-os:masterfrom
shcabin:fix/FREQUENCY_swap
Open

fix(calc): correct FREQUENCY output and simplify implementation#2286
shcabin wants to merge 2 commits intoqax-os:masterfrom
shcabin:fix/FREQUENCY_swap

Conversation

@shcabin
Copy link
Copy Markdown
Contributor

@shcabin shcabin commented Apr 4, 2026

PR Details

Fix the FREQUEncy formula

  • Removed the incorrect c[1], c[2] = c[2], c[1] swapping logic so results match Excel
  • Use row-major traversal and ensure output order
  • Replaced the redundant allocation and assignment loops with a single make allocation for the output matrix.
  • Added comprehensive test cases in calc_test.go using INDEX and array constants to verify the correct distribution of counts across all buckets, ensuring the removal of the swap logic maintains accurate behavior.

Description

Related Issue

Motivation and Context

How Has This Been Tested

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

shcabin added 2 commits April 4, 2026 23:35
- Removed the incorrect `c[1], c[2] = c[2], c[1]` swapping logic so results match Excel
- Use row-major traversal and ensure output order
- Replaced the redundant allocation and assignment loops with a single `make` allocation for the output matrix.
- Added comprehensive test cases in `calc_test.go` using `INDEX` and array constants to verify the correct distribution of counts across all buckets, ensuring the removal of the swap logic maintains accurate behavior.
@shcabin shcabin force-pushed the fix/FREQUENCY_swap branch from 9aac816 to 31a2315 Compare April 4, 2026 16:23
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.60%. Comparing base (2694a36) to head (31a2315).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2286      +/-   ##
==========================================
- Coverage   99.60%   99.60%   -0.01%     
==========================================
  Files          32       32              
  Lines       26715    26706       -9     
==========================================
- Hits        26609    26600       -9     
  Misses         55       55              
  Partials       51       51              
Flag Coverage Δ
unittests 99.60% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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