-
Notifications
You must be signed in to change notification settings - Fork 361
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
Bug: wrong calculate median
function
#4754
Comments
github-merge-queue bot
pushed a commit
that referenced
this issue
Oct 27, 2024
…tion (#4753) ### Description This pull request introduces the following changes to the math utility functions: #### Fix Median Calculation: Corrected the median function to handle even-length arrays properly by averaging the two middle numbers. #### Add Unit Tests: Implemented unit tests for the math utility functions using Chai to ensure their correctness and reliability. The functions tested include: - `median`: Tests for both odd and even-length arrays. - `sum`: Verifies the sum of an array of numbers. - `mean`: Checks the calculation of the mean. - `stdDev`: Validates the standard deviation calculation, including cases with negative numbers. - `randomInt`: Ensures the generated random integer falls within the specified range. <!-- What's included in this PR? --> ### Drive-by changes - Code: Updated the median function in math.ts to correctly calculate the median for even-length arrays. - Tests: Added a new test file math.test.ts with comprehensive test cases for each function. <!-- Are there any minor or drive-by changes also included? --> ### Related issues <!-- - Fixes [#[issue number here]](#4754) --> Fixes [#[4754]](#4754) ### Backward compatibility Yes <!-- Are these changes backward compatible? Are there any infrastructure implications, e.g. changes that would prohibit deploying older commits using this infra tooling? Yes/No --> ### Testing - All tests have been executed and passed successfully, confirming the correctness of the functions. - Special attention was given to edge cases, such as arrays with negative numbers and random integer generation. <!-- What kind of testing have these changes undergone? None/Manual/Unit Tests -->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Calculate wrong value median
Additional context
Add any other context or screenshots about the feature request here.
Solution
Reimplement
median
function at #4753Related logics
Fetches the median prioritization fee for transfers of the collateralAddress token
The text was updated successfully, but these errors were encountered: