facebookresearch / habitat-sim

A flexible, high-performance 3D simulator for Embodied AI research.
https://aihabitat.org/
MIT License
2.58k stars 419 forks source link

--[Bugfix] - Compare Configuration scalar doubles properly #2478

Closed jturner65 closed 6 days ago

jturner65 commented 6 days ago

Motivation and Context

This PR adds, and tests, proper fuzzy comparison between scalar ConfigValues that require it (i.e. doubles) using the same Magnum mechanism that supported Magnum floating point vector-based types use. This comparison uses a scaled epsilon value that acts as a threshold between two values being equal or not. See here for comparison details.

Support for fuzzy comparison must be implemented (following the pattern here for doubles) for any numeric types added to the ConfigValue supported list only if they do not use a similar comparison mechanism already (i.e. this does not need to be included for any magnum floating-point types)

How Has This Been Tested

Locally c++ and python. Tests have been added to validate the process for both below-threshold and above-threshold values.

Types of changes

Checklist

jturner65 commented 6 days ago

LGTM, double makes sense for python APIs particularly. Any other types you predict will need to be explicitly marked (which we may ever use)?

We would probably need extend the support if we ever want to differentiate (type-wise) between different size floating points (i.e. add explicit 32bit float support) or if we wanted to support non-magnum floating-point-based numeric constructs.