Skip to content
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

common/math: Add CalculateAbsPercentageDifference and add DecimalAbsPercentageDifference #1617

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

shazbert
Copy link
Collaborator

PR Description

  • Needed absolute value as it was returning negative values.
  • Adds decimal package calc
  • Adds vars so that less decimal structs are allocated

Fixes # (issue)

Type of change

Please delete options that are not relevant and add an x in [] as item is complete.

  • 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 not work as expected)
  • This change requires a documentation update

How has this been tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration and
also consider improving test coverage whilst working on a certain feature or package.

  • go test ./... -race
  • golangci-lint run
  • Test X

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation and regenerated documentation via the documentation tool
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally and on Github Actions with my changes
  • Any dependent changes have been merged and published in downstream modules

@shazbert shazbert added bug review me This pull request is ready for review labels Aug 17, 2024
@shazbert shazbert requested a review from a team August 17, 2024 01:18
@shazbert shazbert self-assigned this Aug 17, 2024
Copy link
Collaborator

@gloriousCode gloriousCode left a comment

Choose a reason for hiding this comment

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

I wouldn't call it a bug to have a negative percentage difference. I would suggest you add CalculateAbsPercentageDifference and DecimalAbsPercentageDifference

common/math/math.go Outdated Show resolved Hide resolved
@shazbert
Copy link
Collaborator Author

Yeah, I guess they are both valid so it's not a bug, but I would caution adding the difference though as you can get values above 100% in the negative direction, all we are achieving is finding the degree of magnitude, I would say directionality can be applied to the value after if needed? I see that I am starting to furiously agree with you as I type this. So I can add the distinction and people can choose their own destiny. 😆

@shazbert shazbert added reconstructing Based on PR feedback, this is currently being reworked and is not to be merged and removed bug review me This pull request is ready for review labels Aug 18, 2024
@shazbert shazbert added review me This pull request is ready for review low priority This enhancement or update will be implemented at a later date. and removed reconstructing Based on PR feedback, this is currently being reworked and is not to be merged labels Aug 19, 2024
Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.

Project coverage is 36.38%. Comparing base (17c2ef2) to head (ad4c3e8).
Report is 2 commits behind head on master.

Files Patch % Lines
common/math/math.go 95.45% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1617   +/-   ##
=======================================
  Coverage   36.37%   36.38%           
=======================================
  Files         422      422           
  Lines      183113   183125   +12     
=======================================
+ Hits        66602    66623   +21     
+ Misses     108466   108459    -7     
+ Partials     8045     8043    -2     
Files Coverage Δ
common/math/math.go 79.94% <95.45%> (+0.72%) ⬆️

... and 11 files with indirect coverage changes

@shazbert shazbert changed the title common/math: fix bug with CalculatePercentageDifference and add DecimalPercentageDifference common/math: Add CalculateAbsPercentageDifference and add DecimalAbsPercentageDifference Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority This enhancement or update will be implemented at a later date. review me This pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants