Skip to content

allunique behaviour doesn't match documentation #30375

Open
@karajan9

Description

Hello everyone,
allunique doesn't seem to work on my structs. The documentation says: "allunique: Return true if all values from itr are distinct when compared with isequal."

import Base: isequal

mutable struct Cart
    x::Int
    y::Int
end

isequal(c1::Cart, c2::Cart) = return (c1.x == c2.x && c1.y == c2.y)

c1 = Cart(2, 3)
c2 = Cart(2, 3)

isequal(c1, c2)  # == true
c1 ∈ [c1, c2]  # == true

allunique([c1, c2])  # == true?!

Is this expected?

julia> versioninfo()
Julia Version 1.0.2
Commit d789231e99 (2018-11-08 20:11 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Xeon(R) CPU E3-1220 V2 @ 3.10GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
Environment:
  JULIA_NUM_THREADS = 2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    collectionsData structures holding multiple items, e.g. setsdocsThis change adds or pertains to documentationequalityIssues relating to equality relations: ==, ===, isequal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions