https://github.com/ghtaarn/deepequals.jl
https://github.com/ghtaarn/deepequals.jl
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ghtaarn/deepequals.jl
- Owner: GHTaarn
- License: mit
- Created: 2024-08-09T03:43:02.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-11T18:23:30.000Z (over 1 year ago)
- Last Synced: 2025-11-04T16:09:52.151Z (8 months ago)
- Language: Julia
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DeepEquals
A package for doing customised comparison of objects, especially focussed on
itemwise comparison of composite objects.
## Installation
```
using Pkg
pkg"add https://github.com/GHTaarn/DeepEquals.jl"
```
## Use
There are two exported symbols:
- `deepequals` which is a versatile comparison function
- `≗` - a binary operator version of `deepequals` that handles `NaN` and `missing` values in a similar way to `Base.isequal`
The `≗` operator is specialised to handle the situation where one has
calculated a result and wants to check if it is equal to a benchmark result
that has been calculated in a slightly different way.
By default, the `≗` operator will handle simple cases correctly and can be
tweaked if necessary.
In the REPL `≗` can be typed with `\circeq` followed by pressing the `Tab` key.
It has Unicode codepoint 0x2257.
### Example
```julia-repl
julia> using DeepEquals
julia> struct A
a
b
end
julia> A(1,[2,3]) == A(1,[2,3])
false
julia> A(1,[2,3]) ≗ A(1,[2,3])
true
julia> A(A(missing,[2,NaN]),-0.0) ≗ A(A(missing,[2,NaN]),0.0)
true
julia> deepequals(A(1,[2,NaN]), A(1,[2,NaN])) do x, y
x == y || (all(typeof.([x,y]) .<: AbstractFloat) && all(isnan.([x,y])))
end
true
julia>
```
## Related packages
[StructEquality.jl](https://github.com/jolin-io/StructEquality.jl) is a good
package for generating `==`, `isequal` and `isapprox` methods for structs.
`DeepEquals.jl` is preferable when one wishes to do specialised comparisons
that do not easily translate to `==`, `isequal` or `isapprox`.