Skip to content

==(x,y) is true when only partials(y) have NaNs #600

Closed
@magerton

Description

@magerton

When x and y are duals and have equal values, but the partials differ in that some are NaNs, the statement x==y evaluates to true, even though partials(x) == partials(y) is not true. I'm guessing that this is not the intended behavior, but I'm not sure where the fix would go. The problem doesn't seem to hold for Partials

using ForwardDiff: Dual, Partials, partials
Dual(0.0, (1.0, 0.0)) == Dual(0.0, (1.0, NaN)) # true... should be false?
Dual(0.0, (1.0, 0.0)) == Dual(0.0, (NaN, NaN)) # true... should be false?
Dual(0.0, (1.0, 0.0)) == Dual(NaN, (1.0, 0.0)) # false

Partials((0.0, 1.0)) == Partials((0.0, 1.0)) # true
Partials((0.0, 1.0)) == Partials((NaN, 1.0)) # false

partials(Dual(0.0, (1.0, 0.0))) == partials(Dual(0.0, (1.0, 0.0))) # true
partials(Dual(0.0, (1.0, 0.0))) == partials(Dual(0.0, (1.0, NaN))) # false
partials(Dual(0.0, (1.0, 0.0))) == partials(Dual(0.0, (NaN, NaN))) # false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions