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

Improve Test Stability & Minor fixes to documentation #39

Merged
merged 11 commits into from
May 8, 2024

Conversation

schuhmaj
Copy link
Collaborator

@schuhmaj schuhmaj commented May 7, 2024

Changelog

Rational

Our macOS GitHub Action is broken. The runner's environment probably changed somehow.
The tests comparing the calculation's intermediate results to the values yielded by Tsoulis Fortran implementation were implemented using ContainerEq from GoogleTest.
While this is syntactically nice, it only accounts for real equality - which breaks if the compiler/ platform is different and the values deviate by some tiny fractions more.

Changes

  • Add methods almostEqualUlps and almostEqualRelative for floating point comparison
    • almostEqualUlps compare two floating points by computing the ULP Distance (basically, re-interpreting them as integers and then computing the difference yields the distance how "far" the two floats are from each other). Equal are floats by default with ULP Distance <= 4
    • almostEqualRelative compares two floating points by relative comparison with the default EPSILON = 1e-10
    • Source
  • Create custom Test Matchers FloatContainter1D, FloatContainter2D and FloatContainter3D to be used with GoogleTest's ASSERT_THAT statement to compare nested containers of floating points values
  • The named tuples' operator== of HessianPlane, TranscendentalExpression and Distance now use the new equalities
  • Fix typos in the documentation and small errors in the C++ Example Section
  • Bump version number to 3.1 (for the JOSS Release)

JOSS Paper

  • Update UML Diagram in JOSS Paper to reflect changes made with version 3.x (we don't have a UML calculation component anymore!) (The diagram embedded below is a .png file; the one in the repository is a .pdf with a higher DPI/ quality)

UML_Component_Diagram_Polyhedral_Gravity_Model

- add method for calculating ULP distance
- Let the UtilityStructs use this method
- create custom matcher for comparing 2D containers
This improves the stability of the tests and makes them independent of the utilized OS/ Compiler/ Architecture by:
- adding dedicated methods for FloatingPoint comparison using
  - UPL distance
  - Relative Epsilon
- adding custom GoogleTestMatchers using these new methods
- updating the DataStructures Equality methods
@schuhmaj schuhmaj self-assigned this May 7, 2024
Improved the code comments for better clarity and updated some of the examples in the docs. Also corrected minor typos in documentation and comments. The package version number is updated to 3.1.
@schuhmaj schuhmaj changed the title Improve Test Stability & Minor fixes to documentation WIP: Improve Test Stability & Minor fixes to documentation May 7, 2024
@schuhmaj schuhmaj changed the title WIP: Improve Test Stability & Minor fixes to documentation Improve Test Stability & Minor fixes to documentation May 8, 2024
@schuhmaj schuhmaj requested a review from gomezzz May 8, 2024 13:36
Copy link
Collaborator

@gomezzz gomezzz left a comment

Choose a reason for hiding this comment

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

Mostly looks good, but I believe there is a tiny bug in the relative error :P

test/util/UtilityFloatArithmeticTest.cpp Outdated Show resolved Hide resolved
test/model/GoogleTestMatcher.h Outdated Show resolved Hide resolved
src/polyhedralGravity/util/UtilityFloatArithmetic.h Outdated Show resolved Hide resolved
@schuhmaj schuhmaj requested a review from gomezzz May 8, 2024 16:09
Copy link
Collaborator

@gomezzz gomezzz left a comment

Choose a reason for hiding this comment

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

👍

@schuhmaj schuhmaj merged commit 5acb5e2 into main May 8, 2024
6 checks passed
@schuhmaj schuhmaj deleted the stable-cpp-tests branch May 8, 2024 16:33
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.

2 participants