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

Fix definitions of == and isless #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix definitions of == and isless #103

wants to merge 1 commit into from

Conversation

devmotion
Copy link
Member

Given the definitions of == and isequal in ForwardDiff#master, the PR reverts 337539f (see #10) and defines both ==(x, y) and isequal(x, y) in terms of both value(x) and epsilon(x) etc. This makes

  • the definitions in ForwardDiff and DualNumbers consistent,
  • the definitions of == and isequal in DualNumbers consistent,
  • the definitions of == and isequal mathematically correct.

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

Copy link

codecov bot commented Mar 13, 2024

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 ⚠️
Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@devmotion devmotion requested a review from mcabbott August 16, 2024 14:28
@devmotion
Copy link
Member Author

@mcabbott I think you might be interested in this change.

@mcabbott
Copy link
Member

This looks right to me, at first glance.

I see that #104 recently adopted the other convention.

But I have never used this package and am unsure who does, or the value of maintaining it in parallel to ForwardDiff.

@dlfivefifty
Copy link
Collaborator

This package predates ForwardDiff.jl and its value is mostly in its simplicity and accessibility.

The "right" thing to do is move ForwardDiff.Dual here. But that would require someone to take the initiative, and some functionality would need to be added to ForwardDiff.Dual to maintain feature parity.

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.

3 participants