Short answer: probably use round.(A, sigdigits=2)
or similar to assign colors. (Adjust sigdigits
as desired, or use digits
if you want an absolute tolerance.)
Longer answer: approximate comparison is not transitive, so trying to define “uniqueness subject to a tolerance” inevitably will encounter some odd behaviors. This has been a frequently discussed topic. See, for example:
- `unique()` with `isapprox()` instead of `isequal()` · Issue #19147 · JuliaLang/julia · GitHub and Allow tolerance for `unique` · Issue #26837 · JuliaLang/julia · GitHub
- Unique() to a certain tolerance? - #3 by improbable22
- How to make a Set of real values based on rtol? - #3 by djsegal
- The test isequal(+0.0,-0.0) returns FALSE - #8 by stevengj