JuliaDiff / DualNumbers.jl

Julia package for representing dual numbers and for performing dual algebra
Other
80 stars 30 forks source link

Fix definitions of `==` and `isless` #103

Open devmotion opened 7 months ago

devmotion commented 7 months ago

Given the definitions of == and isequal in ForwardDiff#master, the PR reverts https://github.com/JuliaDiff/DualNumbers.jl/commit/337539f32622b8d713a7ea122aeaafb4f1e0de3b (see #10) and defines both ==(x, y) and isequal(x, y) in terms of both value(x) and epsilon(x) etc. This makes

Additionally, the PR fixes isless: According to its docstring, isless(x, y) should

Test whether `x` is less than `y`, according to a fixed total order (defined together with `isequal`). `isless` is not defined for pairs `(x, y)` of all types. However, if it is defined, it is expected to satisfy the following:
- If `isless(x, y)` is defined, then so is `isless(y, x)` and `isequal(x, y)`, and exactly one of those three yields true.
- The relation defined by `isless` is transitive, i.e., `isless(x, y)` && `isless(y, z)` implies `isless(x, z)`.

On the master branch, however, the first requirement is not satisfied (e.g., choose x = dual(3, 0.5) and y = dual(3, 1.0): then neither isless(x, y), isless(y, x), nor isequal(x, y) is satisfied).

cc @andreasnoack who was involved in #10

codecov[bot] commented 7 months ago

Codecov Report

Attention: Patch coverage is 83.33333% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 51.88%. Comparing base (d9251a7) to head (d52f6a3).

Files Patch % Lines
src/dual.jl 83.33% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #103 +/- ## ========================================== + Coverage 50.94% 51.88% +0.94% ========================================== Files 2 2 Lines 212 212 ========================================== + Hits 108 110 +2 + Misses 104 102 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.