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

More flexible and precise approx_eq #869

Merged
merged 33 commits into from
Mar 5, 2024
Merged

More flexible and precise approx_eq #869

merged 33 commits into from
Mar 5, 2024

Conversation

bragov4ik
Copy link
Contributor

@bragov4ik bragov4ik commented Jan 16, 2024

  • Add tolerances relative to magnitude of the compared numbers (i.e. when error accumulates in a larger computations)
  • Add corresponding macros (to compare by constant (absolute) tolerance, by relative, or by both)
  • Separate comparison logic into functions (to call if necessary outside the tests)

Used in tests for #749 (PR #864)

Inspired by https://stackoverflow.com/questions/4915462/how-should-i-do-floating-point-comparison

@bragov4ik bragov4ik added enhancement New feature or request CouldHave Nice to have in the release, small impact on the release if not included labels Jan 16, 2024
@bragov4ik bragov4ik added this to the 4.1.0 - ALT milestone Jan 16, 2024
@bragov4ik bragov4ik self-assigned this Jan 16, 2024
common/src/test_utils.rs Fixed Show fixed Hide fixed
common/src/test_utils.rs Fixed Show fixed Hide fixed
common/src/test_utils.rs Fixed Show fixed Hide fixed
common/src/test_utils.rs Fixed Show fixed Hide fixed
common/src/test_utils.rs Fixed Show fixed Hide fixed
common/src/test_utils.rs Fixed Show fixed Hide fixed
@bragov4ik bragov4ik linked an issue Jan 16, 2024 that may be closed by this pull request
Copy link
Contributor

@Alexey-N-Chernyshov Alexey-N-Chernyshov left a comment

Choose a reason for hiding this comment

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

My concern is usage of float-point approximation for fixed-point arithmetics, discussed it with @bragov4ik. Please, reassign me to the PR review in case of changes.

…tests (#880)

* fix(kensetsu): replace assert_approx_eq with assert_eq in xst pallet tests
Copy link
Contributor

@Alexey-N-Chernyshov Alexey-N-Chernyshov left a comment

Choose a reason for hiding this comment

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

👍

common/src/test_utils.rs Show resolved Hide resolved
common/src/test_utils.rs Fixed Show fixed Hide fixed
common/src/test_utils.rs Fixed Show fixed Hide fixed
@bragov4ik bragov4ik merged commit e48dea5 into develop Mar 5, 2024
6 checks passed
@bragov4ik bragov4ik deleted the 749-approx-eq branch March 5, 2024 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CouldHave Nice to have in the release, small impact on the release if not included enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QA Tools: initialize liquidity source
3 participants